Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
<profile>
<id>v23</id>
<properties>
<vaadin.version>23.3.5</vaadin.version>
<vaadin.version>23.3.6</vaadin.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
46 changes: 34 additions & 12 deletions src/main/resources/META-INF/frontend/fc-xterm/xterm-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,11 +43,13 @@ interface CustomKeyEventHandler {

interface CustomKeyEventHandlerRegistryDisposable extends IDisposable {
id: integer;
unshift: () => void;
}

//sparse array of CustomKeyEventHandler
class CustomKeyEventHandlerRegistry {
private handlers: CustomKeyEventHandler[] = [];
private indexes: number[] = [];
private next:integer=0;

register(customKey: CustomKey, handle?: (event: KeyboardEvent) => void): CustomKeyEventHandlerRegistryDisposable;
Expand All @@ -67,15 +69,36 @@ class CustomKeyEventHandlerRegistry {
const id = this.next++;
if (!handle) handle = () => {};
this.handlers[id] = {predicate, handle};
return {id, dispose : () => delete this.handlers[id]};
this.indexes.push(id);
return {id, dispose : () => this.remove(id), unshift : () => this.unshift(id)};
}

private unshift(id: integer) : void {
const i= this.indexes.indexOf(id);
if (i>=0) {
this.indexes.splice(i, 1);
this.indexes.unshift(id);
}
}

remove(id: integer) : void {
delete this.handlers[id];
const i= this.indexes.indexOf(id);
if (i>=0) this.indexes.splice(i, 1);
}

handle(context: XTermElement, ev: KeyboardEvent) : boolean {
//invoke all the applicable handlers for event

let listeners : CustomKeyEventHandler[] = [];

for(var i=0;i<this.indexes.length;i++) {
const h = this.handlers[this.indexes[i]];
if (h.predicate(ev)) {
listeners.push(h);
}
}

let stopImmediatePropagation = ev.stopImmediatePropagation.bind(ev);

let immediatePropagationStopped = false;
Expand All @@ -84,13 +107,10 @@ class CustomKeyEventHandlerRegistry {
immediatePropagationStopped=true;
};

let handled = false;
for(const i in this.handlers) {
if (/\d+/.test(i) && this.handlers[i].predicate(ev)) {
handled=true;
this.handlers[i].handle?.call(context, ev);
let handled = listeners.length>0;
for (var i=0;i<listeners.length;i++) {
listeners[i].handle?.call(context, ev);
if (immediatePropagationStopped) break;
}
}

if ((ev as any).requestCustomEvent) {
Expand Down Expand Up @@ -161,17 +181,19 @@ export class XTermElement extends LitElement implements TerminalMixin {
this.bellStyle = 'none';
}

_onData(e:string) : void {
//<N CSI is handled by console-feature
this.terminal.write(e.replace(/\r/g,'\x1b[<N\n'));
}

connectedCallback() {
super.connectedCallback();

let term = this.terminal;
term.options.convertEol = true;

//onLineFeed doesn't distinguish lines from user input and lines from terminal.write
//<N CSI is handled by console-feature
term.onData(e => {
term.write(e.replace(/\r/g,'\x1b[<N\n'));
});
term.onData(e=>this._onData(e));

term.onBell(() => {
if (this.bellStyle == 'sound') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Selection Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/frontend/fc-xterm/xterm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2022 Flowing Code
* Copyright (C) 2020 - 2023 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading