mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Export static methods wherever possible
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
* should happen instantly or at a maximum
|
||||
* frequency of 1 rendering per 10ms.
|
||||
*/
|
||||
function attach(term, socket, bidirectional, buffered) {
|
||||
export function attach(term, socket, bidirectional, buffered) {
|
||||
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
||||
term.socket = socket;
|
||||
|
||||
@@ -79,7 +79,7 @@ function attach(term, socket, bidirectional, buffered) {
|
||||
* @param {WebSocket} socket - The socket from which to detach the current
|
||||
* terminal.
|
||||
*/
|
||||
function detach(term, socket) {
|
||||
export function detach(term, socket) {
|
||||
term.off('data', term._sendData);
|
||||
|
||||
socket = (typeof socket == 'undefined') ? term.socket : socket;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* row and truncate its width with the current number of columns).
|
||||
*/
|
||||
|
||||
function proposeGeometry(term) {
|
||||
export function proposeGeometry(term) {
|
||||
if (!term.element.parentElement) {
|
||||
return null;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ function proposeGeometry(term) {
|
||||
return geometry;
|
||||
};
|
||||
|
||||
function fit(term) {
|
||||
export function fit(term) {
|
||||
// Wrap fit in a setTimeout as charMeasure needs time to get initialized
|
||||
// after calling Terminal.open
|
||||
setTimeout(function () {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @param {Terminal} term - The terminal to toggle full screen mode
|
||||
* @param {boolean} fullscreen - Toggle fullscreen on (true) or off (false)
|
||||
*/
|
||||
function toggleFullScreen(term, fullscreen) {
|
||||
export function toggleFullScreen(term, fullscreen) {
|
||||
var fn;
|
||||
|
||||
if (typeof fullscreen == 'undefined') {
|
||||
|
||||
+34
-47
@@ -4,54 +4,41 @@
|
||||
*/
|
||||
|
||||
import { SearchHelper } from './SearchHelper';
|
||||
import { ITerminal } from '../../Interfaces';
|
||||
|
||||
declare var exports: any;
|
||||
declare var module: any;
|
||||
declare var define: any;
|
||||
declare var require: any;
|
||||
declare var window: any;
|
||||
|
||||
(function (addon) {
|
||||
if (typeof window !== 'undefined' && 'Terminal' in window) {
|
||||
/**
|
||||
* Plain browser environment
|
||||
*/
|
||||
addon(window.Terminal);
|
||||
} else if (typeof exports === 'object' && typeof module === 'object') {
|
||||
/**
|
||||
* CommonJS environment
|
||||
*/
|
||||
module.exports = addon(require('../../Terminal').Terminal);
|
||||
} else if (typeof define === 'function') {
|
||||
/**
|
||||
* Require.js is available
|
||||
*/
|
||||
define(['../../xterm'], addon);
|
||||
/**
|
||||
* Find the next instance of the term, then scroll to and select it. If it
|
||||
* doesn't exist, do nothing.
|
||||
* @param term Tne search term.
|
||||
* @return Whether a result was found.
|
||||
*/
|
||||
function findNext(terminal: ITerminal, term: string): boolean {
|
||||
if (!terminal._searchHelper) {
|
||||
terminal.searchHelper = new SearchHelper(terminal);
|
||||
}
|
||||
})((Terminal: any) => {
|
||||
/**
|
||||
* Find the next instance of the term, then scroll to and select it. If it
|
||||
* doesn't exist, do nothing.
|
||||
* @param term Tne search term.
|
||||
* @return Whether a result was found.
|
||||
*/
|
||||
Terminal.prototype.findNext = function(term: string): boolean {
|
||||
if (!this._searchHelper) {
|
||||
this.searchHelper = new SearchHelper(this);
|
||||
}
|
||||
return (<SearchHelper>this.searchHelper).findNext(term);
|
||||
};
|
||||
return (<SearchHelper>terminal.searchHelper).findNext(term);
|
||||
};
|
||||
|
||||
/**
|
||||
* Find the previous instance of the term, then scroll to and select it. If it
|
||||
* doesn't exist, do nothing.
|
||||
* @param term Tne search term.
|
||||
* @return Whether a result was found.
|
||||
*/
|
||||
Terminal.prototype.findPrevious = function(term: string): boolean {
|
||||
if (!this._searchHelper) {
|
||||
this.searchHelper = new SearchHelper(this);
|
||||
}
|
||||
return (<SearchHelper>this.searchHelper).findPrevious(term);
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Find the previous instance of the term, then scroll to and select it. If it
|
||||
* doesn't exist, do nothing.
|
||||
* @param term Tne search term.
|
||||
* @return Whether a result was found.
|
||||
*/
|
||||
Terminal.prototype.findPrevious = function(terminal: ITerminal, term: string): boolean {
|
||||
if (!terminal._searchHelper) {
|
||||
terminal.searchHelper = new SearchHelper(terminal);
|
||||
}
|
||||
return (<SearchHelper>terminal.searchHelper).findPrevious(term);
|
||||
};
|
||||
|
||||
export function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.findNext = function(term) {
|
||||
return findNext(this, term);
|
||||
}
|
||||
|
||||
terminalConstructor.prototype.findPrevious = function(term) {
|
||||
return findPrevious(this, term);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* should happen instantly or at a maximum
|
||||
* frequency of 1 rendering per 10ms.
|
||||
*/
|
||||
function terminadoAttach(term, socket, bidirectional, buffered) {
|
||||
export function terminadoAttach(term, socket, bidirectional, buffered) {
|
||||
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
||||
term.socket = socket;
|
||||
|
||||
@@ -72,7 +72,7 @@ function terminadoAttach(term, socket, bidirectional, buffered) {
|
||||
* @param {WebSocket} socket - The socket from which to detach the current
|
||||
* terminal.
|
||||
*/
|
||||
function terminadoDetach(term, socket) {
|
||||
export function terminadoDetach(term, socket) {
|
||||
term.off('data', term._sendData);
|
||||
|
||||
socket = (typeof socket == 'undefined') ? term.socket : socket;
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
export function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.winptyCompatInit = function(): void {
|
||||
export function winptyCompatInit(terminal): void {
|
||||
// Don't do anything when the platform is not Windows
|
||||
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].indexOf(navigator.platform) >= 0;
|
||||
if (!isWindows) {
|
||||
@@ -21,13 +20,18 @@ export function apply(terminalConstructor) {
|
||||
// space. This is certainly not without its problems, but generally on
|
||||
// Windows when text reaches the end of the terminal it's likely going to be
|
||||
// wrapped.
|
||||
this.on('lineFeed', () => {
|
||||
const line = this.buffer.lines.get(this.buffer.ybase + this.buffer.y - 1);
|
||||
const lastChar = line[this.cols - 1];
|
||||
terminal.on('lineFeed', () => {
|
||||
const line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);
|
||||
const lastChar = line[terminal.cols - 1];
|
||||
|
||||
if (lastChar[3] !== 32 /* ' ' */) {
|
||||
const nextLine = this.buffer.lines.get(this.buffer.ybase + this.buffer.y);
|
||||
const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
|
||||
(<any>nextLine).isWrapped = true;
|
||||
}
|
||||
});
|
||||
|
||||
export function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.winptyCompatInit = function(): void {
|
||||
winptyCompatInit(this);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user