Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90c299da83 | ||
|
|
02a695056a |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap mp desktop rescap">
|
||||
<Identity Name="53621FSApps.FluentTerminal" Publisher="CN=BDC72197-B634-438A-B863-16DCB7D90C85" Version="0.5.2.0" />
|
||||
<Identity Name="53621FSApps.FluentTerminal" Publisher="CN=BDC72197-B634-438A-B863-16DCB7D90C85" Version="0.5.3.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="f7225014-f405-4342-ad2e-ebf6ac60ea2c" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>Fluent Terminal</DisplayName>
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "xcopy /y /s node_modules\\xterm\\css\\xterm.css dist\\ && xcopy /y /s src\\style.css dist\\ && xcopy /y /s src\\index.html dist\\ && npx webpack --config webpack.config.js"
|
||||
"postinstall": "cd node_modules\\xterm && npm install && npm run build && ren build dist",
|
||||
"build": "xcopy /y /s node_modules\\xterm\\dist\\xterm.css dist\\ && xcopy /y /s src\\style.css dist\\ && xcopy /y /s src\\index.html dist\\ && npx webpack --config webpack.config.js"
|
||||
},
|
||||
"author": "FS Apps",
|
||||
"license": "GPL-3.0",
|
||||
@@ -16,9 +17,6 @@
|
||||
"webpack-cli": "^3.2.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"xterm": "3.15.0-beta70",
|
||||
"xterm-addon-attach": "0.1.0",
|
||||
"xterm-addon-fit": "0.1.0",
|
||||
"xterm-addon-search": "0.2.0-beta2"
|
||||
"xterm": "https://github.com/MaxRis/xterm.js.git#reset-wrapped-line-flag"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*
|
||||
* Implements the attach method, that attaches the terminal to a WebSocket stream.
|
||||
*/
|
||||
|
||||
import { Terminal, IDisposable } from 'xterm';
|
||||
|
||||
export interface IAttachAddonTerminal extends Terminal {
|
||||
_core: {
|
||||
register<T extends IDisposable>(d: T): void;
|
||||
};
|
||||
|
||||
__socket?: WebSocket;
|
||||
__attachSocketBuffer?: string;
|
||||
__dataListener?: IDisposable;
|
||||
|
||||
__getMessage?(ev: MessageEvent): void;
|
||||
__flushBuffer?(): void;
|
||||
__pushToBuffer?(data: string): void;
|
||||
__sendData?(data: string): void;
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*
|
||||
* Implements the attach method, that attaches the terminal to a WebSocket stream.
|
||||
* Modified to use writeUtf8
|
||||
*/
|
||||
|
||||
import { Terminal, IDisposable } from 'xterm';
|
||||
import { IAttachAddonTerminal } from './Interfaces';
|
||||
|
||||
/**
|
||||
* Attaches the given terminal to the given socket.
|
||||
*
|
||||
* @param term The terminal to be attached to the given socket.
|
||||
* @param socket The socket to attach the current terminal.
|
||||
* @param bidirectional Whether the terminal should send data to the socket as well.
|
||||
* @param buffered Whether the rendering of incoming data should happen instantly or at a maximum
|
||||
* frequency of 1 rendering per 10ms.
|
||||
*/
|
||||
export function attach(term: Terminal, socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
|
||||
const addonTerminal = <IAttachAddonTerminal>term;
|
||||
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
|
||||
addonTerminal.__socket = socket;
|
||||
|
||||
addonTerminal.__flushBuffer = () => {
|
||||
addonTerminal.write(addonTerminal.__attachSocketBuffer);
|
||||
addonTerminal.__attachSocketBuffer = null;
|
||||
};
|
||||
|
||||
addonTerminal.__pushToBuffer = (data: string) => {
|
||||
if (addonTerminal.__attachSocketBuffer) {
|
||||
addonTerminal.__attachSocketBuffer += data;
|
||||
} else {
|
||||
addonTerminal.__attachSocketBuffer = data;
|
||||
setTimeout(addonTerminal.__flushBuffer, 10);
|
||||
}
|
||||
};
|
||||
|
||||
addonTerminal.__getMessage = function(ev: MessageEvent): void {
|
||||
if (ev.data instanceof ArrayBuffer) {
|
||||
addonTerminal.writeUtf8(new Uint8Array(ev.data));
|
||||
}
|
||||
};
|
||||
|
||||
addonTerminal.__sendData = (data: string) => {
|
||||
if (socket.readyState !== 1) {
|
||||
return;
|
||||
}
|
||||
socket.send(data);
|
||||
};
|
||||
|
||||
addonTerminal._core.register(addSocketListener(socket, 'message', addonTerminal.__getMessage));
|
||||
|
||||
if (bidirectional) {
|
||||
addonTerminal.__dataListener = addonTerminal.onData(addonTerminal.__sendData);
|
||||
addonTerminal._core.register(addonTerminal.__dataListener);
|
||||
}
|
||||
|
||||
addonTerminal._core.register(addSocketListener(socket, 'close', () => detach(addonTerminal, socket)));
|
||||
addonTerminal._core.register(addSocketListener(socket, 'error', () => detach(addonTerminal, socket)));
|
||||
}
|
||||
|
||||
function addSocketListener(socket: WebSocket, type: string, handler: (this: WebSocket, ev: Event) => any): IDisposable {
|
||||
socket.addEventListener(type, handler);
|
||||
return {
|
||||
dispose: () => {
|
||||
if (!handler) {
|
||||
// Already disposed
|
||||
return;
|
||||
}
|
||||
socket.removeEventListener(type, handler);
|
||||
handler = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Detaches the given terminal from the given socket
|
||||
*
|
||||
* @param term The terminal to be detached from the given socket.
|
||||
* @param socket The socket from which to detach the current terminal.
|
||||
*/
|
||||
export function detach(term: Terminal, socket: WebSocket): void {
|
||||
const addonTerminal = <IAttachAddonTerminal>term;
|
||||
addonTerminal.__dataListener.dispose();
|
||||
addonTerminal.__dataListener = undefined;
|
||||
|
||||
socket = (typeof socket === 'undefined') ? addonTerminal.__socket : socket;
|
||||
|
||||
if (socket) {
|
||||
socket.removeEventListener('message', addonTerminal.__getMessage);
|
||||
}
|
||||
|
||||
delete addonTerminal.__socket;
|
||||
}
|
||||
|
||||
|
||||
export function apply(terminalConstructor: typeof Terminal): void {
|
||||
/**
|
||||
* Attaches the current terminal to the given socket
|
||||
*
|
||||
* @param socket The socket to attach the current terminal.
|
||||
* @param bidirectional Whether the terminal should send data to the socket as well.
|
||||
* @param buffered Whether the rendering of incoming data should happen instantly or at a maximum
|
||||
* frequency of 1 rendering per 10ms.
|
||||
*/
|
||||
(<any>terminalConstructor.prototype).attach = function (socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
|
||||
attach(this, socket, bidirectional, buffered);
|
||||
};
|
||||
|
||||
/**
|
||||
* Detaches the current terminal from the given socket.
|
||||
*
|
||||
* @param socket The socket from which to detach the current terminal.
|
||||
*/
|
||||
(<any>terminalConstructor.prototype).detach = function (socket: WebSocket): void {
|
||||
detach(this, socket);
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Terminal, ITerminalOptions } from 'xterm';
|
||||
import { AttachAddon } from 'xterm-addon-attach';
|
||||
import { FitAddon } from 'xterm-addon-fit';
|
||||
import { SearchAddon } from 'xterm-addon-search';
|
||||
import * as attach from "./attach/attach";
|
||||
import * as fit from "xterm/lib/addons/fit/fit";
|
||||
import * as search from "xterm/lib/addons/search/search";
|
||||
|
||||
interface ExtendedWindow extends Window {
|
||||
keyBindings: any[];
|
||||
@@ -19,9 +19,11 @@ interface ExtendedWindow extends Window {
|
||||
|
||||
declare var window: ExtendedWindow;
|
||||
|
||||
Terminal.applyAddon(attach);
|
||||
Terminal.applyAddon(fit);
|
||||
Terminal.applyAddon(search);
|
||||
|
||||
let term: any;
|
||||
let fitAddon: any;
|
||||
let searchAddon: any;
|
||||
let socket: WebSocket;
|
||||
const terminalContainer = document.getElementById('terminal-container');
|
||||
|
||||
@@ -50,16 +52,12 @@ window.createTerminal = (options, theme, keyBindings) => {
|
||||
allowTransparency: true,
|
||||
theme: theme,
|
||||
windowsMode: true,
|
||||
experimentalCharAtlas: "dynamic",
|
||||
wordSeparator: ' ()[]{}\'":;'
|
||||
};
|
||||
|
||||
term = new Terminal(terminalOptions);
|
||||
|
||||
searchAddon = new SearchAddon();
|
||||
term.loadAddon(searchAddon);
|
||||
fitAddon = new FitAddon();
|
||||
term.loadAddon(fitAddon);
|
||||
|
||||
window.term = term;
|
||||
|
||||
term.onResize(({ cols, rows }) => {
|
||||
@@ -75,7 +73,7 @@ window.createTerminal = (options, theme, keyBindings) => {
|
||||
});
|
||||
|
||||
term.open(terminalContainer);
|
||||
fitAddon.fit();
|
||||
term.fit();
|
||||
term.focus();
|
||||
|
||||
setPadding(options.padding);
|
||||
@@ -83,7 +81,7 @@ window.createTerminal = (options, theme, keyBindings) => {
|
||||
let resizeTimeout: any;
|
||||
window.onresize = function () {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(fitAddon.fit(), 500);
|
||||
resizeTimeout = setTimeout(term.fit(), 500);
|
||||
}
|
||||
|
||||
window.onmouseup = function (e) {
|
||||
@@ -133,7 +131,7 @@ window.createTerminal = (options, theme, keyBindings) => {
|
||||
}
|
||||
|
||||
function attachTerminal() {
|
||||
term.loadAddon(new AttachAddon(socket, {inputUtf8: true}));
|
||||
term.attach(socket);
|
||||
term._initialized = true;
|
||||
}
|
||||
|
||||
@@ -179,7 +177,7 @@ function setScrollBarStyle(scrollBarStyle) {
|
||||
|
||||
function setPadding(padding) {
|
||||
document.querySelector('.terminal')["style"].padding = padding + 'px';
|
||||
fitAddon.fit();
|
||||
term.fit();
|
||||
}
|
||||
|
||||
window.changeKeyBindings = (keyBindings) => {
|
||||
@@ -188,11 +186,11 @@ window.changeKeyBindings = (keyBindings) => {
|
||||
}
|
||||
|
||||
window.findNext = (content: string) => {
|
||||
searchAddon.findNext(content);
|
||||
term.findNext(content);
|
||||
}
|
||||
|
||||
window.findPrevious = (content: string) => {
|
||||
searchAddon.findPrevious(content);
|
||||
term.findPrevious(content);
|
||||
}
|
||||
|
||||
document.oncontextmenu = function () {
|
||||
|
||||
Reference in new issue
Block a user