Add Emscripten port for version 6.0
This commit is contained in:
parent
a763f4fdd7
commit
00dcc1495d
@ -1 +1 @@
|
||||
Subproject commit 7ead88632eff06ea268e6ba830496dad93ccd067
|
||||
Subproject commit 6574e29602a9d6016f018a92bcc188616f524ae4
|
||||
10
ports/javascript/JSBackend.patch
Normal file
10
ports/javascript/JSBackend.patch
Normal file
@ -0,0 +1,10 @@
|
||||
--- JSBackend.cpp 2018-01-10 16:35:07.331418145 +1100
|
||||
+++ JSBackend_mp_js.cpp 2018-01-10 16:40:04.804633134 +1100
|
||||
@@ -4280,6 +4280,7 @@
|
||||
|
||||
void JSWriter::calculateNativizedVars(const Function *F) {
|
||||
NativizedVars.clear();
|
||||
+ return;
|
||||
|
||||
for (Function::const_iterator I = F->begin(), BE = F->end(); I != BE; ++I) {
|
||||
auto BI = &*I;
|
||||
87
ports/javascript/Makefile
Normal file
87
ports/javascript/Makefile
Normal file
@ -0,0 +1,87 @@
|
||||
include ../../py/mkenv.mk
|
||||
|
||||
CROSS = 0
|
||||
|
||||
QSTR_DEFS = qstrdefsport.h
|
||||
|
||||
include $(TOP)/py/py.mk
|
||||
|
||||
CC = emcc -g4 $(JSFLAGS)
|
||||
LD = emcc -g4
|
||||
|
||||
INC += -I.
|
||||
INC += -I$(TOP)
|
||||
INC += -I$(BUILD)
|
||||
|
||||
EM_CACHE ?= ~/.emscripten_cache
|
||||
|
||||
|
||||
BOTH_CFLAGS := -s WASM=0
|
||||
|
||||
CPP = clang -E
|
||||
|
||||
ifdef EMSCRIPTEN
|
||||
CPP += -isystem $(EMSCRIPTEN)/system/include/libc -isystem $(EMSCRIPTEN)/system/include/libcxx -isystem $(EM_CACHE)/asmjs/ports-builds/sdl2/include -isystem $(EMSCRIPTEN)/system/include
|
||||
# Act like 'emcc'
|
||||
CPP += -U__i386 -U__i386 -Ui386 -U__SSE -U__SSE_MATH -U__SSE2 -U__SSE2_MATH -U__MMX__ -U__SSE__ -U__SSE_MATH__ -U__SSE2__ -U__SSE2_MATH__
|
||||
endif
|
||||
|
||||
CFLAGS = -m32 -Wall $(INC) $(COPT)
|
||||
LDFLAGS = -m32 -Wl,-Map=$@.map,--cref -Wl,--gc-sections
|
||||
|
||||
OPTIM := -O2
|
||||
|
||||
CFLAGS += $(OPTIM) -DNDEBUG -D__EMSCRIPTEN__ -DLV_CONF_INCLUDE_SIMPLE
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
CFLAGS += $(CFLAGS_MOD)
|
||||
|
||||
SRC_LIB = $(addprefix lib/,\
|
||||
utils/interrupt_char.c \
|
||||
utils/stdout_helpers.c \
|
||||
utils/pyexec.c \
|
||||
mp-readline/readline.c \
|
||||
)
|
||||
|
||||
SRC_C = \
|
||||
main.c \
|
||||
mphalport.c \
|
||||
modutime.c \
|
||||
$(SRC_MOD)
|
||||
|
||||
LIB_SRC_C = $(addprefix lib/,\
|
||||
lv_bindings/driver/SDL/SDL_monitor.c \
|
||||
lv_bindings/driver/SDL/SDL_mouse.c \
|
||||
lv_bindings/driver/SDL/modSDL.c \
|
||||
$(LIB_SRC_C_EXTRA) \
|
||||
timeutils/timeutils.c \
|
||||
)
|
||||
|
||||
OBJ =
|
||||
OBJ = $(PY_O)
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_LIB:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
||||
|
||||
# List of sources for qstr extraction
|
||||
SRC_QSTR += $(SRC_C) $(LIB_SRC_C) dummy_header.h
|
||||
# Append any auto-generated sources that are needed by sources listed in
|
||||
# SRC_QSTR
|
||||
SRC_QSTR_AUTO_DEPS +=
|
||||
|
||||
JSFLAGS = $(BOTH_CFLAGS) -s USE_SDL=2 $(OPTIM) -s EXPORTED_FUNCTIONS="['_mp_js_init', '_mp_handle_pending', '_mp_js_init_repl', '_mp_js_do_str', '_mp_js_process_char', '_mp_hal_get_interrupt_char', '_mp_keyboard_interrupt']" -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" --memory-init-file 0 --js-library library.js
|
||||
|
||||
all: $(BUILD)/micropython.js
|
||||
|
||||
$(BUILD)/micropython.js: $(OBJ) library.js wrapper.js
|
||||
$(ECHO) "LINK $(BUILD)/firmware.js"
|
||||
$(Q)emcc $(LDFLAGS) -o $(BUILD)/firmware.js $(OBJ) $(JSFLAGS)
|
||||
cat wrapper.js $(BUILD)/firmware.js > $@
|
||||
|
||||
min: $(BUILD)/micropython.js
|
||||
uglifyjs $< -c -o $(BUILD)/micropython.min.js
|
||||
|
||||
test: $(BUILD)/micropython.js $(TOP)/tests/run-tests
|
||||
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
|
||||
cd $(TOP)/tests && MICROPY_MICROPYTHON=../ports/javascript/node_run.sh ./run-tests
|
||||
|
||||
include $(TOP)/py/mkrules.mk
|
||||
128
ports/javascript/README.md
Normal file
128
ports/javascript/README.md
Normal file
@ -0,0 +1,128 @@
|
||||
MicroPython.js
|
||||
==============
|
||||
|
||||
MicroPython transmuted into Javascript by Emscripten.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
Building micropython.js bears the same requirements as the standard MicroPython
|
||||
ports with the addition of Emscripten (and uglify-js for the minified file).
|
||||
|
||||
A standard installation of Emscripten should provide functional code, however
|
||||
if memory errors are encountered it may be worthwhile to modify the tool.
|
||||
`emscripten-fastcomp/lib/Target/JSBackend.cpp` may require the minor fix
|
||||
found in JSBackend.patch. This patch attempts to address situations where
|
||||
C code running through Emscripten is denied access to Javascript variables
|
||||
leading to false-positives in the MicroPython garbage collector as variables
|
||||
with pointers exclusively in Javascript will be erased prematurely.
|
||||
Refer to Emscripten documentation for instructions on building Emscripten
|
||||
from source.
|
||||
|
||||
Build instructions
|
||||
------------------
|
||||
|
||||
In order to build micropython.js, run:
|
||||
|
||||
$ make
|
||||
|
||||
To generate the minified file micropython.min.js, run:
|
||||
|
||||
$ make min
|
||||
|
||||
Running with Node.js
|
||||
--------------------
|
||||
|
||||
Access the repl with:
|
||||
|
||||
$ node build/micropython.js
|
||||
|
||||
Stack size may be modified using:
|
||||
|
||||
$ node build/micropython.js -X stack=64K
|
||||
|
||||
Where stack size may be represented in Bytes, KiB or MiB.
|
||||
|
||||
MicroPython scripts may be executed using:
|
||||
|
||||
$ node build/micropython.js hello.py
|
||||
|
||||
Alternatively micropython.js may by accessed by other javascript programs in node
|
||||
using the require command and the general API outlined below. For example:
|
||||
|
||||
```javascript
|
||||
var mp_js = require('./build/micropython.js');
|
||||
|
||||
mp_js_init(64 * 1024);
|
||||
mp_js_do_str("print('hello world')\n");
|
||||
```
|
||||
|
||||
Running with HTML
|
||||
-----------------
|
||||
|
||||
The prerequisite for browser operation of micropython.js is an element with
|
||||
the id `mp_js_stdout` which receives `print` events. The following code
|
||||
demonstrates basic functionality:
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="build/micropython.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id='mp_js_stdout'></div>
|
||||
<script>
|
||||
mp_js_stdout.addEventListener('print', function(e) {
|
||||
document.write(e.data);
|
||||
}, false);
|
||||
|
||||
mp_js_init(64 * 1024);
|
||||
mp_js_do_str('print(\'hello world\')');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
MicroPython code execution will suspend the browser so be sure to atomize usage
|
||||
within this environment. Unfortunately interrupts have not been implemented for the
|
||||
browser.
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
Run the test suite using:
|
||||
|
||||
$ make test
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
The following functions have been exposed to javascript.
|
||||
|
||||
```
|
||||
mp_js_init(stack_size)
|
||||
```
|
||||
|
||||
Initialize MicroPython with the given stack size in bytes. This must be
|
||||
called before attempting to interact with MicroPython.
|
||||
|
||||
```
|
||||
mp_js_do_str(code)
|
||||
```
|
||||
|
||||
Execute the input code. `code` must be a `string`.
|
||||
|
||||
```
|
||||
mp_js_init_repl()
|
||||
```
|
||||
|
||||
Initialize MicroPython repl. Must be called before entering characters into
|
||||
the repl.
|
||||
|
||||
```
|
||||
mp_js_process_char(char)
|
||||
```
|
||||
|
||||
Input character into MicroPython repl. `char` must be of type `number`. This
|
||||
will execute MicroPython code when necessary.
|
||||
1
ports/javascript/dummy_header.h
Normal file
1
ports/javascript/dummy_header.h
Normal file
@ -0,0 +1 @@
|
||||
/* This exists to keep 'emcc' from thinking we are trying to precompile headers. */
|
||||
10
ports/javascript/lextab.py
Normal file
10
ports/javascript/lextab.py
Normal file
File diff suppressed because one or more lines are too long
31
ports/javascript/library.h
Normal file
31
ports/javascript/library.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017, 2018 Rami Ali
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
extern void mp_js_write(const char *str, mp_uint_t len);
|
||||
extern int mp_js_ticks_ms(void);
|
||||
extern void mp_js_hook(void);
|
||||
70
ports/javascript/library.js
Normal file
70
ports/javascript/library.js
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017, 2018 Rami Ali
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
mergeInto(LibraryManager.library, {
|
||||
mp_js_write: function(ptr, len) {
|
||||
for (var i = 0; i < len; ++i) {
|
||||
c = String.fromCharCode(getValue(ptr + i, 'i8'));
|
||||
if (typeof window === 'undefined') {
|
||||
process.stdout.write(c);
|
||||
} else {
|
||||
if(mp_js_stdout === undefined || mp_js_stdout === null)
|
||||
mp_js_stdout = document.getElementById('mp_js_stdout');
|
||||
var print = new Event('print');
|
||||
print.data = c;
|
||||
mp_js_stdout.dispatchEvent(print);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mp_js_ticks_ms: function() {
|
||||
return (new Date()).getTime() - MP_JS_EPOCH;
|
||||
},
|
||||
|
||||
mp_js_hook: function() {
|
||||
if (typeof window === 'undefined') {
|
||||
var mp_interrupt_char = Module.ccall('mp_hal_get_interrupt_char', 'number', ['number'], ['null']);
|
||||
var fs = require('fs');
|
||||
|
||||
var buf = new Buffer(1);
|
||||
try {
|
||||
var n = fs.readSync(process.stdin.fd, buf, 0, 1);
|
||||
if (n > 0) {
|
||||
if (buf[0] == mp_interrupt_char) {
|
||||
Module.ccall('mp_keyboard_interrupt', 'null', ['null'], ['null']);
|
||||
} else {
|
||||
process.stdout.write(String.fromCharCode(buf[0]));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.code === 'EAGAIN') {
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
166
ports/javascript/lvgl.html
Normal file
166
ports/javascript/lvgl.html
Normal file
@ -0,0 +1,166 @@
|
||||
<!doctype html>
|
||||
<!---->
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
a { white-space: nowrap; }
|
||||
table {
|
||||
display: inline-block;
|
||||
}
|
||||
#mp_js_stdout {
|
||||
display: inline-block;
|
||||
max-width: 90%;
|
||||
height: 20%;
|
||||
max-height: 600px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#canvas {
|
||||
border: 4px black solid;
|
||||
border-radius: 4px;
|
||||
vertical-align: middle;
|
||||
};
|
||||
</style>
|
||||
<link rel="stylesheet" href="node_modules/xterm/dist/xterm.css" />
|
||||
<script src="node_modules/xterm/dist/xterm.js"></script>
|
||||
<script src="node_modules/xterm/dist/addons/fit/fit.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>LittlevGL+MicroPython simulator</h1>
|
||||
<p>
|
||||
This is the JavaScript version of MicroPython, plus the LittlevGL bindings available at
|
||||
<a href="https://github.com/littlevgl/lv_binding_micropython">https://github.com/littlevgl/lv_binding_micropython</a>.
|
||||
<br>
|
||||
You can type your own Python code into the prompt in the usual way.
|
||||
<br>
|
||||
For examples, see the README for the MicroPython binding.
|
||||
|
||||
<div id="mp_js_stdout"></div>
|
||||
|
||||
<canvas id="canvas" width="480" height="320" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
|
||||
|
||||
<p>
|
||||
<button onclick="mp_js_process_char(4);">Paste (Ctrl+D)</button>
|
||||
<!-- scripts -->
|
||||
<script src="lvgl_mp.js"></script>
|
||||
<script>
|
||||
|
||||
/*Write text to the terminal */
|
||||
function sendText(text) {
|
||||
var print = new Event('print');
|
||||
print.data = text;
|
||||
mp_js_stdout.dispatchEvent(print);
|
||||
}
|
||||
function processScriptArg(url){
|
||||
// read text from URL location
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', url, true);
|
||||
request.send(null);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4 && request.status === 200) {
|
||||
var type = request.getResponseHeader('Content-Type');
|
||||
if (type.indexOf("text") !== 1) {
|
||||
mp_js_do_str(request.responseText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Module.canvas = (function() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
return canvas;
|
||||
})();
|
||||
var lines = [
|
||||
"import lvgl as lv",
|
||||
"lv.init()",
|
||||
"import SDL",
|
||||
"SDL.init()",
|
||||
|
||||
/* Register SDL display driver. */
|
||||
"disp_buf1 = lv.disp_buf_t()",
|
||||
"buf1_1 = bytes(480*10)",
|
||||
"lv.disp_buf_init(disp_buf1,buf1_1, None, len(buf1_1)//4)",
|
||||
"disp_drv = lv.disp_drv_t()",
|
||||
"lv.disp_drv_init(disp_drv)",
|
||||
"disp_drv.buffer = disp_buf1",
|
||||
"disp_drv.flush_cb = SDL.monitor_flush",
|
||||
"disp_drv.hor_res = 480",
|
||||
"disp_drv.ver_res = 320",
|
||||
"lv.disp_drv_register(disp_drv)",
|
||||
/*Regsiter SDL mouse driver*/
|
||||
"indev_drv = lv.indev_drv_t()",
|
||||
"lv.indev_drv_init(indev_drv)",
|
||||
"indev_drv.type = lv.INDEV_TYPE.POINTER;",
|
||||
"indev_drv.read_cb = SDL.mouse_read;",
|
||||
"lv.indev_drv_register(indev_drv);",
|
||||
/* Create a screen with a button and a label */
|
||||
"scr = lv.obj()",
|
||||
"btn = lv.btn(scr)",
|
||||
"btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)",
|
||||
"label = lv.label(btn)",
|
||||
"label.set_text('Button')",
|
||||
/* Load the screen */
|
||||
"lv.scr_load(scr)"
|
||||
];
|
||||
|
||||
/*Initialization function*/
|
||||
window.onload = function() {
|
||||
|
||||
Terminal.applyAddon(fit);
|
||||
term = new Terminal();
|
||||
mp_js_stdout = document.getElementById('mp_js_stdout');
|
||||
mp_js_stdout.value = "";
|
||||
term.open(mp_js_stdout);
|
||||
term.fit();
|
||||
/*Initialize MicroPython itself*/
|
||||
mp_js_init(1 * 1024 * 1024);
|
||||
/*Setup printing event handler*/
|
||||
mp_js_stdout.addEventListener('print', function(e) {
|
||||
text = e.data;
|
||||
term.write(text);
|
||||
}, false);
|
||||
/*Setup key input handler */
|
||||
term.on('data', function(key, e) {
|
||||
console.log(key);
|
||||
for(var i = 0; i < key.length; i++) {
|
||||
mp_js_process_char(key.charCodeAt(i));
|
||||
}
|
||||
});
|
||||
/* Run init script */
|
||||
for(var i = 0;i < lines.length;i++){
|
||||
mp_js_do_str(lines[i]);
|
||||
}
|
||||
|
||||
/* Run custom script if passed */
|
||||
var custom = undefined;
|
||||
try {
|
||||
custom = new URL(window.location.href).searchParams.get("script");
|
||||
} catch (e) {
|
||||
console.log(e + ": URL seems to be unsupported");
|
||||
}
|
||||
console.log("Custom script: " + custom);
|
||||
if(custom !== undefined && custom !== null)
|
||||
processScriptArg(custom);
|
||||
|
||||
/*Setup lv_task_handler loop*/
|
||||
var the_mp_handle_pending = Module.cwrap('mp_handle_pending', null);
|
||||
function handle_pending() {
|
||||
the_mp_handle_pending();
|
||||
setTimeout(handle_pending, 20); // should call lv_task_handler()
|
||||
}
|
||||
/*Initialize the REPL.*/
|
||||
mp_js_init_repl();
|
||||
/*Start the main loop, asynchronously.*/
|
||||
handle_pending();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
105
ports/javascript/lvgl_mp.js
Normal file
105
ports/javascript/lvgl_mp.js
Normal file
File diff suppressed because one or more lines are too long
263
ports/javascript/main.c
Normal file
263
ports/javascript/main.c
Normal file
@ -0,0 +1,263 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George and 2017, 2018 Rami Ali
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "genhdr/mpversion.h"
|
||||
|
||||
#include "py/compile.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/repl.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/mperrno.h"
|
||||
#include "lib/utils/pyexec.h"
|
||||
|
||||
#include "library.h"
|
||||
|
||||
#define LEX_SRC_STR (1)
|
||||
#define LEX_SRC_VSTR (2)
|
||||
#define LEX_SRC_FILENAME (3)
|
||||
#define LEX_SRC_STDIN (4)
|
||||
|
||||
|
||||
#if MICROPY_ENABLE_COMPILER
|
||||
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
|
||||
qstr source_name = lex->source_name;
|
||||
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
|
||||
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false);
|
||||
mp_call_function_0(module_fun);
|
||||
nlr_pop();
|
||||
} else {
|
||||
// uncaught exception
|
||||
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) {
|
||||
// at the moment, the value of SystemExit is unused
|
||||
} else {
|
||||
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
#define FORCED_EXIT (0x100)
|
||||
// If exc is SystemExit, return value where FORCED_EXIT bit set,
|
||||
// and lower 8 bits are SystemExit value. For all other exceptions,
|
||||
// return 1.
|
||||
STATIC int handle_uncaught_exception(mp_obj_base_t *exc) {
|
||||
// check for SystemExit
|
||||
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(exc->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
|
||||
// None is an exit value of 0; an int is its value; anything else is 1
|
||||
mp_obj_t exit_val = mp_obj_exception_get_value(MP_OBJ_FROM_PTR(exc));
|
||||
mp_int_t val = 0;
|
||||
if (exit_val != mp_const_none && !mp_obj_get_int_maybe(exit_val, &val)) {
|
||||
val = 1;
|
||||
}
|
||||
return FORCED_EXIT | (val & 255);
|
||||
}
|
||||
|
||||
// Report all other exceptions
|
||||
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(exc));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Returns standard error codes: 0 for success, 1 for all other errors,
|
||||
// except if FORCED_EXIT bit is set then script raised SystemExit and the
|
||||
// value of the exit is in the lower 8 bits of the return value
|
||||
STATIC int execute_from_lexer(int source_kind, const void *source, mp_parse_input_kind_t input_kind, bool is_repl) {
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
// create lexer based on source kind
|
||||
mp_lexer_t *lex;
|
||||
if (source_kind == LEX_SRC_STR) {
|
||||
const char *line = source;
|
||||
lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, line, strlen(line), false);
|
||||
} else if (source_kind == LEX_SRC_VSTR) {
|
||||
const vstr_t *vstr = source;
|
||||
lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr->buf, vstr->len, false);
|
||||
} else if (source_kind == LEX_SRC_FILENAME) {
|
||||
lex = mp_lexer_new_from_file((const char*)source);
|
||||
} else { // LEX_SRC_STDIN
|
||||
assert(false); /* Not supported */
|
||||
return 1 | FORCED_EXIT;
|
||||
}
|
||||
|
||||
qstr source_name = lex->source_name;
|
||||
|
||||
#if MICROPY_PY___FILE__
|
||||
if (input_kind == MP_PARSE_FILE_INPUT) {
|
||||
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
|
||||
}
|
||||
#endif
|
||||
|
||||
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
|
||||
|
||||
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, is_repl);
|
||||
|
||||
// execute it
|
||||
mp_call_function_0(module_fun);
|
||||
// check for pending exception
|
||||
if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) {
|
||||
mp_obj_t obj = MP_STATE_VM(mp_pending_exception);
|
||||
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
|
||||
nlr_raise(obj);
|
||||
}
|
||||
|
||||
|
||||
nlr_pop();
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
// uncaught exception
|
||||
return handle_uncaught_exception(nlr.ret_val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
STATIC void mp_js_tx_str(const char *str)
|
||||
{
|
||||
mp_js_write(str, strlen(str));
|
||||
}
|
||||
|
||||
STATIC char *prompt(const char *str)
|
||||
{
|
||||
static char *buf[256];
|
||||
}
|
||||
|
||||
STATIC int do_repl(void) {
|
||||
mp_js_tx_str("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; "
|
||||
MICROPY_PY_SYS_PLATFORM " version\nUse Ctrl-D to exit, Ctrl-E for paste mode\n");
|
||||
|
||||
// use simple readline
|
||||
|
||||
for (;;) {
|
||||
char *line = prompt(">>> ");
|
||||
if (line == NULL) {
|
||||
// EOF
|
||||
return 0;
|
||||
}
|
||||
while (mp_repl_continue_with_input(line)) {
|
||||
char *line2 = prompt("... ");
|
||||
if (line2 == NULL) {
|
||||
break;
|
||||
}
|
||||
char *line3 = strjoin(line, '\n', line2);
|
||||
free(line);
|
||||
free(line2);
|
||||
line = line3;
|
||||
}
|
||||
|
||||
int ret = execute_from_lexer(LEX_SRC_STR, line, MP_PARSE_SINGLE_INPUT, true);
|
||||
if (ret & FORCED_EXIT) {
|
||||
return ret;
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static char *stack_top;
|
||||
|
||||
void mp_js_do_str(const char *code) {
|
||||
do_str(code, MP_PARSE_FILE_INPUT);
|
||||
}
|
||||
|
||||
int mp_js_process_char(int c) {
|
||||
return pyexec_event_repl_process_char(c);
|
||||
}
|
||||
|
||||
void mp_js_init(int heap_size) {
|
||||
int stack_dummy;
|
||||
stack_top = (char*)&stack_dummy;
|
||||
|
||||
#if MICROPY_ENABLE_GC
|
||||
char *heap = (char*)malloc(heap_size * sizeof(char));
|
||||
gc_init(heap, heap + heap_size);
|
||||
#endif
|
||||
|
||||
#if MICROPY_ENABLE_PYSTACK
|
||||
static mp_obj_t pystack[1024];
|
||||
mp_pystack_init(pystack, &pystack[MP_ARRAY_SIZE(pystack)]);
|
||||
#endif
|
||||
|
||||
mp_init();
|
||||
|
||||
mp_obj_list_init(mp_sys_path, 0);
|
||||
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_));
|
||||
mp_obj_list_init(mp_sys_argv, 0);
|
||||
}
|
||||
|
||||
void mp_js_init_repl() {
|
||||
pyexec_event_repl_init();
|
||||
}
|
||||
|
||||
void gc_collect(void) {
|
||||
// WARNING: This gc_collect implementation doesn't try to get root
|
||||
// pointers from CPU registers, and thus may function incorrectly.
|
||||
jmp_buf dummy;
|
||||
if (setjmp(dummy) == 0) {
|
||||
longjmp(dummy, 1);
|
||||
}
|
||||
gc_collect_start();
|
||||
gc_collect_root((void*)stack_top, ((mp_uint_t)(void*)(&dummy + 1) - (mp_uint_t)stack_top) / sizeof(mp_uint_t));
|
||||
gc_collect_end();
|
||||
}
|
||||
|
||||
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
||||
mp_raise_OSError(MP_ENOENT);
|
||||
}
|
||||
|
||||
mp_import_stat_t mp_import_stat(const char *path) {
|
||||
return MP_IMPORT_STAT_NO_EXIST;
|
||||
}
|
||||
|
||||
mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
|
||||
|
||||
void nlr_jump_fail(void *val) {
|
||||
while (1);
|
||||
}
|
||||
|
||||
void NORETURN __fatal_error(const char *msg) {
|
||||
while (1);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
|
||||
printf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
|
||||
__fatal_error("Assertion failed");
|
||||
}
|
||||
#endif
|
||||
56
ports/javascript/modutime.c
Normal file
56
ports/javascript/modutime.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George and 2017, 2018 Rami Ali
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mphalport.h"
|
||||
#include "py/nlr.h"
|
||||
#include "py/smallint.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "lib/timeutils/timeutils.h"
|
||||
#include "extmod/utime_mphal.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t time_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utime) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mp_utime_sleep_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_utime_sleep_ms_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_utime_sleep_us_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&mp_utime_ticks_ms_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mp_utime_ticks_us_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_utime_ticks_cpu_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_utime_ticks_add_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_utime_ticks_diff_obj) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table);
|
||||
|
||||
const mp_obj_module_t mp_module_utime = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&time_module_globals,
|
||||
};
|
||||
229
ports/javascript/mpconfigport.h
Normal file
229
ports/javascript/mpconfigport.h
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George and 2017, 2018 Rami Ali
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// options to control how MicroPython is built
|
||||
|
||||
// You can disable the built-in MicroPython compiler by setting the following
|
||||
// config option to 0. If you do this then you won't get a REPL prompt, but you
|
||||
// will still be able to execute pre-compiled scripts, compiled with mpy-cross.
|
||||
#define MICROPY_ENABLE_COMPILER (1)
|
||||
|
||||
#define MICROPY_QSTR_BYTES_IN_HASH (2)
|
||||
#define MICROPY_ALLOC_PATH_MAX (256)
|
||||
#define MICROPY_ALLOC_PARSE_CHUNK_INIT (16)
|
||||
#define MICROPY_EMIT_X64 (0) //BROKEN
|
||||
#define MICROPY_EMIT_THUMB (0) //BROKEN
|
||||
#define MICROPY_EMIT_INLINE_THUMB (0)
|
||||
#define MICROPY_COMP_MODULE_CONST (0)
|
||||
#define MICROPY_COMP_CONST (1)
|
||||
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
|
||||
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
|
||||
#define MICROPY_MEM_STATS (0) //BROKEN
|
||||
#define MICROPY_DEBUG_PRINTERS (0)
|
||||
#define MICROPY_ENABLE_GC (1)
|
||||
#define MICROPY_GC_ALLOC_THRESHOLD (1)
|
||||
#define MICROPY_GC_USES_ALLOCATED_SIZE (1)
|
||||
#define MICROPY_REPL_EVENT_DRIVEN (1)
|
||||
#define MICROPY_HELPER_REPL (1)
|
||||
#define MICROPY_HELPER_LEXER_UNIX (0)
|
||||
#define MICROPY_ENABLE_SOURCE_LINE (1)
|
||||
#define MICROPY_ENABLE_DOC_STRING (1)
|
||||
#define MICROPY_WARNINGS (1)
|
||||
#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1)
|
||||
#define MICROPY_PY_ASYNC_AWAIT (1)
|
||||
#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
|
||||
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
|
||||
#define MICROPY_PY_BUILTINS_ENUMERATE (1)
|
||||
#define MICROPY_PY_BUILTINS_FILTER (1)
|
||||
#define MICROPY_PY_BUILTINS_FROZENSET (1)
|
||||
#define MICROPY_PY_BUILTINS_REVERSED (1)
|
||||
#define MICROPY_PY_BUILTINS_SET (1)
|
||||
#define MICROPY_PY_BUILTINS_SLICE (1)
|
||||
#define MICROPY_PY_BUILTINS_PROPERTY (1)
|
||||
#define MICROPY_PY_BUILTINS_MIN_MAX (1)
|
||||
#define MICROPY_PY___FILE__ (1)
|
||||
#define MICROPY_PY_GC (1)
|
||||
#define MICROPY_PY_ARRAY (1)
|
||||
#define MICROPY_PY_ATTRTUPLE (1)
|
||||
#define MICROPY_PY_COLLECTIONS (1)
|
||||
#define MICROPY_PY_MATH (1)
|
||||
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1)
|
||||
#define MICROPY_PY_CMATH (1)
|
||||
#define MICROPY_PY_IO (1)
|
||||
#define MICROPY_PY_STRUCT (1)
|
||||
#define MICROPY_PY_SYS (1)
|
||||
#define MICROPY_PY_SYS_MAXSIZE (1)
|
||||
#define MICROPY_CPYTHON_COMPAT (1)
|
||||
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
||||
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
|
||||
|
||||
#define MICROPY_USE_INTERNAL_PRINTF (0)
|
||||
#define MICROPY_ENABLE_PYSTACK (1)
|
||||
#define MICROPY_KBD_EXCEPTION (1)
|
||||
#define MICROPY_PY_UTIME_MP_HAL (1)
|
||||
#define MICROPY_REPL_AUTO_INDENT (1)
|
||||
#define MICROPY_PY_FUNCTION_ATTRS (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_CENTER (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_PARTITION (1)
|
||||
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (1)
|
||||
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
|
||||
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_BUILTINS_COMPILE (1)
|
||||
#define MICROPY_PY_BUILTINS_EXECFILE (1)
|
||||
#define MICROPY_PY_BUILTINS_INPUT (1)
|
||||
#define MICROPY_PY_BUILTINS_POW3 (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
|
||||
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
||||
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
|
||||
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
|
||||
#define MICROPY_PY_SYS_PLATFORM "javascript"
|
||||
#define MICROPY_PY_UERRNO (1)
|
||||
#define MICROPY_PY_UCTYPES (1)
|
||||
#define MICROPY_PY_UZLIB (1)
|
||||
#define MICROPY_PY_UJSON (1)
|
||||
#define MICROPY_PY_URE (1)
|
||||
#define MICROPY_PY_UHEAPQ (1)
|
||||
#define MICROPY_PY_LVGL (1)
|
||||
#define MICROPY_PY_UHASHLIB (1)
|
||||
#define MICROPY_PY_UBINASCII (1)
|
||||
#define MICROPY_PY_URANDOM (1)
|
||||
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
|
||||
#define MICROPY_PY_USELECT (1)
|
||||
#define MICROPY_PY_FRAMEBUF (1)
|
||||
#define MICROPY_STREAMS_NON_BLOCK (1)
|
||||
#define MICROPY_MODULE_WEAK_LINKS (1)
|
||||
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
|
||||
#define MICROPY_USE_INTERNAL_ERRNO (1)
|
||||
#define MICROPY_ENABLE_SCHEDULER (1)
|
||||
#define MICROPY_SCHEDULER_DEPTH (1)
|
||||
|
||||
#define MP_SSIZE_MAX (0x7fffffff)
|
||||
|
||||
extern const struct _mp_obj_module_t mp_module_utime;
|
||||
extern const struct _mp_obj_module_t mp_module_lvgl;
|
||||
extern const struct _mp_obj_module_t mp_module_lvindev;
|
||||
extern const struct _mp_obj_module_t mp_module_SDL;
|
||||
|
||||
#if MICROPY_PY_LVGL
|
||||
#include "lib/lv_bindings/lvgl/src/lv_misc/lv_gc.h"
|
||||
#define MICROPY_PY_LVGL_DEF \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_lvgl), (mp_obj_t)&mp_module_lvgl },\
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_lvindev), (mp_obj_t)&mp_module_lvindev},\
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDL), (mp_obj_t)&mp_module_SDL },
|
||||
#else
|
||||
#define MICROPY_PY_LVGL_DEF
|
||||
#endif
|
||||
|
||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
|
||||
MICROPY_PY_LVGL_DEF \
|
||||
|
||||
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
|
||||
{ MP_ROM_QSTR(MP_QSTR_binascii), MP_ROM_PTR(&mp_module_ubinascii) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_collections), MP_ROM_PTR(&mp_module_collections) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_zlib), MP_ROM_PTR(&mp_module_uzlib) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_heapq), MP_ROM_PTR(&mp_module_uheapq) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_hashlib), MP_ROM_PTR(&mp_module_uhashlib) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mp_module_urandom) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_module_utime) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_module_uselect) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_struct), MP_ROM_PTR(&mp_module_ustruct) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, \
|
||||
|
||||
//#define MICROPY_EVENT_POLL_HOOK {ets_event_poll();}
|
||||
#if MICROPY_PY_THREAD
|
||||
#define MICROPY_EVENT_POLL_HOOK \
|
||||
do { \
|
||||
extern void mp_handle_pending(void); \
|
||||
mp_handle_pending(); \
|
||||
if (pyb_thread_enabled) { \
|
||||
MP_THREAD_GIL_EXIT(); \
|
||||
pyb_thread_yield(); \
|
||||
MP_THREAD_GIL_ENTER(); \
|
||||
} else { \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define MICROPY_THREAD_YIELD() pyb_thread_yield()
|
||||
#else
|
||||
#define MICROPY_EVENT_POLL_HOOK \
|
||||
do { \
|
||||
extern void mp_handle_pending(void); \
|
||||
mp_handle_pending(); \
|
||||
} while (0);
|
||||
|
||||
#define MICROPY_THREAD_YIELD()
|
||||
#endif
|
||||
|
||||
#define MICROPY_VM_HOOK_COUNT (10)
|
||||
#define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT;
|
||||
#define MICROPY_VM_HOOK_POLL if (--vm_hook_divisor == 0) { \
|
||||
vm_hook_divisor = MICROPY_VM_HOOK_COUNT; \
|
||||
extern void mp_js_hook(void); \
|
||||
mp_js_hook(); \
|
||||
}
|
||||
#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
|
||||
#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
|
||||
|
||||
// type definitions for the specific machine
|
||||
|
||||
//#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
|
||||
|
||||
// This port is intended to be 32-bit, but unfortunately, int32_t for
|
||||
// different targets may be defined in different ways - either as int
|
||||
// or as long. This requires different printf formatting specifiers
|
||||
// to print such value. So, we avoid int32_t and use int directly.
|
||||
#define UINT_FMT "%u"
|
||||
#define INT_FMT "%d"
|
||||
typedef int mp_int_t; // must be pointer size
|
||||
typedef unsigned mp_uint_t; // must be pointer size
|
||||
typedef long mp_off_t;
|
||||
|
||||
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
|
||||
|
||||
// extra built in names to add to the global namespace
|
||||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
|
||||
|
||||
// We need to provide a declaration/definition of alloca()
|
||||
#include <alloca.h>
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "JS"
|
||||
#define MICROPY_HW_MCU_NAME "Emscripten"
|
||||
|
||||
#define MP_STATE_PORT MP_STATE_VM
|
||||
|
||||
#define MICROPY_PORT_ROOT_POINTERS \
|
||||
LV_ROOTS \
|
||||
const char *readline_hist[8];
|
||||
|
||||
70
ports/javascript/mphalport.c
Normal file
70
ports/javascript/mphalport.c
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George and 2017, 2018 Rami Ali
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "library.h"
|
||||
#include "mphalport.h"
|
||||
|
||||
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
|
||||
mp_js_write(str, len);
|
||||
}
|
||||
|
||||
void mp_hal_delay_ms(mp_uint_t ms) {
|
||||
uint32_t start = mp_hal_ticks_ms();
|
||||
while (mp_hal_ticks_ms() - start < ms) {
|
||||
}
|
||||
}
|
||||
|
||||
void mp_hal_delay_us(mp_uint_t us) {
|
||||
uint32_t start = mp_hal_ticks_us();
|
||||
while (mp_hal_ticks_us() - start < us) {
|
||||
}
|
||||
}
|
||||
|
||||
mp_uint_t mp_hal_ticks_us(void) {
|
||||
return mp_js_ticks_ms() * 1000;
|
||||
}
|
||||
|
||||
mp_uint_t mp_hal_ticks_ms(void) {
|
||||
return mp_js_ticks_ms();
|
||||
}
|
||||
|
||||
mp_uint_t mp_hal_ticks_cpu(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int mp_interrupt_char;
|
||||
|
||||
int mp_hal_get_interrupt_char(void) {
|
||||
return mp_interrupt_char;
|
||||
}
|
||||
|
||||
void mp_hal_move_cursor_back(uint pos)
|
||||
{
|
||||
mp_hal_stdout_tx_strn("\b", 1);
|
||||
}
|
||||
void mp_hal_erase_line_from_cursor(uint pos)
|
||||
{
|
||||
}
|
||||
39
ports/javascript/mphalport.h
Normal file
39
ports/javascript/mphalport.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George and 2017, 2018 Rami Ali
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
|
||||
#define mp_hal_stdin_rx_chr() (0)
|
||||
void mp_hal_stdout_tx_strn(const char *str, size_t len);
|
||||
|
||||
void mp_hal_delay_ms(mp_uint_t ms);
|
||||
void mp_hal_delay_us(mp_uint_t us);
|
||||
mp_uint_t mp_hal_ticks_ms(void);
|
||||
mp_uint_t mp_hal_ticks_us(void);
|
||||
mp_uint_t mp_hal_ticks_cpu(void);
|
||||
|
||||
int mp_hal_get_interrupt_char(void);
|
||||
9
ports/javascript/node_modules/xterm/.devcontainer/devcontainer.json
generated
vendored
Normal file
9
ports/javascript/node_modules/xterm/.devcontainer/devcontainer.json
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "xterm.js",
|
||||
"dockerFile": "Dockerfile",
|
||||
"appPort": 3000,
|
||||
"extensions": [
|
||||
"editorconfig.editorconfig",
|
||||
"ms-vscode.vscode-typescript-tslint-plugin"
|
||||
]
|
||||
}
|
||||
21
ports/javascript/node_modules/xterm/LICENSE
generated
vendored
Normal file
21
ports/javascript/node_modules/xterm/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Copyright (c) 2017-2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
||||
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
|
||||
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
192
ports/javascript/node_modules/xterm/README.md
generated
vendored
Normal file
192
ports/javascript/node_modules/xterm/README.md
generated
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
# [](https://xtermjs.org)
|
||||
|
||||
[](https://dev.azure.com/xtermjs/xterm.js/_build/latest?definitionId=3)
|
||||
[](https://coveralls.io/github/xtermjs/xterm.js?branch=master)
|
||||
|
||||
Xterm.js is a front-end component written in TypeScript that lets applications bring fully-featured terminals to their users in the browser. It's used by popular projects such as VS Code, Hyper and Theia.
|
||||
|
||||
## Features
|
||||
|
||||
- **Terminal apps just work**: Xterm.js works with most terminal apps such as `bash`, `vim` and `tmux`, this includes support for curses-based apps and mouse event support.
|
||||
- **Perfomant**: Xterm.js is *really* fast, it even includes a GPU-accelerated renderer.
|
||||
- **Rich unicode support**: Supports CJK, emojis and IMEs.
|
||||
- **Self-contained**: Requires zero dependencies to work.
|
||||
- **Accessible**: Screen reader support can be turned on using the `screenReaderMode` option.
|
||||
- **And much more**: Links, theming, addons, well documented API, etc.
|
||||
|
||||
## What xterm.js is not
|
||||
|
||||
- Xterm.js is not a terminal application that you can download and use on your computer.
|
||||
- Xterm.js is not `bash`. Xterm.js can be connected to processes like `bash` and let you interact with them (provide input, receive output).
|
||||
|
||||
## Getting Started
|
||||
|
||||
First you need to install the module, we ship exclusively through [npm](https://www.npmjs.com/) so you need that installed and then add xterm.js as a dependency by running:
|
||||
|
||||
```
|
||||
npm install xterm
|
||||
```
|
||||
|
||||
To start using xterm.js on your browser, add the `xterm.js` and `xterm.css` to the head of your html page. Then create a `<div id="terminal"></div>` onto which xterm can attach itself. Finally instantiate the `Terminal` object and then call the `open` function with the DOM object of the `div`.
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="node_modules/xterm/dist/xterm.css" />
|
||||
<script src="node_modules/xterm/dist/xterm.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="terminal"></div>
|
||||
<script>
|
||||
var term = new Terminal();
|
||||
term.open(document.getElementById('terminal'));
|
||||
term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
### Importing
|
||||
|
||||
The recommended way to load xterm.js is via the ES6 module syntax:
|
||||
|
||||
```javascript
|
||||
import { Terminal } from 'xterm';
|
||||
```
|
||||
|
||||
### Addons
|
||||
|
||||
Addons are JavaScript modules that extend the `Terminal` prototype with new methods and attributes to provide additional functionality. There are a handful available in the main repository in the `src/addons` directory and you can even write your own by using the [public API](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts).
|
||||
|
||||
To use an addon, just import the JavaScript module and pass it to `Terminal`'s `applyAddon` method:
|
||||
|
||||
```javascript
|
||||
import { Terminal } from 'xterm';
|
||||
import * as fit from 'xterm/lib/addons/fit/fit';
|
||||
|
||||
Terminal.applyAddon(fit);
|
||||
|
||||
var xterm = new Terminal(); // Instantiate the terminal
|
||||
xterm.fit(); // Use the `fit` method, provided by the `fit` addon
|
||||
```
|
||||
|
||||
You will also need to include the addon's CSS file if it has one in the folder.
|
||||
|
||||
#### Importing Addons in TypeScript
|
||||
|
||||
There are currently no typings for addons if they are accessed via extending Terminal prototype, so you will need to upcast if using TypeScript, eg. `(xterm as any).fit()`. Alternatively, you can import the addon function and enhance the terminal on demand. This has better typing support and is friendly to treeshaking.
|
||||
|
||||
```typescript
|
||||
import { Terminal } from 'xterm';
|
||||
import { fit } from 'xterm/lib/addons/fit/fit';
|
||||
const xterm = new Terminal();
|
||||
|
||||
fit(xterm); // Fit the terminal when necessary
|
||||
```
|
||||
|
||||
## Browser Support
|
||||
|
||||
Since xterm.js is typically implemented as a developer tool, only modern browsers are supported officially. Here is a list of the versions we aim to support:
|
||||
|
||||
- Chrome latest
|
||||
- Edge latest
|
||||
- Firefox latest
|
||||
- Safari latest
|
||||
- IE11
|
||||
|
||||
Xterm.js works seamlessly in [Electron](https://electronjs.org/) apps and may even work on earlier versions of the browsers, these are the versions we strive to keep working.
|
||||
|
||||
## API
|
||||
|
||||
The full API for xterm.js is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts), use the branch/tag picker in GitHub (`w`) to navigate to the correct version of the API.
|
||||
|
||||
Note that some APIs are marked *experimental*, these are added to enable experimentation with new ideas without committing to support it like a normal [semver](https://semver.org/) API. Note that these APIs can change radically between versions so be sure to read release notes if you plan on using experimental APIs.
|
||||
|
||||
## Real-world uses
|
||||
Xterm.js is used in several world-class applications to provide great terminal experiences.
|
||||
|
||||
- [**SourceLair**](https://www.sourcelair.com/): In-browser IDE that provides its users with fully-featured Linux terminals based on xterm.js.
|
||||
- [**Microsoft Visual Studio Code**](http://code.visualstudio.com/): Modern, versatile and powerful open source code editor that provides an integrated terminal based on xterm.js.
|
||||
- [**ttyd**](https://github.com/tsl0922/ttyd): A command-line tool for sharing terminal over the web, with fully-featured terminal emulation based on xterm.js.
|
||||
- [**Katacoda**](https://www.katacoda.com/): Katacoda is an Interactive Learning Platform for software developers, covering the latest Cloud Native technologies.
|
||||
- [**Eclipse Che**](http://www.eclipse.org/che): Developer workspace server, cloud IDE, and Eclipse next-generation IDE.
|
||||
- [**Codenvy**](http://www.codenvy.com): Cloud workspaces for development teams.
|
||||
- [**CoderPad**](https://coderpad.io): Online interviewing platform for programmers. Run code in many programming languages, with results displayed by xterm.js.
|
||||
- [**WebSSH2**](https://github.com/billchurch/WebSSH2): A web based SSH2 client using xterm.js, socket.io, and ssh2.
|
||||
- [**Spyder Terminal**](https://github.com/spyder-ide/spyder-terminal): A full fledged system terminal embedded on Spyder IDE.
|
||||
- [**Cloud Commander**](https://cloudcmd.io "Cloud Commander"): Orthodox web file manager with console and editor.
|
||||
- [**Codevolve**](https://www.codevolve.com "Codevolve"): Online platform for interactive coding and web development courses. Live container-backed terminal uses xterm.js.
|
||||
- [**RStudio**](https://www.rstudio.com/products/RStudio "RStudio"): RStudio is an integrated development environment (IDE) for R.
|
||||
- [**Terminal for Atom**](https://github.com/jsmecham/atom-terminal-tab): A simple terminal for the Atom text editor.
|
||||
- [**Eclipse Orion**](https://orionhub.org): A modern, open source software development environment that runs in the cloud. Code, deploy and run in the cloud.
|
||||
- [**Gravitational Teleport**](https://github.com/gravitational/teleport): Gravitational Teleport is a modern SSH server for remotely accessing clusters of Linux servers via SSH or HTTPS.
|
||||
- [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job.
|
||||
- [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scallable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers.
|
||||
- [**Portainer**](https://portainer.io): Simple management UI for Docker.
|
||||
- [**SSHy**](https://github.com/stuicey/SSHy): HTML5 Based SSHv2 Web Client with E2E encryption utilising xterm.js, SJCL & websockets.
|
||||
- [**JupyterLab**](https://github.com/jupyterlab/jupyterlab): An extensible computational environment for Jupyter, supporting interactive data science and scientific computing across all programming languages.
|
||||
- [**Theia**](https://github.com/theia-ide/theia): Theia is a cloud & desktop IDE framework implemented in TypeScript.
|
||||
- [**Opshell**](https://github.com/ricktbaker/opshell) Ops Helper tool to make life easier working with AWS instances across multiple organizations.
|
||||
- [**Proxmox VE**](https://www.proxmox.com/en/proxmox-ve): Proxmox VE is a complete open-source platform for enterprise virtualization. It uses xterm.js for container terminals and the host shell.
|
||||
- [**Script Runner**](https://github.com/ioquatix/script-runner): Run scripts (or a shell) in Atom.
|
||||
- [**Whack Whack Terminal**](https://github.com/Microsoft/WhackWhackTerminal): Terminal emulator for Visual Studio 2017.
|
||||
- [**VTerm**](https://github.com/vterm/vterm): Extensible terminal emulator based on Electron and React.
|
||||
- [**electerm**](http://electerm.html5beta.com): electerm is a terminal/ssh/sftp client(mac, win, linux) based on electron/node-pty/xterm.
|
||||
- [**Kubebox**](https://github.com/astefanutti/kubebox): Terminal console for Kubernetes clusters.
|
||||
- [**Azure Cloud Shell**](https://shell.azure.com): Azure Cloud Shell is a Microsoft-managed admin machine built on Azure, for Azure.
|
||||
- [**atom-xterm**](https://atom.io/packages/atom-xterm): Atom plugin for providing terminals inside your Atom workspace.
|
||||
- [**rtty**](https://github.com/zhaojh329/rtty): Access your terminals from anywhere via the web.
|
||||
- [**Pisth**](https://github.com/ColdGrub1384/Pisth): An SFTP and SSH client for iOS.
|
||||
- [**abstruse**](https://github.com/bleenco/abstruse): Abstruse CI is a continuous integration platform based on Node.JS and Docker.
|
||||
- [**Azure Data Studio**](https://github.com/Microsoft/azuredatastudio): A data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.
|
||||
- [**FreeMAN**](https://github.com/matthew-matvei/freeman): A free, cross-platform file manager for power users.
|
||||
- [**Fluent Terminal**](https://github.com/felixse/FluentTerminal): A terminal emulator based on UWP and web technologies.
|
||||
- [**Hyper**](https://hyper.is): A terminal built on web technologies.
|
||||
- [**Diag**](https://diag.ai): A better way to troubleshoot problems faster. Capture, share and reapply troubleshooting knowledge so you can focus on solving problems that matter.
|
||||
- [**GoTTY**](https://github.com/yudai/gotty): A simple command line tool that shares your terminal as a web application based on xterm.js.
|
||||
- [**genact**](https://github.com/svenstaro/genact): A nonsense activity generator.
|
||||
- [**cPanel & WHM**](https://cpanel.com): The hosting platform of choice.
|
||||
- [**Nutanix**](https://github.com/nutanix): Nutanix Enterprise Cloud uses xterm in the webssh functionality within Nutanix Calm, and is also looking to move our old noserial (termjs) functionality to xterm.js.
|
||||
- [**SSH Web Client**](https://github.com/roke22/PHP-SSH2-Web-Client): SSH Web Client with PHP.
|
||||
- [**Shellvault**](https://www.shellvault.io): The cloud-based SSH terminal you can access from anywhere.
|
||||
- [**Juno**](http://junolab.org/): A flexible Julia IDE, based on Atom.
|
||||
- [**webssh**](https://github.com/huashengdun/webssh): Web based ssh client.
|
||||
- [**info-beamer hosted**](https://info-beamer.com): Uses xterm.js to manage digital signage devices from the web dashboard.
|
||||
- [**Jumpserver**](https://github.com/jumpserver/luna): Jumpserver Luna project, Jumpserver is a bastion server project, Luna use xterm.js for web terminal emulation.
|
||||
- [**LxdMosaic**](https://github.com/turtle0x1/LxdMosaic): Uses xterm.js to give terminal access to containers through LXD
|
||||
- [**CodeInterview.io**](https://codeinterview.io): A coding interview platform in 25+ languages and many web frameworks. Uses xterm.js to provide shell access.
|
||||
- [**Bastillion**](https://www.bastillion.io): Bastillion is an open-source web-based SSH console that centrally manages administrative access to systems.
|
||||
- [**PHP App Server**](https://github.com/cubiclesoft/php-app-server/): Create lightweight, installable almost-native applications for desktop OSes. ExecTerminal (nicely wraps the xterm.js Terminal), TerminalManager, and RunProcessSDK are self-contained, reusable ES5+ compliant Javascript components.
|
||||
|
||||
[And much more...](https://github.com/xtermjs/xterm.js/network/dependents)
|
||||
|
||||
Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. Note: Please add any new contributions to the end of the list only.
|
||||
|
||||
## Releases
|
||||
|
||||
Xterm.js follows a monthly release cycle roughly.
|
||||
|
||||
All current and past releases are available on this repo's [Releases page](https://github.com/sourcelair/xterm.js/releases), you can view the [high-level roadmap on the wiki](https://github.com/xtermjs/xterm.js/wiki/Roadmap) and see what we're working on now by looking through [Milestones](https://github.com/sourcelair/xterm.js/milestones).
|
||||
|
||||
### Beta builds
|
||||
|
||||
Our CI releases beta builds to npm for every change that goes into master, install the latest beta build with:
|
||||
|
||||
```
|
||||
npm install -S xterm@beta
|
||||
```
|
||||
|
||||
These should generally be stable but some bugs may slip in, we recommend using the beta build primarily to test out new features and for verifying bug fixes.
|
||||
|
||||
## Contributing
|
||||
|
||||
You can read the [guide on the wiki](https://github.com/xtermjs/xterm.js/wiki/Contributing) to learn how to contribute and setup xterm.js for development.
|
||||
|
||||
## License Agreement
|
||||
|
||||
If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work.
|
||||
|
||||
Copyright (c) 2017-2019, [The xterm.js authors](https://github.com/xtermjs/xterm.js/graphs/contributors) (MIT License)<br>
|
||||
Copyright (c) 2014-2017, SourceLair, Private Company ([www.sourcelair.com](https://www.sourcelair.com/home)) (MIT License)<br>
|
||||
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||
106
ports/javascript/node_modules/xterm/dist/addons/attach/attach.js
generated
vendored
Normal file
106
ports/javascript/node_modules/xterm/dist/addons/attach/attach.js
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.attach = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function attach(term, socket, bidirectional, buffered) {
|
||||
var addonTerminal = term;
|
||||
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
|
||||
addonTerminal.__socket = socket;
|
||||
addonTerminal.__flushBuffer = function () {
|
||||
addonTerminal.write(addonTerminal.__attachSocketBuffer);
|
||||
addonTerminal.__attachSocketBuffer = null;
|
||||
};
|
||||
addonTerminal.__pushToBuffer = function (data) {
|
||||
if (addonTerminal.__attachSocketBuffer) {
|
||||
addonTerminal.__attachSocketBuffer += data;
|
||||
}
|
||||
else {
|
||||
addonTerminal.__attachSocketBuffer = data;
|
||||
setTimeout(addonTerminal.__flushBuffer, 10);
|
||||
}
|
||||
};
|
||||
var myTextDecoder;
|
||||
addonTerminal.__getMessage = function (ev) {
|
||||
var str;
|
||||
if (typeof ev.data === 'object') {
|
||||
if (!myTextDecoder) {
|
||||
myTextDecoder = new TextDecoder();
|
||||
}
|
||||
if (ev.data instanceof ArrayBuffer) {
|
||||
str = myTextDecoder.decode(ev.data);
|
||||
displayData(str);
|
||||
}
|
||||
else {
|
||||
var fileReader_1 = new FileReader();
|
||||
fileReader_1.addEventListener('load', function () {
|
||||
str = myTextDecoder.decode(fileReader_1.result);
|
||||
displayData(str);
|
||||
});
|
||||
fileReader_1.readAsArrayBuffer(ev.data);
|
||||
}
|
||||
}
|
||||
else if (typeof ev.data === 'string') {
|
||||
displayData(ev.data);
|
||||
}
|
||||
else {
|
||||
throw Error("Cannot handle \"" + typeof ev.data + "\" websocket message.");
|
||||
}
|
||||
};
|
||||
function displayData(str, data) {
|
||||
if (buffered) {
|
||||
addonTerminal.__pushToBuffer(str || data);
|
||||
}
|
||||
else {
|
||||
addonTerminal.write(str || data);
|
||||
}
|
||||
}
|
||||
addonTerminal.__sendData = function (data) {
|
||||
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', function () { return detach(addonTerminal, socket); }));
|
||||
addonTerminal._core.register(addSocketListener(socket, 'error', function () { return detach(addonTerminal, socket); }));
|
||||
}
|
||||
exports.attach = attach;
|
||||
function addSocketListener(socket, type, handler) {
|
||||
socket.addEventListener(type, handler);
|
||||
return {
|
||||
dispose: function () {
|
||||
if (!handler) {
|
||||
return;
|
||||
}
|
||||
socket.removeEventListener(type, handler);
|
||||
handler = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
function detach(term, socket) {
|
||||
var addonTerminal = term;
|
||||
addonTerminal.__dataListener.dispose();
|
||||
addonTerminal.__dataListener = undefined;
|
||||
socket = (typeof socket === 'undefined') ? addonTerminal.__socket : socket;
|
||||
if (socket) {
|
||||
socket.removeEventListener('message', addonTerminal.__getMessage);
|
||||
}
|
||||
delete addonTerminal.__socket;
|
||||
}
|
||||
exports.detach = detach;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.attach = function (socket, bidirectional, buffered) {
|
||||
attach(this, socket, bidirectional, buffered);
|
||||
};
|
||||
terminalConstructor.prototype.detach = function (socket) {
|
||||
detach(this, socket);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
//# sourceMappingURL=attach.js.map
|
||||
51
ports/javascript/node_modules/xterm/dist/addons/fit/fit.js
generated
vendored
Normal file
51
ports/javascript/node_modules/xterm/dist/addons/fit/fit.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fit = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function proposeGeometry(term) {
|
||||
if (!term.element.parentElement) {
|
||||
return null;
|
||||
}
|
||||
var parentElementStyle = window.getComputedStyle(term.element.parentElement);
|
||||
var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||
var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
||||
var elementStyle = window.getComputedStyle(term.element);
|
||||
var elementPadding = {
|
||||
top: parseInt(elementStyle.getPropertyValue('padding-top')),
|
||||
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||
right: parseInt(elementStyle.getPropertyValue('padding-right')),
|
||||
left: parseInt(elementStyle.getPropertyValue('padding-left'))
|
||||
};
|
||||
var elementPaddingVer = elementPadding.top + elementPadding.bottom;
|
||||
var elementPaddingHor = elementPadding.right + elementPadding.left;
|
||||
var availableHeight = parentElementHeight - elementPaddingVer;
|
||||
var availableWidth = parentElementWidth - elementPaddingHor - term._core.viewport.scrollBarWidth;
|
||||
var geometry = {
|
||||
cols: Math.floor(availableWidth / term._core._renderCoordinator.dimensions.actualCellWidth),
|
||||
rows: Math.floor(availableHeight / term._core._renderCoordinator.dimensions.actualCellHeight)
|
||||
};
|
||||
return geometry;
|
||||
}
|
||||
exports.proposeGeometry = proposeGeometry;
|
||||
function fit(term) {
|
||||
var geometry = proposeGeometry(term);
|
||||
if (geometry) {
|
||||
if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
|
||||
term._core._renderCoordinator.clear();
|
||||
term.resize(geometry.cols, geometry.rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.fit = fit;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.proposeGeometry = function () {
|
||||
return proposeGeometry(this);
|
||||
};
|
||||
terminalConstructor.prototype.fit = function () {
|
||||
fit(this);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
//# sourceMappingURL=fit.js.map
|
||||
10
ports/javascript/node_modules/xterm/dist/addons/fullscreen/fullscreen.css
generated
vendored
Normal file
10
ports/javascript/node_modules/xterm/dist/addons/fullscreen/fullscreen.css
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.xterm.fullscreen {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: auto;
|
||||
height: auto;
|
||||
z-index: 255;
|
||||
}
|
||||
29
ports/javascript/node_modules/xterm/dist/addons/fullscreen/fullscreen.js
generated
vendored
Normal file
29
ports/javascript/node_modules/xterm/dist/addons/fullscreen/fullscreen.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fullscreen = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function toggleFullScreen(term, fullscreen) {
|
||||
var fn;
|
||||
if (typeof fullscreen === 'undefined') {
|
||||
fn = (term.element.classList.contains('fullscreen')) ?
|
||||
term.element.classList.remove : term.element.classList.add;
|
||||
}
|
||||
else if (!fullscreen) {
|
||||
fn = term.element.classList.remove;
|
||||
}
|
||||
else {
|
||||
fn = term.element.classList.add;
|
||||
}
|
||||
fn = fn.bind(term.element.classList);
|
||||
fn('fullscreen');
|
||||
}
|
||||
exports.toggleFullScreen = toggleFullScreen;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.toggleFullScreen = function (fullscreen) {
|
||||
toggleFullScreen(this, fullscreen);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
//# sourceMappingURL=fullscreen.js.map
|
||||
262
ports/javascript/node_modules/xterm/dist/addons/search/search.js
generated
vendored
Normal file
262
ports/javascript/node_modules/xterm/dist/addons/search/search.js
generated
vendored
Normal file
@ -0,0 +1,262 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.search = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\;:"\',./<>?';
|
||||
var LINES_CACHE_TIME_TO_LIVE = 15 * 1000;
|
||||
var SearchHelper = (function () {
|
||||
function SearchHelper(_terminal) {
|
||||
this._terminal = _terminal;
|
||||
this._linesCache = null;
|
||||
this._linesCacheTimeoutId = 0;
|
||||
this._destroyLinesCache = this._destroyLinesCache.bind(this);
|
||||
}
|
||||
SearchHelper.prototype.findNext = function (term, searchOptions) {
|
||||
var incremental = searchOptions.incremental;
|
||||
var result;
|
||||
if (!term || term.length === 0) {
|
||||
this._terminal.clearSelection();
|
||||
return false;
|
||||
}
|
||||
var startCol = 0;
|
||||
var startRow = this._terminal.buffer.viewportY;
|
||||
if (this._terminal.hasSelection()) {
|
||||
var currentSelection = this._terminal.getSelectionPosition();
|
||||
startRow = incremental ? currentSelection.startRow : currentSelection.endRow;
|
||||
startCol = incremental ? currentSelection.startColumn : currentSelection.endColumn;
|
||||
}
|
||||
this._initLinesCache();
|
||||
var findingRow = startRow;
|
||||
var cumulativeCols = startCol;
|
||||
while (this._terminal.buffer.getLine(findingRow).isWrapped) {
|
||||
findingRow--;
|
||||
cumulativeCols += this._terminal.cols;
|
||||
}
|
||||
result = this._findInLine(term, findingRow, cumulativeCols, searchOptions);
|
||||
if (!result) {
|
||||
for (var y = startRow + 1; y < this._terminal.buffer.baseY + this._terminal.rows; y++) {
|
||||
result = this._findInLine(term, y, 0, searchOptions);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
for (var y = 0; y < findingRow; y++) {
|
||||
result = this._findInLine(term, y, 0, searchOptions);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._selectResult(result);
|
||||
};
|
||||
SearchHelper.prototype.findPrevious = function (term, searchOptions) {
|
||||
var result;
|
||||
if (!term || term.length === 0) {
|
||||
this._terminal.clearSelection();
|
||||
return false;
|
||||
}
|
||||
var isReverseSearch = true;
|
||||
var startRow = this._terminal.buffer.viewportY + this._terminal.rows - 1;
|
||||
var startCol = this._terminal.cols;
|
||||
if (this._terminal.hasSelection()) {
|
||||
var currentSelection = this._terminal.getSelectionPosition();
|
||||
startRow = currentSelection.startRow;
|
||||
startCol = currentSelection.startColumn;
|
||||
}
|
||||
this._initLinesCache();
|
||||
result = this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
|
||||
if (!result) {
|
||||
var cumulativeCols = this._terminal.cols;
|
||||
if (this._terminal.buffer.getLine(startRow).isWrapped) {
|
||||
cumulativeCols += startCol;
|
||||
}
|
||||
for (var y = startRow - 1; y >= 0; y--) {
|
||||
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
if (this._terminal.buffer.getLine(y).isWrapped) {
|
||||
cumulativeCols += this._terminal.cols;
|
||||
}
|
||||
else {
|
||||
cumulativeCols = this._terminal.cols;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
var searchFrom = this._terminal.buffer.baseY + this._terminal.rows - 1;
|
||||
var cumulativeCols = this._terminal.cols;
|
||||
for (var y = searchFrom; y >= startRow; y--) {
|
||||
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
if (this._terminal.buffer.getLine(y).isWrapped) {
|
||||
cumulativeCols += this._terminal.cols;
|
||||
}
|
||||
else {
|
||||
cumulativeCols = this._terminal.cols;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._selectResult(result);
|
||||
};
|
||||
SearchHelper.prototype._initLinesCache = function () {
|
||||
var _this = this;
|
||||
if (!this._linesCache) {
|
||||
this._linesCache = new Array(this._terminal.buffer.length);
|
||||
this._cursorMoveListener = this._terminal.onCursorMove(function () { return _this._destroyLinesCache(); });
|
||||
this._resizeListener = this._terminal.onResize(function () { return _this._destroyLinesCache(); });
|
||||
}
|
||||
window.clearTimeout(this._linesCacheTimeoutId);
|
||||
this._linesCacheTimeoutId = window.setTimeout(function () { return _this._destroyLinesCache(); }, LINES_CACHE_TIME_TO_LIVE);
|
||||
};
|
||||
SearchHelper.prototype._destroyLinesCache = function () {
|
||||
this._linesCache = null;
|
||||
if (this._cursorMoveListener) {
|
||||
this._cursorMoveListener.dispose();
|
||||
this._cursorMoveListener = undefined;
|
||||
}
|
||||
if (this._resizeListener) {
|
||||
this._resizeListener.dispose();
|
||||
this._resizeListener = undefined;
|
||||
}
|
||||
if (this._linesCacheTimeoutId) {
|
||||
window.clearTimeout(this._linesCacheTimeoutId);
|
||||
this._linesCacheTimeoutId = 0;
|
||||
}
|
||||
};
|
||||
SearchHelper.prototype._isWholeWord = function (searchIndex, line, term) {
|
||||
return (((searchIndex === 0) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex - 1]) !== -1)) &&
|
||||
(((searchIndex + term.length) === line.length) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex + term.length]) !== -1)));
|
||||
};
|
||||
SearchHelper.prototype._findInLine = function (term, row, col, searchOptions, isReverseSearch) {
|
||||
if (searchOptions === void 0) { searchOptions = {}; }
|
||||
if (isReverseSearch === void 0) { isReverseSearch = false; }
|
||||
if (this._terminal.buffer.getLine(row).isWrapped) {
|
||||
return;
|
||||
}
|
||||
var stringLine = this._linesCache ? this._linesCache[row] : void 0;
|
||||
if (stringLine === void 0) {
|
||||
stringLine = this.translateBufferLineToStringWithWrap(row, true);
|
||||
if (this._linesCache) {
|
||||
this._linesCache[row] = stringLine;
|
||||
}
|
||||
}
|
||||
var searchTerm = searchOptions.caseSensitive ? term : term.toLowerCase();
|
||||
var searchStringLine = searchOptions.caseSensitive ? stringLine : stringLine.toLowerCase();
|
||||
var resultIndex = -1;
|
||||
if (searchOptions.regex) {
|
||||
var searchRegex = RegExp(searchTerm, 'g');
|
||||
var foundTerm = void 0;
|
||||
if (isReverseSearch) {
|
||||
while (foundTerm = searchRegex.exec(searchStringLine.slice(0, col))) {
|
||||
resultIndex = searchRegex.lastIndex - foundTerm[0].length;
|
||||
term = foundTerm[0];
|
||||
searchRegex.lastIndex -= (term.length - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
foundTerm = searchRegex.exec(searchStringLine.slice(col));
|
||||
if (foundTerm && foundTerm[0].length > 0) {
|
||||
resultIndex = col + (searchRegex.lastIndex - foundTerm[0].length);
|
||||
term = foundTerm[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isReverseSearch) {
|
||||
if (col - searchTerm.length >= 0) {
|
||||
resultIndex = searchStringLine.lastIndexOf(searchTerm, col - searchTerm.length);
|
||||
}
|
||||
}
|
||||
else {
|
||||
resultIndex = searchStringLine.indexOf(searchTerm, col);
|
||||
}
|
||||
}
|
||||
if (resultIndex >= 0) {
|
||||
if (resultIndex >= this._terminal.cols) {
|
||||
row += Math.floor(resultIndex / this._terminal.cols);
|
||||
resultIndex = resultIndex % this._terminal.cols;
|
||||
}
|
||||
if (searchOptions.wholeWord && !this._isWholeWord(resultIndex, searchStringLine, term)) {
|
||||
return;
|
||||
}
|
||||
var line = this._terminal.buffer.getLine(row);
|
||||
for (var i = 0; i < resultIndex; i++) {
|
||||
var cell = line.getCell(i);
|
||||
var char = cell.char;
|
||||
if (char.length > 1) {
|
||||
resultIndex -= char.length - 1;
|
||||
}
|
||||
var charWidth = cell.width;
|
||||
if (charWidth === 0) {
|
||||
resultIndex++;
|
||||
}
|
||||
}
|
||||
return {
|
||||
term: term,
|
||||
col: resultIndex,
|
||||
row: row
|
||||
};
|
||||
}
|
||||
};
|
||||
SearchHelper.prototype.translateBufferLineToStringWithWrap = function (lineIndex, trimRight) {
|
||||
var lineString = '';
|
||||
var lineWrapsToNext;
|
||||
do {
|
||||
var nextLine = this._terminal.buffer.getLine(lineIndex + 1);
|
||||
lineWrapsToNext = nextLine ? nextLine.isWrapped : false;
|
||||
lineString += this._terminal.buffer.getLine(lineIndex).translateToString(!lineWrapsToNext && trimRight).substring(0, this._terminal.cols);
|
||||
lineIndex++;
|
||||
} while (lineWrapsToNext);
|
||||
return lineString;
|
||||
};
|
||||
SearchHelper.prototype._selectResult = function (result) {
|
||||
if (!result) {
|
||||
this._terminal.clearSelection();
|
||||
return false;
|
||||
}
|
||||
this._terminal.select(result.col, result.row, result.term.length);
|
||||
this._terminal.scrollLines(result.row - this._terminal.buffer.viewportY);
|
||||
return true;
|
||||
};
|
||||
return SearchHelper;
|
||||
}());
|
||||
exports.SearchHelper = SearchHelper;
|
||||
|
||||
},{}],2:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var SearchHelper_1 = require("./SearchHelper");
|
||||
function findNext(terminal, term, searchOptions) {
|
||||
if (searchOptions === void 0) { searchOptions = {}; }
|
||||
var addonTerminal = terminal;
|
||||
if (!addonTerminal.__searchHelper) {
|
||||
addonTerminal.__searchHelper = new SearchHelper_1.SearchHelper(addonTerminal);
|
||||
}
|
||||
return addonTerminal.__searchHelper.findNext(term, searchOptions);
|
||||
}
|
||||
exports.findNext = findNext;
|
||||
function findPrevious(terminal, term, searchOptions) {
|
||||
var addonTerminal = terminal;
|
||||
if (!addonTerminal.__searchHelper) {
|
||||
addonTerminal.__searchHelper = new SearchHelper_1.SearchHelper(addonTerminal);
|
||||
}
|
||||
return addonTerminal.__searchHelper.findPrevious(term, searchOptions);
|
||||
}
|
||||
exports.findPrevious = findPrevious;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.findNext = function (term, searchOptions) {
|
||||
return findNext(this, term, searchOptions);
|
||||
};
|
||||
terminalConstructor.prototype.findPrevious = function (term, searchOptions) {
|
||||
return findPrevious(this, term, searchOptions);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
|
||||
},{"./SearchHelper":1}]},{},[2])(2)
|
||||
});
|
||||
//# sourceMappingURL=search.js.map
|
||||
70
ports/javascript/node_modules/xterm/dist/addons/terminado/terminado.js
generated
vendored
Normal file
70
ports/javascript/node_modules/xterm/dist/addons/terminado/terminado.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.terminado = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function terminadoAttach(term, socket, bidirectional, buffered) {
|
||||
var addonTerminal = term;
|
||||
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
|
||||
addonTerminal.__socket = socket;
|
||||
addonTerminal.__flushBuffer = function () {
|
||||
addonTerminal.write(addonTerminal.__attachSocketBuffer);
|
||||
addonTerminal.__attachSocketBuffer = null;
|
||||
};
|
||||
addonTerminal.__pushToBuffer = function (data) {
|
||||
if (addonTerminal.__attachSocketBuffer) {
|
||||
addonTerminal.__attachSocketBuffer += data;
|
||||
}
|
||||
else {
|
||||
addonTerminal.__attachSocketBuffer = data;
|
||||
setTimeout(addonTerminal.__flushBuffer, 10);
|
||||
}
|
||||
};
|
||||
addonTerminal.__getMessage = function (ev) {
|
||||
var data = JSON.parse(ev.data);
|
||||
if (data[0] === 'stdout') {
|
||||
if (buffered) {
|
||||
addonTerminal.__pushToBuffer(data[1]);
|
||||
}
|
||||
else {
|
||||
addonTerminal.write(data[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
addonTerminal.__sendData = function (data) {
|
||||
socket.send(JSON.stringify(['stdin', data]));
|
||||
};
|
||||
addonTerminal.__setSize = function (size) {
|
||||
socket.send(JSON.stringify(['set_size', size.rows, size.cols]));
|
||||
};
|
||||
socket.addEventListener('message', addonTerminal.__getMessage);
|
||||
if (bidirectional) {
|
||||
addonTerminal._core.register(addonTerminal.onData(addonTerminal.__sendData));
|
||||
}
|
||||
addonTerminal._core.register(addonTerminal.onResize(addonTerminal.__setSize));
|
||||
socket.addEventListener('close', function () { return terminadoDetach(addonTerminal, socket); });
|
||||
socket.addEventListener('error', function () { return terminadoDetach(addonTerminal, socket); });
|
||||
}
|
||||
exports.terminadoAttach = terminadoAttach;
|
||||
function terminadoDetach(term, socket) {
|
||||
var addonTerminal = term;
|
||||
addonTerminal.__dataListener.dispose();
|
||||
addonTerminal.__dataListener = undefined;
|
||||
socket = (typeof socket === 'undefined') ? addonTerminal.__socket : socket;
|
||||
if (socket) {
|
||||
socket.removeEventListener('message', addonTerminal.__getMessage);
|
||||
}
|
||||
delete addonTerminal.__socket;
|
||||
}
|
||||
exports.terminadoDetach = terminadoDetach;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.terminadoAttach = function (socket, bidirectional, buffered) {
|
||||
return terminadoAttach(this, socket, bidirectional, buffered);
|
||||
};
|
||||
terminalConstructor.prototype.terminadoDetach = function (socket) {
|
||||
return terminadoDetach(this, socket);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
//# sourceMappingURL=terminado.js.map
|
||||
42
ports/javascript/node_modules/xterm/dist/addons/webLinks/webLinks.js
generated
vendored
Normal file
42
ports/javascript/node_modules/xterm/dist/addons/webLinks/webLinks.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.webLinks = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var protocolClause = '(https?:\\/\\/)';
|
||||
var domainCharacterSet = '[\\da-z\\.-]+';
|
||||
var negatedDomainCharacterSet = '[^\\da-z\\.-]+';
|
||||
var domainBodyClause = '(' + domainCharacterSet + ')';
|
||||
var tldClause = '([a-z\\.]{2,6})';
|
||||
var ipClause = '((\\d{1,3}\\.){3}\\d{1,3})';
|
||||
var localHostClause = '(localhost)';
|
||||
var portClause = '(:\\d{1,5})';
|
||||
var hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
|
||||
var pathCharacterSet = '(\\/[\\/\\w\\.\\-%~:+]*)*([^:"\'\\s])';
|
||||
var pathClause = '(' + pathCharacterSet + ')?';
|
||||
var queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';
|
||||
var queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';
|
||||
var hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';
|
||||
var negatedPathCharacterSet = '[^\\/\\w\\.\\-%]+';
|
||||
var bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;
|
||||
var start = '(?:^|' + negatedDomainCharacterSet + ')(';
|
||||
var end = ')($|' + negatedPathCharacterSet + ')';
|
||||
var strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);
|
||||
function handleLink(event, uri) {
|
||||
window.open(uri, '_blank');
|
||||
}
|
||||
function webLinksInit(term, handler, options) {
|
||||
if (handler === void 0) { handler = handleLink; }
|
||||
if (options === void 0) { options = {}; }
|
||||
options.matchIndex = 1;
|
||||
term.registerLinkMatcher(strictUrlRegex, handler, options);
|
||||
}
|
||||
exports.webLinksInit = webLinksInit;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.webLinksInit = function (handler, options) {
|
||||
webLinksInit(this, handler, options);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
//# sourceMappingURL=webLinks.js.map
|
||||
45
ports/javascript/node_modules/xterm/dist/addons/zmodem/zmodem.js
generated
vendored
Normal file
45
ports/javascript/node_modules/xterm/dist/addons/zmodem/zmodem.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.zmodem = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var zmodem;
|
||||
function zmodemAttach(ws, opts) {
|
||||
if (opts === void 0) { opts = {}; }
|
||||
var term = this;
|
||||
var senderFunc = function (octets) { return ws.send(new Uint8Array(octets)); };
|
||||
var zsentry;
|
||||
function shouldWrite() {
|
||||
return !!zsentry.get_confirmed_session() || !opts.noTerminalWriteOutsideSession;
|
||||
}
|
||||
zsentry = new zmodem.Sentry({
|
||||
to_terminal: function (octets) {
|
||||
if (shouldWrite()) {
|
||||
term.write(String.fromCharCode.apply(String, octets));
|
||||
}
|
||||
},
|
||||
sender: senderFunc,
|
||||
on_retract: function () { return term.emit('zmodemRetract'); },
|
||||
on_detect: function (detection) { return term.emit('zmodemDetect', detection); }
|
||||
});
|
||||
function handleWSMessage(evt) {
|
||||
if (typeof evt.data === 'string') {
|
||||
if (shouldWrite()) {
|
||||
term.write(evt.data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
zsentry.consume(evt.data);
|
||||
}
|
||||
}
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.addEventListener('message', handleWSMessage);
|
||||
}
|
||||
function apply(terminalConstructor) {
|
||||
zmodem = (typeof window === 'object') ? window.Zmodem : { Browser: null };
|
||||
terminalConstructor.prototype.zmodemAttach = zmodemAttach;
|
||||
terminalConstructor.prototype.zmodemBrowser = zmodem.Browser;
|
||||
}
|
||||
exports.apply = apply;
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
//# sourceMappingURL=zmodem.js.map
|
||||
171
ports/javascript/node_modules/xterm/dist/xterm.css
generated
vendored
Normal file
171
ports/javascript/node_modules/xterm/dist/xterm.css
generated
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
/**
|
||||
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
||||
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||
* https://github.com/chjj/term.js
|
||||
* @license MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Originally forked from (with the author's permission):
|
||||
* Fabrice Bellard's javascript vt100 for jslinux:
|
||||
* http://bellard.org/jslinux/
|
||||
* Copyright (c) 2011 Fabrice Bellard
|
||||
* The original design remains. The terminal itself
|
||||
* has been extended to include xterm CSI codes, among
|
||||
* other features.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default styles for xterm.js
|
||||
*/
|
||||
|
||||
.xterm {
|
||||
font-feature-settings: "liga" 0;
|
||||
position: relative;
|
||||
user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.xterm.focus,
|
||||
.xterm:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.xterm .xterm-helpers {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
/**
|
||||
* The z-index of the helpers must be higher than the canvases in order for
|
||||
* IMEs to appear on top.
|
||||
*/
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.xterm .xterm-helper-textarea {
|
||||
/*
|
||||
* HACK: to fix IE's blinking cursor
|
||||
* Move textarea out of the screen to the far left, so that the cursor is not visible.
|
||||
*/
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
left: -9999em;
|
||||
top: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
z-index: -10;
|
||||
/** Prevent wrapping so the IME appears against the textarea at the correct position */
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.xterm .composition-view {
|
||||
/* TODO: Composition position got messed up somewhere */
|
||||
background: #000;
|
||||
color: #FFF;
|
||||
display: none;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.xterm .composition-view.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.xterm .xterm-viewport {
|
||||
/* On OS X this is required in order for the scroll bar to appear fully opaque */
|
||||
background-color: #000;
|
||||
overflow-y: scroll;
|
||||
cursor: default;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.xterm .xterm-screen {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.xterm .xterm-screen canvas {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.xterm .xterm-scroll-area {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.xterm-char-measure-element {
|
||||
display: inline-block;
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -9999em;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.xterm {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.xterm.enable-mouse-events {
|
||||
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.xterm.xterm-cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.xterm.column-select.focus {
|
||||
/* Column selection mode */
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.xterm .xterm-accessibility,
|
||||
.xterm .xterm-message {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 100;
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.xterm .live-region {
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.xterm-dim {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.xterm-underline {
|
||||
text-decoration: underline;
|
||||
}
|
||||
10708
ports/javascript/node_modules/xterm/dist/xterm.js
generated
vendored
Normal file
10708
ports/javascript/node_modules/xterm/dist/xterm.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
145
ports/javascript/node_modules/xterm/gulpfile.js
generated
vendored
Normal file
145
ports/javascript/node_modules/xterm/gulpfile.js
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
/**
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
const browserify = require('browserify');
|
||||
const buffer = require('vinyl-buffer');
|
||||
const fs = require('fs-extra');
|
||||
const gulp = require('gulp');
|
||||
const path = require('path');
|
||||
const merge = require('merge-stream');
|
||||
const mocha = require('gulp-mocha');
|
||||
const sorcery = require('sorcery');
|
||||
const source = require('vinyl-source-stream');
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const ts = require('gulp-typescript');
|
||||
const util = require('gulp-util');
|
||||
|
||||
const buildDir = process.env.BUILD_DIR || 'build';
|
||||
const tsProject = ts.createProject('src/tsconfig.json');
|
||||
let srcDir = './src';
|
||||
let outDir = './lib';
|
||||
|
||||
const addons = fs.readdirSync(`${__dirname}/src/addons`);
|
||||
|
||||
const TEST_PATHS = [
|
||||
`${outDir}/*test.js`,
|
||||
`${outDir}/**/*test.js`,
|
||||
`${outDir}/*integration.js`,
|
||||
`${outDir}/**/*integration.js`
|
||||
];
|
||||
|
||||
// Under some environments like TravisCI, this comes out at absolute which can
|
||||
// break the build. This ensures that the outDir is absolute.
|
||||
if (path.normalize(outDir).indexOf(__dirname) !== 0) {
|
||||
outDir = `${__dirname}/${path.normalize(outDir)}`;
|
||||
}
|
||||
|
||||
gulp.task('css', function() {
|
||||
return gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir));
|
||||
});
|
||||
|
||||
gulp.task('css-build', function() {
|
||||
return gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(buildDir));
|
||||
});
|
||||
|
||||
gulp.task('watch-css', function() {
|
||||
return gulp.watch(`${srcDir}/**/*.css`, ['css']);
|
||||
});
|
||||
|
||||
/**
|
||||
* Bundle JavaScript files produced by the `tsc` task, into a single file named `xterm.js` with
|
||||
* Browserify.
|
||||
*/
|
||||
gulp.task('browserify', function() {
|
||||
// Ensure that the build directory exists
|
||||
fs.ensureDirSync(buildDir);
|
||||
|
||||
let browserifyOptions = {
|
||||
basedir: buildDir,
|
||||
debug: true,
|
||||
entries: [`${outDir}/xterm.js`],
|
||||
standalone: 'Terminal',
|
||||
cache: {},
|
||||
packageCache: {}
|
||||
};
|
||||
let bundleStream = browserify(browserifyOptions)
|
||||
.bundle()
|
||||
.pipe(source(`xterm.js`))
|
||||
.pipe(buffer())
|
||||
.pipe(sourcemaps.init({loadMaps: true, sourceRoot: '..'}))
|
||||
.pipe(sourcemaps.write('./'))
|
||||
.pipe(gulp.dest(buildDir));
|
||||
|
||||
// Copy stylesheets from ${outDir}/ to ${buildDir}/
|
||||
let copyStylesheets = gulp.src(`${outDir}/**/*.css`).pipe(gulp.dest(buildDir));
|
||||
|
||||
return merge(bundleStream, copyStylesheets);
|
||||
});
|
||||
|
||||
gulp.task('browserify-addons', function() {
|
||||
const bundles = addons.map((addon) => {
|
||||
const addonOptions = {
|
||||
basedir: `${buildDir}/addons/${addon}`,
|
||||
debug: true,
|
||||
entries: [`${outDir}/addons/${addon}/${addon}.js`],
|
||||
standalone: addon,
|
||||
cache: {},
|
||||
packageCache: {}
|
||||
};
|
||||
|
||||
const addonBundle = browserify(addonOptions)
|
||||
.external(path.join(outDir, 'Terminal.js'))
|
||||
.bundle()
|
||||
.pipe(source(`./addons/${addon}/${addon}.js`))
|
||||
.pipe(buffer())
|
||||
.pipe(sourcemaps.init({loadMaps: true, sourceRoot: ''}))
|
||||
.pipe(sourcemaps.write('./'))
|
||||
.pipe(gulp.dest(buildDir));
|
||||
|
||||
return addonBundle;
|
||||
});
|
||||
|
||||
return merge(...bundles);
|
||||
});
|
||||
|
||||
gulp.task('mocha', function () {
|
||||
return gulp.src(TEST_PATHS, {read: false})
|
||||
.pipe(mocha())
|
||||
.once('error', () => process.exit(1));
|
||||
});
|
||||
|
||||
/**
|
||||
* Run single test suite (file) by file name (without file extension). Example of the command:
|
||||
* gulp mocha-suite --test InputHandler.test
|
||||
*/
|
||||
gulp.task('mocha-suite', [], function () {
|
||||
let testName = util.env.test;
|
||||
util.log("Run test by Name: " + testName);
|
||||
return gulp.src([`${outDir}/${testName}.js`, `${outDir}/**/${testName}.js`], {read: false})
|
||||
.pipe(mocha())
|
||||
.once('error', () => process.exit(1));
|
||||
});
|
||||
|
||||
/**
|
||||
* Use `sorcery` to resolve the source map chain and point back to the TypeScript files.
|
||||
* (Without this task the source maps produced for the JavaScript bundle points into the
|
||||
* compiled JavaScript files in ${outDir}/).
|
||||
*/
|
||||
gulp.task('sorcery', ['browserify'], function () {
|
||||
let chain = sorcery.loadSync(`${buildDir}/xterm.js`);
|
||||
chain.apply();
|
||||
chain.writeSync();
|
||||
});
|
||||
|
||||
gulp.task('sorcery-addons', ['browserify-addons'], function () {
|
||||
addons.forEach((addon) => {
|
||||
const chain = sorcery.loadSync(`${buildDir}/addons/${addon}/${addon}.js`);
|
||||
chain.apply();
|
||||
chain.writeSync();
|
||||
})
|
||||
});
|
||||
|
||||
gulp.task('build', ['css', 'css-build', 'sorcery', 'sorcery-addons']);
|
||||
gulp.task('test', ['mocha']);
|
||||
gulp.task('default', ['build']);
|
||||
226
ports/javascript/node_modules/xterm/lib/AccessibilityManager.js
generated
vendored
Normal file
226
ports/javascript/node_modules/xterm/lib/AccessibilityManager.js
generated
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Strings = require("./Strings");
|
||||
var Platform_1 = require("./common/Platform");
|
||||
var RenderDebouncer_1 = require("./ui/RenderDebouncer");
|
||||
var Lifecycle_1 = require("./ui/Lifecycle");
|
||||
var Lifecycle_2 = require("./common/Lifecycle");
|
||||
var ScreenDprMonitor_1 = require("./ui/ScreenDprMonitor");
|
||||
var MAX_ROWS_TO_READ = 20;
|
||||
var AccessibilityManager = (function (_super) {
|
||||
__extends(AccessibilityManager, _super);
|
||||
function AccessibilityManager(_terminal, _dimensions) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this._terminal = _terminal;
|
||||
_this._dimensions = _dimensions;
|
||||
_this._liveRegionLineCount = 0;
|
||||
_this._charsToConsume = [];
|
||||
_this._charsToAnnounce = '';
|
||||
_this._accessibilityTreeRoot = document.createElement('div');
|
||||
_this._accessibilityTreeRoot.classList.add('xterm-accessibility');
|
||||
_this._rowContainer = document.createElement('div');
|
||||
_this._rowContainer.classList.add('xterm-accessibility-tree');
|
||||
_this._rowElements = [];
|
||||
for (var i = 0; i < _this._terminal.rows; i++) {
|
||||
_this._rowElements[i] = _this._createAccessibilityTreeNode();
|
||||
_this._rowContainer.appendChild(_this._rowElements[i]);
|
||||
}
|
||||
_this._topBoundaryFocusListener = function (e) { return _this._onBoundaryFocus(e, 0); };
|
||||
_this._bottomBoundaryFocusListener = function (e) { return _this._onBoundaryFocus(e, 1); };
|
||||
_this._rowElements[0].addEventListener('focus', _this._topBoundaryFocusListener);
|
||||
_this._rowElements[_this._rowElements.length - 1].addEventListener('focus', _this._bottomBoundaryFocusListener);
|
||||
_this._refreshRowsDimensions();
|
||||
_this._accessibilityTreeRoot.appendChild(_this._rowContainer);
|
||||
_this._renderRowsDebouncer = new RenderDebouncer_1.RenderDebouncer(_this._renderRows.bind(_this));
|
||||
_this._refreshRows();
|
||||
_this._liveRegion = document.createElement('div');
|
||||
_this._liveRegion.classList.add('live-region');
|
||||
_this._liveRegion.setAttribute('aria-live', 'assertive');
|
||||
_this._accessibilityTreeRoot.appendChild(_this._liveRegion);
|
||||
_this._terminal.element.insertAdjacentElement('afterbegin', _this._accessibilityTreeRoot);
|
||||
_this.register(_this._renderRowsDebouncer);
|
||||
_this.register(_this._terminal.onResize(function (e) { return _this._onResize(e.rows); }));
|
||||
_this.register(_this._terminal.onRender(function (e) { return _this._refreshRows(e.start, e.end); }));
|
||||
_this.register(_this._terminal.onScroll(function () { return _this._refreshRows(); }));
|
||||
_this.register(_this._terminal.addDisposableListener('a11y.char', function (char) { return _this._onChar(char); }));
|
||||
_this.register(_this._terminal.onLineFeed(function () { return _this._onChar('\n'); }));
|
||||
_this.register(_this._terminal.addDisposableListener('a11y.tab', function (spaceCount) { return _this._onTab(spaceCount); }));
|
||||
_this.register(_this._terminal.onKey(function (e) { return _this._onKey(e.key); }));
|
||||
_this.register(_this._terminal.addDisposableListener('blur', function () { return _this._clearLiveRegion(); }));
|
||||
_this._screenDprMonitor = new ScreenDprMonitor_1.ScreenDprMonitor();
|
||||
_this.register(_this._screenDprMonitor);
|
||||
_this._screenDprMonitor.setListener(function () { return _this._refreshRowsDimensions(); });
|
||||
_this.register(Lifecycle_1.addDisposableDomListener(window, 'resize', function () { return _this._refreshRowsDimensions(); }));
|
||||
return _this;
|
||||
}
|
||||
AccessibilityManager.prototype.dispose = function () {
|
||||
_super.prototype.dispose.call(this);
|
||||
this._terminal.element.removeChild(this._accessibilityTreeRoot);
|
||||
this._rowElements.length = 0;
|
||||
};
|
||||
AccessibilityManager.prototype._onBoundaryFocus = function (e, position) {
|
||||
var boundaryElement = e.target;
|
||||
var beforeBoundaryElement = this._rowElements[position === 0 ? 1 : this._rowElements.length - 2];
|
||||
var posInSet = boundaryElement.getAttribute('aria-posinset');
|
||||
var lastRowPos = position === 0 ? '1' : "" + this._terminal.buffer.lines.length;
|
||||
if (posInSet === lastRowPos) {
|
||||
return;
|
||||
}
|
||||
if (e.relatedTarget !== beforeBoundaryElement) {
|
||||
return;
|
||||
}
|
||||
var topBoundaryElement;
|
||||
var bottomBoundaryElement;
|
||||
if (position === 0) {
|
||||
topBoundaryElement = boundaryElement;
|
||||
bottomBoundaryElement = this._rowElements.pop();
|
||||
this._rowContainer.removeChild(bottomBoundaryElement);
|
||||
}
|
||||
else {
|
||||
topBoundaryElement = this._rowElements.shift();
|
||||
bottomBoundaryElement = boundaryElement;
|
||||
this._rowContainer.removeChild(topBoundaryElement);
|
||||
}
|
||||
topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener);
|
||||
bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener);
|
||||
if (position === 0) {
|
||||
var newElement = this._createAccessibilityTreeNode();
|
||||
this._rowElements.unshift(newElement);
|
||||
this._rowContainer.insertAdjacentElement('afterbegin', newElement);
|
||||
}
|
||||
else {
|
||||
var newElement = this._createAccessibilityTreeNode();
|
||||
this._rowElements.push(newElement);
|
||||
this._rowContainer.appendChild(newElement);
|
||||
}
|
||||
this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);
|
||||
this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
|
||||
this._terminal.scrollLines(position === 0 ? -1 : 1);
|
||||
this._rowElements[position === 0 ? 1 : this._rowElements.length - 2].focus();
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
};
|
||||
AccessibilityManager.prototype._onResize = function (rows) {
|
||||
this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener);
|
||||
for (var i = this._rowContainer.children.length; i < this._terminal.rows; i++) {
|
||||
this._rowElements[i] = this._createAccessibilityTreeNode();
|
||||
this._rowContainer.appendChild(this._rowElements[i]);
|
||||
}
|
||||
while (this._rowElements.length > rows) {
|
||||
this._rowContainer.removeChild(this._rowElements.pop());
|
||||
}
|
||||
this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
|
||||
this._refreshRowsDimensions();
|
||||
};
|
||||
AccessibilityManager.prototype._createAccessibilityTreeNode = function () {
|
||||
var element = document.createElement('div');
|
||||
element.setAttribute('role', 'listitem');
|
||||
element.tabIndex = -1;
|
||||
this._refreshRowDimensions(element);
|
||||
return element;
|
||||
};
|
||||
AccessibilityManager.prototype._onTab = function (spaceCount) {
|
||||
for (var i = 0; i < spaceCount; i++) {
|
||||
this._onChar(' ');
|
||||
}
|
||||
};
|
||||
AccessibilityManager.prototype._onChar = function (char) {
|
||||
var _this = this;
|
||||
if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) {
|
||||
if (this._charsToConsume.length > 0) {
|
||||
var shiftedChar = this._charsToConsume.shift();
|
||||
if (shiftedChar !== char) {
|
||||
this._charsToAnnounce += char;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._charsToAnnounce += char;
|
||||
}
|
||||
if (char === '\n') {
|
||||
this._liveRegionLineCount++;
|
||||
if (this._liveRegionLineCount === MAX_ROWS_TO_READ + 1) {
|
||||
this._liveRegion.textContent += Strings.tooMuchOutput;
|
||||
}
|
||||
}
|
||||
if (Platform_1.isMac) {
|
||||
if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
|
||||
setTimeout(function () {
|
||||
_this._accessibilityTreeRoot.appendChild(_this._liveRegion);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
AccessibilityManager.prototype._clearLiveRegion = function () {
|
||||
this._liveRegion.textContent = '';
|
||||
this._liveRegionLineCount = 0;
|
||||
if (Platform_1.isMac) {
|
||||
if (this._liveRegion.parentNode) {
|
||||
this._accessibilityTreeRoot.removeChild(this._liveRegion);
|
||||
}
|
||||
}
|
||||
};
|
||||
AccessibilityManager.prototype._onKey = function (keyChar) {
|
||||
this._clearLiveRegion();
|
||||
this._charsToConsume.push(keyChar);
|
||||
};
|
||||
AccessibilityManager.prototype._refreshRows = function (start, end) {
|
||||
this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);
|
||||
};
|
||||
AccessibilityManager.prototype._renderRows = function (start, end) {
|
||||
var buffer = this._terminal.buffer;
|
||||
var setSize = buffer.lines.length.toString();
|
||||
for (var i = start; i <= end; i++) {
|
||||
var lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);
|
||||
var posInSet = (buffer.ydisp + i + 1).toString();
|
||||
var element = this._rowElements[i];
|
||||
if (element) {
|
||||
element.textContent = lineData.length === 0 ? Strings.blankLine : lineData;
|
||||
element.setAttribute('aria-posinset', posInSet);
|
||||
element.setAttribute('aria-setsize', setSize);
|
||||
}
|
||||
}
|
||||
this._announceCharacters();
|
||||
};
|
||||
AccessibilityManager.prototype._refreshRowsDimensions = function () {
|
||||
if (!this._dimensions.actualCellHeight) {
|
||||
return;
|
||||
}
|
||||
if (this._rowElements.length !== this._terminal.rows) {
|
||||
this._onResize(this._terminal.rows);
|
||||
}
|
||||
for (var i = 0; i < this._terminal.rows; i++) {
|
||||
this._refreshRowDimensions(this._rowElements[i]);
|
||||
}
|
||||
};
|
||||
AccessibilityManager.prototype.setDimensions = function (dimensions) {
|
||||
this._dimensions = dimensions;
|
||||
this._refreshRowsDimensions();
|
||||
};
|
||||
AccessibilityManager.prototype._refreshRowDimensions = function (element) {
|
||||
element.style.height = this._dimensions.actualCellHeight + "px";
|
||||
};
|
||||
AccessibilityManager.prototype._announceCharacters = function () {
|
||||
if (this._charsToAnnounce.length === 0) {
|
||||
return;
|
||||
}
|
||||
this._liveRegion.textContent += this._charsToAnnounce;
|
||||
this._charsToAnnounce = '';
|
||||
};
|
||||
return AccessibilityManager;
|
||||
}(Lifecycle_2.Disposable));
|
||||
exports.AccessibilityManager = AccessibilityManager;
|
||||
//# sourceMappingURL=AccessibilityManager.js.map
|
||||
486
ports/javascript/node_modules/xterm/lib/Buffer.js
generated
vendored
Normal file
486
ports/javascript/node_modules/xterm/lib/Buffer.js
generated
vendored
Normal file
@ -0,0 +1,486 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var CircularList_1 = require("./common/CircularList");
|
||||
var BufferLine_1 = require("./core/buffer/BufferLine");
|
||||
var BufferReflow_1 = require("./core/buffer/BufferReflow");
|
||||
var Marker_1 = require("./core/buffer/Marker");
|
||||
exports.MAX_BUFFER_SIZE = 4294967295;
|
||||
var Buffer = (function () {
|
||||
function Buffer(_terminal, _hasScrollback) {
|
||||
this._terminal = _terminal;
|
||||
this._hasScrollback = _hasScrollback;
|
||||
this.savedCurAttrData = BufferLine_1.DEFAULT_ATTR_DATA.clone();
|
||||
this.markers = [];
|
||||
this._nullCell = BufferLine_1.CellData.fromCharData([0, BufferLine_1.NULL_CELL_CHAR, BufferLine_1.NULL_CELL_WIDTH, BufferLine_1.NULL_CELL_CODE]);
|
||||
this._whitespaceCell = BufferLine_1.CellData.fromCharData([0, BufferLine_1.WHITESPACE_CELL_CHAR, BufferLine_1.WHITESPACE_CELL_WIDTH, BufferLine_1.WHITESPACE_CELL_CODE]);
|
||||
this._cols = this._terminal.cols;
|
||||
this._rows = this._terminal.rows;
|
||||
this.clear();
|
||||
}
|
||||
Buffer.prototype.getNullCell = function (attr) {
|
||||
if (attr) {
|
||||
this._nullCell.fg = attr.fg;
|
||||
this._nullCell.bg = attr.bg;
|
||||
}
|
||||
else {
|
||||
this._nullCell.fg = 0;
|
||||
this._nullCell.bg = 0;
|
||||
}
|
||||
return this._nullCell;
|
||||
};
|
||||
Buffer.prototype.getWhitespaceCell = function (attr) {
|
||||
if (attr) {
|
||||
this._whitespaceCell.fg = attr.fg;
|
||||
this._whitespaceCell.bg = attr.bg;
|
||||
}
|
||||
else {
|
||||
this._whitespaceCell.fg = 0;
|
||||
this._whitespaceCell.bg = 0;
|
||||
}
|
||||
return this._whitespaceCell;
|
||||
};
|
||||
Buffer.prototype.getBlankLine = function (attr, isWrapped) {
|
||||
return new BufferLine_1.BufferLine(this._terminal.cols, this.getNullCell(attr), isWrapped);
|
||||
};
|
||||
Object.defineProperty(Buffer.prototype, "hasScrollback", {
|
||||
get: function () {
|
||||
return this._hasScrollback && this.lines.maxLength > this._rows;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Buffer.prototype, "isCursorInViewport", {
|
||||
get: function () {
|
||||
var absoluteY = this.ybase + this.y;
|
||||
var relativeY = absoluteY - this.ydisp;
|
||||
return (relativeY >= 0 && relativeY < this._rows);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Buffer.prototype._getCorrectBufferLength = function (rows) {
|
||||
if (!this._hasScrollback) {
|
||||
return rows;
|
||||
}
|
||||
var correctBufferLength = rows + this._terminal.options.scrollback;
|
||||
return correctBufferLength > exports.MAX_BUFFER_SIZE ? exports.MAX_BUFFER_SIZE : correctBufferLength;
|
||||
};
|
||||
Buffer.prototype.fillViewportRows = function (fillAttr) {
|
||||
if (this.lines.length === 0) {
|
||||
if (fillAttr === undefined) {
|
||||
fillAttr = BufferLine_1.DEFAULT_ATTR_DATA;
|
||||
}
|
||||
var i = this._rows;
|
||||
while (i--) {
|
||||
this.lines.push(this.getBlankLine(fillAttr));
|
||||
}
|
||||
}
|
||||
};
|
||||
Buffer.prototype.clear = function () {
|
||||
this.ydisp = 0;
|
||||
this.ybase = 0;
|
||||
this.y = 0;
|
||||
this.x = 0;
|
||||
this.lines = new CircularList_1.CircularList(this._getCorrectBufferLength(this._rows));
|
||||
this.scrollTop = 0;
|
||||
this.scrollBottom = this._rows - 1;
|
||||
this.setupTabStops();
|
||||
};
|
||||
Buffer.prototype.resize = function (newCols, newRows) {
|
||||
var nullCell = this.getNullCell(BufferLine_1.DEFAULT_ATTR_DATA);
|
||||
var newMaxLength = this._getCorrectBufferLength(newRows);
|
||||
if (newMaxLength > this.lines.maxLength) {
|
||||
this.lines.maxLength = newMaxLength;
|
||||
}
|
||||
if (this.lines.length > 0) {
|
||||
if (this._cols < newCols) {
|
||||
for (var i = 0; i < this.lines.length; i++) {
|
||||
this.lines.get(i).resize(newCols, nullCell);
|
||||
}
|
||||
}
|
||||
var addToY = 0;
|
||||
if (this._rows < newRows) {
|
||||
for (var y = this._rows; y < newRows; y++) {
|
||||
if (this.lines.length < newRows + this.ybase) {
|
||||
if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) {
|
||||
this.ybase--;
|
||||
addToY++;
|
||||
if (this.ydisp > 0) {
|
||||
this.ydisp--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.lines.push(new BufferLine_1.BufferLine(newCols, nullCell));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var y = this._rows; y > newRows; y--) {
|
||||
if (this.lines.length > newRows + this.ybase) {
|
||||
if (this.lines.length > this.ybase + this.y + 1) {
|
||||
this.lines.pop();
|
||||
}
|
||||
else {
|
||||
this.ybase++;
|
||||
this.ydisp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newMaxLength < this.lines.maxLength) {
|
||||
var amountToTrim = this.lines.length - newMaxLength;
|
||||
if (amountToTrim > 0) {
|
||||
this.lines.trimStart(amountToTrim);
|
||||
this.ybase = Math.max(this.ybase - amountToTrim, 0);
|
||||
this.ydisp = Math.max(this.ydisp - amountToTrim, 0);
|
||||
}
|
||||
this.lines.maxLength = newMaxLength;
|
||||
}
|
||||
this.x = Math.min(this.x, newCols - 1);
|
||||
this.y = Math.min(this.y, newRows - 1);
|
||||
if (addToY) {
|
||||
this.y += addToY;
|
||||
}
|
||||
this.savedY = Math.min(this.savedY, newRows - 1);
|
||||
this.savedX = Math.min(this.savedX, newCols - 1);
|
||||
this.scrollTop = 0;
|
||||
}
|
||||
this.scrollBottom = newRows - 1;
|
||||
if (this._isReflowEnabled) {
|
||||
this._reflow(newCols, newRows);
|
||||
if (this._cols > newCols) {
|
||||
for (var i = 0; i < this.lines.length; i++) {
|
||||
this.lines.get(i).resize(newCols, nullCell);
|
||||
}
|
||||
}
|
||||
}
|
||||
this._cols = newCols;
|
||||
this._rows = newRows;
|
||||
};
|
||||
Object.defineProperty(Buffer.prototype, "_isReflowEnabled", {
|
||||
get: function () {
|
||||
return this._hasScrollback && !this._terminal.options.windowsMode;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Buffer.prototype._reflow = function (newCols, newRows) {
|
||||
if (this._cols === newCols) {
|
||||
return;
|
||||
}
|
||||
if (newCols > this._cols) {
|
||||
this._reflowLarger(newCols, newRows);
|
||||
}
|
||||
else {
|
||||
this._reflowSmaller(newCols, newRows);
|
||||
}
|
||||
};
|
||||
Buffer.prototype._reflowLarger = function (newCols, newRows) {
|
||||
var toRemove = BufferReflow_1.reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(BufferLine_1.DEFAULT_ATTR_DATA));
|
||||
if (toRemove.length > 0) {
|
||||
var newLayoutResult = BufferReflow_1.reflowLargerCreateNewLayout(this.lines, toRemove);
|
||||
BufferReflow_1.reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
|
||||
this._reflowLargerAdjustViewport(newCols, newRows, newLayoutResult.countRemoved);
|
||||
}
|
||||
};
|
||||
Buffer.prototype._reflowLargerAdjustViewport = function (newCols, newRows, countRemoved) {
|
||||
var nullCell = this.getNullCell(BufferLine_1.DEFAULT_ATTR_DATA);
|
||||
var viewportAdjustments = countRemoved;
|
||||
while (viewportAdjustments-- > 0) {
|
||||
if (this.ybase === 0) {
|
||||
if (this.y > 0) {
|
||||
this.y--;
|
||||
}
|
||||
if (this.lines.length < newRows) {
|
||||
this.lines.push(new BufferLine_1.BufferLine(newCols, nullCell));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.ydisp === this.ybase) {
|
||||
this.ydisp--;
|
||||
}
|
||||
this.ybase--;
|
||||
}
|
||||
}
|
||||
};
|
||||
Buffer.prototype._reflowSmaller = function (newCols, newRows) {
|
||||
var nullCell = this.getNullCell(BufferLine_1.DEFAULT_ATTR_DATA);
|
||||
var toInsert = [];
|
||||
var countToInsert = 0;
|
||||
for (var y = this.lines.length - 1; y >= 0; y--) {
|
||||
var nextLine = this.lines.get(y);
|
||||
if (!nextLine || !nextLine.isWrapped && nextLine.getTrimmedLength() <= newCols) {
|
||||
continue;
|
||||
}
|
||||
var wrappedLines = [nextLine];
|
||||
while (nextLine.isWrapped && y > 0) {
|
||||
nextLine = this.lines.get(--y);
|
||||
wrappedLines.unshift(nextLine);
|
||||
}
|
||||
var absoluteY = this.ybase + this.y;
|
||||
if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
|
||||
continue;
|
||||
}
|
||||
var lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();
|
||||
var destLineLengths = BufferReflow_1.reflowSmallerGetNewLineLengths(wrappedLines, this._cols, newCols);
|
||||
var linesToAdd = destLineLengths.length - wrappedLines.length;
|
||||
var trimmedLines = void 0;
|
||||
if (this.ybase === 0 && this.y !== this.lines.length - 1) {
|
||||
trimmedLines = Math.max(0, this.y - this.lines.maxLength + linesToAdd);
|
||||
}
|
||||
else {
|
||||
trimmedLines = Math.max(0, this.lines.length - this.lines.maxLength + linesToAdd);
|
||||
}
|
||||
var newLines = [];
|
||||
for (var i = 0; i < linesToAdd; i++) {
|
||||
var newLine = this.getBlankLine(BufferLine_1.DEFAULT_ATTR_DATA, true);
|
||||
newLines.push(newLine);
|
||||
}
|
||||
if (newLines.length > 0) {
|
||||
toInsert.push({
|
||||
start: y + wrappedLines.length + countToInsert,
|
||||
newLines: newLines
|
||||
});
|
||||
countToInsert += newLines.length;
|
||||
}
|
||||
wrappedLines.push.apply(wrappedLines, newLines);
|
||||
var destLineIndex = destLineLengths.length - 1;
|
||||
var destCol = destLineLengths[destLineIndex];
|
||||
if (destCol === 0) {
|
||||
destLineIndex--;
|
||||
destCol = destLineLengths[destLineIndex];
|
||||
}
|
||||
var srcLineIndex = wrappedLines.length - linesToAdd - 1;
|
||||
var srcCol = lastLineLength;
|
||||
while (srcLineIndex >= 0) {
|
||||
var cellsToCopy = Math.min(srcCol, destCol);
|
||||
wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol - cellsToCopy, destCol - cellsToCopy, cellsToCopy, true);
|
||||
destCol -= cellsToCopy;
|
||||
if (destCol === 0) {
|
||||
destLineIndex--;
|
||||
destCol = destLineLengths[destLineIndex];
|
||||
}
|
||||
srcCol -= cellsToCopy;
|
||||
if (srcCol === 0) {
|
||||
srcLineIndex--;
|
||||
var wrappedLinesIndex = Math.max(srcLineIndex, 0);
|
||||
srcCol = BufferReflow_1.getWrappedLineTrimmedLength(wrappedLines, wrappedLinesIndex, this._cols);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < wrappedLines.length; i++) {
|
||||
if (destLineLengths[i] < newCols) {
|
||||
wrappedLines[i].setCell(destLineLengths[i], nullCell);
|
||||
}
|
||||
}
|
||||
var viewportAdjustments = linesToAdd - trimmedLines;
|
||||
while (viewportAdjustments-- > 0) {
|
||||
if (this.ybase === 0) {
|
||||
if (this.y < newRows - 1) {
|
||||
this.y++;
|
||||
this.lines.pop();
|
||||
}
|
||||
else {
|
||||
this.ybase++;
|
||||
this.ydisp++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.ybase < Math.min(this.lines.maxLength, this.lines.length + countToInsert) - newRows) {
|
||||
if (this.ybase === this.ydisp) {
|
||||
this.ydisp++;
|
||||
}
|
||||
this.ybase++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toInsert.length > 0) {
|
||||
var insertEvents = [];
|
||||
var originalLines = [];
|
||||
for (var i = 0; i < this.lines.length; i++) {
|
||||
originalLines.push(this.lines.get(i));
|
||||
}
|
||||
var originalLinesLength = this.lines.length;
|
||||
var originalLineIndex = originalLinesLength - 1;
|
||||
var nextToInsertIndex = 0;
|
||||
var nextToInsert = toInsert[nextToInsertIndex];
|
||||
this.lines.length = Math.min(this.lines.maxLength, this.lines.length + countToInsert);
|
||||
var countInsertedSoFar = 0;
|
||||
for (var i = Math.min(this.lines.maxLength - 1, originalLinesLength + countToInsert - 1); i >= 0; i--) {
|
||||
if (nextToInsert && nextToInsert.start > originalLineIndex + countInsertedSoFar) {
|
||||
for (var nextI = nextToInsert.newLines.length - 1; nextI >= 0; nextI--) {
|
||||
this.lines.set(i--, nextToInsert.newLines[nextI]);
|
||||
}
|
||||
i++;
|
||||
insertEvents.push({
|
||||
index: originalLineIndex + 1,
|
||||
amount: nextToInsert.newLines.length
|
||||
});
|
||||
countInsertedSoFar += nextToInsert.newLines.length;
|
||||
nextToInsert = toInsert[++nextToInsertIndex];
|
||||
}
|
||||
else {
|
||||
this.lines.set(i, originalLines[originalLineIndex--]);
|
||||
}
|
||||
}
|
||||
var insertCountEmitted = 0;
|
||||
for (var i = insertEvents.length - 1; i >= 0; i--) {
|
||||
insertEvents[i].index += insertCountEmitted;
|
||||
this.lines.onInsertEmitter.fire(insertEvents[i]);
|
||||
insertCountEmitted += insertEvents[i].amount;
|
||||
}
|
||||
var amountToTrim = Math.max(0, originalLinesLength + countToInsert - this.lines.maxLength);
|
||||
if (amountToTrim > 0) {
|
||||
this.lines.onTrimEmitter.fire(amountToTrim);
|
||||
}
|
||||
}
|
||||
};
|
||||
Buffer.prototype.stringIndexToBufferIndex = function (lineIndex, stringIndex, trimRight) {
|
||||
if (trimRight === void 0) { trimRight = false; }
|
||||
while (stringIndex) {
|
||||
var line = this.lines.get(lineIndex);
|
||||
if (!line) {
|
||||
return [-1, -1];
|
||||
}
|
||||
var length_1 = (trimRight) ? line.getTrimmedLength() : line.length;
|
||||
for (var i = 0; i < length_1; ++i) {
|
||||
if (line.get(i)[BufferLine_1.CHAR_DATA_WIDTH_INDEX]) {
|
||||
stringIndex -= line.get(i)[BufferLine_1.CHAR_DATA_CHAR_INDEX].length || 1;
|
||||
}
|
||||
if (stringIndex < 0) {
|
||||
return [lineIndex, i];
|
||||
}
|
||||
}
|
||||
lineIndex++;
|
||||
}
|
||||
return [lineIndex, 0];
|
||||
};
|
||||
Buffer.prototype.translateBufferLineToString = function (lineIndex, trimRight, startCol, endCol) {
|
||||
if (startCol === void 0) { startCol = 0; }
|
||||
var line = this.lines.get(lineIndex);
|
||||
if (!line) {
|
||||
return '';
|
||||
}
|
||||
return line.translateToString(trimRight, startCol, endCol);
|
||||
};
|
||||
Buffer.prototype.getWrappedRangeForLine = function (y) {
|
||||
var first = y;
|
||||
var last = y;
|
||||
while (first > 0 && this.lines.get(first).isWrapped) {
|
||||
first--;
|
||||
}
|
||||
while (last + 1 < this.lines.length && this.lines.get(last + 1).isWrapped) {
|
||||
last++;
|
||||
}
|
||||
return { first: first, last: last };
|
||||
};
|
||||
Buffer.prototype.setupTabStops = function (i) {
|
||||
if (i !== null && i !== undefined) {
|
||||
if (!this.tabs[i]) {
|
||||
i = this.prevStop(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.tabs = {};
|
||||
i = 0;
|
||||
}
|
||||
for (; i < this._cols; i += this._terminal.options.tabStopWidth) {
|
||||
this.tabs[i] = true;
|
||||
}
|
||||
};
|
||||
Buffer.prototype.prevStop = function (x) {
|
||||
if (x === null || x === undefined) {
|
||||
x = this.x;
|
||||
}
|
||||
while (!this.tabs[--x] && x > 0)
|
||||
;
|
||||
return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
|
||||
};
|
||||
Buffer.prototype.nextStop = function (x) {
|
||||
if (x === null || x === undefined) {
|
||||
x = this.x;
|
||||
}
|
||||
while (!this.tabs[++x] && x < this._cols)
|
||||
;
|
||||
return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
|
||||
};
|
||||
Buffer.prototype.addMarker = function (y) {
|
||||
var _this = this;
|
||||
var marker = new Marker_1.Marker(y);
|
||||
this.markers.push(marker);
|
||||
marker.register(this.lines.onTrim(function (amount) {
|
||||
marker.line -= amount;
|
||||
if (marker.line < 0) {
|
||||
marker.dispose();
|
||||
}
|
||||
}));
|
||||
marker.register(this.lines.onInsert(function (event) {
|
||||
if (marker.line >= event.index) {
|
||||
marker.line += event.amount;
|
||||
}
|
||||
}));
|
||||
marker.register(this.lines.onDelete(function (event) {
|
||||
if (marker.line >= event.index && marker.line < event.index + event.amount) {
|
||||
marker.dispose();
|
||||
}
|
||||
if (marker.line > event.index) {
|
||||
marker.line -= event.amount;
|
||||
}
|
||||
}));
|
||||
marker.register(marker.onDispose(function () { return _this._removeMarker(marker); }));
|
||||
return marker;
|
||||
};
|
||||
Buffer.prototype._removeMarker = function (marker) {
|
||||
this.markers.splice(this.markers.indexOf(marker), 1);
|
||||
};
|
||||
Buffer.prototype.iterator = function (trimRight, startIndex, endIndex, startOverscan, endOverscan) {
|
||||
return new BufferStringIterator(this, trimRight, startIndex, endIndex, startOverscan, endOverscan);
|
||||
};
|
||||
return Buffer;
|
||||
}());
|
||||
exports.Buffer = Buffer;
|
||||
var BufferStringIterator = (function () {
|
||||
function BufferStringIterator(_buffer, _trimRight, _startIndex, _endIndex, _startOverscan, _endOverscan) {
|
||||
if (_startIndex === void 0) { _startIndex = 0; }
|
||||
if (_endIndex === void 0) { _endIndex = _buffer.lines.length; }
|
||||
if (_startOverscan === void 0) { _startOverscan = 0; }
|
||||
if (_endOverscan === void 0) { _endOverscan = 0; }
|
||||
this._buffer = _buffer;
|
||||
this._trimRight = _trimRight;
|
||||
this._startIndex = _startIndex;
|
||||
this._endIndex = _endIndex;
|
||||
this._startOverscan = _startOverscan;
|
||||
this._endOverscan = _endOverscan;
|
||||
if (this._startIndex < 0) {
|
||||
this._startIndex = 0;
|
||||
}
|
||||
if (this._endIndex > this._buffer.lines.length) {
|
||||
this._endIndex = this._buffer.lines.length;
|
||||
}
|
||||
this._current = this._startIndex;
|
||||
}
|
||||
BufferStringIterator.prototype.hasNext = function () {
|
||||
return this._current < this._endIndex;
|
||||
};
|
||||
BufferStringIterator.prototype.next = function () {
|
||||
var range = this._buffer.getWrappedRangeForLine(this._current);
|
||||
if (range.first < this._startIndex - this._startOverscan) {
|
||||
range.first = this._startIndex - this._startOverscan;
|
||||
}
|
||||
if (range.last > this._endIndex + this._endOverscan) {
|
||||
range.last = this._endIndex + this._endOverscan;
|
||||
}
|
||||
range.first = Math.max(range.first, 0);
|
||||
range.last = Math.min(range.last, this._buffer.lines.length);
|
||||
var result = '';
|
||||
for (var i = range.first; i <= range.last; ++i) {
|
||||
result += this._buffer.translateBufferLineToString(i, this._trimRight);
|
||||
}
|
||||
this._current = range.last + 1;
|
||||
return { range: range, content: result };
|
||||
};
|
||||
return BufferStringIterator;
|
||||
}());
|
||||
exports.BufferStringIterator = BufferStringIterator;
|
||||
//# sourceMappingURL=Buffer.js.map
|
||||
78
ports/javascript/node_modules/xterm/lib/BufferSet.js
generated
vendored
Normal file
78
ports/javascript/node_modules/xterm/lib/BufferSet.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Buffer_1 = require("./Buffer");
|
||||
var EventEmitter2_1 = require("./common/EventEmitter2");
|
||||
var BufferSet = (function () {
|
||||
function BufferSet(_terminal) {
|
||||
this._terminal = _terminal;
|
||||
this._onBufferActivate = new EventEmitter2_1.EventEmitter2();
|
||||
this._normal = new Buffer_1.Buffer(this._terminal, true);
|
||||
this._normal.fillViewportRows();
|
||||
this._alt = new Buffer_1.Buffer(this._terminal, false);
|
||||
this._activeBuffer = this._normal;
|
||||
this.setupTabStops();
|
||||
}
|
||||
Object.defineProperty(BufferSet.prototype, "onBufferActivate", {
|
||||
get: function () { return this._onBufferActivate.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(BufferSet.prototype, "alt", {
|
||||
get: function () {
|
||||
return this._alt;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(BufferSet.prototype, "active", {
|
||||
get: function () {
|
||||
return this._activeBuffer;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(BufferSet.prototype, "normal", {
|
||||
get: function () {
|
||||
return this._normal;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
BufferSet.prototype.activateNormalBuffer = function () {
|
||||
if (this._activeBuffer === this._normal) {
|
||||
return;
|
||||
}
|
||||
this._normal.x = this._alt.x;
|
||||
this._normal.y = this._alt.y;
|
||||
this._alt.clear();
|
||||
this._activeBuffer = this._normal;
|
||||
this._onBufferActivate.fire({
|
||||
activeBuffer: this._normal,
|
||||
inactiveBuffer: this._alt
|
||||
});
|
||||
};
|
||||
BufferSet.prototype.activateAltBuffer = function (fillAttr) {
|
||||
if (this._activeBuffer === this._alt) {
|
||||
return;
|
||||
}
|
||||
this._alt.fillViewportRows(fillAttr);
|
||||
this._alt.x = this._normal.x;
|
||||
this._alt.y = this._normal.y;
|
||||
this._activeBuffer = this._alt;
|
||||
this._onBufferActivate.fire({
|
||||
activeBuffer: this._alt,
|
||||
inactiveBuffer: this._normal
|
||||
});
|
||||
};
|
||||
BufferSet.prototype.resize = function (newCols, newRows) {
|
||||
this._normal.resize(newCols, newRows);
|
||||
this._alt.resize(newCols, newRows);
|
||||
};
|
||||
BufferSet.prototype.setupTabStops = function (i) {
|
||||
this._normal.setupTabStops(i);
|
||||
this._alt.setupTabStops(i);
|
||||
};
|
||||
return BufferSet;
|
||||
}());
|
||||
exports.BufferSet = BufferSet;
|
||||
//# sourceMappingURL=BufferSet.js.map
|
||||
51
ports/javascript/node_modules/xterm/lib/CharMeasure.js
generated
vendored
Normal file
51
ports/javascript/node_modules/xterm/lib/CharMeasure.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var EventEmitter2_1 = require("./common/EventEmitter2");
|
||||
var CharMeasure = (function () {
|
||||
function CharMeasure(document, parentElement) {
|
||||
this._onCharSizeChanged = new EventEmitter2_1.EventEmitter2();
|
||||
this._document = document;
|
||||
this._parentElement = parentElement;
|
||||
this._measureElement = this._document.createElement('span');
|
||||
this._measureElement.classList.add('xterm-char-measure-element');
|
||||
this._measureElement.textContent = 'W';
|
||||
this._measureElement.setAttribute('aria-hidden', 'true');
|
||||
this._parentElement.appendChild(this._measureElement);
|
||||
}
|
||||
Object.defineProperty(CharMeasure.prototype, "onCharSizeChanged", {
|
||||
get: function () { return this._onCharSizeChanged.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(CharMeasure.prototype, "width", {
|
||||
get: function () {
|
||||
return this._width;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(CharMeasure.prototype, "height", {
|
||||
get: function () {
|
||||
return this._height;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
CharMeasure.prototype.measure = function (options) {
|
||||
this._measureElement.style.fontFamily = options.fontFamily;
|
||||
this._measureElement.style.fontSize = options.fontSize + "px";
|
||||
var geometry = this._measureElement.getBoundingClientRect();
|
||||
if (geometry.width === 0 || geometry.height === 0) {
|
||||
return;
|
||||
}
|
||||
var adjustedHeight = Math.ceil(geometry.height);
|
||||
if (this._width !== geometry.width || this._height !== adjustedHeight) {
|
||||
this._width = geometry.width;
|
||||
this._height = adjustedHeight;
|
||||
this._onCharSizeChanged.fire();
|
||||
}
|
||||
};
|
||||
return CharMeasure;
|
||||
}());
|
||||
exports.CharMeasure = CharMeasure;
|
||||
//# sourceMappingURL=CharMeasure.js.map
|
||||
142
ports/javascript/node_modules/xterm/lib/CharWidth.js
generated
vendored
Normal file
142
ports/javascript/node_modules/xterm/lib/CharWidth.js
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var TypedArrayUtils_1 = require("./common/TypedArrayUtils");
|
||||
exports.wcwidth = (function (opts) {
|
||||
var COMBINING_BMP = [
|
||||
[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
|
||||
[0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
|
||||
[0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
|
||||
[0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
|
||||
[0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
|
||||
[0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
|
||||
[0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
|
||||
[0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
|
||||
[0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
|
||||
[0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
|
||||
[0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
|
||||
[0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
|
||||
[0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
|
||||
[0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
|
||||
[0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
|
||||
[0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
|
||||
[0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
|
||||
[0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
|
||||
[0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
|
||||
[0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
|
||||
[0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
|
||||
[0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
|
||||
[0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
|
||||
[0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
|
||||
[0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
|
||||
[0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
|
||||
[0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
|
||||
[0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
|
||||
[0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
|
||||
[0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
|
||||
[0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
|
||||
[0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
|
||||
[0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
|
||||
[0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
|
||||
[0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
|
||||
[0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
|
||||
[0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
|
||||
[0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
|
||||
[0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
|
||||
[0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
|
||||
[0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
|
||||
[0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
|
||||
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]
|
||||
];
|
||||
var COMBINING_HIGH = [
|
||||
[0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
|
||||
[0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
|
||||
[0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
|
||||
[0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
|
||||
[0xE0100, 0xE01EF]
|
||||
];
|
||||
function bisearch(ucs, data) {
|
||||
var min = 0;
|
||||
var max = data.length - 1;
|
||||
var mid;
|
||||
if (ucs < data[0][0] || ucs > data[max][1]) {
|
||||
return false;
|
||||
}
|
||||
while (max >= min) {
|
||||
mid = (min + max) >> 1;
|
||||
if (ucs > data[mid][1]) {
|
||||
min = mid + 1;
|
||||
}
|
||||
else if (ucs < data[mid][0]) {
|
||||
max = mid - 1;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function wcwidthHigh(ucs) {
|
||||
if (bisearch(ucs, COMBINING_HIGH)) {
|
||||
return 0;
|
||||
}
|
||||
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
var control = opts.control | 0;
|
||||
var table = new Uint8Array(65536);
|
||||
TypedArrayUtils_1.fill(table, 1);
|
||||
table[0] = opts.nul;
|
||||
TypedArrayUtils_1.fill(table, opts.control, 1, 32);
|
||||
TypedArrayUtils_1.fill(table, opts.control, 0x7f, 0xa0);
|
||||
TypedArrayUtils_1.fill(table, 2, 0x1100, 0x1160);
|
||||
table[0x2329] = 2;
|
||||
table[0x232a] = 2;
|
||||
TypedArrayUtils_1.fill(table, 2, 0x2e80, 0xa4d0);
|
||||
table[0x303f] = 1;
|
||||
TypedArrayUtils_1.fill(table, 2, 0xac00, 0xd7a4);
|
||||
TypedArrayUtils_1.fill(table, 2, 0xf900, 0xfb00);
|
||||
TypedArrayUtils_1.fill(table, 2, 0xfe10, 0xfe1a);
|
||||
TypedArrayUtils_1.fill(table, 2, 0xfe30, 0xfe70);
|
||||
TypedArrayUtils_1.fill(table, 2, 0xff00, 0xff61);
|
||||
TypedArrayUtils_1.fill(table, 2, 0xffe0, 0xffe7);
|
||||
for (var r = 0; r < COMBINING_BMP.length; ++r) {
|
||||
TypedArrayUtils_1.fill(table, 0, COMBINING_BMP[r][0], COMBINING_BMP[r][1] + 1);
|
||||
}
|
||||
return function (num) {
|
||||
if (num < 32) {
|
||||
return control | 0;
|
||||
}
|
||||
if (num < 127) {
|
||||
return 1;
|
||||
}
|
||||
if (num < 65536) {
|
||||
return table[num];
|
||||
}
|
||||
return wcwidthHigh(num);
|
||||
};
|
||||
})({ nul: 0, control: 0 });
|
||||
function getStringCellWidth(s) {
|
||||
var result = 0;
|
||||
var length = s.length;
|
||||
for (var i = 0; i < length; ++i) {
|
||||
var code = s.charCodeAt(i);
|
||||
if (0xD800 <= code && code <= 0xDBFF) {
|
||||
if (++i >= length) {
|
||||
return result + exports.wcwidth(code);
|
||||
}
|
||||
var second = s.charCodeAt(i);
|
||||
if (0xDC00 <= second && second <= 0xDFFF) {
|
||||
code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
|
||||
}
|
||||
else {
|
||||
result += exports.wcwidth(second);
|
||||
}
|
||||
}
|
||||
result += exports.wcwidth(code);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.getStringCellWidth = getStringCellWidth;
|
||||
//# sourceMappingURL=CharWidth.js.map
|
||||
79
ports/javascript/node_modules/xterm/lib/Clipboard.js
generated
vendored
Normal file
79
ports/javascript/node_modules/xterm/lib/Clipboard.js
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function prepareTextForTerminal(text) {
|
||||
return text.replace(/\r?\n/g, '\r');
|
||||
}
|
||||
exports.prepareTextForTerminal = prepareTextForTerminal;
|
||||
function bracketTextForPaste(text, bracketedPasteMode) {
|
||||
if (bracketedPasteMode) {
|
||||
return '\x1b[200~' + text + '\x1b[201~';
|
||||
}
|
||||
return text;
|
||||
}
|
||||
exports.bracketTextForPaste = bracketTextForPaste;
|
||||
function copyHandler(ev, term, selectionManager) {
|
||||
if (term.browser.isMSIE) {
|
||||
window.clipboardData.setData('Text', selectionManager.selectionText);
|
||||
}
|
||||
else {
|
||||
ev.clipboardData.setData('text/plain', selectionManager.selectionText);
|
||||
}
|
||||
ev.preventDefault();
|
||||
}
|
||||
exports.copyHandler = copyHandler;
|
||||
function pasteHandler(ev, term) {
|
||||
ev.stopPropagation();
|
||||
var text;
|
||||
var dispatchPaste = function (text) {
|
||||
text = prepareTextForTerminal(text);
|
||||
text = bracketTextForPaste(text, term.bracketedPasteMode);
|
||||
term.handler(text);
|
||||
term.textarea.value = '';
|
||||
term.emit('paste', text);
|
||||
term.cancel(ev);
|
||||
};
|
||||
if (term.browser.isMSIE) {
|
||||
if (window.clipboardData) {
|
||||
text = window.clipboardData.getData('Text');
|
||||
dispatchPaste(text);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ev.clipboardData) {
|
||||
text = ev.clipboardData.getData('text/plain');
|
||||
dispatchPaste(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.pasteHandler = pasteHandler;
|
||||
function moveTextAreaUnderMouseCursor(ev, term) {
|
||||
var pos = term.screenElement.getBoundingClientRect();
|
||||
var left = ev.clientX - pos.left - 10;
|
||||
var top = ev.clientY - pos.top - 10;
|
||||
term.textarea.style.position = 'absolute';
|
||||
term.textarea.style.width = '20px';
|
||||
term.textarea.style.height = '20px';
|
||||
term.textarea.style.left = left + "px";
|
||||
term.textarea.style.top = top + "px";
|
||||
term.textarea.style.zIndex = '1000';
|
||||
term.textarea.focus();
|
||||
setTimeout(function () {
|
||||
term.textarea.style.position = null;
|
||||
term.textarea.style.width = null;
|
||||
term.textarea.style.height = null;
|
||||
term.textarea.style.left = null;
|
||||
term.textarea.style.top = null;
|
||||
term.textarea.style.zIndex = null;
|
||||
}, 200);
|
||||
}
|
||||
exports.moveTextAreaUnderMouseCursor = moveTextAreaUnderMouseCursor;
|
||||
function rightClickHandler(ev, term, selectionManager, shouldSelectWord) {
|
||||
moveTextAreaUnderMouseCursor(ev, term);
|
||||
if (shouldSelectWord && !selectionManager.isClickInSelection(ev)) {
|
||||
selectionManager.selectWordAtCursor(ev);
|
||||
}
|
||||
term.textarea.value = selectionManager.selectionText;
|
||||
term.textarea.select();
|
||||
}
|
||||
exports.rightClickHandler = rightClickHandler;
|
||||
//# sourceMappingURL=Clipboard.js.map
|
||||
122
ports/javascript/node_modules/xterm/lib/CompositionHelper.js
generated
vendored
Normal file
122
ports/javascript/node_modules/xterm/lib/CompositionHelper.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var CompositionHelper = (function () {
|
||||
function CompositionHelper(_textarea, _compositionView, _terminal) {
|
||||
this._textarea = _textarea;
|
||||
this._compositionView = _compositionView;
|
||||
this._terminal = _terminal;
|
||||
this._isComposing = false;
|
||||
this._isSendingComposition = false;
|
||||
this._compositionPosition = { start: null, end: null };
|
||||
}
|
||||
CompositionHelper.prototype.compositionstart = function () {
|
||||
this._isComposing = true;
|
||||
this._compositionPosition.start = this._textarea.value.length;
|
||||
this._compositionView.textContent = '';
|
||||
this._compositionView.classList.add('active');
|
||||
};
|
||||
CompositionHelper.prototype.compositionupdate = function (ev) {
|
||||
var _this = this;
|
||||
this._compositionView.textContent = ev.data;
|
||||
this.updateCompositionElements();
|
||||
setTimeout(function () {
|
||||
_this._compositionPosition.end = _this._textarea.value.length;
|
||||
}, 0);
|
||||
};
|
||||
CompositionHelper.prototype.compositionend = function () {
|
||||
this._finalizeComposition(true);
|
||||
};
|
||||
CompositionHelper.prototype.keydown = function (ev) {
|
||||
if (this._isComposing || this._isSendingComposition) {
|
||||
if (ev.keyCode === 229) {
|
||||
return false;
|
||||
}
|
||||
else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {
|
||||
return false;
|
||||
}
|
||||
this._finalizeComposition(false);
|
||||
}
|
||||
if (ev.keyCode === 229) {
|
||||
this._handleAnyTextareaChanges();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
CompositionHelper.prototype._finalizeComposition = function (waitForPropagation) {
|
||||
var _this = this;
|
||||
this._compositionView.classList.remove('active');
|
||||
this._isComposing = false;
|
||||
this._clearTextareaPosition();
|
||||
if (!waitForPropagation) {
|
||||
this._isSendingComposition = false;
|
||||
var input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end);
|
||||
this._terminal.handler(input);
|
||||
}
|
||||
else {
|
||||
var currentCompositionPosition_1 = {
|
||||
start: this._compositionPosition.start,
|
||||
end: this._compositionPosition.end
|
||||
};
|
||||
this._isSendingComposition = true;
|
||||
setTimeout(function () {
|
||||
if (_this._isSendingComposition) {
|
||||
_this._isSendingComposition = false;
|
||||
var input = void 0;
|
||||
if (_this._isComposing) {
|
||||
input = _this._textarea.value.substring(currentCompositionPosition_1.start, currentCompositionPosition_1.end);
|
||||
}
|
||||
else {
|
||||
input = _this._textarea.value.substring(currentCompositionPosition_1.start);
|
||||
}
|
||||
_this._terminal.handler(input);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
CompositionHelper.prototype._handleAnyTextareaChanges = function () {
|
||||
var _this = this;
|
||||
var oldValue = this._textarea.value;
|
||||
setTimeout(function () {
|
||||
if (!_this._isComposing) {
|
||||
var newValue = _this._textarea.value;
|
||||
var diff = newValue.replace(oldValue, '');
|
||||
if (diff.length > 0) {
|
||||
_this._terminal.handler(diff);
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
CompositionHelper.prototype.updateCompositionElements = function (dontRecurse) {
|
||||
var _this = this;
|
||||
if (!this._isComposing) {
|
||||
return;
|
||||
}
|
||||
if (this._terminal.buffer.isCursorInViewport) {
|
||||
var cellHeight = Math.ceil(this._terminal.charMeasure.height * this._terminal.options.lineHeight);
|
||||
var cursorTop = this._terminal.buffer.y * cellHeight;
|
||||
var cursorLeft = this._terminal.buffer.x * this._terminal.charMeasure.width;
|
||||
this._compositionView.style.left = cursorLeft + 'px';
|
||||
this._compositionView.style.top = cursorTop + 'px';
|
||||
this._compositionView.style.height = cellHeight + 'px';
|
||||
this._compositionView.style.lineHeight = cellHeight + 'px';
|
||||
this._compositionView.style.fontFamily = this._terminal.options.fontFamily;
|
||||
this._compositionView.style.fontSize = this._terminal.options.fontSize + 'px';
|
||||
var compositionViewBounds = this._compositionView.getBoundingClientRect();
|
||||
this._textarea.style.left = cursorLeft + 'px';
|
||||
this._textarea.style.top = cursorTop + 'px';
|
||||
this._textarea.style.width = compositionViewBounds.width + 'px';
|
||||
this._textarea.style.height = compositionViewBounds.height + 'px';
|
||||
this._textarea.style.lineHeight = compositionViewBounds.height + 'px';
|
||||
}
|
||||
if (!dontRecurse) {
|
||||
setTimeout(function () { return _this.updateCompositionElements(true); }, 0);
|
||||
}
|
||||
};
|
||||
CompositionHelper.prototype._clearTextareaPosition = function () {
|
||||
this._textarea.style.left = '';
|
||||
this._textarea.style.top = '';
|
||||
};
|
||||
return CompositionHelper;
|
||||
}());
|
||||
exports.CompositionHelper = CompositionHelper;
|
||||
//# sourceMappingURL=CompositionHelper.js.map
|
||||
523
ports/javascript/node_modules/xterm/lib/EscapeSequenceParser.js
generated
vendored
Normal file
523
ports/javascript/node_modules/xterm/lib/EscapeSequenceParser.js
generated
vendored
Normal file
@ -0,0 +1,523 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Lifecycle_1 = require("./common/Lifecycle");
|
||||
var TextDecoder_1 = require("./core/input/TextDecoder");
|
||||
function r(low, high) {
|
||||
var c = high - low;
|
||||
var arr = new Array(c);
|
||||
while (c--) {
|
||||
arr[c] = --high;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
var TransitionTable = (function () {
|
||||
function TransitionTable(length) {
|
||||
this.table = (typeof Uint8Array === 'undefined')
|
||||
? new Array(length)
|
||||
: new Uint8Array(length);
|
||||
}
|
||||
TransitionTable.prototype.add = function (code, state, action, next) {
|
||||
this.table[state << 8 | code] = ((action | 0) << 4) | ((next === undefined) ? state : next);
|
||||
};
|
||||
TransitionTable.prototype.addMany = function (codes, state, action, next) {
|
||||
for (var i = 0; i < codes.length; i++) {
|
||||
this.add(codes[i], state, action, next);
|
||||
}
|
||||
};
|
||||
return TransitionTable;
|
||||
}());
|
||||
exports.TransitionTable = TransitionTable;
|
||||
var PRINTABLES = r(0x20, 0x7f);
|
||||
var EXECUTABLES = r(0x00, 0x18);
|
||||
EXECUTABLES.push(0x19);
|
||||
EXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));
|
||||
var NON_ASCII_PRINTABLE = 0xA0;
|
||||
exports.VT500_TRANSITION_TABLE = (function () {
|
||||
var table = new TransitionTable(4095);
|
||||
var states = r(0, 13 + 1);
|
||||
var state;
|
||||
for (state in states) {
|
||||
for (var code = 0; code <= NON_ASCII_PRINTABLE; ++code) {
|
||||
table.add(code, state, 1, 0);
|
||||
}
|
||||
}
|
||||
table.addMany(PRINTABLES, 0, 2, 0);
|
||||
for (state in states) {
|
||||
table.addMany([0x18, 0x1a, 0x99, 0x9a], state, 3, 0);
|
||||
table.addMany(r(0x80, 0x90), state, 3, 0);
|
||||
table.addMany(r(0x90, 0x98), state, 3, 0);
|
||||
table.add(0x9c, state, 0, 0);
|
||||
table.add(0x1b, state, 11, 1);
|
||||
table.add(0x9d, state, 4, 8);
|
||||
table.addMany([0x98, 0x9e, 0x9f], state, 0, 7);
|
||||
table.add(0x9b, state, 11, 3);
|
||||
table.add(0x90, state, 11, 9);
|
||||
}
|
||||
table.addMany(EXECUTABLES, 0, 3, 0);
|
||||
table.addMany(EXECUTABLES, 1, 3, 1);
|
||||
table.add(0x7f, 1, 0, 1);
|
||||
table.addMany(EXECUTABLES, 8, 0, 8);
|
||||
table.addMany(EXECUTABLES, 3, 3, 3);
|
||||
table.add(0x7f, 3, 0, 3);
|
||||
table.addMany(EXECUTABLES, 4, 3, 4);
|
||||
table.add(0x7f, 4, 0, 4);
|
||||
table.addMany(EXECUTABLES, 6, 3, 6);
|
||||
table.addMany(EXECUTABLES, 5, 3, 5);
|
||||
table.add(0x7f, 5, 0, 5);
|
||||
table.addMany(EXECUTABLES, 2, 3, 2);
|
||||
table.add(0x7f, 2, 0, 2);
|
||||
table.add(0x5d, 1, 4, 8);
|
||||
table.addMany(PRINTABLES, 8, 5, 8);
|
||||
table.add(0x7f, 8, 5, 8);
|
||||
table.addMany([0x9c, 0x1b, 0x18, 0x1a, 0x07], 8, 6, 0);
|
||||
table.addMany(r(0x1c, 0x20), 8, 0, 8);
|
||||
table.addMany([0x58, 0x5e, 0x5f], 1, 0, 7);
|
||||
table.addMany(PRINTABLES, 7, 0, 7);
|
||||
table.addMany(EXECUTABLES, 7, 0, 7);
|
||||
table.add(0x9c, 7, 0, 0);
|
||||
table.add(0x7f, 7, 0, 7);
|
||||
table.add(0x5b, 1, 11, 3);
|
||||
table.addMany(r(0x40, 0x7f), 3, 7, 0);
|
||||
table.addMany(r(0x30, 0x3a), 3, 8, 4);
|
||||
table.add(0x3b, 3, 8, 4);
|
||||
table.addMany([0x3c, 0x3d, 0x3e, 0x3f], 3, 9, 4);
|
||||
table.addMany(r(0x30, 0x3a), 4, 8, 4);
|
||||
table.add(0x3b, 4, 8, 4);
|
||||
table.addMany(r(0x40, 0x7f), 4, 7, 0);
|
||||
table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 4, 0, 6);
|
||||
table.addMany(r(0x20, 0x40), 6, 0, 6);
|
||||
table.add(0x7f, 6, 0, 6);
|
||||
table.addMany(r(0x40, 0x7f), 6, 0, 0);
|
||||
table.add(0x3a, 3, 0, 6);
|
||||
table.addMany(r(0x20, 0x30), 3, 9, 5);
|
||||
table.addMany(r(0x20, 0x30), 5, 9, 5);
|
||||
table.addMany(r(0x30, 0x40), 5, 0, 6);
|
||||
table.addMany(r(0x40, 0x7f), 5, 7, 0);
|
||||
table.addMany(r(0x20, 0x30), 4, 9, 5);
|
||||
table.addMany(r(0x20, 0x30), 1, 9, 2);
|
||||
table.addMany(r(0x20, 0x30), 2, 9, 2);
|
||||
table.addMany(r(0x30, 0x7f), 2, 10, 0);
|
||||
table.addMany(r(0x30, 0x50), 1, 10, 0);
|
||||
table.addMany(r(0x51, 0x58), 1, 10, 0);
|
||||
table.addMany([0x59, 0x5a, 0x5c], 1, 10, 0);
|
||||
table.addMany(r(0x60, 0x7f), 1, 10, 0);
|
||||
table.add(0x50, 1, 11, 9);
|
||||
table.addMany(EXECUTABLES, 9, 0, 9);
|
||||
table.add(0x7f, 9, 0, 9);
|
||||
table.addMany(r(0x1c, 0x20), 9, 0, 9);
|
||||
table.addMany(r(0x20, 0x30), 9, 9, 12);
|
||||
table.add(0x3a, 9, 0, 11);
|
||||
table.addMany(r(0x30, 0x3a), 9, 8, 10);
|
||||
table.add(0x3b, 9, 8, 10);
|
||||
table.addMany([0x3c, 0x3d, 0x3e, 0x3f], 9, 9, 10);
|
||||
table.addMany(EXECUTABLES, 11, 0, 11);
|
||||
table.addMany(r(0x20, 0x80), 11, 0, 11);
|
||||
table.addMany(r(0x1c, 0x20), 11, 0, 11);
|
||||
table.addMany(EXECUTABLES, 10, 0, 10);
|
||||
table.add(0x7f, 10, 0, 10);
|
||||
table.addMany(r(0x1c, 0x20), 10, 0, 10);
|
||||
table.addMany(r(0x30, 0x3a), 10, 8, 10);
|
||||
table.add(0x3b, 10, 8, 10);
|
||||
table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 10, 0, 11);
|
||||
table.addMany(r(0x20, 0x30), 10, 9, 12);
|
||||
table.addMany(EXECUTABLES, 12, 0, 12);
|
||||
table.add(0x7f, 12, 0, 12);
|
||||
table.addMany(r(0x1c, 0x20), 12, 0, 12);
|
||||
table.addMany(r(0x20, 0x30), 12, 9, 12);
|
||||
table.addMany(r(0x30, 0x40), 12, 0, 11);
|
||||
table.addMany(r(0x40, 0x7f), 12, 12, 13);
|
||||
table.addMany(r(0x40, 0x7f), 10, 12, 13);
|
||||
table.addMany(r(0x40, 0x7f), 9, 12, 13);
|
||||
table.addMany(EXECUTABLES, 13, 13, 13);
|
||||
table.addMany(PRINTABLES, 13, 13, 13);
|
||||
table.add(0x7f, 13, 0, 13);
|
||||
table.addMany([0x1b, 0x9c], 13, 14, 0);
|
||||
table.add(NON_ASCII_PRINTABLE, 8, 5, 8);
|
||||
return table;
|
||||
})();
|
||||
var DcsDummy = (function () {
|
||||
function DcsDummy() {
|
||||
}
|
||||
DcsDummy.prototype.hook = function (collect, params, flag) { };
|
||||
DcsDummy.prototype.put = function (data, start, end) { };
|
||||
DcsDummy.prototype.unhook = function () { };
|
||||
return DcsDummy;
|
||||
}());
|
||||
var EscapeSequenceParser = (function (_super) {
|
||||
__extends(EscapeSequenceParser, _super);
|
||||
function EscapeSequenceParser(TRANSITIONS) {
|
||||
if (TRANSITIONS === void 0) { TRANSITIONS = exports.VT500_TRANSITION_TABLE; }
|
||||
var _this = _super.call(this) || this;
|
||||
_this.TRANSITIONS = TRANSITIONS;
|
||||
_this.initialState = 0;
|
||||
_this.currentState = _this.initialState;
|
||||
_this._osc = '';
|
||||
_this._params = [0];
|
||||
_this._collect = '';
|
||||
_this._printHandlerFb = function (data, start, end) { };
|
||||
_this._executeHandlerFb = function (code) { };
|
||||
_this._csiHandlerFb = function (collect, params, flag) { };
|
||||
_this._escHandlerFb = function (collect, flag) { };
|
||||
_this._oscHandlerFb = function (identifier, data) { };
|
||||
_this._dcsHandlerFb = new DcsDummy();
|
||||
_this._errorHandlerFb = function (state) { return state; };
|
||||
_this._printHandler = _this._printHandlerFb;
|
||||
_this._executeHandlers = Object.create(null);
|
||||
_this._csiHandlers = Object.create(null);
|
||||
_this._escHandlers = Object.create(null);
|
||||
_this._oscHandlers = Object.create(null);
|
||||
_this._dcsHandlers = Object.create(null);
|
||||
_this._activeDcsHandler = null;
|
||||
_this._errorHandler = _this._errorHandlerFb;
|
||||
_this.setEscHandler('\\', function () { });
|
||||
return _this;
|
||||
}
|
||||
EscapeSequenceParser.prototype.dispose = function () {
|
||||
this._printHandlerFb = null;
|
||||
this._executeHandlerFb = null;
|
||||
this._csiHandlerFb = null;
|
||||
this._escHandlerFb = null;
|
||||
this._oscHandlerFb = null;
|
||||
this._dcsHandlerFb = null;
|
||||
this._errorHandlerFb = null;
|
||||
this._printHandler = null;
|
||||
this._executeHandlers = null;
|
||||
this._escHandlers = null;
|
||||
this._csiHandlers = null;
|
||||
this._oscHandlers = null;
|
||||
this._dcsHandlers = null;
|
||||
this._activeDcsHandler = null;
|
||||
this._errorHandler = null;
|
||||
};
|
||||
EscapeSequenceParser.prototype.setPrintHandler = function (callback) {
|
||||
this._printHandler = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.clearPrintHandler = function () {
|
||||
this._printHandler = this._printHandlerFb;
|
||||
};
|
||||
EscapeSequenceParser.prototype.setExecuteHandler = function (flag, callback) {
|
||||
this._executeHandlers[flag.charCodeAt(0)] = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.clearExecuteHandler = function (flag) {
|
||||
if (this._executeHandlers[flag.charCodeAt(0)])
|
||||
delete this._executeHandlers[flag.charCodeAt(0)];
|
||||
};
|
||||
EscapeSequenceParser.prototype.setExecuteHandlerFallback = function (callback) {
|
||||
this._executeHandlerFb = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.addCsiHandler = function (flag, callback) {
|
||||
var index = flag.charCodeAt(0);
|
||||
if (this._csiHandlers[index] === undefined) {
|
||||
this._csiHandlers[index] = [];
|
||||
}
|
||||
var handlerList = this._csiHandlers[index];
|
||||
handlerList.push(callback);
|
||||
return {
|
||||
dispose: function () {
|
||||
var handlerIndex = handlerList.indexOf(callback);
|
||||
if (handlerIndex !== -1) {
|
||||
handlerList.splice(handlerIndex, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
EscapeSequenceParser.prototype.setCsiHandler = function (flag, callback) {
|
||||
this._csiHandlers[flag.charCodeAt(0)] = [callback];
|
||||
};
|
||||
EscapeSequenceParser.prototype.clearCsiHandler = function (flag) {
|
||||
if (this._csiHandlers[flag.charCodeAt(0)])
|
||||
delete this._csiHandlers[flag.charCodeAt(0)];
|
||||
};
|
||||
EscapeSequenceParser.prototype.setCsiHandlerFallback = function (callback) {
|
||||
this._csiHandlerFb = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.setEscHandler = function (collectAndFlag, callback) {
|
||||
this._escHandlers[collectAndFlag] = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.clearEscHandler = function (collectAndFlag) {
|
||||
if (this._escHandlers[collectAndFlag])
|
||||
delete this._escHandlers[collectAndFlag];
|
||||
};
|
||||
EscapeSequenceParser.prototype.setEscHandlerFallback = function (callback) {
|
||||
this._escHandlerFb = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.addOscHandler = function (ident, callback) {
|
||||
if (this._oscHandlers[ident] === undefined) {
|
||||
this._oscHandlers[ident] = [];
|
||||
}
|
||||
var handlerList = this._oscHandlers[ident];
|
||||
handlerList.push(callback);
|
||||
return {
|
||||
dispose: function () {
|
||||
var handlerIndex = handlerList.indexOf(callback);
|
||||
if (handlerIndex !== -1) {
|
||||
handlerList.splice(handlerIndex, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
EscapeSequenceParser.prototype.setOscHandler = function (ident, callback) {
|
||||
this._oscHandlers[ident] = [callback];
|
||||
};
|
||||
EscapeSequenceParser.prototype.clearOscHandler = function (ident) {
|
||||
if (this._oscHandlers[ident])
|
||||
delete this._oscHandlers[ident];
|
||||
};
|
||||
EscapeSequenceParser.prototype.setOscHandlerFallback = function (callback) {
|
||||
this._oscHandlerFb = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.setDcsHandler = function (collectAndFlag, handler) {
|
||||
this._dcsHandlers[collectAndFlag] = handler;
|
||||
};
|
||||
EscapeSequenceParser.prototype.clearDcsHandler = function (collectAndFlag) {
|
||||
if (this._dcsHandlers[collectAndFlag])
|
||||
delete this._dcsHandlers[collectAndFlag];
|
||||
};
|
||||
EscapeSequenceParser.prototype.setDcsHandlerFallback = function (handler) {
|
||||
this._dcsHandlerFb = handler;
|
||||
};
|
||||
EscapeSequenceParser.prototype.setErrorHandler = function (callback) {
|
||||
this._errorHandler = callback;
|
||||
};
|
||||
EscapeSequenceParser.prototype.clearErrorHandler = function () {
|
||||
this._errorHandler = this._errorHandlerFb;
|
||||
};
|
||||
EscapeSequenceParser.prototype.reset = function () {
|
||||
this.currentState = this.initialState;
|
||||
this._osc = '';
|
||||
this._params = [0];
|
||||
this._collect = '';
|
||||
this._activeDcsHandler = null;
|
||||
};
|
||||
EscapeSequenceParser.prototype.parse = function (data, length) {
|
||||
var code = 0;
|
||||
var transition = 0;
|
||||
var error = false;
|
||||
var currentState = this.currentState;
|
||||
var print = -1;
|
||||
var dcs = -1;
|
||||
var osc = this._osc;
|
||||
var collect = this._collect;
|
||||
var params = this._params;
|
||||
var table = this.TRANSITIONS.table;
|
||||
var dcsHandler = this._activeDcsHandler;
|
||||
var callback = null;
|
||||
for (var i = 0; i < length; ++i) {
|
||||
code = data[i];
|
||||
if (currentState === 0 && code > 0x1f && code < 0x80) {
|
||||
print = (~print) ? print : i;
|
||||
do
|
||||
i++;
|
||||
while (i < length && data[i] > 0x1f && data[i] < 0x80);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if (currentState === 4 && (code > 0x2f && code < 0x39)) {
|
||||
params[params.length - 1] = params[params.length - 1] * 10 + code - 48;
|
||||
continue;
|
||||
}
|
||||
transition = table[currentState << 8 | (code < 0xa0 ? code : NON_ASCII_PRINTABLE)];
|
||||
switch (transition >> 4) {
|
||||
case 2:
|
||||
print = (~print) ? print : i;
|
||||
break;
|
||||
case 3:
|
||||
if (~print) {
|
||||
this._printHandler(data, print, i);
|
||||
print = -1;
|
||||
}
|
||||
callback = this._executeHandlers[code];
|
||||
if (callback)
|
||||
callback();
|
||||
else
|
||||
this._executeHandlerFb(code);
|
||||
break;
|
||||
case 0:
|
||||
if (~print) {
|
||||
this._printHandler(data, print, i);
|
||||
print = -1;
|
||||
}
|
||||
else if (~dcs) {
|
||||
dcsHandler.put(data, dcs, i);
|
||||
dcs = -1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (code > 0x9f) {
|
||||
switch (currentState) {
|
||||
case 0:
|
||||
print = (~print) ? print : i;
|
||||
break;
|
||||
case 6:
|
||||
transition |= 6;
|
||||
break;
|
||||
case 11:
|
||||
transition |= 11;
|
||||
break;
|
||||
case 13:
|
||||
dcs = (~dcs) ? dcs : i;
|
||||
transition |= 13;
|
||||
break;
|
||||
default:
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = true;
|
||||
}
|
||||
if (error) {
|
||||
var inject = this._errorHandler({
|
||||
position: i,
|
||||
code: code,
|
||||
currentState: currentState,
|
||||
print: print,
|
||||
dcs: dcs,
|
||||
osc: osc,
|
||||
collect: collect,
|
||||
params: params,
|
||||
abort: false
|
||||
});
|
||||
if (inject.abort)
|
||||
return;
|
||||
error = false;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
var handlers = this._csiHandlers[code];
|
||||
var j = handlers ? handlers.length - 1 : -1;
|
||||
for (; j >= 0; j--) {
|
||||
if (handlers[j](params, collect) !== false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j < 0) {
|
||||
this._csiHandlerFb(collect, params, code);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (code === 0x3b)
|
||||
params.push(0);
|
||||
else
|
||||
params[params.length - 1] = params[params.length - 1] * 10 + code - 48;
|
||||
break;
|
||||
case 9:
|
||||
collect += String.fromCharCode(code);
|
||||
break;
|
||||
case 10:
|
||||
callback = this._escHandlers[collect + String.fromCharCode(code)];
|
||||
if (callback)
|
||||
callback(collect, code);
|
||||
else
|
||||
this._escHandlerFb(collect, code);
|
||||
break;
|
||||
case 11:
|
||||
if (~print) {
|
||||
this._printHandler(data, print, i);
|
||||
print = -1;
|
||||
}
|
||||
osc = '';
|
||||
params = [0];
|
||||
collect = '';
|
||||
dcs = -1;
|
||||
break;
|
||||
case 12:
|
||||
dcsHandler = this._dcsHandlers[collect + String.fromCharCode(code)];
|
||||
if (!dcsHandler)
|
||||
dcsHandler = this._dcsHandlerFb;
|
||||
dcsHandler.hook(collect, params, code);
|
||||
break;
|
||||
case 13:
|
||||
dcs = (~dcs) ? dcs : i;
|
||||
break;
|
||||
case 14:
|
||||
if (dcsHandler) {
|
||||
if (~dcs)
|
||||
dcsHandler.put(data, dcs, i);
|
||||
dcsHandler.unhook();
|
||||
dcsHandler = null;
|
||||
}
|
||||
if (code === 0x1b)
|
||||
transition |= 1;
|
||||
osc = '';
|
||||
params = [0];
|
||||
collect = '';
|
||||
dcs = -1;
|
||||
break;
|
||||
case 4:
|
||||
if (~print) {
|
||||
this._printHandler(data, print, i);
|
||||
print = -1;
|
||||
}
|
||||
osc = '';
|
||||
break;
|
||||
case 5:
|
||||
for (var j_1 = i + 1;; j_1++) {
|
||||
if (j_1 >= length
|
||||
|| (code = data[j_1]) < 0x20
|
||||
|| (code > 0x7f && code <= 0x9f)) {
|
||||
osc += TextDecoder_1.utf32ToString(data, i, j_1);
|
||||
i = j_1 - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (osc && code !== 0x18 && code !== 0x1a) {
|
||||
var idx = osc.indexOf(';');
|
||||
if (idx === -1) {
|
||||
this._oscHandlerFb(-1, osc);
|
||||
}
|
||||
else {
|
||||
var identifier = parseInt(osc.substring(0, idx));
|
||||
var content = osc.substring(idx + 1);
|
||||
var handlers_1 = this._oscHandlers[identifier];
|
||||
var j_2 = handlers_1 ? handlers_1.length - 1 : -1;
|
||||
for (; j_2 >= 0; j_2--) {
|
||||
if (handlers_1[j_2](content) !== false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j_2 < 0) {
|
||||
this._oscHandlerFb(identifier, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (code === 0x1b)
|
||||
transition |= 1;
|
||||
osc = '';
|
||||
params = [0];
|
||||
collect = '';
|
||||
dcs = -1;
|
||||
break;
|
||||
}
|
||||
currentState = transition & 15;
|
||||
}
|
||||
if (currentState === 0 && ~print) {
|
||||
this._printHandler(data, print, length);
|
||||
}
|
||||
else if (currentState === 13 && ~dcs && dcsHandler) {
|
||||
dcsHandler.put(data, dcs, length);
|
||||
}
|
||||
this._osc = osc;
|
||||
this._collect = collect;
|
||||
this._params = params;
|
||||
this._activeDcsHandler = dcsHandler;
|
||||
this.currentState = currentState;
|
||||
};
|
||||
return EscapeSequenceParser;
|
||||
}(Lifecycle_1.Disposable));
|
||||
exports.EscapeSequenceParser = EscapeSequenceParser;
|
||||
//# sourceMappingURL=EscapeSequenceParser.js.map
|
||||
459
ports/javascript/node_modules/xterm/lib/InputHandler.api.js
generated
vendored
Normal file
459
ports/javascript/node_modules/xterm/lib/InputHandler.api.js
generated
vendored
Normal file
@ -0,0 +1,459 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var puppeteer = require("puppeteer");
|
||||
var chai_1 = require("chai");
|
||||
var APP = 'http://127.0.0.1:3000/test';
|
||||
var browser;
|
||||
var page;
|
||||
var width = 800;
|
||||
var height = 600;
|
||||
describe('InputHandler Integration Tests', function () {
|
||||
var _this = this;
|
||||
this.timeout(20000);
|
||||
before(function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4, puppeteer.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
slowMo: 80,
|
||||
args: ["--window-size=" + width + "," + height]
|
||||
})];
|
||||
case 1:
|
||||
browser = _a.sent();
|
||||
return [4, browser.pages()];
|
||||
case 2:
|
||||
page = (_a.sent())[0];
|
||||
return [4, page.setViewport({ width: width, height: height })];
|
||||
case 3:
|
||||
_a.sent();
|
||||
return [4, page.goto(APP)];
|
||||
case 4:
|
||||
_a.sent();
|
||||
return [4, openTerminal()];
|
||||
case 5:
|
||||
_a.sent();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
after(function () {
|
||||
browser.close();
|
||||
});
|
||||
describe('CSI', function () {
|
||||
beforeEach(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4, page.evaluate("window.term.reset()")];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
it('ICH: Insert Ps (Blank) Character(s) (default = 1) - CSI Ps @', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\\x1b[3D\\x1b[@\\n\\r')\n // Explicit\n window.term.write('bar\\x1b[3D\\x1b[4@')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(2)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), [' foo', ' bar']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CUU: Cursor Up Ps Times (default = 1) - CSI Ps A', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\\n\\n\\n\\n\u001B[Aa')\n // Explicit\n window.term.write('\u001B[2Ab')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(4)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), ['', ' b', '', 'a']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CUD: Cursor Down Ps Times (default = 1) - CSI Ps B', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ba')\n // Explicit\n window.term.write('\u001B[2Bb')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(4)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), ['', 'a', '', ' b']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CUF: Cursor Forward Ps Times (default = 1) - CSI Ps C', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ca')\n // Explicit\n window.term.write('\u001B[2Cb')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(1)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), [' a b']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CUB: Cursor Backward Ps Times (default = 1) - CSI Ps D', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\u001B[Da')\n // Explicit\n window.term.write('\u001B[2Db')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(1)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), ['fba']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CNL: Cursor Next Line Ps Times (default = 1) - CSI Ps E', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ea')\n // Explicit\n window.term.write('\u001B[2Eb')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(4)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), ['', 'a', '', 'b']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CPL: Cursor Preceding Line Ps Times (default = 1) - CSI Ps F', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\\n\\n\\n\\n\u001B[Fa')\n // Explicit\n window.term.write('\u001B[2Fb')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(5)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), ['', 'b', '', 'a', '']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CHA: Cursor Character Absolute [column] (default = [row,1]) - CSI Ps G', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\u001B[Ga')\n // Explicit\n window.term.write('\u001B[10Gb')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(1)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), ['aoo b']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CUP: Cursor Position [row;column] (default = [1,1]) - CSI Ps ; Ps H', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('foo\u001B[Ha')\n // Explicit\n window.term.write('\u001B[3;3Hb')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(3)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), ['aoo', '', ' b']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('CHT: Cursor Forward Tabulation Ps tab stops (default = 1) - CSI Ps I', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n // Default\n window.term.write('\u001B[Ia')\n // Explicit\n window.term.write('\\n\\r\u001B[2Ib')\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(2)];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), [' a', ' b']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('ED: Erase in Display, VT100 - CSI Ps J', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var fixture, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
||||
return __generator(this, function (_l) {
|
||||
switch (_l.label) {
|
||||
case 0:
|
||||
fixture = 'abc\\n\\rdef\\n\\rghi\x1b[2;2H';
|
||||
return [4, page.evaluate("\n // Default: Erase Below\n window.term.resize(5, 5);\n window.term.write('" + fixture + "\u001B[J')\n ")];
|
||||
case 1:
|
||||
_l.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(3)];
|
||||
case 2:
|
||||
_b.apply(_a, [_l.sent(), ['abc', 'd', '']]);
|
||||
return [4, page.evaluate("\n // 0: Erase Below\n window.term.reset()\n window.term.write('" + fixture + "\u001B[0J')\n ")];
|
||||
case 3:
|
||||
_l.sent();
|
||||
_d = (_c = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(3)];
|
||||
case 4:
|
||||
_d.apply(_c, [_l.sent(), ['abc', 'd', '']]);
|
||||
return [4, page.evaluate("\n // 1: Erase Above\n window.term.reset()\n window.term.write('" + fixture + "\u001B[1J')\n ")];
|
||||
case 5:
|
||||
_l.sent();
|
||||
_f = (_e = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(3)];
|
||||
case 6:
|
||||
_f.apply(_e, [_l.sent(), ['', ' f', 'ghi']]);
|
||||
return [4, page.evaluate("\n // 2: Erase Saved Lines (scrollback)\n window.term.reset()\n window.term.write('1\\n2\\n3\\n4\\n5" + fixture + "\u001B[3J')\n ")];
|
||||
case 7:
|
||||
_l.sent();
|
||||
_h = (_g = chai_1.assert).equal;
|
||||
return [4, page.evaluate("window.term.buffer.length")];
|
||||
case 8:
|
||||
_h.apply(_g, [_l.sent(), 5]);
|
||||
_k = (_j = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(5)];
|
||||
case 9:
|
||||
_k.apply(_j, [_l.sent(), [' 4', ' 5', 'abc', 'def', 'ghi']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('DECSED: Erase in Display, VT220 - CSI ? Ps J', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var fixture, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
||||
return __generator(this, function (_l) {
|
||||
switch (_l.label) {
|
||||
case 0:
|
||||
fixture = 'abc\\n\\rdef\\n\\rghi\x1b[2;2H';
|
||||
return [4, page.evaluate("\n // Default: Erase Below\n window.term.resize(5, 5);\n window.term.write('" + fixture + "\u001B[?J')\n ")];
|
||||
case 1:
|
||||
_l.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(3)];
|
||||
case 2:
|
||||
_b.apply(_a, [_l.sent(), ['abc', 'd', '']]);
|
||||
return [4, page.evaluate("\n // 0: Erase Below\n window.term.reset()\n window.term.write('" + fixture + "\u001B[?0J')\n ")];
|
||||
case 3:
|
||||
_l.sent();
|
||||
_d = (_c = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(3)];
|
||||
case 4:
|
||||
_d.apply(_c, [_l.sent(), ['abc', 'd', '']]);
|
||||
return [4, page.evaluate("\n // 1: Erase Above\n window.term.reset()\n window.term.write('" + fixture + "\u001B[?1J')\n ")];
|
||||
case 5:
|
||||
_l.sent();
|
||||
_f = (_e = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(3)];
|
||||
case 6:
|
||||
_f.apply(_e, [_l.sent(), ['', ' f', 'ghi']]);
|
||||
return [4, page.evaluate("\n // 2: Erase Saved Lines (scrollback)\n window.term.reset()\n window.term.write('1\\n2\\n3\\n4\\n5" + fixture + "\u001B[?3J')\n ")];
|
||||
case 7:
|
||||
_l.sent();
|
||||
_h = (_g = chai_1.assert).equal;
|
||||
return [4, page.evaluate("window.term.buffer.length")];
|
||||
case 8:
|
||||
_h.apply(_g, [_l.sent(), 5]);
|
||||
_k = (_j = chai_1.assert).deepEqual;
|
||||
return [4, getLinesAsArray(5)];
|
||||
case 9:
|
||||
_k.apply(_j, [_l.sent(), [' 4', ' 5', 'abc', 'def', 'ghi']]);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('DSR: Device Status Report', function () {
|
||||
it('Status Report - CSI 5 n', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0: return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[5n');\n ")];
|
||||
case 1:
|
||||
_c.sent();
|
||||
_b = (_a = chai_1.assert).equal;
|
||||
return [4, page.evaluate("window.result")];
|
||||
case 2:
|
||||
_b.apply(_a, [_c.sent(), '\x1b[0n']);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('Report Cursor Position (CPR) - CSI 6 n', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b, _c, _d;
|
||||
return __generator(this, function (_e) {
|
||||
switch (_e.label) {
|
||||
case 0: return [4, page.evaluate("window.term.write('\\n\\nfoo')")];
|
||||
case 1:
|
||||
_e.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, page.evaluate("\n [window.term.buffer.cursorY, window.term.buffer.cursorX]\n ")];
|
||||
case 2:
|
||||
_b.apply(_a, [_e.sent(), [2, 3]]);
|
||||
return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[6n');\n ")];
|
||||
case 3:
|
||||
_e.sent();
|
||||
_d = (_c = chai_1.assert).equal;
|
||||
return [4, page.evaluate("window.result")];
|
||||
case 4:
|
||||
_d.apply(_c, [_e.sent(), '\x1b[3;4R']);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('Report Cursor Position (DECXCPR) - CSI ? 6 n', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, _b, _c, _d;
|
||||
return __generator(this, function (_e) {
|
||||
switch (_e.label) {
|
||||
case 0: return [4, page.evaluate("window.term.write('\\n\\nfoo')")];
|
||||
case 1:
|
||||
_e.sent();
|
||||
_b = (_a = chai_1.assert).deepEqual;
|
||||
return [4, page.evaluate("\n [window.term.buffer.cursorY, window.term.buffer.cursorX]\n ")];
|
||||
case 2:
|
||||
_b.apply(_a, [_e.sent(), [2, 3]]);
|
||||
return [4, page.evaluate("\n window.term.onData(e => window.result = e);\n window.term.write('\\x1b[?6n');\n ")];
|
||||
case 3:
|
||||
_e.sent();
|
||||
_d = (_c = chai_1.assert).equal;
|
||||
return [4, page.evaluate("window.result")];
|
||||
case 4:
|
||||
_d.apply(_c, [_e.sent(), '\x1b[?3;4R']);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
function openTerminal(options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4, page.evaluate("window.term = new Terminal(" + JSON.stringify(options) + ")")];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [4, page.evaluate("window.term.open(document.querySelector('#terminal-container'))")];
|
||||
case 2:
|
||||
_a.sent();
|
||||
if (!(options.rendererType === 'dom')) return [3, 4];
|
||||
return [4, page.waitForSelector('.xterm-rows')];
|
||||
case 3:
|
||||
_a.sent();
|
||||
return [3, 6];
|
||||
case 4: return [4, page.waitForSelector('.xterm-text-layer')];
|
||||
case 5:
|
||||
_a.sent();
|
||||
_a.label = 6;
|
||||
case 6: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function getLinesAsArray(count, start) {
|
||||
if (start === void 0) { start = 0; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var text, i;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
text = '';
|
||||
for (i = start; i < start + count; i++) {
|
||||
text += "window.term.buffer.getLine(" + i + ").translateToString(true),";
|
||||
}
|
||||
return [4, page.evaluate("[" + text + "]")];
|
||||
case 1: return [2, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=InputHandler.api.js.map
|
||||
1156
ports/javascript/node_modules/xterm/lib/InputHandler.js
generated
vendored
Normal file
1156
ports/javascript/node_modules/xterm/lib/InputHandler.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
211
ports/javascript/node_modules/xterm/lib/Linkifier.js
generated
vendored
Normal file
211
ports/javascript/node_modules/xterm/lib/Linkifier.js
generated
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var MouseZoneManager_1 = require("./MouseZoneManager");
|
||||
var CharWidth_1 = require("./CharWidth");
|
||||
var EventEmitter2_1 = require("./common/EventEmitter2");
|
||||
var Linkifier = (function () {
|
||||
function Linkifier(_terminal) {
|
||||
this._terminal = _terminal;
|
||||
this._linkMatchers = [];
|
||||
this._nextLinkMatcherId = 0;
|
||||
this._onLinkHover = new EventEmitter2_1.EventEmitter2();
|
||||
this._onLinkLeave = new EventEmitter2_1.EventEmitter2();
|
||||
this._onLinkTooltip = new EventEmitter2_1.EventEmitter2();
|
||||
this._rowsToLinkify = {
|
||||
start: null,
|
||||
end: null
|
||||
};
|
||||
}
|
||||
Object.defineProperty(Linkifier.prototype, "onLinkHover", {
|
||||
get: function () { return this._onLinkHover.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Linkifier.prototype, "onLinkLeave", {
|
||||
get: function () { return this._onLinkLeave.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Linkifier.prototype, "onLinkTooltip", {
|
||||
get: function () { return this._onLinkTooltip.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Linkifier.prototype.attachToDom = function (mouseZoneManager) {
|
||||
this._mouseZoneManager = mouseZoneManager;
|
||||
};
|
||||
Linkifier.prototype.linkifyRows = function (start, end) {
|
||||
var _this = this;
|
||||
if (!this._mouseZoneManager) {
|
||||
return;
|
||||
}
|
||||
if (this._rowsToLinkify.start === null) {
|
||||
this._rowsToLinkify.start = start;
|
||||
this._rowsToLinkify.end = end;
|
||||
}
|
||||
else {
|
||||
this._rowsToLinkify.start = Math.min(this._rowsToLinkify.start, start);
|
||||
this._rowsToLinkify.end = Math.max(this._rowsToLinkify.end, end);
|
||||
}
|
||||
this._mouseZoneManager.clearAll(start, end);
|
||||
if (this._rowsTimeoutId) {
|
||||
clearTimeout(this._rowsTimeoutId);
|
||||
}
|
||||
this._rowsTimeoutId = setTimeout(function () { return _this._linkifyRows(); }, Linkifier.TIME_BEFORE_LINKIFY);
|
||||
};
|
||||
Linkifier.prototype._linkifyRows = function () {
|
||||
this._rowsTimeoutId = null;
|
||||
var buffer = this._terminal.buffer;
|
||||
var absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start;
|
||||
if (absoluteRowIndexStart >= buffer.lines.length) {
|
||||
return;
|
||||
}
|
||||
var absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._terminal.rows) + 1;
|
||||
var overscanLineLimit = Math.ceil(Linkifier.OVERSCAN_CHAR_LIMIT / this._terminal.cols);
|
||||
var iterator = this._terminal.buffer.iterator(false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
|
||||
while (iterator.hasNext()) {
|
||||
var lineData = iterator.next();
|
||||
for (var i = 0; i < this._linkMatchers.length; i++) {
|
||||
this._doLinkifyRow(lineData.range.first, lineData.content, this._linkMatchers[i]);
|
||||
}
|
||||
}
|
||||
this._rowsToLinkify.start = null;
|
||||
this._rowsToLinkify.end = null;
|
||||
};
|
||||
Linkifier.prototype.registerLinkMatcher = function (regex, handler, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
if (!handler) {
|
||||
throw new Error('handler must be defined');
|
||||
}
|
||||
var matcher = {
|
||||
id: this._nextLinkMatcherId++,
|
||||
regex: regex,
|
||||
handler: handler,
|
||||
matchIndex: options.matchIndex,
|
||||
validationCallback: options.validationCallback,
|
||||
hoverTooltipCallback: options.tooltipCallback,
|
||||
hoverLeaveCallback: options.leaveCallback,
|
||||
willLinkActivate: options.willLinkActivate,
|
||||
priority: options.priority || 0
|
||||
};
|
||||
this._addLinkMatcherToList(matcher);
|
||||
return matcher.id;
|
||||
};
|
||||
Linkifier.prototype._addLinkMatcherToList = function (matcher) {
|
||||
if (this._linkMatchers.length === 0) {
|
||||
this._linkMatchers.push(matcher);
|
||||
return;
|
||||
}
|
||||
for (var i = this._linkMatchers.length - 1; i >= 0; i--) {
|
||||
if (matcher.priority <= this._linkMatchers[i].priority) {
|
||||
this._linkMatchers.splice(i + 1, 0, matcher);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._linkMatchers.splice(0, 0, matcher);
|
||||
};
|
||||
Linkifier.prototype.deregisterLinkMatcher = function (matcherId) {
|
||||
for (var i = 0; i < this._linkMatchers.length; i++) {
|
||||
if (this._linkMatchers[i].id === matcherId) {
|
||||
this._linkMatchers.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Linkifier.prototype._doLinkifyRow = function (rowIndex, text, matcher) {
|
||||
var _this = this;
|
||||
var rex = new RegExp(matcher.regex.source, matcher.regex.flags + 'g');
|
||||
var match;
|
||||
var stringIndex = -1;
|
||||
var _loop_1 = function () {
|
||||
var uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];
|
||||
if (!uri) {
|
||||
if (this_1._terminal.debug) {
|
||||
console.log({ match: match, matcher: matcher });
|
||||
throw new Error('match found without corresponding matchIndex');
|
||||
}
|
||||
return "break";
|
||||
}
|
||||
stringIndex = text.indexOf(uri, stringIndex + 1);
|
||||
rex.lastIndex = stringIndex + uri.length;
|
||||
if (stringIndex < 0) {
|
||||
return "break";
|
||||
}
|
||||
var bufferIndex = this_1._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex);
|
||||
if (bufferIndex[0] < 0) {
|
||||
return "break";
|
||||
}
|
||||
var line = this_1._terminal.buffer.lines.get(bufferIndex[0]);
|
||||
var attr = line.getFg(bufferIndex[1]);
|
||||
var fg;
|
||||
if (attr) {
|
||||
fg = (attr >> 9) & 0x1ff;
|
||||
}
|
||||
if (matcher.validationCallback) {
|
||||
matcher.validationCallback(uri, function (isValid) {
|
||||
if (_this._rowsTimeoutId) {
|
||||
return;
|
||||
}
|
||||
if (isValid) {
|
||||
_this._addLink(bufferIndex[1], bufferIndex[0] - _this._terminal.buffer.ydisp, uri, matcher, fg);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this_1._addLink(bufferIndex[1], bufferIndex[0] - this_1._terminal.buffer.ydisp, uri, matcher, fg);
|
||||
}
|
||||
};
|
||||
var this_1 = this;
|
||||
while ((match = rex.exec(text)) !== null) {
|
||||
var state_1 = _loop_1();
|
||||
if (state_1 === "break")
|
||||
break;
|
||||
}
|
||||
};
|
||||
Linkifier.prototype._addLink = function (x, y, uri, matcher, fg) {
|
||||
var _this = this;
|
||||
var width = CharWidth_1.getStringCellWidth(uri);
|
||||
var x1 = x % this._terminal.cols;
|
||||
var y1 = y + Math.floor(x / this._terminal.cols);
|
||||
var x2 = (x1 + width) % this._terminal.cols;
|
||||
var y2 = y1 + Math.floor((x1 + width) / this._terminal.cols);
|
||||
if (x2 === 0) {
|
||||
x2 = this._terminal.cols;
|
||||
y2--;
|
||||
}
|
||||
this._mouseZoneManager.add(new MouseZoneManager_1.MouseZone(x1 + 1, y1 + 1, x2 + 1, y2 + 1, function (e) {
|
||||
if (matcher.handler) {
|
||||
return matcher.handler(e, uri);
|
||||
}
|
||||
window.open(uri, '_blank');
|
||||
}, function () {
|
||||
_this._onLinkHover.fire(_this._createLinkHoverEvent(x1, y1, x2, y2, fg));
|
||||
_this._terminal.element.classList.add('xterm-cursor-pointer');
|
||||
}, function (e) {
|
||||
_this._onLinkTooltip.fire(_this._createLinkHoverEvent(x1, y1, x2, y2, fg));
|
||||
if (matcher.hoverTooltipCallback) {
|
||||
matcher.hoverTooltipCallback(e, uri);
|
||||
}
|
||||
}, function () {
|
||||
_this._onLinkLeave.fire(_this._createLinkHoverEvent(x1, y1, x2, y2, fg));
|
||||
_this._terminal.element.classList.remove('xterm-cursor-pointer');
|
||||
if (matcher.hoverLeaveCallback) {
|
||||
matcher.hoverLeaveCallback();
|
||||
}
|
||||
}, function (e) {
|
||||
if (matcher.willLinkActivate) {
|
||||
return matcher.willLinkActivate(e, uri);
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
};
|
||||
Linkifier.prototype._createLinkHoverEvent = function (x1, y1, x2, y2, fg) {
|
||||
return { x1: x1, y1: y1, x2: x2, y2: y2, cols: this._terminal.cols, fg: fg };
|
||||
};
|
||||
Linkifier.TIME_BEFORE_LINKIFY = 200;
|
||||
Linkifier.OVERSCAN_CHAR_LIMIT = 2000;
|
||||
return Linkifier;
|
||||
}());
|
||||
exports.Linkifier = Linkifier;
|
||||
//# sourceMappingURL=Linkifier.js.map
|
||||
36
ports/javascript/node_modules/xterm/lib/MouseHelper.js
generated
vendored
Normal file
36
ports/javascript/node_modules/xterm/lib/MouseHelper.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var MouseHelper = (function () {
|
||||
function MouseHelper(_renderCoordinator) {
|
||||
this._renderCoordinator = _renderCoordinator;
|
||||
}
|
||||
MouseHelper.getCoordsRelativeToElement = function (event, element) {
|
||||
var rect = element.getBoundingClientRect();
|
||||
return [event.clientX - rect.left, event.clientY - rect.top];
|
||||
};
|
||||
MouseHelper.prototype.getCoords = function (event, element, charMeasure, colCount, rowCount, isSelection) {
|
||||
if (!charMeasure.width || !charMeasure.height) {
|
||||
return null;
|
||||
}
|
||||
var coords = MouseHelper.getCoordsRelativeToElement(event, element);
|
||||
if (!coords) {
|
||||
return null;
|
||||
}
|
||||
coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderCoordinator.dimensions.actualCellWidth / 2 : 0)) / this._renderCoordinator.dimensions.actualCellWidth);
|
||||
coords[1] = Math.ceil(coords[1] / this._renderCoordinator.dimensions.actualCellHeight);
|
||||
coords[0] = Math.min(Math.max(coords[0], 1), colCount + (isSelection ? 1 : 0));
|
||||
coords[1] = Math.min(Math.max(coords[1], 1), rowCount);
|
||||
return coords;
|
||||
};
|
||||
MouseHelper.prototype.getRawByteCoords = function (event, element, charMeasure, colCount, rowCount) {
|
||||
var coords = this.getCoords(event, element, charMeasure, colCount, rowCount);
|
||||
var x = coords[0];
|
||||
var y = coords[1];
|
||||
x += 32;
|
||||
y += 32;
|
||||
return { x: x, y: y };
|
||||
};
|
||||
return MouseHelper;
|
||||
}());
|
||||
exports.MouseHelper = MouseHelper;
|
||||
//# sourceMappingURL=MouseHelper.js.map
|
||||
193
ports/javascript/node_modules/xterm/lib/MouseZoneManager.js
generated
vendored
Normal file
193
ports/javascript/node_modules/xterm/lib/MouseZoneManager.js
generated
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Lifecycle_1 = require("./common/Lifecycle");
|
||||
var Lifecycle_2 = require("./ui/Lifecycle");
|
||||
var HOVER_DURATION = 500;
|
||||
var MouseZoneManager = (function (_super) {
|
||||
__extends(MouseZoneManager, _super);
|
||||
function MouseZoneManager(_terminal) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this._terminal = _terminal;
|
||||
_this._zones = [];
|
||||
_this._areZonesActive = false;
|
||||
_this._tooltipTimeout = null;
|
||||
_this._currentZone = null;
|
||||
_this._lastHoverCoords = [null, null];
|
||||
_this.register(Lifecycle_2.addDisposableDomListener(_this._terminal.element, 'mousedown', function (e) { return _this._onMouseDown(e); }));
|
||||
_this._mouseMoveListener = function (e) { return _this._onMouseMove(e); };
|
||||
_this._mouseLeaveListener = function (e) { return _this._onMouseLeave(e); };
|
||||
_this._clickListener = function (e) { return _this._onClick(e); };
|
||||
return _this;
|
||||
}
|
||||
MouseZoneManager.prototype.dispose = function () {
|
||||
_super.prototype.dispose.call(this);
|
||||
this._deactivate();
|
||||
};
|
||||
MouseZoneManager.prototype.add = function (zone) {
|
||||
this._zones.push(zone);
|
||||
if (this._zones.length === 1) {
|
||||
this._activate();
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype.clearAll = function (start, end) {
|
||||
if (this._zones.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (!end) {
|
||||
start = 0;
|
||||
end = this._terminal.rows - 1;
|
||||
}
|
||||
for (var i = 0; i < this._zones.length; i++) {
|
||||
var zone = this._zones[i];
|
||||
if ((zone.y1 > start && zone.y1 <= end + 1) ||
|
||||
(zone.y2 > start && zone.y2 <= end + 1) ||
|
||||
(zone.y1 < start && zone.y2 > end + 1)) {
|
||||
if (this._currentZone && this._currentZone === zone) {
|
||||
this._currentZone.leaveCallback();
|
||||
this._currentZone = null;
|
||||
}
|
||||
this._zones.splice(i--, 1);
|
||||
}
|
||||
}
|
||||
if (this._zones.length === 0) {
|
||||
this._deactivate();
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._activate = function () {
|
||||
if (!this._areZonesActive) {
|
||||
this._areZonesActive = true;
|
||||
this._terminal.element.addEventListener('mousemove', this._mouseMoveListener);
|
||||
this._terminal.element.addEventListener('mouseleave', this._mouseLeaveListener);
|
||||
this._terminal.element.addEventListener('click', this._clickListener);
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._deactivate = function () {
|
||||
if (this._areZonesActive) {
|
||||
this._areZonesActive = false;
|
||||
this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);
|
||||
this._terminal.element.removeEventListener('mouseleave', this._mouseLeaveListener);
|
||||
this._terminal.element.removeEventListener('click', this._clickListener);
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._onMouseMove = function (e) {
|
||||
if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {
|
||||
this._onHover(e);
|
||||
this._lastHoverCoords = [e.pageX, e.pageY];
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._onHover = function (e) {
|
||||
var _this = this;
|
||||
var zone = this._findZoneEventAt(e);
|
||||
if (zone === this._currentZone) {
|
||||
return;
|
||||
}
|
||||
if (this._currentZone) {
|
||||
this._currentZone.leaveCallback();
|
||||
this._currentZone = null;
|
||||
if (this._tooltipTimeout) {
|
||||
clearTimeout(this._tooltipTimeout);
|
||||
}
|
||||
}
|
||||
if (!zone) {
|
||||
return;
|
||||
}
|
||||
this._currentZone = zone;
|
||||
if (zone.hoverCallback) {
|
||||
zone.hoverCallback(e);
|
||||
}
|
||||
this._tooltipTimeout = setTimeout(function () { return _this._onTooltip(e); }, HOVER_DURATION);
|
||||
};
|
||||
MouseZoneManager.prototype._onTooltip = function (e) {
|
||||
this._tooltipTimeout = null;
|
||||
var zone = this._findZoneEventAt(e);
|
||||
if (zone && zone.tooltipCallback) {
|
||||
zone.tooltipCallback(e);
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._onMouseDown = function (e) {
|
||||
this._initialSelectionLength = this._terminal.getSelection().length;
|
||||
if (!this._areZonesActive) {
|
||||
return;
|
||||
}
|
||||
var zone = this._findZoneEventAt(e);
|
||||
if (zone) {
|
||||
if (zone.willLinkActivate(e)) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._onMouseLeave = function (e) {
|
||||
if (this._currentZone) {
|
||||
this._currentZone.leaveCallback();
|
||||
this._currentZone = null;
|
||||
if (this._tooltipTimeout) {
|
||||
clearTimeout(this._tooltipTimeout);
|
||||
}
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._onClick = function (e) {
|
||||
var zone = this._findZoneEventAt(e);
|
||||
var currentSelectionLength = this._terminal.getSelection().length;
|
||||
if (zone && currentSelectionLength === this._initialSelectionLength) {
|
||||
zone.clickCallback(e);
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
};
|
||||
MouseZoneManager.prototype._findZoneEventAt = function (e) {
|
||||
var coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows);
|
||||
if (!coords) {
|
||||
return null;
|
||||
}
|
||||
var x = coords[0];
|
||||
var y = coords[1];
|
||||
for (var i = 0; i < this._zones.length; i++) {
|
||||
var zone = this._zones[i];
|
||||
if (zone.y1 === zone.y2) {
|
||||
if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((y === zone.y1 && x >= zone.x1) ||
|
||||
(y === zone.y2 && x < zone.x2) ||
|
||||
(y > zone.y1 && y < zone.y2)) {
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
return MouseZoneManager;
|
||||
}(Lifecycle_1.Disposable));
|
||||
exports.MouseZoneManager = MouseZoneManager;
|
||||
var MouseZone = (function () {
|
||||
function MouseZone(x1, y1, x2, y2, clickCallback, hoverCallback, tooltipCallback, leaveCallback, willLinkActivate) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
this.clickCallback = clickCallback;
|
||||
this.hoverCallback = hoverCallback;
|
||||
this.tooltipCallback = tooltipCallback;
|
||||
this.leaveCallback = leaveCallback;
|
||||
this.willLinkActivate = willLinkActivate;
|
||||
}
|
||||
return MouseZone;
|
||||
}());
|
||||
exports.MouseZone = MouseZone;
|
||||
//# sourceMappingURL=MouseZoneManager.js.map
|
||||
580
ports/javascript/node_modules/xterm/lib/SelectionManager.js
generated
vendored
Normal file
580
ports/javascript/node_modules/xterm/lib/SelectionManager.js
generated
vendored
Normal file
@ -0,0 +1,580 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var MouseHelper_1 = require("./MouseHelper");
|
||||
var Browser = require("./common/Platform");
|
||||
var SelectionModel_1 = require("./SelectionModel");
|
||||
var AltClickHandler_1 = require("./handlers/AltClickHandler");
|
||||
var BufferLine_1 = require("./core/buffer/BufferLine");
|
||||
var EventEmitter2_1 = require("./common/EventEmitter2");
|
||||
var DRAG_SCROLL_MAX_THRESHOLD = 50;
|
||||
var DRAG_SCROLL_MAX_SPEED = 15;
|
||||
var DRAG_SCROLL_INTERVAL = 50;
|
||||
var ALT_CLICK_MOVE_CURSOR_TIME = 500;
|
||||
var WORD_SEPARATORS = ' ()[]{}\'"';
|
||||
var NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);
|
||||
var ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');
|
||||
var SelectionManager = (function () {
|
||||
function SelectionManager(_terminal, _charMeasure) {
|
||||
this._terminal = _terminal;
|
||||
this._charMeasure = _charMeasure;
|
||||
this._enabled = true;
|
||||
this._workCell = new BufferLine_1.CellData();
|
||||
this._onLinuxMouseSelection = new EventEmitter2_1.EventEmitter2();
|
||||
this._onRedrawRequest = new EventEmitter2_1.EventEmitter2();
|
||||
this._onSelectionChange = new EventEmitter2_1.EventEmitter2();
|
||||
this._initListeners();
|
||||
this.enable();
|
||||
this._model = new SelectionModel_1.SelectionModel(_terminal);
|
||||
this._activeSelectionMode = 0;
|
||||
}
|
||||
Object.defineProperty(SelectionManager.prototype, "onLinuxMouseSelection", {
|
||||
get: function () { return this._onLinuxMouseSelection.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(SelectionManager.prototype, "onRedrawRequest", {
|
||||
get: function () { return this._onRedrawRequest.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(SelectionManager.prototype, "onSelectionChange", {
|
||||
get: function () { return this._onSelectionChange.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
SelectionManager.prototype.dispose = function () {
|
||||
this._removeMouseDownListeners();
|
||||
};
|
||||
Object.defineProperty(SelectionManager.prototype, "_buffer", {
|
||||
get: function () {
|
||||
return this._terminal.buffers.active;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
SelectionManager.prototype._initListeners = function () {
|
||||
var _this = this;
|
||||
this._mouseMoveListener = function (event) { return _this._onMouseMove(event); };
|
||||
this._mouseUpListener = function (event) { return _this._onMouseUp(event); };
|
||||
this.initBuffersListeners();
|
||||
};
|
||||
SelectionManager.prototype.initBuffersListeners = function () {
|
||||
var _this = this;
|
||||
this._trimListener = this._terminal.buffer.lines.onTrim(function (amount) { return _this._onTrim(amount); });
|
||||
this._terminal.buffers.onBufferActivate(function (e) { return _this._onBufferActivate(e); });
|
||||
};
|
||||
SelectionManager.prototype.disable = function () {
|
||||
this.clearSelection();
|
||||
this._enabled = false;
|
||||
};
|
||||
SelectionManager.prototype.enable = function () {
|
||||
this._enabled = true;
|
||||
};
|
||||
Object.defineProperty(SelectionManager.prototype, "selectionStart", {
|
||||
get: function () { return this._model.finalSelectionStart; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(SelectionManager.prototype, "selectionEnd", {
|
||||
get: function () { return this._model.finalSelectionEnd; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(SelectionManager.prototype, "hasSelection", {
|
||||
get: function () {
|
||||
var start = this._model.finalSelectionStart;
|
||||
var end = this._model.finalSelectionEnd;
|
||||
if (!start || !end) {
|
||||
return false;
|
||||
}
|
||||
return start[0] !== end[0] || start[1] !== end[1];
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(SelectionManager.prototype, "selectionText", {
|
||||
get: function () {
|
||||
var start = this._model.finalSelectionStart;
|
||||
var end = this._model.finalSelectionEnd;
|
||||
if (!start || !end) {
|
||||
return '';
|
||||
}
|
||||
var result = [];
|
||||
if (this._activeSelectionMode === 3) {
|
||||
if (start[0] === end[0]) {
|
||||
return '';
|
||||
}
|
||||
for (var i = start[1]; i <= end[1]; i++) {
|
||||
var lineText = this._buffer.translateBufferLineToString(i, true, start[0], end[0]);
|
||||
result.push(lineText);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var startRowEndCol = start[1] === end[1] ? end[0] : undefined;
|
||||
result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));
|
||||
for (var i = start[1] + 1; i <= end[1] - 1; i++) {
|
||||
var bufferLine = this._buffer.lines.get(i);
|
||||
var lineText = this._buffer.translateBufferLineToString(i, true);
|
||||
if (bufferLine.isWrapped) {
|
||||
result[result.length - 1] += lineText;
|
||||
}
|
||||
else {
|
||||
result.push(lineText);
|
||||
}
|
||||
}
|
||||
if (start[1] !== end[1]) {
|
||||
var bufferLine = this._buffer.lines.get(end[1]);
|
||||
var lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);
|
||||
if (bufferLine.isWrapped) {
|
||||
result[result.length - 1] += lineText;
|
||||
}
|
||||
else {
|
||||
result.push(lineText);
|
||||
}
|
||||
}
|
||||
}
|
||||
var formattedResult = result.map(function (line) {
|
||||
return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');
|
||||
}).join(Browser.isMSWindows ? '\r\n' : '\n');
|
||||
return formattedResult;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
SelectionManager.prototype.clearSelection = function () {
|
||||
this._model.clearSelection();
|
||||
this._removeMouseDownListeners();
|
||||
this.refresh();
|
||||
this._onSelectionChange.fire();
|
||||
};
|
||||
SelectionManager.prototype.refresh = function (isLinuxMouseSelection) {
|
||||
var _this = this;
|
||||
if (!this._refreshAnimationFrame) {
|
||||
this._refreshAnimationFrame = window.requestAnimationFrame(function () { return _this._refresh(); });
|
||||
}
|
||||
if (Browser.isLinux && isLinuxMouseSelection) {
|
||||
var selectionText = this.selectionText;
|
||||
if (selectionText.length) {
|
||||
this._onLinuxMouseSelection.fire(this.selectionText);
|
||||
}
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._refresh = function () {
|
||||
this._refreshAnimationFrame = null;
|
||||
this._onRedrawRequest.fire({
|
||||
start: this._model.finalSelectionStart,
|
||||
end: this._model.finalSelectionEnd,
|
||||
columnSelectMode: this._activeSelectionMode === 3
|
||||
});
|
||||
};
|
||||
SelectionManager.prototype.isClickInSelection = function (event) {
|
||||
var coords = this._getMouseBufferCoords(event);
|
||||
var start = this._model.finalSelectionStart;
|
||||
var end = this._model.finalSelectionEnd;
|
||||
if (!start || !end) {
|
||||
return false;
|
||||
}
|
||||
return this._areCoordsInSelection(coords, start, end);
|
||||
};
|
||||
SelectionManager.prototype._areCoordsInSelection = function (coords, start, end) {
|
||||
return (coords[1] > start[1] && coords[1] < end[1]) ||
|
||||
(start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||
|
||||
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||
|
||||
(start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);
|
||||
};
|
||||
SelectionManager.prototype.selectWordAtCursor = function (event) {
|
||||
var coords = this._getMouseBufferCoords(event);
|
||||
if (coords) {
|
||||
this._selectWordAt(coords, false);
|
||||
this._model.selectionEnd = null;
|
||||
this.refresh(true);
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype.selectAll = function () {
|
||||
this._model.isSelectAllActive = true;
|
||||
this.refresh();
|
||||
this._onSelectionChange.fire();
|
||||
};
|
||||
SelectionManager.prototype.selectLines = function (start, end) {
|
||||
this._model.clearSelection();
|
||||
start = Math.max(start, 0);
|
||||
end = Math.min(end, this._terminal.buffer.lines.length - 1);
|
||||
this._model.selectionStart = [0, start];
|
||||
this._model.selectionEnd = [this._terminal.cols, end];
|
||||
this.refresh();
|
||||
this._onSelectionChange.fire();
|
||||
};
|
||||
SelectionManager.prototype._onTrim = function (amount) {
|
||||
var needsRefresh = this._model.onTrim(amount);
|
||||
if (needsRefresh) {
|
||||
this.refresh();
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._getMouseBufferCoords = function (event) {
|
||||
var coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.cols, this._terminal.rows, true);
|
||||
if (!coords) {
|
||||
return null;
|
||||
}
|
||||
coords[0]--;
|
||||
coords[1]--;
|
||||
coords[1] += this._terminal.buffer.ydisp;
|
||||
return coords;
|
||||
};
|
||||
SelectionManager.prototype._getMouseEventScrollAmount = function (event) {
|
||||
var offset = MouseHelper_1.MouseHelper.getCoordsRelativeToElement(event, this._terminal.screenElement)[1];
|
||||
var terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);
|
||||
if (offset >= 0 && offset <= terminalHeight) {
|
||||
return 0;
|
||||
}
|
||||
if (offset > terminalHeight) {
|
||||
offset -= terminalHeight;
|
||||
}
|
||||
offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);
|
||||
offset /= DRAG_SCROLL_MAX_THRESHOLD;
|
||||
return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));
|
||||
};
|
||||
SelectionManager.prototype.shouldForceSelection = function (event) {
|
||||
if (Browser.isMac) {
|
||||
return event.altKey && this._terminal.options.macOptionClickForcesSelection;
|
||||
}
|
||||
return event.shiftKey;
|
||||
};
|
||||
SelectionManager.prototype.onMouseDown = function (event) {
|
||||
this._mouseDownTimeStamp = event.timeStamp;
|
||||
if (event.button === 2 && this.hasSelection) {
|
||||
return;
|
||||
}
|
||||
if (event.button !== 0) {
|
||||
return;
|
||||
}
|
||||
if (!this._enabled) {
|
||||
if (!this.shouldForceSelection(event)) {
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
}
|
||||
event.preventDefault();
|
||||
this._dragScrollAmount = 0;
|
||||
if (this._enabled && event.shiftKey) {
|
||||
this._onIncrementalClick(event);
|
||||
}
|
||||
else {
|
||||
if (event.detail === 1) {
|
||||
this._onSingleClick(event);
|
||||
}
|
||||
else if (event.detail === 2) {
|
||||
this._onDoubleClick(event);
|
||||
}
|
||||
else if (event.detail === 3) {
|
||||
this._onTripleClick(event);
|
||||
}
|
||||
}
|
||||
this._addMouseDownListeners();
|
||||
this.refresh(true);
|
||||
};
|
||||
SelectionManager.prototype._addMouseDownListeners = function () {
|
||||
var _this = this;
|
||||
this._terminal.element.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);
|
||||
this._terminal.element.ownerDocument.addEventListener('mouseup', this._mouseUpListener);
|
||||
this._dragScrollIntervalTimer = setInterval(function () { return _this._dragScroll(); }, DRAG_SCROLL_INTERVAL);
|
||||
};
|
||||
SelectionManager.prototype._removeMouseDownListeners = function () {
|
||||
if (this._terminal.element.ownerDocument) {
|
||||
this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);
|
||||
this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);
|
||||
}
|
||||
clearInterval(this._dragScrollIntervalTimer);
|
||||
this._dragScrollIntervalTimer = null;
|
||||
};
|
||||
SelectionManager.prototype._onIncrementalClick = function (event) {
|
||||
if (this._model.selectionStart) {
|
||||
this._model.selectionEnd = this._getMouseBufferCoords(event);
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._onSingleClick = function (event) {
|
||||
this._model.selectionStartLength = 0;
|
||||
this._model.isSelectAllActive = false;
|
||||
this._activeSelectionMode = this.shouldColumnSelect(event) ? 3 : 0;
|
||||
this._model.selectionStart = this._getMouseBufferCoords(event);
|
||||
if (!this._model.selectionStart) {
|
||||
return;
|
||||
}
|
||||
this._model.selectionEnd = null;
|
||||
var line = this._buffer.lines.get(this._model.selectionStart[1]);
|
||||
if (!line) {
|
||||
return;
|
||||
}
|
||||
if (line.length >= this._model.selectionStart[0]) {
|
||||
return;
|
||||
}
|
||||
if (line.hasWidth(this._model.selectionStart[0]) === 0) {
|
||||
this._model.selectionStart[0]++;
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._onDoubleClick = function (event) {
|
||||
var coords = this._getMouseBufferCoords(event);
|
||||
if (coords) {
|
||||
this._activeSelectionMode = 1;
|
||||
this._selectWordAt(coords, true);
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._onTripleClick = function (event) {
|
||||
var coords = this._getMouseBufferCoords(event);
|
||||
if (coords) {
|
||||
this._activeSelectionMode = 2;
|
||||
this._selectLineAt(coords[1]);
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype.shouldColumnSelect = function (event) {
|
||||
return event.altKey && !(Browser.isMac && this._terminal.options.macOptionClickForcesSelection);
|
||||
};
|
||||
SelectionManager.prototype._onMouseMove = function (event) {
|
||||
event.stopImmediatePropagation();
|
||||
var previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;
|
||||
this._model.selectionEnd = this._getMouseBufferCoords(event);
|
||||
if (!this._model.selectionEnd) {
|
||||
this.refresh(true);
|
||||
return;
|
||||
}
|
||||
if (this._activeSelectionMode === 2) {
|
||||
if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {
|
||||
this._model.selectionEnd[0] = 0;
|
||||
}
|
||||
else {
|
||||
this._model.selectionEnd[0] = this._terminal.cols;
|
||||
}
|
||||
}
|
||||
else if (this._activeSelectionMode === 1) {
|
||||
this._selectToWordAt(this._model.selectionEnd);
|
||||
}
|
||||
this._dragScrollAmount = this._getMouseEventScrollAmount(event);
|
||||
if (this._activeSelectionMode !== 3) {
|
||||
if (this._dragScrollAmount > 0) {
|
||||
this._model.selectionEnd[0] = this._terminal.cols;
|
||||
}
|
||||
else if (this._dragScrollAmount < 0) {
|
||||
this._model.selectionEnd[0] = 0;
|
||||
}
|
||||
}
|
||||
if (this._model.selectionEnd[1] < this._buffer.lines.length) {
|
||||
if (this._buffer.lines.get(this._model.selectionEnd[1]).hasWidth(this._model.selectionEnd[0]) === 0) {
|
||||
this._model.selectionEnd[0]++;
|
||||
}
|
||||
}
|
||||
if (!previousSelectionEnd ||
|
||||
previousSelectionEnd[0] !== this._model.selectionEnd[0] ||
|
||||
previousSelectionEnd[1] !== this._model.selectionEnd[1]) {
|
||||
this.refresh(true);
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._dragScroll = function () {
|
||||
if (this._dragScrollAmount) {
|
||||
this._terminal.scrollLines(this._dragScrollAmount, false);
|
||||
if (this._dragScrollAmount > 0) {
|
||||
if (this._activeSelectionMode !== 3) {
|
||||
this._model.selectionEnd[0] = this._terminal.cols;
|
||||
}
|
||||
this._model.selectionEnd[1] = Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1);
|
||||
}
|
||||
else {
|
||||
if (this._activeSelectionMode !== 3) {
|
||||
this._model.selectionEnd[0] = 0;
|
||||
}
|
||||
this._model.selectionEnd[1] = this._terminal.buffer.ydisp;
|
||||
}
|
||||
this.refresh();
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._onMouseUp = function (event) {
|
||||
var timeElapsed = event.timeStamp - this._mouseDownTimeStamp;
|
||||
this._removeMouseDownListeners();
|
||||
if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME) {
|
||||
(new AltClickHandler_1.AltClickHandler(event, this._terminal)).move();
|
||||
}
|
||||
else if (this.hasSelection) {
|
||||
this._onSelectionChange.fire();
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._onBufferActivate = function (e) {
|
||||
var _this = this;
|
||||
this.clearSelection();
|
||||
if (this._trimListener) {
|
||||
this._trimListener.dispose();
|
||||
}
|
||||
this._trimListener = e.activeBuffer.lines.onTrim(function (amount) { return _this._onTrim(amount); });
|
||||
};
|
||||
SelectionManager.prototype._convertViewportColToCharacterIndex = function (bufferLine, coords) {
|
||||
var charIndex = coords[0];
|
||||
for (var i = 0; coords[0] >= i; i++) {
|
||||
var length_1 = bufferLine.loadCell(i, this._workCell).getChars().length;
|
||||
if (this._workCell.getWidth() === 0) {
|
||||
charIndex--;
|
||||
}
|
||||
else if (length_1 > 1 && coords[0] !== i) {
|
||||
charIndex += length_1 - 1;
|
||||
}
|
||||
}
|
||||
return charIndex;
|
||||
};
|
||||
SelectionManager.prototype.setSelection = function (col, row, length) {
|
||||
this._model.clearSelection();
|
||||
this._removeMouseDownListeners();
|
||||
this._model.selectionStart = [col, row];
|
||||
this._model.selectionStartLength = length;
|
||||
this.refresh();
|
||||
};
|
||||
SelectionManager.prototype._getWordAt = function (coords, allowWhitespaceOnlySelection, followWrappedLinesAbove, followWrappedLinesBelow) {
|
||||
if (followWrappedLinesAbove === void 0) { followWrappedLinesAbove = true; }
|
||||
if (followWrappedLinesBelow === void 0) { followWrappedLinesBelow = true; }
|
||||
if (coords[0] >= this._terminal.cols) {
|
||||
return null;
|
||||
}
|
||||
var bufferLine = this._buffer.lines.get(coords[1]);
|
||||
if (!bufferLine) {
|
||||
return null;
|
||||
}
|
||||
var line = this._buffer.translateBufferLineToString(coords[1], false);
|
||||
var startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);
|
||||
var endIndex = startIndex;
|
||||
var charOffset = coords[0] - startIndex;
|
||||
var leftWideCharCount = 0;
|
||||
var rightWideCharCount = 0;
|
||||
var leftLongCharOffset = 0;
|
||||
var rightLongCharOffset = 0;
|
||||
if (line.charAt(startIndex) === ' ') {
|
||||
while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {
|
||||
startIndex--;
|
||||
}
|
||||
while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {
|
||||
endIndex++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var startCol = coords[0];
|
||||
var endCol = coords[0];
|
||||
if (bufferLine.getWidth(startCol) === 0) {
|
||||
leftWideCharCount++;
|
||||
startCol--;
|
||||
}
|
||||
if (bufferLine.getWidth(endCol) === 2) {
|
||||
rightWideCharCount++;
|
||||
endCol++;
|
||||
}
|
||||
var length_2 = bufferLine.getString(endCol).length;
|
||||
if (length_2 > 1) {
|
||||
rightLongCharOffset += length_2 - 1;
|
||||
endIndex += length_2 - 1;
|
||||
}
|
||||
while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine.loadCell(startCol - 1, this._workCell))) {
|
||||
bufferLine.loadCell(startCol - 1, this._workCell);
|
||||
var length_3 = this._workCell.getChars().length;
|
||||
if (this._workCell.getWidth() === 0) {
|
||||
leftWideCharCount++;
|
||||
startCol--;
|
||||
}
|
||||
else if (length_3 > 1) {
|
||||
leftLongCharOffset += length_3 - 1;
|
||||
startIndex -= length_3 - 1;
|
||||
}
|
||||
startIndex--;
|
||||
startCol--;
|
||||
}
|
||||
while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine.loadCell(endCol + 1, this._workCell))) {
|
||||
bufferLine.loadCell(endCol + 1, this._workCell);
|
||||
var length_4 = this._workCell.getChars().length;
|
||||
if (this._workCell.getWidth() === 2) {
|
||||
rightWideCharCount++;
|
||||
endCol++;
|
||||
}
|
||||
else if (length_4 > 1) {
|
||||
rightLongCharOffset += length_4 - 1;
|
||||
endIndex += length_4 - 1;
|
||||
}
|
||||
endIndex++;
|
||||
endCol++;
|
||||
}
|
||||
}
|
||||
endIndex++;
|
||||
var start = startIndex
|
||||
+ charOffset
|
||||
- leftWideCharCount
|
||||
+ leftLongCharOffset;
|
||||
var length = Math.min(this._terminal.cols, endIndex
|
||||
- startIndex
|
||||
+ leftWideCharCount
|
||||
+ rightWideCharCount
|
||||
- leftLongCharOffset
|
||||
- rightLongCharOffset);
|
||||
if (!allowWhitespaceOnlySelection && line.slice(startIndex, endIndex).trim() === '') {
|
||||
return null;
|
||||
}
|
||||
if (followWrappedLinesAbove) {
|
||||
if (start === 0 && bufferLine.getCodePoint(0) !== 32) {
|
||||
var previousBufferLine = this._buffer.lines.get(coords[1] - 1);
|
||||
if (previousBufferLine && bufferLine.isWrapped && previousBufferLine.getCodePoint(this._terminal.cols - 1) !== 32) {
|
||||
var previousLineWordPosition = this._getWordAt([this._terminal.cols - 1, coords[1] - 1], false, true, false);
|
||||
if (previousLineWordPosition) {
|
||||
var offset = this._terminal.cols - previousLineWordPosition.start;
|
||||
start -= offset;
|
||||
length += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (followWrappedLinesBelow) {
|
||||
if (start + length === this._terminal.cols && bufferLine.getCodePoint(this._terminal.cols - 1) !== 32) {
|
||||
var nextBufferLine = this._buffer.lines.get(coords[1] + 1);
|
||||
if (nextBufferLine && nextBufferLine.isWrapped && nextBufferLine.getCodePoint(0) !== 32) {
|
||||
var nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true);
|
||||
if (nextLineWordPosition) {
|
||||
length += nextLineWordPosition.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return { start: start, length: length };
|
||||
};
|
||||
SelectionManager.prototype._selectWordAt = function (coords, allowWhitespaceOnlySelection) {
|
||||
var wordPosition = this._getWordAt(coords, allowWhitespaceOnlySelection);
|
||||
if (wordPosition) {
|
||||
while (wordPosition.start < 0) {
|
||||
wordPosition.start += this._terminal.cols;
|
||||
coords[1]--;
|
||||
}
|
||||
this._model.selectionStart = [wordPosition.start, coords[1]];
|
||||
this._model.selectionStartLength = wordPosition.length;
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._selectToWordAt = function (coords) {
|
||||
var wordPosition = this._getWordAt(coords, true);
|
||||
if (wordPosition) {
|
||||
var endRow = coords[1];
|
||||
while (wordPosition.start < 0) {
|
||||
wordPosition.start += this._terminal.cols;
|
||||
endRow--;
|
||||
}
|
||||
if (!this._model.areSelectionValuesReversed()) {
|
||||
while (wordPosition.start + wordPosition.length > this._terminal.cols) {
|
||||
wordPosition.length -= this._terminal.cols;
|
||||
endRow++;
|
||||
}
|
||||
}
|
||||
this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : wordPosition.start + wordPosition.length, endRow];
|
||||
}
|
||||
};
|
||||
SelectionManager.prototype._isCharWordSeparator = function (cell) {
|
||||
if (cell.getWidth() === 0) {
|
||||
return false;
|
||||
}
|
||||
return WORD_SEPARATORS.indexOf(cell.getChars()) >= 0;
|
||||
};
|
||||
SelectionManager.prototype._selectLineAt = function (line) {
|
||||
var wrappedRange = this._buffer.getWrappedRangeForLine(line);
|
||||
this._model.selectionStart = [0, wrappedRange.first];
|
||||
this._model.selectionEnd = [this._terminal.cols, wrappedRange.last];
|
||||
this._model.selectionStartLength = 0;
|
||||
};
|
||||
return SelectionManager;
|
||||
}());
|
||||
exports.SelectionManager = SelectionManager;
|
||||
//# sourceMappingURL=SelectionManager.js.map
|
||||
79
ports/javascript/node_modules/xterm/lib/SelectionModel.js
generated
vendored
Normal file
79
ports/javascript/node_modules/xterm/lib/SelectionModel.js
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var SelectionModel = (function () {
|
||||
function SelectionModel(_terminal) {
|
||||
this._terminal = _terminal;
|
||||
this.clearSelection();
|
||||
}
|
||||
SelectionModel.prototype.clearSelection = function () {
|
||||
this.selectionStart = null;
|
||||
this.selectionEnd = null;
|
||||
this.isSelectAllActive = false;
|
||||
this.selectionStartLength = 0;
|
||||
};
|
||||
Object.defineProperty(SelectionModel.prototype, "finalSelectionStart", {
|
||||
get: function () {
|
||||
if (this.isSelectAllActive) {
|
||||
return [0, 0];
|
||||
}
|
||||
if (!this.selectionEnd || !this.selectionStart) {
|
||||
return this.selectionStart;
|
||||
}
|
||||
return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(SelectionModel.prototype, "finalSelectionEnd", {
|
||||
get: function () {
|
||||
if (this.isSelectAllActive) {
|
||||
return [this._terminal.cols, this._terminal.buffer.ybase + this._terminal.rows - 1];
|
||||
}
|
||||
if (!this.selectionStart) {
|
||||
return null;
|
||||
}
|
||||
if (!this.selectionEnd || this.areSelectionValuesReversed()) {
|
||||
var startPlusLength = this.selectionStart[0] + this.selectionStartLength;
|
||||
if (startPlusLength > this._terminal.cols) {
|
||||
return [startPlusLength % this._terminal.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._terminal.cols)];
|
||||
}
|
||||
return [startPlusLength, this.selectionStart[1]];
|
||||
}
|
||||
if (this.selectionStartLength) {
|
||||
if (this.selectionEnd[1] === this.selectionStart[1]) {
|
||||
return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];
|
||||
}
|
||||
}
|
||||
return this.selectionEnd;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
SelectionModel.prototype.areSelectionValuesReversed = function () {
|
||||
var start = this.selectionStart;
|
||||
var end = this.selectionEnd;
|
||||
if (!start || !end) {
|
||||
return false;
|
||||
}
|
||||
return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);
|
||||
};
|
||||
SelectionModel.prototype.onTrim = function (amount) {
|
||||
if (this.selectionStart) {
|
||||
this.selectionStart[1] -= amount;
|
||||
}
|
||||
if (this.selectionEnd) {
|
||||
this.selectionEnd[1] -= amount;
|
||||
}
|
||||
if (this.selectionEnd && this.selectionEnd[1] < 0) {
|
||||
this.clearSelection();
|
||||
return true;
|
||||
}
|
||||
if (this.selectionStart && this.selectionStart[1] < 0) {
|
||||
this.selectionStart[1] = 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
return SelectionModel;
|
||||
}());
|
||||
exports.SelectionModel = SelectionModel;
|
||||
//# sourceMappingURL=SelectionModel.js.map
|
||||
51
ports/javascript/node_modules/xterm/lib/SoundManager.js
generated
vendored
Normal file
51
ports/javascript/node_modules/xterm/lib/SoundManager.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DEFAULT_BELL_SOUND = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';
|
||||
var SoundManager = (function () {
|
||||
function SoundManager(_terminal) {
|
||||
this._terminal = _terminal;
|
||||
}
|
||||
Object.defineProperty(SoundManager, "audioContext", {
|
||||
get: function () {
|
||||
if (!SoundManager._audioContext) {
|
||||
var audioContextCtor = window.AudioContext || window.webkitAudioContext;
|
||||
if (!audioContextCtor) {
|
||||
console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');
|
||||
return null;
|
||||
}
|
||||
SoundManager._audioContext = new audioContextCtor();
|
||||
}
|
||||
return SoundManager._audioContext;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
SoundManager.prototype.playBellSound = function () {
|
||||
var ctx = SoundManager.audioContext;
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
var bellAudioSource = ctx.createBufferSource();
|
||||
ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), function (buffer) {
|
||||
bellAudioSource.buffer = buffer;
|
||||
bellAudioSource.connect(ctx.destination);
|
||||
bellAudioSource.start(0);
|
||||
});
|
||||
};
|
||||
SoundManager.prototype._base64ToArrayBuffer = function (base64) {
|
||||
var binaryString = window.atob(base64);
|
||||
var len = binaryString.length;
|
||||
var bytes = new Uint8Array(len);
|
||||
for (var i = 0; i < len; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
return bytes.buffer;
|
||||
};
|
||||
SoundManager.prototype._removeMimeType = function (dataURI) {
|
||||
var splitUri = dataURI.split(',');
|
||||
return splitUri[1];
|
||||
};
|
||||
return SoundManager;
|
||||
}());
|
||||
exports.SoundManager = SoundManager;
|
||||
//# sourceMappingURL=SoundManager.js.map
|
||||
6
ports/javascript/node_modules/xterm/lib/Strings.js
generated
vendored
Normal file
6
ports/javascript/node_modules/xterm/lib/Strings.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.blankLine = 'Blank line';
|
||||
exports.promptLabel = 'Terminal input';
|
||||
exports.tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';
|
||||
//# sourceMappingURL=Strings.js.map
|
||||
140
ports/javascript/node_modules/xterm/lib/Terminal.integration.js
generated
vendored
Normal file
140
ports/javascript/node_modules/xterm/lib/Terminal.integration.js
generated
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var cp = require("child_process");
|
||||
var glob = require("glob");
|
||||
var fs = require("fs");
|
||||
var os = require("os");
|
||||
var path = require("path");
|
||||
var pty = require("node-pty");
|
||||
var chai_1 = require("chai");
|
||||
var Terminal_1 = require("./Terminal");
|
||||
var BufferLine_1 = require("./core/buffer/BufferLine");
|
||||
var TestTerminal = (function (_super) {
|
||||
__extends(TestTerminal, _super);
|
||||
function TestTerminal() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
TestTerminal.prototype.innerWrite = function () { this._innerWrite(); };
|
||||
return TestTerminal;
|
||||
}(Terminal_1.Terminal));
|
||||
var primitivePty;
|
||||
function ptyWriteRead(data, cb) {
|
||||
fs.writeSync(primitivePty.slave, data);
|
||||
setTimeout(function () {
|
||||
var b = new Buffer(64000);
|
||||
var bytes = fs.readSync(primitivePty.master, b, 0, 64000, null);
|
||||
cb(b.toString('utf8', 0, bytes));
|
||||
});
|
||||
}
|
||||
function ptyReset(cb) {
|
||||
ptyWriteRead('\r\n', cb);
|
||||
}
|
||||
function formatError(input, output, expected) {
|
||||
function addLineNumber(start, color) {
|
||||
var counter = start || 0;
|
||||
return function (s) {
|
||||
counter += 1;
|
||||
return '\x1b[33m' + (' ' + counter).slice(-2) + color + s;
|
||||
};
|
||||
}
|
||||
var line80 = '12345678901234567890123456789012345678901234567890123456789012345678901234567890';
|
||||
var s = '';
|
||||
s += '\n\x1b[34m' + JSON.stringify(input);
|
||||
s += '\n\x1b[33m ' + line80 + '\n';
|
||||
s += output.split('\n').map(addLineNumber(0, '\x1b[31m')).join('\n');
|
||||
s += '\n\x1b[33m ' + line80 + '\n';
|
||||
s += expected.split('\n').map(addLineNumber(0, '\x1b[32m')).join('\n');
|
||||
return s;
|
||||
}
|
||||
function terminalToString(term) {
|
||||
var result = '';
|
||||
var lineText = '';
|
||||
for (var line = term.buffer.ybase; line < term.buffer.ybase + term.rows; line++) {
|
||||
lineText = '';
|
||||
for (var cell = 0; cell < term.cols; ++cell) {
|
||||
lineText += term.buffer.lines.get(line).loadCell(cell, new BufferLine_1.CellData()).getChars() || BufferLine_1.WHITESPACE_CELL_CHAR;
|
||||
}
|
||||
lineText = lineText.replace(/\s+$/, '');
|
||||
result += lineText;
|
||||
result += '\n';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (os.platform() !== 'win32') {
|
||||
var consoleLog_1 = console.log;
|
||||
var cols_1 = 80;
|
||||
var rows_1 = 25;
|
||||
primitivePty = pty.native.open(cols_1, rows_1);
|
||||
describe('xterm output comparison', function () {
|
||||
this.timeout(10000);
|
||||
var xterm;
|
||||
beforeEach(function () {
|
||||
xterm = new TestTerminal({ cols: cols_1, rows: rows_1 });
|
||||
xterm.refresh = function () { };
|
||||
xterm.viewport = {
|
||||
syncScrollArea: function () { }
|
||||
};
|
||||
});
|
||||
Error.stackTraceLimit = 0;
|
||||
var files = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..') });
|
||||
var skip = [
|
||||
10, 16, 17, 19, 32, 33, 34, 35, 36, 39,
|
||||
40, 42, 43, 44, 45, 46, 47, 48, 49, 50,
|
||||
51, 52, 54, 55, 56, 57, 58, 59, 60, 61,
|
||||
63, 68
|
||||
];
|
||||
if (os.platform() === 'darwin') {
|
||||
skip.push(3, 7, 11, 67);
|
||||
}
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
if (skip.indexOf(i) >= 0) {
|
||||
continue;
|
||||
}
|
||||
(function (filename) {
|
||||
var inFile = fs.readFileSync(filename, 'utf8');
|
||||
it(filename.split('/').slice(-1)[0], function (done) {
|
||||
ptyReset(function () {
|
||||
ptyWriteRead(inFile, function (fromPty) {
|
||||
xterm.writeBuffer.push(fromPty);
|
||||
xterm.innerWrite();
|
||||
var fromEmulator = terminalToString(xterm);
|
||||
console.log = consoleLog_1;
|
||||
var expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
|
||||
var expectedRightTrimmed = expected.split('\n').map(function (l) { return l.replace(/\s+$/, ''); }).join('\n');
|
||||
if (fromEmulator !== expectedRightTrimmed) {
|
||||
throw new Error(formatError(inFile, fromEmulator, expected));
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
})(files[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
describe('typings', function () {
|
||||
it('should throw no compile errors', function () {
|
||||
this.timeout(20000);
|
||||
var tsc = path.join(__dirname, '..', 'node_modules', '.bin', 'tsc');
|
||||
if (process.platform === 'win32') {
|
||||
tsc += '.cmd';
|
||||
}
|
||||
var fixtureDir = path.join(__dirname, '..', 'fixtures', 'typings-test');
|
||||
var result = cp.spawnSync(tsc, { cwd: fixtureDir });
|
||||
chai_1.assert.equal(result.status, 0, "build did not succeed:\nstdout: " + result.stdout.toString() + "\nstderr: " + result.stderr.toString() + "\n");
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=Terminal.integration.js.map
|
||||
1386
ports/javascript/node_modules/xterm/lib/Terminal.js
generated
vendored
Normal file
1386
ports/javascript/node_modules/xterm/lib/Terminal.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
ports/javascript/node_modules/xterm/lib/Types.js
generated
vendored
Normal file
3
ports/javascript/node_modules/xterm/lib/Types.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Types.js.map
|
||||
160
ports/javascript/node_modules/xterm/lib/Viewport.js
generated
vendored
Normal file
160
ports/javascript/node_modules/xterm/lib/Viewport.js
generated
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Lifecycle_1 = require("./common/Lifecycle");
|
||||
var Lifecycle_2 = require("./ui/Lifecycle");
|
||||
var FALLBACK_SCROLL_BAR_WIDTH = 15;
|
||||
var Viewport = (function (_super) {
|
||||
__extends(Viewport, _super);
|
||||
function Viewport(_terminal, _viewportElement, _scrollArea, _charMeasure, _dimensions) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this._terminal = _terminal;
|
||||
_this._viewportElement = _viewportElement;
|
||||
_this._scrollArea = _scrollArea;
|
||||
_this._charMeasure = _charMeasure;
|
||||
_this._dimensions = _dimensions;
|
||||
_this.scrollBarWidth = 0;
|
||||
_this._currentRowHeight = 0;
|
||||
_this._lastRecordedBufferLength = 0;
|
||||
_this._lastRecordedViewportHeight = 0;
|
||||
_this._lastRecordedBufferHeight = 0;
|
||||
_this._lastScrollTop = 0;
|
||||
_this._wheelPartialScroll = 0;
|
||||
_this._refreshAnimationFrame = null;
|
||||
_this._ignoreNextScrollEvent = false;
|
||||
_this.scrollBarWidth = (_this._viewportElement.offsetWidth - _this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
|
||||
_this.register(Lifecycle_2.addDisposableDomListener(_this._viewportElement, 'scroll', _this._onScroll.bind(_this)));
|
||||
setTimeout(function () { return _this.syncScrollArea(); }, 0);
|
||||
return _this;
|
||||
}
|
||||
Viewport.prototype.onDimensionsChance = function (dimensions) {
|
||||
this._dimensions = dimensions;
|
||||
};
|
||||
Viewport.prototype.onThemeChange = function (colors) {
|
||||
this._viewportElement.style.backgroundColor = colors.background.css;
|
||||
};
|
||||
Viewport.prototype._refresh = function () {
|
||||
var _this = this;
|
||||
if (this._refreshAnimationFrame === null) {
|
||||
this._refreshAnimationFrame = requestAnimationFrame(function () { return _this._innerRefresh(); });
|
||||
}
|
||||
};
|
||||
Viewport.prototype._innerRefresh = function () {
|
||||
if (this._charMeasure.height > 0) {
|
||||
this._currentRowHeight = this._dimensions.scaledCellHeight / window.devicePixelRatio;
|
||||
this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;
|
||||
var newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._dimensions.canvasHeight);
|
||||
if (this._lastRecordedBufferHeight !== newBufferHeight) {
|
||||
this._lastRecordedBufferHeight = newBufferHeight;
|
||||
this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';
|
||||
}
|
||||
}
|
||||
var scrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
|
||||
if (this._viewportElement.scrollTop !== scrollTop) {
|
||||
this._ignoreNextScrollEvent = true;
|
||||
this._viewportElement.scrollTop = scrollTop;
|
||||
}
|
||||
this._refreshAnimationFrame = null;
|
||||
};
|
||||
Viewport.prototype.syncScrollArea = function () {
|
||||
if (this._lastRecordedBufferLength !== this._terminal.buffer.lines.length) {
|
||||
this._lastRecordedBufferLength = this._terminal.buffer.lines.length;
|
||||
this._refresh();
|
||||
return;
|
||||
}
|
||||
if (this._lastRecordedViewportHeight !== this._dimensions.canvasHeight) {
|
||||
this._refresh();
|
||||
return;
|
||||
}
|
||||
var newScrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
|
||||
if (this._lastScrollTop !== newScrollTop) {
|
||||
this._refresh();
|
||||
return;
|
||||
}
|
||||
if (this._lastScrollTop !== this._viewportElement.scrollTop) {
|
||||
this._refresh();
|
||||
return;
|
||||
}
|
||||
if (this._dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) {
|
||||
this._refresh();
|
||||
return;
|
||||
}
|
||||
};
|
||||
Viewport.prototype._onScroll = function (ev) {
|
||||
this._lastScrollTop = this._viewportElement.scrollTop;
|
||||
if (!this._viewportElement.offsetParent) {
|
||||
return;
|
||||
}
|
||||
if (this._ignoreNextScrollEvent) {
|
||||
this._ignoreNextScrollEvent = false;
|
||||
return;
|
||||
}
|
||||
var newRow = Math.round(this._lastScrollTop / this._currentRowHeight);
|
||||
var diff = newRow - this._terminal.buffer.ydisp;
|
||||
this._terminal.scrollLines(diff, true);
|
||||
};
|
||||
Viewport.prototype.onWheel = function (ev) {
|
||||
var amount = this._getPixelsScrolled(ev);
|
||||
if (amount === 0) {
|
||||
return;
|
||||
}
|
||||
this._viewportElement.scrollTop += amount;
|
||||
ev.preventDefault();
|
||||
};
|
||||
Viewport.prototype._getPixelsScrolled = function (ev) {
|
||||
if (ev.deltaY === 0) {
|
||||
return 0;
|
||||
}
|
||||
var amount = ev.deltaY;
|
||||
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
||||
amount *= this._currentRowHeight;
|
||||
}
|
||||
else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
||||
amount *= this._currentRowHeight * this._terminal.rows;
|
||||
}
|
||||
return amount;
|
||||
};
|
||||
Viewport.prototype.getLinesScrolled = function (ev) {
|
||||
if (ev.deltaY === 0) {
|
||||
return 0;
|
||||
}
|
||||
var amount = ev.deltaY;
|
||||
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
||||
amount /= this._currentRowHeight + 0.0;
|
||||
this._wheelPartialScroll += amount;
|
||||
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
|
||||
this._wheelPartialScroll %= 1;
|
||||
}
|
||||
else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
||||
amount *= this._terminal.rows;
|
||||
}
|
||||
return amount;
|
||||
};
|
||||
Viewport.prototype.onTouchStart = function (ev) {
|
||||
this._lastTouchY = ev.touches[0].pageY;
|
||||
};
|
||||
Viewport.prototype.onTouchMove = function (ev) {
|
||||
var deltaY = this._lastTouchY - ev.touches[0].pageY;
|
||||
this._lastTouchY = ev.touches[0].pageY;
|
||||
if (deltaY === 0) {
|
||||
return;
|
||||
}
|
||||
this._viewportElement.scrollTop += deltaY;
|
||||
ev.preventDefault();
|
||||
};
|
||||
return Viewport;
|
||||
}(Lifecycle_1.Disposable));
|
||||
exports.Viewport = Viewport;
|
||||
//# sourceMappingURL=Viewport.js.map
|
||||
15
ports/javascript/node_modules/xterm/lib/WindowsMode.js
generated
vendored
Normal file
15
ports/javascript/node_modules/xterm/lib/WindowsMode.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var BufferLine_1 = require("./core/buffer/BufferLine");
|
||||
function applyWindowsMode(terminal) {
|
||||
return terminal.onLineFeed(function () {
|
||||
var line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);
|
||||
var lastChar = line.get(terminal.cols - 1);
|
||||
if (lastChar[BufferLine_1.CHAR_DATA_CODE_INDEX] !== BufferLine_1.NULL_CELL_CODE && lastChar[BufferLine_1.CHAR_DATA_CODE_INDEX] !== BufferLine_1.WHITESPACE_CELL_CODE) {
|
||||
var nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
|
||||
nextLine.isWrapped = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.applyWindowsMode = applyWindowsMode;
|
||||
//# sourceMappingURL=WindowsMode.js.map
|
||||
13
ports/javascript/node_modules/xterm/lib/addons/attach/Interfaces.d.ts
generated
vendored
Normal file
13
ports/javascript/node_modules/xterm/lib/addons/attach/Interfaces.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
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;
|
||||
}
|
||||
3
ports/javascript/node_modules/xterm/lib/addons/attach/Interfaces.js
generated
vendored
Normal file
3
ports/javascript/node_modules/xterm/lib/addons/attach/Interfaces.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Interfaces.js.map
|
||||
4
ports/javascript/node_modules/xterm/lib/addons/attach/attach.d.ts
generated
vendored
Normal file
4
ports/javascript/node_modules/xterm/lib/addons/attach/attach.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { Terminal } from 'xterm';
|
||||
export declare function attach(term: Terminal, socket: WebSocket, bidirectional: boolean, buffered: boolean): void;
|
||||
export declare function detach(term: Terminal, socket: WebSocket): void;
|
||||
export declare function apply(terminalConstructor: typeof Terminal): void;
|
||||
102
ports/javascript/node_modules/xterm/lib/addons/attach/attach.js
generated
vendored
Normal file
102
ports/javascript/node_modules/xterm/lib/addons/attach/attach.js
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function attach(term, socket, bidirectional, buffered) {
|
||||
var addonTerminal = term;
|
||||
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
|
||||
addonTerminal.__socket = socket;
|
||||
addonTerminal.__flushBuffer = function () {
|
||||
addonTerminal.write(addonTerminal.__attachSocketBuffer);
|
||||
addonTerminal.__attachSocketBuffer = null;
|
||||
};
|
||||
addonTerminal.__pushToBuffer = function (data) {
|
||||
if (addonTerminal.__attachSocketBuffer) {
|
||||
addonTerminal.__attachSocketBuffer += data;
|
||||
}
|
||||
else {
|
||||
addonTerminal.__attachSocketBuffer = data;
|
||||
setTimeout(addonTerminal.__flushBuffer, 10);
|
||||
}
|
||||
};
|
||||
var myTextDecoder;
|
||||
addonTerminal.__getMessage = function (ev) {
|
||||
var str;
|
||||
if (typeof ev.data === 'object') {
|
||||
if (!myTextDecoder) {
|
||||
myTextDecoder = new TextDecoder();
|
||||
}
|
||||
if (ev.data instanceof ArrayBuffer) {
|
||||
str = myTextDecoder.decode(ev.data);
|
||||
displayData(str);
|
||||
}
|
||||
else {
|
||||
var fileReader_1 = new FileReader();
|
||||
fileReader_1.addEventListener('load', function () {
|
||||
str = myTextDecoder.decode(fileReader_1.result);
|
||||
displayData(str);
|
||||
});
|
||||
fileReader_1.readAsArrayBuffer(ev.data);
|
||||
}
|
||||
}
|
||||
else if (typeof ev.data === 'string') {
|
||||
displayData(ev.data);
|
||||
}
|
||||
else {
|
||||
throw Error("Cannot handle \"" + typeof ev.data + "\" websocket message.");
|
||||
}
|
||||
};
|
||||
function displayData(str, data) {
|
||||
if (buffered) {
|
||||
addonTerminal.__pushToBuffer(str || data);
|
||||
}
|
||||
else {
|
||||
addonTerminal.write(str || data);
|
||||
}
|
||||
}
|
||||
addonTerminal.__sendData = function (data) {
|
||||
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', function () { return detach(addonTerminal, socket); }));
|
||||
addonTerminal._core.register(addSocketListener(socket, 'error', function () { return detach(addonTerminal, socket); }));
|
||||
}
|
||||
exports.attach = attach;
|
||||
function addSocketListener(socket, type, handler) {
|
||||
socket.addEventListener(type, handler);
|
||||
return {
|
||||
dispose: function () {
|
||||
if (!handler) {
|
||||
return;
|
||||
}
|
||||
socket.removeEventListener(type, handler);
|
||||
handler = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
function detach(term, socket) {
|
||||
var addonTerminal = term;
|
||||
addonTerminal.__dataListener.dispose();
|
||||
addonTerminal.__dataListener = undefined;
|
||||
socket = (typeof socket === 'undefined') ? addonTerminal.__socket : socket;
|
||||
if (socket) {
|
||||
socket.removeEventListener('message', addonTerminal.__getMessage);
|
||||
}
|
||||
delete addonTerminal.__socket;
|
||||
}
|
||||
exports.detach = detach;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.attach = function (socket, bidirectional, buffered) {
|
||||
attach(this, socket, bidirectional, buffered);
|
||||
};
|
||||
terminalConstructor.prototype.detach = function (socket) {
|
||||
detach(this, socket);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
//# sourceMappingURL=attach.js.map
|
||||
8
ports/javascript/node_modules/xterm/lib/addons/fit/fit.d.ts
generated
vendored
Normal file
8
ports/javascript/node_modules/xterm/lib/addons/fit/fit.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { Terminal } from 'xterm';
|
||||
export interface IGeometry {
|
||||
rows: number;
|
||||
cols: number;
|
||||
}
|
||||
export declare function proposeGeometry(term: Terminal): IGeometry;
|
||||
export declare function fit(term: Terminal): void;
|
||||
export declare function apply(terminalConstructor: typeof Terminal): void;
|
||||
47
ports/javascript/node_modules/xterm/lib/addons/fit/fit.js
generated
vendored
Normal file
47
ports/javascript/node_modules/xterm/lib/addons/fit/fit.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function proposeGeometry(term) {
|
||||
if (!term.element.parentElement) {
|
||||
return null;
|
||||
}
|
||||
var parentElementStyle = window.getComputedStyle(term.element.parentElement);
|
||||
var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||
var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
||||
var elementStyle = window.getComputedStyle(term.element);
|
||||
var elementPadding = {
|
||||
top: parseInt(elementStyle.getPropertyValue('padding-top')),
|
||||
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||
right: parseInt(elementStyle.getPropertyValue('padding-right')),
|
||||
left: parseInt(elementStyle.getPropertyValue('padding-left'))
|
||||
};
|
||||
var elementPaddingVer = elementPadding.top + elementPadding.bottom;
|
||||
var elementPaddingHor = elementPadding.right + elementPadding.left;
|
||||
var availableHeight = parentElementHeight - elementPaddingVer;
|
||||
var availableWidth = parentElementWidth - elementPaddingHor - term._core.viewport.scrollBarWidth;
|
||||
var geometry = {
|
||||
cols: Math.floor(availableWidth / term._core._renderCoordinator.dimensions.actualCellWidth),
|
||||
rows: Math.floor(availableHeight / term._core._renderCoordinator.dimensions.actualCellHeight)
|
||||
};
|
||||
return geometry;
|
||||
}
|
||||
exports.proposeGeometry = proposeGeometry;
|
||||
function fit(term) {
|
||||
var geometry = proposeGeometry(term);
|
||||
if (geometry) {
|
||||
if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
|
||||
term._core._renderCoordinator.clear();
|
||||
term.resize(geometry.cols, geometry.rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.fit = fit;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.proposeGeometry = function () {
|
||||
return proposeGeometry(this);
|
||||
};
|
||||
terminalConstructor.prototype.fit = function () {
|
||||
fit(this);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
//# sourceMappingURL=fit.js.map
|
||||
10
ports/javascript/node_modules/xterm/lib/addons/fullscreen/fullscreen.css
generated
vendored
Normal file
10
ports/javascript/node_modules/xterm/lib/addons/fullscreen/fullscreen.css
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.xterm.fullscreen {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: auto;
|
||||
height: auto;
|
||||
z-index: 255;
|
||||
}
|
||||
3
ports/javascript/node_modules/xterm/lib/addons/fullscreen/fullscreen.d.ts
generated
vendored
Normal file
3
ports/javascript/node_modules/xterm/lib/addons/fullscreen/fullscreen.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Terminal } from 'xterm';
|
||||
export declare function toggleFullScreen(term: Terminal, fullscreen: boolean): void;
|
||||
export declare function apply(terminalConstructor: typeof Terminal): void;
|
||||
25
ports/javascript/node_modules/xterm/lib/addons/fullscreen/fullscreen.js
generated
vendored
Normal file
25
ports/javascript/node_modules/xterm/lib/addons/fullscreen/fullscreen.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function toggleFullScreen(term, fullscreen) {
|
||||
var fn;
|
||||
if (typeof fullscreen === 'undefined') {
|
||||
fn = (term.element.classList.contains('fullscreen')) ?
|
||||
term.element.classList.remove : term.element.classList.add;
|
||||
}
|
||||
else if (!fullscreen) {
|
||||
fn = term.element.classList.remove;
|
||||
}
|
||||
else {
|
||||
fn = term.element.classList.add;
|
||||
}
|
||||
fn = fn.bind(term.element.classList);
|
||||
fn('fullscreen');
|
||||
}
|
||||
exports.toggleFullScreen = toggleFullScreen;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.toggleFullScreen = function (fullscreen) {
|
||||
toggleFullScreen(this, fullscreen);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
//# sourceMappingURL=fullscreen.js.map
|
||||
19
ports/javascript/node_modules/xterm/lib/addons/search/Interfaces.d.ts
generated
vendored
Normal file
19
ports/javascript/node_modules/xterm/lib/addons/search/Interfaces.d.ts
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
import { Terminal } from 'xterm';
|
||||
export interface ISearchAddonTerminal extends Terminal {
|
||||
__searchHelper?: ISearchHelper;
|
||||
}
|
||||
export interface ISearchHelper {
|
||||
findNext(term: string, searchOptions: ISearchOptions): boolean;
|
||||
findPrevious(term: string, searchOptions: ISearchOptions): boolean;
|
||||
}
|
||||
export interface ISearchOptions {
|
||||
regex?: boolean;
|
||||
wholeWord?: boolean;
|
||||
caseSensitive?: boolean;
|
||||
incremental?: boolean;
|
||||
}
|
||||
export interface ISearchResult {
|
||||
term: string;
|
||||
col: number;
|
||||
row: number;
|
||||
}
|
||||
3
ports/javascript/node_modules/xterm/lib/addons/search/Interfaces.js
generated
vendored
Normal file
3
ports/javascript/node_modules/xterm/lib/addons/search/Interfaces.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Interfaces.js.map
|
||||
17
ports/javascript/node_modules/xterm/lib/addons/search/SearchHelper.d.ts
generated
vendored
Normal file
17
ports/javascript/node_modules/xterm/lib/addons/search/SearchHelper.d.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { ISearchHelper, ISearchAddonTerminal, ISearchOptions, ISearchResult } from './Interfaces';
|
||||
export declare class SearchHelper implements ISearchHelper {
|
||||
private _terminal;
|
||||
private _linesCache;
|
||||
private _linesCacheTimeoutId;
|
||||
private _cursorMoveListener;
|
||||
private _resizeListener;
|
||||
constructor(_terminal: ISearchAddonTerminal);
|
||||
findNext(term: string, searchOptions?: ISearchOptions): boolean;
|
||||
findPrevious(term: string, searchOptions?: ISearchOptions): boolean;
|
||||
private _initLinesCache;
|
||||
private _destroyLinesCache;
|
||||
private _isWholeWord;
|
||||
protected _findInLine(term: string, row: number, col: number, searchOptions?: ISearchOptions, isReverseSearch?: boolean): ISearchResult;
|
||||
translateBufferLineToStringWithWrap(lineIndex: number, trimRight: boolean): string;
|
||||
private _selectResult;
|
||||
}
|
||||
227
ports/javascript/node_modules/xterm/lib/addons/search/SearchHelper.js
generated
vendored
Normal file
227
ports/javascript/node_modules/xterm/lib/addons/search/SearchHelper.js
generated
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\;:"\',./<>?';
|
||||
var LINES_CACHE_TIME_TO_LIVE = 15 * 1000;
|
||||
var SearchHelper = (function () {
|
||||
function SearchHelper(_terminal) {
|
||||
this._terminal = _terminal;
|
||||
this._linesCache = null;
|
||||
this._linesCacheTimeoutId = 0;
|
||||
this._destroyLinesCache = this._destroyLinesCache.bind(this);
|
||||
}
|
||||
SearchHelper.prototype.findNext = function (term, searchOptions) {
|
||||
var incremental = searchOptions.incremental;
|
||||
var result;
|
||||
if (!term || term.length === 0) {
|
||||
this._terminal.clearSelection();
|
||||
return false;
|
||||
}
|
||||
var startCol = 0;
|
||||
var startRow = this._terminal.buffer.viewportY;
|
||||
if (this._terminal.hasSelection()) {
|
||||
var currentSelection = this._terminal.getSelectionPosition();
|
||||
startRow = incremental ? currentSelection.startRow : currentSelection.endRow;
|
||||
startCol = incremental ? currentSelection.startColumn : currentSelection.endColumn;
|
||||
}
|
||||
this._initLinesCache();
|
||||
var findingRow = startRow;
|
||||
var cumulativeCols = startCol;
|
||||
while (this._terminal.buffer.getLine(findingRow).isWrapped) {
|
||||
findingRow--;
|
||||
cumulativeCols += this._terminal.cols;
|
||||
}
|
||||
result = this._findInLine(term, findingRow, cumulativeCols, searchOptions);
|
||||
if (!result) {
|
||||
for (var y = startRow + 1; y < this._terminal.buffer.baseY + this._terminal.rows; y++) {
|
||||
result = this._findInLine(term, y, 0, searchOptions);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
for (var y = 0; y < findingRow; y++) {
|
||||
result = this._findInLine(term, y, 0, searchOptions);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._selectResult(result);
|
||||
};
|
||||
SearchHelper.prototype.findPrevious = function (term, searchOptions) {
|
||||
var result;
|
||||
if (!term || term.length === 0) {
|
||||
this._terminal.clearSelection();
|
||||
return false;
|
||||
}
|
||||
var isReverseSearch = true;
|
||||
var startRow = this._terminal.buffer.viewportY + this._terminal.rows - 1;
|
||||
var startCol = this._terminal.cols;
|
||||
if (this._terminal.hasSelection()) {
|
||||
var currentSelection = this._terminal.getSelectionPosition();
|
||||
startRow = currentSelection.startRow;
|
||||
startCol = currentSelection.startColumn;
|
||||
}
|
||||
this._initLinesCache();
|
||||
result = this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
|
||||
if (!result) {
|
||||
var cumulativeCols = this._terminal.cols;
|
||||
if (this._terminal.buffer.getLine(startRow).isWrapped) {
|
||||
cumulativeCols += startCol;
|
||||
}
|
||||
for (var y = startRow - 1; y >= 0; y--) {
|
||||
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
if (this._terminal.buffer.getLine(y).isWrapped) {
|
||||
cumulativeCols += this._terminal.cols;
|
||||
}
|
||||
else {
|
||||
cumulativeCols = this._terminal.cols;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
var searchFrom = this._terminal.buffer.baseY + this._terminal.rows - 1;
|
||||
var cumulativeCols = this._terminal.cols;
|
||||
for (var y = searchFrom; y >= startRow; y--) {
|
||||
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
if (this._terminal.buffer.getLine(y).isWrapped) {
|
||||
cumulativeCols += this._terminal.cols;
|
||||
}
|
||||
else {
|
||||
cumulativeCols = this._terminal.cols;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._selectResult(result);
|
||||
};
|
||||
SearchHelper.prototype._initLinesCache = function () {
|
||||
var _this = this;
|
||||
if (!this._linesCache) {
|
||||
this._linesCache = new Array(this._terminal.buffer.length);
|
||||
this._cursorMoveListener = this._terminal.onCursorMove(function () { return _this._destroyLinesCache(); });
|
||||
this._resizeListener = this._terminal.onResize(function () { return _this._destroyLinesCache(); });
|
||||
}
|
||||
window.clearTimeout(this._linesCacheTimeoutId);
|
||||
this._linesCacheTimeoutId = window.setTimeout(function () { return _this._destroyLinesCache(); }, LINES_CACHE_TIME_TO_LIVE);
|
||||
};
|
||||
SearchHelper.prototype._destroyLinesCache = function () {
|
||||
this._linesCache = null;
|
||||
if (this._cursorMoveListener) {
|
||||
this._cursorMoveListener.dispose();
|
||||
this._cursorMoveListener = undefined;
|
||||
}
|
||||
if (this._resizeListener) {
|
||||
this._resizeListener.dispose();
|
||||
this._resizeListener = undefined;
|
||||
}
|
||||
if (this._linesCacheTimeoutId) {
|
||||
window.clearTimeout(this._linesCacheTimeoutId);
|
||||
this._linesCacheTimeoutId = 0;
|
||||
}
|
||||
};
|
||||
SearchHelper.prototype._isWholeWord = function (searchIndex, line, term) {
|
||||
return (((searchIndex === 0) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex - 1]) !== -1)) &&
|
||||
(((searchIndex + term.length) === line.length) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex + term.length]) !== -1)));
|
||||
};
|
||||
SearchHelper.prototype._findInLine = function (term, row, col, searchOptions, isReverseSearch) {
|
||||
if (searchOptions === void 0) { searchOptions = {}; }
|
||||
if (isReverseSearch === void 0) { isReverseSearch = false; }
|
||||
if (this._terminal.buffer.getLine(row).isWrapped) {
|
||||
return;
|
||||
}
|
||||
var stringLine = this._linesCache ? this._linesCache[row] : void 0;
|
||||
if (stringLine === void 0) {
|
||||
stringLine = this.translateBufferLineToStringWithWrap(row, true);
|
||||
if (this._linesCache) {
|
||||
this._linesCache[row] = stringLine;
|
||||
}
|
||||
}
|
||||
var searchTerm = searchOptions.caseSensitive ? term : term.toLowerCase();
|
||||
var searchStringLine = searchOptions.caseSensitive ? stringLine : stringLine.toLowerCase();
|
||||
var resultIndex = -1;
|
||||
if (searchOptions.regex) {
|
||||
var searchRegex = RegExp(searchTerm, 'g');
|
||||
var foundTerm = void 0;
|
||||
if (isReverseSearch) {
|
||||
while (foundTerm = searchRegex.exec(searchStringLine.slice(0, col))) {
|
||||
resultIndex = searchRegex.lastIndex - foundTerm[0].length;
|
||||
term = foundTerm[0];
|
||||
searchRegex.lastIndex -= (term.length - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
foundTerm = searchRegex.exec(searchStringLine.slice(col));
|
||||
if (foundTerm && foundTerm[0].length > 0) {
|
||||
resultIndex = col + (searchRegex.lastIndex - foundTerm[0].length);
|
||||
term = foundTerm[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isReverseSearch) {
|
||||
if (col - searchTerm.length >= 0) {
|
||||
resultIndex = searchStringLine.lastIndexOf(searchTerm, col - searchTerm.length);
|
||||
}
|
||||
}
|
||||
else {
|
||||
resultIndex = searchStringLine.indexOf(searchTerm, col);
|
||||
}
|
||||
}
|
||||
if (resultIndex >= 0) {
|
||||
if (resultIndex >= this._terminal.cols) {
|
||||
row += Math.floor(resultIndex / this._terminal.cols);
|
||||
resultIndex = resultIndex % this._terminal.cols;
|
||||
}
|
||||
if (searchOptions.wholeWord && !this._isWholeWord(resultIndex, searchStringLine, term)) {
|
||||
return;
|
||||
}
|
||||
var line = this._terminal.buffer.getLine(row);
|
||||
for (var i = 0; i < resultIndex; i++) {
|
||||
var cell = line.getCell(i);
|
||||
var char = cell.char;
|
||||
if (char.length > 1) {
|
||||
resultIndex -= char.length - 1;
|
||||
}
|
||||
var charWidth = cell.width;
|
||||
if (charWidth === 0) {
|
||||
resultIndex++;
|
||||
}
|
||||
}
|
||||
return {
|
||||
term: term,
|
||||
col: resultIndex,
|
||||
row: row
|
||||
};
|
||||
}
|
||||
};
|
||||
SearchHelper.prototype.translateBufferLineToStringWithWrap = function (lineIndex, trimRight) {
|
||||
var lineString = '';
|
||||
var lineWrapsToNext;
|
||||
do {
|
||||
var nextLine = this._terminal.buffer.getLine(lineIndex + 1);
|
||||
lineWrapsToNext = nextLine ? nextLine.isWrapped : false;
|
||||
lineString += this._terminal.buffer.getLine(lineIndex).translateToString(!lineWrapsToNext && trimRight).substring(0, this._terminal.cols);
|
||||
lineIndex++;
|
||||
} while (lineWrapsToNext);
|
||||
return lineString;
|
||||
};
|
||||
SearchHelper.prototype._selectResult = function (result) {
|
||||
if (!result) {
|
||||
this._terminal.clearSelection();
|
||||
return false;
|
||||
}
|
||||
this._terminal.select(result.col, result.row, result.term.length);
|
||||
this._terminal.scrollLines(result.row - this._terminal.buffer.viewportY);
|
||||
return true;
|
||||
};
|
||||
return SearchHelper;
|
||||
}());
|
||||
exports.SearchHelper = SearchHelper;
|
||||
//# sourceMappingURL=SearchHelper.js.map
|
||||
5
ports/javascript/node_modules/xterm/lib/addons/search/search.d.ts
generated
vendored
Normal file
5
ports/javascript/node_modules/xterm/lib/addons/search/search.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { Terminal } from 'xterm';
|
||||
import { ISearchOptions } from './Interfaces';
|
||||
export declare function findNext(terminal: Terminal, term: string, searchOptions?: ISearchOptions): boolean;
|
||||
export declare function findPrevious(terminal: Terminal, term: string, searchOptions: ISearchOptions): boolean;
|
||||
export declare function apply(terminalConstructor: typeof Terminal): void;
|
||||
30
ports/javascript/node_modules/xterm/lib/addons/search/search.js
generated
vendored
Normal file
30
ports/javascript/node_modules/xterm/lib/addons/search/search.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var SearchHelper_1 = require("./SearchHelper");
|
||||
function findNext(terminal, term, searchOptions) {
|
||||
if (searchOptions === void 0) { searchOptions = {}; }
|
||||
var addonTerminal = terminal;
|
||||
if (!addonTerminal.__searchHelper) {
|
||||
addonTerminal.__searchHelper = new SearchHelper_1.SearchHelper(addonTerminal);
|
||||
}
|
||||
return addonTerminal.__searchHelper.findNext(term, searchOptions);
|
||||
}
|
||||
exports.findNext = findNext;
|
||||
function findPrevious(terminal, term, searchOptions) {
|
||||
var addonTerminal = terminal;
|
||||
if (!addonTerminal.__searchHelper) {
|
||||
addonTerminal.__searchHelper = new SearchHelper_1.SearchHelper(addonTerminal);
|
||||
}
|
||||
return addonTerminal.__searchHelper.findPrevious(term, searchOptions);
|
||||
}
|
||||
exports.findPrevious = findPrevious;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.findNext = function (term, searchOptions) {
|
||||
return findNext(this, term, searchOptions);
|
||||
};
|
||||
terminalConstructor.prototype.findPrevious = function (term, searchOptions) {
|
||||
return findPrevious(this, term, searchOptions);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
//# sourceMappingURL=search.js.map
|
||||
17
ports/javascript/node_modules/xterm/lib/addons/terminado/Interfaces.d.ts
generated
vendored
Normal file
17
ports/javascript/node_modules/xterm/lib/addons/terminado/Interfaces.d.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { Terminal, IDisposable } from 'xterm';
|
||||
export interface ITerminadoAddonTerminal 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;
|
||||
__setSize?(size: {
|
||||
rows: number;
|
||||
cols: number;
|
||||
}): void;
|
||||
}
|
||||
3
ports/javascript/node_modules/xterm/lib/addons/terminado/Interfaces.js
generated
vendored
Normal file
3
ports/javascript/node_modules/xterm/lib/addons/terminado/Interfaces.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Interfaces.js.map
|
||||
4
ports/javascript/node_modules/xterm/lib/addons/terminado/terminado.d.ts
generated
vendored
Normal file
4
ports/javascript/node_modules/xterm/lib/addons/terminado/terminado.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { Terminal } from 'xterm';
|
||||
export declare function terminadoAttach(term: Terminal, socket: WebSocket, bidirectional: boolean, buffered: boolean): void;
|
||||
export declare function terminadoDetach(term: Terminal, socket: WebSocket): void;
|
||||
export declare function apply(terminalConstructor: typeof Terminal): void;
|
||||
66
ports/javascript/node_modules/xterm/lib/addons/terminado/terminado.js
generated
vendored
Normal file
66
ports/javascript/node_modules/xterm/lib/addons/terminado/terminado.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function terminadoAttach(term, socket, bidirectional, buffered) {
|
||||
var addonTerminal = term;
|
||||
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
|
||||
addonTerminal.__socket = socket;
|
||||
addonTerminal.__flushBuffer = function () {
|
||||
addonTerminal.write(addonTerminal.__attachSocketBuffer);
|
||||
addonTerminal.__attachSocketBuffer = null;
|
||||
};
|
||||
addonTerminal.__pushToBuffer = function (data) {
|
||||
if (addonTerminal.__attachSocketBuffer) {
|
||||
addonTerminal.__attachSocketBuffer += data;
|
||||
}
|
||||
else {
|
||||
addonTerminal.__attachSocketBuffer = data;
|
||||
setTimeout(addonTerminal.__flushBuffer, 10);
|
||||
}
|
||||
};
|
||||
addonTerminal.__getMessage = function (ev) {
|
||||
var data = JSON.parse(ev.data);
|
||||
if (data[0] === 'stdout') {
|
||||
if (buffered) {
|
||||
addonTerminal.__pushToBuffer(data[1]);
|
||||
}
|
||||
else {
|
||||
addonTerminal.write(data[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
addonTerminal.__sendData = function (data) {
|
||||
socket.send(JSON.stringify(['stdin', data]));
|
||||
};
|
||||
addonTerminal.__setSize = function (size) {
|
||||
socket.send(JSON.stringify(['set_size', size.rows, size.cols]));
|
||||
};
|
||||
socket.addEventListener('message', addonTerminal.__getMessage);
|
||||
if (bidirectional) {
|
||||
addonTerminal._core.register(addonTerminal.onData(addonTerminal.__sendData));
|
||||
}
|
||||
addonTerminal._core.register(addonTerminal.onResize(addonTerminal.__setSize));
|
||||
socket.addEventListener('close', function () { return terminadoDetach(addonTerminal, socket); });
|
||||
socket.addEventListener('error', function () { return terminadoDetach(addonTerminal, socket); });
|
||||
}
|
||||
exports.terminadoAttach = terminadoAttach;
|
||||
function terminadoDetach(term, socket) {
|
||||
var addonTerminal = term;
|
||||
addonTerminal.__dataListener.dispose();
|
||||
addonTerminal.__dataListener = undefined;
|
||||
socket = (typeof socket === 'undefined') ? addonTerminal.__socket : socket;
|
||||
if (socket) {
|
||||
socket.removeEventListener('message', addonTerminal.__getMessage);
|
||||
}
|
||||
delete addonTerminal.__socket;
|
||||
}
|
||||
exports.terminadoDetach = terminadoDetach;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.terminadoAttach = function (socket, bidirectional, buffered) {
|
||||
return terminadoAttach(this, socket, bidirectional, buffered);
|
||||
};
|
||||
terminalConstructor.prototype.terminadoDetach = function (socket) {
|
||||
return terminadoDetach(this, socket);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
//# sourceMappingURL=terminado.js.map
|
||||
3
ports/javascript/node_modules/xterm/lib/addons/webLinks/webLinks.d.ts
generated
vendored
Normal file
3
ports/javascript/node_modules/xterm/lib/addons/webLinks/webLinks.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Terminal, ILinkMatcherOptions } from 'xterm';
|
||||
export declare function webLinksInit(term: Terminal, handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void;
|
||||
export declare function apply(terminalConstructor: typeof Terminal): void;
|
||||
38
ports/javascript/node_modules/xterm/lib/addons/webLinks/webLinks.js
generated
vendored
Normal file
38
ports/javascript/node_modules/xterm/lib/addons/webLinks/webLinks.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var protocolClause = '(https?:\\/\\/)';
|
||||
var domainCharacterSet = '[\\da-z\\.-]+';
|
||||
var negatedDomainCharacterSet = '[^\\da-z\\.-]+';
|
||||
var domainBodyClause = '(' + domainCharacterSet + ')';
|
||||
var tldClause = '([a-z\\.]{2,6})';
|
||||
var ipClause = '((\\d{1,3}\\.){3}\\d{1,3})';
|
||||
var localHostClause = '(localhost)';
|
||||
var portClause = '(:\\d{1,5})';
|
||||
var hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
|
||||
var pathCharacterSet = '(\\/[\\/\\w\\.\\-%~:+]*)*([^:"\'\\s])';
|
||||
var pathClause = '(' + pathCharacterSet + ')?';
|
||||
var queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';
|
||||
var queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';
|
||||
var hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';
|
||||
var negatedPathCharacterSet = '[^\\/\\w\\.\\-%]+';
|
||||
var bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;
|
||||
var start = '(?:^|' + negatedDomainCharacterSet + ')(';
|
||||
var end = ')($|' + negatedPathCharacterSet + ')';
|
||||
var strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);
|
||||
function handleLink(event, uri) {
|
||||
window.open(uri, '_blank');
|
||||
}
|
||||
function webLinksInit(term, handler, options) {
|
||||
if (handler === void 0) { handler = handleLink; }
|
||||
if (options === void 0) { options = {}; }
|
||||
options.matchIndex = 1;
|
||||
term.registerLinkMatcher(strictUrlRegex, handler, options);
|
||||
}
|
||||
exports.webLinksInit = webLinksInit;
|
||||
function apply(terminalConstructor) {
|
||||
terminalConstructor.prototype.webLinksInit = function (handler, options) {
|
||||
webLinksInit(this, handler, options);
|
||||
};
|
||||
}
|
||||
exports.apply = apply;
|
||||
//# sourceMappingURL=webLinks.js.map
|
||||
5
ports/javascript/node_modules/xterm/lib/addons/zmodem/zmodem.d.ts
generated
vendored
Normal file
5
ports/javascript/node_modules/xterm/lib/addons/zmodem/zmodem.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { Terminal } from 'xterm';
|
||||
export interface IZmodemOptions {
|
||||
noTerminalWriteOutsideSession?: boolean;
|
||||
}
|
||||
export declare function apply(terminalConstructor: typeof Terminal): void;
|
||||
41
ports/javascript/node_modules/xterm/lib/addons/zmodem/zmodem.js
generated
vendored
Normal file
41
ports/javascript/node_modules/xterm/lib/addons/zmodem/zmodem.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var zmodem;
|
||||
function zmodemAttach(ws, opts) {
|
||||
if (opts === void 0) { opts = {}; }
|
||||
var term = this;
|
||||
var senderFunc = function (octets) { return ws.send(new Uint8Array(octets)); };
|
||||
var zsentry;
|
||||
function shouldWrite() {
|
||||
return !!zsentry.get_confirmed_session() || !opts.noTerminalWriteOutsideSession;
|
||||
}
|
||||
zsentry = new zmodem.Sentry({
|
||||
to_terminal: function (octets) {
|
||||
if (shouldWrite()) {
|
||||
term.write(String.fromCharCode.apply(String, octets));
|
||||
}
|
||||
},
|
||||
sender: senderFunc,
|
||||
on_retract: function () { return term.emit('zmodemRetract'); },
|
||||
on_detect: function (detection) { return term.emit('zmodemDetect', detection); }
|
||||
});
|
||||
function handleWSMessage(evt) {
|
||||
if (typeof evt.data === 'string') {
|
||||
if (shouldWrite()) {
|
||||
term.write(evt.data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
zsentry.consume(evt.data);
|
||||
}
|
||||
}
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.addEventListener('message', handleWSMessage);
|
||||
}
|
||||
function apply(terminalConstructor) {
|
||||
zmodem = (typeof window === 'object') ? window.Zmodem : { Browser: null };
|
||||
terminalConstructor.prototype.zmodemAttach = zmodemAttach;
|
||||
terminalConstructor.prototype.zmodemBrowser = zmodem.Browser;
|
||||
}
|
||||
exports.apply = apply;
|
||||
//# sourceMappingURL=zmodem.js.map
|
||||
35
ports/javascript/node_modules/xterm/lib/common/CircularList.d.ts
generated
vendored
Normal file
35
ports/javascript/node_modules/xterm/lib/common/CircularList.d.ts
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
import { ICircularList } from './Types';
|
||||
import { EventEmitter2, IEvent } from './EventEmitter2';
|
||||
export interface IInsertEvent {
|
||||
index: number;
|
||||
amount: number;
|
||||
}
|
||||
export interface IDeleteEvent {
|
||||
index: number;
|
||||
amount: number;
|
||||
}
|
||||
export declare class CircularList<T> implements ICircularList<T> {
|
||||
private _maxLength;
|
||||
protected _array: (T | undefined)[];
|
||||
private _startIndex;
|
||||
private _length;
|
||||
onDeleteEmitter: EventEmitter2<IDeleteEvent>;
|
||||
readonly onDelete: IEvent<IDeleteEvent>;
|
||||
onInsertEmitter: EventEmitter2<IInsertEvent>;
|
||||
readonly onInsert: IEvent<IInsertEvent>;
|
||||
onTrimEmitter: EventEmitter2<number>;
|
||||
readonly onTrim: IEvent<number>;
|
||||
constructor(_maxLength: number);
|
||||
maxLength: number;
|
||||
length: number;
|
||||
get(index: number): T | undefined;
|
||||
set(index: number, value: T | undefined): void;
|
||||
push(value: T): void;
|
||||
recycle(): T;
|
||||
readonly isFull: boolean;
|
||||
pop(): T | undefined;
|
||||
splice(start: number, deleteCount: number, ...items: T[]): void;
|
||||
trimStart(count: number): void;
|
||||
shiftElements(start: number, count: number, offset: number): void;
|
||||
private _getCyclicIndex;
|
||||
}
|
||||
168
ports/javascript/node_modules/xterm/lib/common/CircularList.js
generated
vendored
Normal file
168
ports/javascript/node_modules/xterm/lib/common/CircularList.js
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var EventEmitter2_1 = require("./EventEmitter2");
|
||||
var CircularList = (function () {
|
||||
function CircularList(_maxLength) {
|
||||
this._maxLength = _maxLength;
|
||||
this.onDeleteEmitter = new EventEmitter2_1.EventEmitter2();
|
||||
this.onInsertEmitter = new EventEmitter2_1.EventEmitter2();
|
||||
this.onTrimEmitter = new EventEmitter2_1.EventEmitter2();
|
||||
this._array = new Array(this._maxLength);
|
||||
this._startIndex = 0;
|
||||
this._length = 0;
|
||||
}
|
||||
Object.defineProperty(CircularList.prototype, "onDelete", {
|
||||
get: function () { return this.onDeleteEmitter.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(CircularList.prototype, "onInsert", {
|
||||
get: function () { return this.onInsertEmitter.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(CircularList.prototype, "onTrim", {
|
||||
get: function () { return this.onTrimEmitter.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(CircularList.prototype, "maxLength", {
|
||||
get: function () {
|
||||
return this._maxLength;
|
||||
},
|
||||
set: function (newMaxLength) {
|
||||
if (this._maxLength === newMaxLength) {
|
||||
return;
|
||||
}
|
||||
var newArray = new Array(newMaxLength);
|
||||
for (var i = 0; i < Math.min(newMaxLength, this.length); i++) {
|
||||
newArray[i] = this._array[this._getCyclicIndex(i)];
|
||||
}
|
||||
this._array = newArray;
|
||||
this._maxLength = newMaxLength;
|
||||
this._startIndex = 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(CircularList.prototype, "length", {
|
||||
get: function () {
|
||||
return this._length;
|
||||
},
|
||||
set: function (newLength) {
|
||||
if (newLength > this._length) {
|
||||
for (var i = this._length; i < newLength; i++) {
|
||||
this._array[i] = undefined;
|
||||
}
|
||||
}
|
||||
this._length = newLength;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
CircularList.prototype.get = function (index) {
|
||||
return this._array[this._getCyclicIndex(index)];
|
||||
};
|
||||
CircularList.prototype.set = function (index, value) {
|
||||
this._array[this._getCyclicIndex(index)] = value;
|
||||
};
|
||||
CircularList.prototype.push = function (value) {
|
||||
this._array[this._getCyclicIndex(this._length)] = value;
|
||||
if (this._length === this._maxLength) {
|
||||
this._startIndex = ++this._startIndex % this._maxLength;
|
||||
this.onTrimEmitter.fire(1);
|
||||
}
|
||||
else {
|
||||
this._length++;
|
||||
}
|
||||
};
|
||||
CircularList.prototype.recycle = function () {
|
||||
if (this._length !== this._maxLength) {
|
||||
throw new Error('Can only recycle when the buffer is full');
|
||||
}
|
||||
this._startIndex = ++this._startIndex % this._maxLength;
|
||||
this.onTrimEmitter.fire(1);
|
||||
return this._array[this._getCyclicIndex(this._length - 1)];
|
||||
};
|
||||
Object.defineProperty(CircularList.prototype, "isFull", {
|
||||
get: function () {
|
||||
return this._length === this._maxLength;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
CircularList.prototype.pop = function () {
|
||||
return this._array[this._getCyclicIndex(this._length-- - 1)];
|
||||
};
|
||||
CircularList.prototype.splice = function (start, deleteCount) {
|
||||
var items = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
items[_i - 2] = arguments[_i];
|
||||
}
|
||||
if (deleteCount) {
|
||||
for (var i = start; i < this._length - deleteCount; i++) {
|
||||
this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];
|
||||
}
|
||||
this._length -= deleteCount;
|
||||
}
|
||||
for (var i = this._length - 1; i >= start; i--) {
|
||||
this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
|
||||
}
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
this._array[this._getCyclicIndex(start + i)] = items[i];
|
||||
}
|
||||
if (this._length + items.length > this._maxLength) {
|
||||
var countToTrim = (this._length + items.length) - this._maxLength;
|
||||
this._startIndex += countToTrim;
|
||||
this._length = this._maxLength;
|
||||
this.onTrimEmitter.fire(countToTrim);
|
||||
}
|
||||
else {
|
||||
this._length += items.length;
|
||||
}
|
||||
};
|
||||
CircularList.prototype.trimStart = function (count) {
|
||||
if (count > this._length) {
|
||||
count = this._length;
|
||||
}
|
||||
this._startIndex += count;
|
||||
this._length -= count;
|
||||
this.onTrimEmitter.fire(count);
|
||||
};
|
||||
CircularList.prototype.shiftElements = function (start, count, offset) {
|
||||
if (count <= 0) {
|
||||
return;
|
||||
}
|
||||
if (start < 0 || start >= this._length) {
|
||||
throw new Error('start argument out of range');
|
||||
}
|
||||
if (start + offset < 0) {
|
||||
throw new Error('Cannot shift elements in list beyond index 0');
|
||||
}
|
||||
if (offset > 0) {
|
||||
for (var i = count - 1; i >= 0; i--) {
|
||||
this.set(start + i + offset, this.get(start + i));
|
||||
}
|
||||
var expandListBy = (start + count + offset) - this._length;
|
||||
if (expandListBy > 0) {
|
||||
this._length += expandListBy;
|
||||
while (this._length > this._maxLength) {
|
||||
this._length--;
|
||||
this._startIndex++;
|
||||
this.onTrimEmitter.fire(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < count; i++) {
|
||||
this.set(start + i + offset, this.get(start + i));
|
||||
}
|
||||
}
|
||||
};
|
||||
CircularList.prototype._getCyclicIndex = function (index) {
|
||||
return (this._startIndex + index) % this._maxLength;
|
||||
};
|
||||
return CircularList;
|
||||
}());
|
||||
exports.CircularList = CircularList;
|
||||
//# sourceMappingURL=CircularList.js.map
|
||||
1
ports/javascript/node_modules/xterm/lib/common/Clone.d.ts
generated
vendored
Normal file
1
ports/javascript/node_modules/xterm/lib/common/Clone.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function clone<T>(val: T, depth?: number): T | null;
|
||||
18
ports/javascript/node_modules/xterm/lib/common/Clone.js
generated
vendored
Normal file
18
ports/javascript/node_modules/xterm/lib/common/Clone.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function clone(val, depth) {
|
||||
if (depth === void 0) { depth = 5; }
|
||||
if (typeof val !== 'object') {
|
||||
return val;
|
||||
}
|
||||
if (val === null) {
|
||||
return null;
|
||||
}
|
||||
var clonedObject = Array.isArray(val) ? [] : {};
|
||||
for (var key in val) {
|
||||
clonedObject[key] = depth <= 1 ? val[key] : clone(val[key], depth - 1);
|
||||
}
|
||||
return clonedObject;
|
||||
}
|
||||
exports.clone = clone;
|
||||
//# sourceMappingURL=Clone.js.map
|
||||
14
ports/javascript/node_modules/xterm/lib/common/EventEmitter.d.ts
generated
vendored
Normal file
14
ports/javascript/node_modules/xterm/lib/common/EventEmitter.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { IDisposable, IEventEmitter, XtermListener } from './Types';
|
||||
import { Disposable } from './Lifecycle';
|
||||
export declare class EventEmitter extends Disposable implements IEventEmitter, IDisposable {
|
||||
private _events;
|
||||
constructor();
|
||||
on(type: string, listener: XtermListener): void;
|
||||
addDisposableListener(type: string, handler: XtermListener): IDisposable;
|
||||
off(type: string, listener: XtermListener): void;
|
||||
removeAllListeners(type: string): void;
|
||||
emit(type: string, ...args: any[]): void;
|
||||
emitMayRemoveListeners(type: string, ...args: any[]): void;
|
||||
listeners(type: string): XtermListener[];
|
||||
dispose(): void;
|
||||
}
|
||||
99
ports/javascript/node_modules/xterm/lib/common/EventEmitter.js
generated
vendored
Normal file
99
ports/javascript/node_modules/xterm/lib/common/EventEmitter.js
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Lifecycle_1 = require("./Lifecycle");
|
||||
var EventEmitter = (function (_super) {
|
||||
__extends(EventEmitter, _super);
|
||||
function EventEmitter() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this._events = _this._events || {};
|
||||
return _this;
|
||||
}
|
||||
EventEmitter.prototype.on = function (type, listener) {
|
||||
this._events[type] = this._events[type] || [];
|
||||
this._events[type].push(listener);
|
||||
};
|
||||
EventEmitter.prototype.addDisposableListener = function (type, handler) {
|
||||
var _this = this;
|
||||
this.on(type, handler);
|
||||
var disposed = false;
|
||||
return {
|
||||
dispose: function () {
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
_this.off(type, handler);
|
||||
disposed = true;
|
||||
}
|
||||
};
|
||||
};
|
||||
EventEmitter.prototype.off = function (type, listener) {
|
||||
if (!this._events[type]) {
|
||||
return;
|
||||
}
|
||||
var obj = this._events[type];
|
||||
var i = obj.length;
|
||||
while (i--) {
|
||||
if (obj[i] === listener) {
|
||||
obj.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
EventEmitter.prototype.removeAllListeners = function (type) {
|
||||
if (this._events[type]) {
|
||||
delete this._events[type];
|
||||
}
|
||||
};
|
||||
EventEmitter.prototype.emit = function (type) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
if (!this._events[type]) {
|
||||
return;
|
||||
}
|
||||
var obj = this._events[type];
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
obj[i].apply(this, args);
|
||||
}
|
||||
};
|
||||
EventEmitter.prototype.emitMayRemoveListeners = function (type) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
if (!this._events[type]) {
|
||||
return;
|
||||
}
|
||||
var obj = this._events[type];
|
||||
var length = obj.length;
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
obj[i].apply(this, args);
|
||||
i -= length - obj.length;
|
||||
length = obj.length;
|
||||
}
|
||||
};
|
||||
EventEmitter.prototype.listeners = function (type) {
|
||||
return this._events[type] || [];
|
||||
};
|
||||
EventEmitter.prototype.dispose = function () {
|
||||
_super.prototype.dispose.call(this);
|
||||
this._events = {};
|
||||
};
|
||||
return EventEmitter;
|
||||
}(Lifecycle_1.Disposable));
|
||||
exports.EventEmitter = EventEmitter;
|
||||
//# sourceMappingURL=EventEmitter.js.map
|
||||
10
ports/javascript/node_modules/xterm/lib/common/EventEmitter2.d.ts
generated
vendored
Normal file
10
ports/javascript/node_modules/xterm/lib/common/EventEmitter2.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { IDisposable } from './Types';
|
||||
export interface IEvent<T> {
|
||||
(listener: (e: T) => any): IDisposable;
|
||||
}
|
||||
export declare class EventEmitter2<T> {
|
||||
private _listeners;
|
||||
private _event?;
|
||||
readonly event: IEvent<T>;
|
||||
fire(data: T): void;
|
||||
}
|
||||
43
ports/javascript/node_modules/xterm/lib/common/EventEmitter2.js
generated
vendored
Normal file
43
ports/javascript/node_modules/xterm/lib/common/EventEmitter2.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var EventEmitter2 = (function () {
|
||||
function EventEmitter2() {
|
||||
this._listeners = [];
|
||||
}
|
||||
Object.defineProperty(EventEmitter2.prototype, "event", {
|
||||
get: function () {
|
||||
var _this = this;
|
||||
if (!this._event) {
|
||||
this._event = function (listener) {
|
||||
_this._listeners.push(listener);
|
||||
var disposable = {
|
||||
dispose: function () {
|
||||
for (var i = 0; i < _this._listeners.length; i++) {
|
||||
if (_this._listeners[i] === listener) {
|
||||
_this._listeners.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return disposable;
|
||||
};
|
||||
}
|
||||
return this._event;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
EventEmitter2.prototype.fire = function (data) {
|
||||
var queue = [];
|
||||
for (var i = 0; i < this._listeners.length; i++) {
|
||||
queue.push(this._listeners[i]);
|
||||
}
|
||||
for (var i = 0; i < queue.length; i++) {
|
||||
queue[i].call(undefined, data);
|
||||
}
|
||||
};
|
||||
return EventEmitter2;
|
||||
}());
|
||||
exports.EventEmitter2 = EventEmitter2;
|
||||
//# sourceMappingURL=EventEmitter2.js.map
|
||||
9
ports/javascript/node_modules/xterm/lib/common/Lifecycle.d.ts
generated
vendored
Normal file
9
ports/javascript/node_modules/xterm/lib/common/Lifecycle.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import { IDisposable } from './Types';
|
||||
export declare abstract class Disposable implements IDisposable {
|
||||
protected _disposables: IDisposable[];
|
||||
protected _isDisposed: boolean;
|
||||
constructor();
|
||||
dispose(): void;
|
||||
register<T extends IDisposable>(d: T): void;
|
||||
unregister<T extends IDisposable>(d: T): void;
|
||||
}
|
||||
25
ports/javascript/node_modules/xterm/lib/common/Lifecycle.js
generated
vendored
Normal file
25
ports/javascript/node_modules/xterm/lib/common/Lifecycle.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Disposable = (function () {
|
||||
function Disposable() {
|
||||
this._disposables = [];
|
||||
this._isDisposed = false;
|
||||
}
|
||||
Disposable.prototype.dispose = function () {
|
||||
this._isDisposed = true;
|
||||
this._disposables.forEach(function (d) { return d.dispose(); });
|
||||
this._disposables.length = 0;
|
||||
};
|
||||
Disposable.prototype.register = function (d) {
|
||||
this._disposables.push(d);
|
||||
};
|
||||
Disposable.prototype.unregister = function (d) {
|
||||
var index = this._disposables.indexOf(d);
|
||||
if (index !== -1) {
|
||||
this._disposables.splice(index, 1);
|
||||
}
|
||||
};
|
||||
return Disposable;
|
||||
}());
|
||||
exports.Disposable = Disposable;
|
||||
//# sourceMappingURL=Lifecycle.js.map
|
||||
8
ports/javascript/node_modules/xterm/lib/common/Platform.d.ts
generated
vendored
Normal file
8
ports/javascript/node_modules/xterm/lib/common/Platform.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export declare const isFirefox: boolean;
|
||||
export declare const isSafari: boolean;
|
||||
export declare const isMSIE: boolean;
|
||||
export declare const isMac: boolean;
|
||||
export declare const isIpad: boolean;
|
||||
export declare const isIphone: boolean;
|
||||
export declare const isMSWindows: boolean;
|
||||
export declare const isLinux: boolean;
|
||||
17
ports/javascript/node_modules/xterm/lib/common/Platform.js
generated
vendored
Normal file
17
ports/javascript/node_modules/xterm/lib/common/Platform.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var isNode = (typeof navigator === 'undefined') ? true : false;
|
||||
var userAgent = (isNode) ? 'node' : navigator.userAgent;
|
||||
var platform = (isNode) ? 'node' : navigator.platform;
|
||||
exports.isFirefox = !!~userAgent.indexOf('Firefox');
|
||||
exports.isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
|
||||
exports.isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');
|
||||
exports.isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);
|
||||
exports.isIpad = platform === 'iPad';
|
||||
exports.isIphone = platform === 'iPhone';
|
||||
exports.isMSWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);
|
||||
exports.isLinux = platform.indexOf('Linux') >= 0;
|
||||
function contains(arr, el) {
|
||||
return arr.indexOf(el) >= 0;
|
||||
}
|
||||
//# sourceMappingURL=Platform.js.map
|
||||
4
ports/javascript/node_modules/xterm/lib/common/TypedArrayUtils.d.ts
generated
vendored
Normal file
4
ports/javascript/node_modules/xterm/lib/common/TypedArrayUtils.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export declare type TypedArray = Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
|
||||
export declare function fill<T extends TypedArray>(array: T, value: number, start?: number, end?: number): T;
|
||||
export declare function fillFallback<T extends TypedArray>(array: T, value: number, start?: number, end?: number): T;
|
||||
export declare function concat<T extends TypedArray>(a: T, b: T): T;
|
||||
36
ports/javascript/node_modules/xterm/lib/common/TypedArrayUtils.js
generated
vendored
Normal file
36
ports/javascript/node_modules/xterm/lib/common/TypedArrayUtils.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function fill(array, value, start, end) {
|
||||
if (array.fill) {
|
||||
return array.fill(value, start, end);
|
||||
}
|
||||
return fillFallback(array, value, start, end);
|
||||
}
|
||||
exports.fill = fill;
|
||||
function fillFallback(array, value, start, end) {
|
||||
if (start === void 0) { start = 0; }
|
||||
if (end === void 0) { end = array.length; }
|
||||
if (start >= array.length) {
|
||||
return array;
|
||||
}
|
||||
start = (array.length + start) % array.length;
|
||||
if (end >= array.length) {
|
||||
end = array.length;
|
||||
}
|
||||
else {
|
||||
end = (array.length + end) % array.length;
|
||||
}
|
||||
for (var i = start; i < end; ++i) {
|
||||
array[i] = value;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
exports.fillFallback = fillFallback;
|
||||
function concat(a, b) {
|
||||
var result = new a.constructor(a.length + b.length);
|
||||
result.set(a);
|
||||
result.set(b, a.length);
|
||||
return result;
|
||||
}
|
||||
exports.concat = concat;
|
||||
//# sourceMappingURL=TypedArrayUtils.js.map
|
||||
41
ports/javascript/node_modules/xterm/lib/common/Types.d.ts
generated
vendored
Normal file
41
ports/javascript/node_modules/xterm/lib/common/Types.d.ts
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
import { IEvent, EventEmitter2 } from './EventEmitter2';
|
||||
import { IDeleteEvent, IInsertEvent } from './CircularList';
|
||||
export declare const DEFAULT_COLOR = 256;
|
||||
export interface IDisposable {
|
||||
dispose(): void;
|
||||
}
|
||||
export interface IEventEmitter {
|
||||
on(type: string, listener: (...args: any[]) => void): void;
|
||||
off(type: string, listener: (...args: any[]) => void): void;
|
||||
emit(type: string, data?: any): void;
|
||||
addDisposableListener(type: string, handler: (...args: any[]) => void): IDisposable;
|
||||
}
|
||||
export declare type XtermListener = (...args: any[]) => void;
|
||||
export interface IKeyboardEvent {
|
||||
altKey: boolean;
|
||||
ctrlKey: boolean;
|
||||
shiftKey: boolean;
|
||||
metaKey: boolean;
|
||||
keyCode: number;
|
||||
key: string;
|
||||
type: string;
|
||||
}
|
||||
export interface ICircularList<T> {
|
||||
length: number;
|
||||
maxLength: number;
|
||||
isFull: boolean;
|
||||
onDeleteEmitter: EventEmitter2<IDeleteEvent>;
|
||||
onDelete: IEvent<IDeleteEvent>;
|
||||
onInsertEmitter: EventEmitter2<IInsertEvent>;
|
||||
onInsert: IEvent<IInsertEvent>;
|
||||
onTrimEmitter: EventEmitter2<number>;
|
||||
onTrim: IEvent<number>;
|
||||
get(index: number): T | undefined;
|
||||
set(index: number, value: T): void;
|
||||
push(value: T): void;
|
||||
recycle(): T | undefined;
|
||||
pop(): T | undefined;
|
||||
splice(start: number, deleteCount: number, ...items: T[]): void;
|
||||
trimStart(count: number): void;
|
||||
shiftElements(start: number, count: number, offset: number): void;
|
||||
}
|
||||
4
ports/javascript/node_modules/xterm/lib/common/Types.js
generated
vendored
Normal file
4
ports/javascript/node_modules/xterm/lib/common/Types.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DEFAULT_COLOR = 256;
|
||||
//# sourceMappingURL=Types.js.map
|
||||
70
ports/javascript/node_modules/xterm/lib/common/data/EscapeSequences.d.ts
generated
vendored
Normal file
70
ports/javascript/node_modules/xterm/lib/common/data/EscapeSequences.d.ts
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
export declare namespace C0 {
|
||||
const NUL = "\0";
|
||||
const SOH = "\u0001";
|
||||
const STX = "\u0002";
|
||||
const ETX = "\u0003";
|
||||
const EOT = "\u0004";
|
||||
const ENQ = "\u0005";
|
||||
const ACK = "\u0006";
|
||||
const BEL = "\u0007";
|
||||
const BS = "\b";
|
||||
const HT = "\t";
|
||||
const LF = "\n";
|
||||
const VT = "\v";
|
||||
const FF = "\f";
|
||||
const CR = "\r";
|
||||
const SO = "\u000E";
|
||||
const SI = "\u000F";
|
||||
const DLE = "\u0010";
|
||||
const DC1 = "\u0011";
|
||||
const DC2 = "\u0012";
|
||||
const DC3 = "\u0013";
|
||||
const DC4 = "\u0014";
|
||||
const NAK = "\u0015";
|
||||
const SYN = "\u0016";
|
||||
const ETB = "\u0017";
|
||||
const CAN = "\u0018";
|
||||
const EM = "\u0019";
|
||||
const SUB = "\u001A";
|
||||
const ESC = "\u001B";
|
||||
const FS = "\u001C";
|
||||
const GS = "\u001D";
|
||||
const RS = "\u001E";
|
||||
const US = "\u001F";
|
||||
const SP = " ";
|
||||
const DEL = "";
|
||||
}
|
||||
export declare namespace C1 {
|
||||
const PAD = "\u0080";
|
||||
const HOP = "\u0081";
|
||||
const BPH = "\u0082";
|
||||
const NBH = "\u0083";
|
||||
const IND = "\u0084";
|
||||
const NEL = "\u0085";
|
||||
const SSA = "\u0086";
|
||||
const ESA = "\u0087";
|
||||
const HTS = "\u0088";
|
||||
const HTJ = "\u0089";
|
||||
const VTS = "\u008A";
|
||||
const PLD = "\u008B";
|
||||
const PLU = "\u008C";
|
||||
const RI = "\u008D";
|
||||
const SS2 = "\u008E";
|
||||
const SS3 = "\u008F";
|
||||
const DCS = "\u0090";
|
||||
const PU1 = "\u0091";
|
||||
const PU2 = "\u0092";
|
||||
const STS = "\u0093";
|
||||
const CCH = "\u0094";
|
||||
const MW = "\u0095";
|
||||
const SPA = "\u0096";
|
||||
const EPA = "\u0097";
|
||||
const SOS = "\u0098";
|
||||
const SGCI = "\u0099";
|
||||
const SCI = "\u009A";
|
||||
const CSI = "\u009B";
|
||||
const ST = "\u009C";
|
||||
const OSC = "\u009D";
|
||||
const PM = "\u009E";
|
||||
const APC = "\u009F";
|
||||
}
|
||||
75
ports/javascript/node_modules/xterm/lib/common/data/EscapeSequences.js
generated
vendored
Normal file
75
ports/javascript/node_modules/xterm/lib/common/data/EscapeSequences.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var C0;
|
||||
(function (C0) {
|
||||
C0.NUL = '\x00';
|
||||
C0.SOH = '\x01';
|
||||
C0.STX = '\x02';
|
||||
C0.ETX = '\x03';
|
||||
C0.EOT = '\x04';
|
||||
C0.ENQ = '\x05';
|
||||
C0.ACK = '\x06';
|
||||
C0.BEL = '\x07';
|
||||
C0.BS = '\x08';
|
||||
C0.HT = '\x09';
|
||||
C0.LF = '\x0a';
|
||||
C0.VT = '\x0b';
|
||||
C0.FF = '\x0c';
|
||||
C0.CR = '\x0d';
|
||||
C0.SO = '\x0e';
|
||||
C0.SI = '\x0f';
|
||||
C0.DLE = '\x10';
|
||||
C0.DC1 = '\x11';
|
||||
C0.DC2 = '\x12';
|
||||
C0.DC3 = '\x13';
|
||||
C0.DC4 = '\x14';
|
||||
C0.NAK = '\x15';
|
||||
C0.SYN = '\x16';
|
||||
C0.ETB = '\x17';
|
||||
C0.CAN = '\x18';
|
||||
C0.EM = '\x19';
|
||||
C0.SUB = '\x1a';
|
||||
C0.ESC = '\x1b';
|
||||
C0.FS = '\x1c';
|
||||
C0.GS = '\x1d';
|
||||
C0.RS = '\x1e';
|
||||
C0.US = '\x1f';
|
||||
C0.SP = '\x20';
|
||||
C0.DEL = '\x7f';
|
||||
})(C0 = exports.C0 || (exports.C0 = {}));
|
||||
var C1;
|
||||
(function (C1) {
|
||||
C1.PAD = '\x80';
|
||||
C1.HOP = '\x81';
|
||||
C1.BPH = '\x82';
|
||||
C1.NBH = '\x83';
|
||||
C1.IND = '\x84';
|
||||
C1.NEL = '\x85';
|
||||
C1.SSA = '\x86';
|
||||
C1.ESA = '\x87';
|
||||
C1.HTS = '\x88';
|
||||
C1.HTJ = '\x89';
|
||||
C1.VTS = '\x8a';
|
||||
C1.PLD = '\x8b';
|
||||
C1.PLU = '\x8c';
|
||||
C1.RI = '\x8d';
|
||||
C1.SS2 = '\x8e';
|
||||
C1.SS3 = '\x8f';
|
||||
C1.DCS = '\x90';
|
||||
C1.PU1 = '\x91';
|
||||
C1.PU2 = '\x92';
|
||||
C1.STS = '\x93';
|
||||
C1.CCH = '\x94';
|
||||
C1.MW = '\x95';
|
||||
C1.SPA = '\x96';
|
||||
C1.EPA = '\x97';
|
||||
C1.SOS = '\x98';
|
||||
C1.SGCI = '\x99';
|
||||
C1.SCI = '\x9a';
|
||||
C1.CSI = '\x9b';
|
||||
C1.ST = '\x9c';
|
||||
C1.OSC = '\x9d';
|
||||
C1.PM = '\x9e';
|
||||
C1.APC = '\x9f';
|
||||
})(C1 = exports.C1 || (exports.C1 = {}));
|
||||
//# sourceMappingURL=EscapeSequences.js.map
|
||||
81
ports/javascript/node_modules/xterm/lib/core/Types.d.ts
generated
vendored
Normal file
81
ports/javascript/node_modules/xterm/lib/core/Types.d.ts
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
import { IDisposable } from '../common/Types';
|
||||
export declare const enum KeyboardResultType {
|
||||
SEND_KEY = 0,
|
||||
SELECT_ALL = 1,
|
||||
PAGE_UP = 2,
|
||||
PAGE_DOWN = 3
|
||||
}
|
||||
export interface IKeyboardResult {
|
||||
type: KeyboardResultType;
|
||||
cancel: boolean;
|
||||
key: string | undefined;
|
||||
}
|
||||
export interface ICharset {
|
||||
[key: string]: string;
|
||||
}
|
||||
export declare type CharData = [number, string, number, number];
|
||||
export declare type IColorRGB = [number, number, number];
|
||||
export interface IAttributeData {
|
||||
fg: number;
|
||||
bg: number;
|
||||
clone(): IAttributeData;
|
||||
isInverse(): number;
|
||||
isBold(): number;
|
||||
isUnderline(): number;
|
||||
isBlink(): number;
|
||||
isInvisible(): number;
|
||||
isItalic(): number;
|
||||
isDim(): number;
|
||||
getFgColorMode(): number;
|
||||
getBgColorMode(): number;
|
||||
isFgRGB(): boolean;
|
||||
isBgRGB(): boolean;
|
||||
isFgPalette(): boolean;
|
||||
isBgPalette(): boolean;
|
||||
isFgDefault(): boolean;
|
||||
isBgDefault(): boolean;
|
||||
getFgColor(): number;
|
||||
getBgColor(): number;
|
||||
}
|
||||
export interface ICellData extends IAttributeData {
|
||||
content: number;
|
||||
combinedData: string;
|
||||
isCombined(): number;
|
||||
getWidth(): number;
|
||||
getChars(): string;
|
||||
getCode(): number;
|
||||
setFromCharData(value: CharData): void;
|
||||
getAsCharData(): CharData;
|
||||
}
|
||||
export interface IBufferLine {
|
||||
length: number;
|
||||
isWrapped: boolean;
|
||||
get(index: number): CharData;
|
||||
set(index: number, value: CharData): void;
|
||||
loadCell(index: number, cell: ICellData): ICellData;
|
||||
setCell(index: number, cell: ICellData): void;
|
||||
setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number): void;
|
||||
addCodepointToCell(index: number, codePoint: number): void;
|
||||
insertCells(pos: number, n: number, ch: ICellData): void;
|
||||
deleteCells(pos: number, n: number, fill: ICellData): void;
|
||||
replaceCells(start: number, end: number, fill: ICellData): void;
|
||||
resize(cols: number, fill: ICellData): void;
|
||||
fill(fillCellData: ICellData): void;
|
||||
copyFrom(line: IBufferLine): void;
|
||||
clone(): IBufferLine;
|
||||
getTrimmedLength(): number;
|
||||
translateToString(trimRight?: boolean, startCol?: number, endCol?: number): string;
|
||||
getWidth(index: number): number;
|
||||
hasWidth(index: number): number;
|
||||
getFg(index: number): number;
|
||||
getBg(index: number): number;
|
||||
hasContent(index: number): number;
|
||||
getCodePoint(index: number): number;
|
||||
isCombined(index: number): number;
|
||||
getString(index: number): string;
|
||||
}
|
||||
export interface IMarker extends IDisposable {
|
||||
readonly id: number;
|
||||
readonly isDisposed: boolean;
|
||||
readonly line: number;
|
||||
}
|
||||
3
ports/javascript/node_modules/xterm/lib/core/Types.js
generated
vendored
Normal file
3
ports/javascript/node_modules/xterm/lib/core/Types.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Types.js.map
|
||||
117
ports/javascript/node_modules/xterm/lib/core/buffer/BufferLine.d.ts
generated
vendored
Normal file
117
ports/javascript/node_modules/xterm/lib/core/buffer/BufferLine.d.ts
generated
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
import { CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from '../Types';
|
||||
export declare const DEFAULT_ATTR: number;
|
||||
export declare const CHAR_DATA_ATTR_INDEX = 0;
|
||||
export declare const CHAR_DATA_CHAR_INDEX = 1;
|
||||
export declare const CHAR_DATA_WIDTH_INDEX = 2;
|
||||
export declare const CHAR_DATA_CODE_INDEX = 3;
|
||||
export declare const NULL_CELL_CHAR = "";
|
||||
export declare const NULL_CELL_WIDTH = 1;
|
||||
export declare const NULL_CELL_CODE = 0;
|
||||
export declare const WHITESPACE_CELL_CHAR = " ";
|
||||
export declare const WHITESPACE_CELL_WIDTH = 1;
|
||||
export declare const WHITESPACE_CELL_CODE = 32;
|
||||
export declare const enum Content {
|
||||
CODEPOINT_MASK = 2097151,
|
||||
IS_COMBINED_MASK = 2097152,
|
||||
HAS_CONTENT_MASK = 4194303,
|
||||
WIDTH_MASK = 12582912,
|
||||
WIDTH_SHIFT = 22
|
||||
}
|
||||
export declare const enum Attributes {
|
||||
BLUE_MASK = 255,
|
||||
BLUE_SHIFT = 0,
|
||||
PCOLOR_MASK = 255,
|
||||
PCOLOR_SHIFT = 0,
|
||||
GREEN_MASK = 65280,
|
||||
GREEN_SHIFT = 8,
|
||||
RED_MASK = 16711680,
|
||||
RED_SHIFT = 16,
|
||||
CM_MASK = 50331648,
|
||||
CM_DEFAULT = 0,
|
||||
CM_P16 = 16777216,
|
||||
CM_P256 = 33554432,
|
||||
CM_RGB = 50331648,
|
||||
RGB_MASK = 16777215
|
||||
}
|
||||
export declare const enum FgFlags {
|
||||
INVERSE = 67108864,
|
||||
BOLD = 134217728,
|
||||
UNDERLINE = 268435456,
|
||||
BLINK = 536870912,
|
||||
INVISIBLE = 1073741824
|
||||
}
|
||||
export declare const enum BgFlags {
|
||||
ITALIC = 67108864,
|
||||
DIM = 134217728
|
||||
}
|
||||
export declare class AttributeData implements IAttributeData {
|
||||
static toColorRGB(value: number): IColorRGB;
|
||||
static fromColorRGB(value: IColorRGB): number;
|
||||
clone(): IAttributeData;
|
||||
fg: number;
|
||||
bg: number;
|
||||
isInverse(): number;
|
||||
isBold(): number;
|
||||
isUnderline(): number;
|
||||
isBlink(): number;
|
||||
isInvisible(): number;
|
||||
isItalic(): number;
|
||||
isDim(): number;
|
||||
getFgColorMode(): number;
|
||||
getBgColorMode(): number;
|
||||
isFgRGB(): boolean;
|
||||
isBgRGB(): boolean;
|
||||
isFgPalette(): boolean;
|
||||
isBgPalette(): boolean;
|
||||
isFgDefault(): boolean;
|
||||
isBgDefault(): boolean;
|
||||
getFgColor(): number;
|
||||
getBgColor(): number;
|
||||
}
|
||||
export declare const DEFAULT_ATTR_DATA: AttributeData;
|
||||
export declare class CellData extends AttributeData implements ICellData {
|
||||
static fromCharData(value: CharData): CellData;
|
||||
content: number;
|
||||
fg: number;
|
||||
bg: number;
|
||||
combinedData: string;
|
||||
isCombined(): number;
|
||||
getWidth(): number;
|
||||
getChars(): string;
|
||||
getCode(): number;
|
||||
setFromCharData(value: CharData): void;
|
||||
getAsCharData(): CharData;
|
||||
}
|
||||
export declare class BufferLine implements IBufferLine {
|
||||
isWrapped: boolean;
|
||||
protected _data: Uint32Array;
|
||||
protected _combined: {
|
||||
[index: number]: string;
|
||||
};
|
||||
length: number;
|
||||
constructor(cols: number, fillCellData?: ICellData, isWrapped?: boolean);
|
||||
get(index: number): CharData;
|
||||
set(index: number, value: CharData): void;
|
||||
getWidth(index: number): number;
|
||||
hasWidth(index: number): number;
|
||||
getFg(index: number): number;
|
||||
getBg(index: number): number;
|
||||
hasContent(index: number): number;
|
||||
getCodePoint(index: number): number;
|
||||
isCombined(index: number): number;
|
||||
getString(index: number): string;
|
||||
loadCell(index: number, cell: ICellData): ICellData;
|
||||
setCell(index: number, cell: ICellData): void;
|
||||
setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number): void;
|
||||
addCodepointToCell(index: number, codePoint: number): void;
|
||||
insertCells(pos: number, n: number, fillCellData: ICellData): void;
|
||||
deleteCells(pos: number, n: number, fillCellData: ICellData): void;
|
||||
replaceCells(start: number, end: number, fillCellData: ICellData): void;
|
||||
resize(cols: number, fillCellData: ICellData): void;
|
||||
fill(fillCellData: ICellData): void;
|
||||
copyFrom(line: BufferLine): void;
|
||||
clone(): IBufferLine;
|
||||
getTrimmedLength(): number;
|
||||
copyCellsFrom(src: BufferLine, srcCol: number, destCol: number, length: number, applyInReverse: boolean): void;
|
||||
translateToString(trimRight?: boolean, startCol?: number, endCol?: number): string;
|
||||
}
|
||||
427
ports/javascript/node_modules/xterm/lib/core/buffer/BufferLine.js
generated
vendored
Normal file
427
ports/javascript/node_modules/xterm/lib/core/buffer/BufferLine.js
generated
vendored
Normal file
@ -0,0 +1,427 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var TextDecoder_1 = require("../input/TextDecoder");
|
||||
var Types_1 = require("../../common/Types");
|
||||
exports.DEFAULT_ATTR = (0 << 18) | (Types_1.DEFAULT_COLOR << 9) | (256 << 0);
|
||||
exports.CHAR_DATA_ATTR_INDEX = 0;
|
||||
exports.CHAR_DATA_CHAR_INDEX = 1;
|
||||
exports.CHAR_DATA_WIDTH_INDEX = 2;
|
||||
exports.CHAR_DATA_CODE_INDEX = 3;
|
||||
exports.NULL_CELL_CHAR = '';
|
||||
exports.NULL_CELL_WIDTH = 1;
|
||||
exports.NULL_CELL_CODE = 0;
|
||||
exports.WHITESPACE_CELL_CHAR = ' ';
|
||||
exports.WHITESPACE_CELL_WIDTH = 1;
|
||||
exports.WHITESPACE_CELL_CODE = 32;
|
||||
var CELL_SIZE = 3;
|
||||
var AttributeData = (function () {
|
||||
function AttributeData() {
|
||||
this.fg = 0;
|
||||
this.bg = 0;
|
||||
}
|
||||
AttributeData.toColorRGB = function (value) {
|
||||
return [
|
||||
value >>> 16 & 255,
|
||||
value >>> 8 & 255,
|
||||
value & 255
|
||||
];
|
||||
};
|
||||
AttributeData.fromColorRGB = function (value) {
|
||||
return (value[0] & 255) << 16 | (value[1] & 255) << 8 | value[2] & 255;
|
||||
};
|
||||
AttributeData.prototype.clone = function () {
|
||||
var newObj = new AttributeData();
|
||||
newObj.fg = this.fg;
|
||||
newObj.bg = this.bg;
|
||||
return newObj;
|
||||
};
|
||||
AttributeData.prototype.isInverse = function () { return this.fg & 67108864; };
|
||||
AttributeData.prototype.isBold = function () { return this.fg & 134217728; };
|
||||
AttributeData.prototype.isUnderline = function () { return this.fg & 268435456; };
|
||||
AttributeData.prototype.isBlink = function () { return this.fg & 536870912; };
|
||||
AttributeData.prototype.isInvisible = function () { return this.fg & 1073741824; };
|
||||
AttributeData.prototype.isItalic = function () { return this.bg & 67108864; };
|
||||
AttributeData.prototype.isDim = function () { return this.bg & 134217728; };
|
||||
AttributeData.prototype.getFgColorMode = function () { return this.fg & 50331648; };
|
||||
AttributeData.prototype.getBgColorMode = function () { return this.bg & 50331648; };
|
||||
AttributeData.prototype.isFgRGB = function () { return (this.fg & 50331648) === 50331648; };
|
||||
AttributeData.prototype.isBgRGB = function () { return (this.bg & 50331648) === 50331648; };
|
||||
AttributeData.prototype.isFgPalette = function () { return (this.fg & 50331648) === 16777216 || (this.fg & 50331648) === 33554432; };
|
||||
AttributeData.prototype.isBgPalette = function () { return (this.bg & 50331648) === 16777216 || (this.bg & 50331648) === 33554432; };
|
||||
AttributeData.prototype.isFgDefault = function () { return (this.fg & 50331648) === 0; };
|
||||
AttributeData.prototype.isBgDefault = function () { return (this.bg & 50331648) === 0; };
|
||||
AttributeData.prototype.getFgColor = function () {
|
||||
switch (this.fg & 50331648) {
|
||||
case 16777216:
|
||||
case 33554432: return this.fg & 255;
|
||||
case 50331648: return this.fg & 16777215;
|
||||
default: return -1;
|
||||
}
|
||||
};
|
||||
AttributeData.prototype.getBgColor = function () {
|
||||
switch (this.bg & 50331648) {
|
||||
case 16777216:
|
||||
case 33554432: return this.bg & 255;
|
||||
case 50331648: return this.bg & 16777215;
|
||||
default: return -1;
|
||||
}
|
||||
};
|
||||
return AttributeData;
|
||||
}());
|
||||
exports.AttributeData = AttributeData;
|
||||
exports.DEFAULT_ATTR_DATA = new AttributeData();
|
||||
var CellData = (function (_super) {
|
||||
__extends(CellData, _super);
|
||||
function CellData() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.content = 0;
|
||||
_this.fg = 0;
|
||||
_this.bg = 0;
|
||||
_this.combinedData = '';
|
||||
return _this;
|
||||
}
|
||||
CellData.fromCharData = function (value) {
|
||||
var obj = new CellData();
|
||||
obj.setFromCharData(value);
|
||||
return obj;
|
||||
};
|
||||
CellData.prototype.isCombined = function () {
|
||||
return this.content & 2097152;
|
||||
};
|
||||
CellData.prototype.getWidth = function () {
|
||||
return this.content >> 22;
|
||||
};
|
||||
CellData.prototype.getChars = function () {
|
||||
if (this.content & 2097152) {
|
||||
return this.combinedData;
|
||||
}
|
||||
if (this.content & 2097151) {
|
||||
return TextDecoder_1.stringFromCodePoint(this.content & 2097151);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
CellData.prototype.getCode = function () {
|
||||
return (this.isCombined())
|
||||
? this.combinedData.charCodeAt(this.combinedData.length - 1)
|
||||
: this.content & 2097151;
|
||||
};
|
||||
CellData.prototype.setFromCharData = function (value) {
|
||||
this.fg = value[exports.CHAR_DATA_ATTR_INDEX];
|
||||
this.bg = 0;
|
||||
var combined = false;
|
||||
if (value[exports.CHAR_DATA_CHAR_INDEX].length > 2) {
|
||||
combined = true;
|
||||
}
|
||||
else if (value[exports.CHAR_DATA_CHAR_INDEX].length === 2) {
|
||||
var code = value[exports.CHAR_DATA_CHAR_INDEX].charCodeAt(0);
|
||||
if (0xD800 <= code && code <= 0xDBFF) {
|
||||
var second = value[exports.CHAR_DATA_CHAR_INDEX].charCodeAt(1);
|
||||
if (0xDC00 <= second && second <= 0xDFFF) {
|
||||
this.content = ((code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000) | (value[exports.CHAR_DATA_WIDTH_INDEX] << 22);
|
||||
}
|
||||
else {
|
||||
combined = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
combined = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.content = value[exports.CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[exports.CHAR_DATA_WIDTH_INDEX] << 22);
|
||||
}
|
||||
if (combined) {
|
||||
this.combinedData = value[exports.CHAR_DATA_CHAR_INDEX];
|
||||
this.content = 2097152 | (value[exports.CHAR_DATA_WIDTH_INDEX] << 22);
|
||||
}
|
||||
};
|
||||
CellData.prototype.getAsCharData = function () {
|
||||
return [this.fg, this.getChars(), this.getWidth(), this.getCode()];
|
||||
};
|
||||
return CellData;
|
||||
}(AttributeData));
|
||||
exports.CellData = CellData;
|
||||
var BufferLine = (function () {
|
||||
function BufferLine(cols, fillCellData, isWrapped) {
|
||||
if (isWrapped === void 0) { isWrapped = false; }
|
||||
this.isWrapped = isWrapped;
|
||||
this._combined = {};
|
||||
this._data = new Uint32Array(cols * CELL_SIZE);
|
||||
var cell = fillCellData || CellData.fromCharData([0, exports.NULL_CELL_CHAR, exports.NULL_CELL_WIDTH, exports.NULL_CELL_CODE]);
|
||||
for (var i = 0; i < cols; ++i) {
|
||||
this.setCell(i, cell);
|
||||
}
|
||||
this.length = cols;
|
||||
}
|
||||
BufferLine.prototype.get = function (index) {
|
||||
var content = this._data[index * CELL_SIZE + 0];
|
||||
var cp = content & 2097151;
|
||||
return [
|
||||
this._data[index * CELL_SIZE + 1],
|
||||
(content & 2097152)
|
||||
? this._combined[index]
|
||||
: (cp) ? TextDecoder_1.stringFromCodePoint(cp) : '',
|
||||
content >> 22,
|
||||
(content & 2097152)
|
||||
? this._combined[index].charCodeAt(this._combined[index].length - 1)
|
||||
: cp
|
||||
];
|
||||
};
|
||||
BufferLine.prototype.set = function (index, value) {
|
||||
this._data[index * CELL_SIZE + 1] = value[exports.CHAR_DATA_ATTR_INDEX];
|
||||
if (value[exports.CHAR_DATA_CHAR_INDEX].length > 1) {
|
||||
this._combined[index] = value[1];
|
||||
this._data[index * CELL_SIZE + 0] = index | 2097152 | (value[exports.CHAR_DATA_WIDTH_INDEX] << 22);
|
||||
}
|
||||
else {
|
||||
this._data[index * CELL_SIZE + 0] = value[exports.CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[exports.CHAR_DATA_WIDTH_INDEX] << 22);
|
||||
}
|
||||
};
|
||||
BufferLine.prototype.getWidth = function (index) {
|
||||
return this._data[index * CELL_SIZE + 0] >> 22;
|
||||
};
|
||||
BufferLine.prototype.hasWidth = function (index) {
|
||||
return this._data[index * CELL_SIZE + 0] & 12582912;
|
||||
};
|
||||
BufferLine.prototype.getFg = function (index) {
|
||||
return this._data[index * CELL_SIZE + 1];
|
||||
};
|
||||
BufferLine.prototype.getBg = function (index) {
|
||||
return this._data[index * CELL_SIZE + 2];
|
||||
};
|
||||
BufferLine.prototype.hasContent = function (index) {
|
||||
return this._data[index * CELL_SIZE + 0] & 4194303;
|
||||
};
|
||||
BufferLine.prototype.getCodePoint = function (index) {
|
||||
var content = this._data[index * CELL_SIZE + 0];
|
||||
if (content & 2097152) {
|
||||
return this._combined[index].charCodeAt(this._combined[index].length - 1);
|
||||
}
|
||||
return content & 2097151;
|
||||
};
|
||||
BufferLine.prototype.isCombined = function (index) {
|
||||
return this._data[index * CELL_SIZE + 0] & 2097152;
|
||||
};
|
||||
BufferLine.prototype.getString = function (index) {
|
||||
var content = this._data[index * CELL_SIZE + 0];
|
||||
if (content & 2097152) {
|
||||
return this._combined[index];
|
||||
}
|
||||
if (content & 2097151) {
|
||||
return TextDecoder_1.stringFromCodePoint(content & 2097151);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
BufferLine.prototype.loadCell = function (index, cell) {
|
||||
var startIndex = index * CELL_SIZE;
|
||||
cell.content = this._data[startIndex + 0];
|
||||
cell.fg = this._data[startIndex + 1];
|
||||
cell.bg = this._data[startIndex + 2];
|
||||
if (cell.content & 2097152) {
|
||||
cell.combinedData = this._combined[index];
|
||||
}
|
||||
return cell;
|
||||
};
|
||||
BufferLine.prototype.setCell = function (index, cell) {
|
||||
if (cell.content & 2097152) {
|
||||
this._combined[index] = cell.combinedData;
|
||||
}
|
||||
this._data[index * CELL_SIZE + 0] = cell.content;
|
||||
this._data[index * CELL_SIZE + 1] = cell.fg;
|
||||
this._data[index * CELL_SIZE + 2] = cell.bg;
|
||||
};
|
||||
BufferLine.prototype.setCellFromCodePoint = function (index, codePoint, width, fg, bg) {
|
||||
this._data[index * CELL_SIZE + 0] = codePoint | (width << 22);
|
||||
this._data[index * CELL_SIZE + 1] = fg;
|
||||
this._data[index * CELL_SIZE + 2] = bg;
|
||||
};
|
||||
BufferLine.prototype.addCodepointToCell = function (index, codePoint) {
|
||||
var content = this._data[index * CELL_SIZE + 0];
|
||||
if (content & 2097152) {
|
||||
this._combined[index] += TextDecoder_1.stringFromCodePoint(codePoint);
|
||||
}
|
||||
else {
|
||||
if (content & 2097151) {
|
||||
this._combined[index] = TextDecoder_1.stringFromCodePoint(content & 2097151) + TextDecoder_1.stringFromCodePoint(codePoint);
|
||||
content &= ~2097151;
|
||||
content |= 2097152;
|
||||
}
|
||||
else {
|
||||
content = codePoint | (1 << 22);
|
||||
}
|
||||
this._data[index * CELL_SIZE + 0] = content;
|
||||
}
|
||||
};
|
||||
BufferLine.prototype.insertCells = function (pos, n, fillCellData) {
|
||||
pos %= this.length;
|
||||
if (n < this.length - pos) {
|
||||
var cell = new CellData();
|
||||
for (var i = this.length - pos - n - 1; i >= 0; --i) {
|
||||
this.setCell(pos + n + i, this.loadCell(pos + i, cell));
|
||||
}
|
||||
for (var i = 0; i < n; ++i) {
|
||||
this.setCell(pos + i, fillCellData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = pos; i < this.length; ++i) {
|
||||
this.setCell(i, fillCellData);
|
||||
}
|
||||
}
|
||||
};
|
||||
BufferLine.prototype.deleteCells = function (pos, n, fillCellData) {
|
||||
pos %= this.length;
|
||||
if (n < this.length - pos) {
|
||||
var cell = new CellData();
|
||||
for (var i = 0; i < this.length - pos - n; ++i) {
|
||||
this.setCell(pos + i, this.loadCell(pos + n + i, cell));
|
||||
}
|
||||
for (var i = this.length - n; i < this.length; ++i) {
|
||||
this.setCell(i, fillCellData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = pos; i < this.length; ++i) {
|
||||
this.setCell(i, fillCellData);
|
||||
}
|
||||
}
|
||||
};
|
||||
BufferLine.prototype.replaceCells = function (start, end, fillCellData) {
|
||||
while (start < end && start < this.length) {
|
||||
this.setCell(start++, fillCellData);
|
||||
}
|
||||
};
|
||||
BufferLine.prototype.resize = function (cols, fillCellData) {
|
||||
if (cols === this.length) {
|
||||
return;
|
||||
}
|
||||
if (cols > this.length) {
|
||||
var data = new Uint32Array(cols * CELL_SIZE);
|
||||
if (this.length) {
|
||||
if (cols * CELL_SIZE < this._data.length) {
|
||||
data.set(this._data.subarray(0, cols * CELL_SIZE));
|
||||
}
|
||||
else {
|
||||
data.set(this._data);
|
||||
}
|
||||
}
|
||||
this._data = data;
|
||||
for (var i = this.length; i < cols; ++i) {
|
||||
this.setCell(i, fillCellData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (cols) {
|
||||
var data = new Uint32Array(cols * CELL_SIZE);
|
||||
data.set(this._data.subarray(0, cols * CELL_SIZE));
|
||||
this._data = data;
|
||||
var keys = Object.keys(this._combined);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = parseInt(keys[i], 10);
|
||||
if (key >= cols) {
|
||||
delete this._combined[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._data = new Uint32Array(0);
|
||||
this._combined = {};
|
||||
}
|
||||
}
|
||||
this.length = cols;
|
||||
};
|
||||
BufferLine.prototype.fill = function (fillCellData) {
|
||||
this._combined = {};
|
||||
for (var i = 0; i < this.length; ++i) {
|
||||
this.setCell(i, fillCellData);
|
||||
}
|
||||
};
|
||||
BufferLine.prototype.copyFrom = function (line) {
|
||||
if (this.length !== line.length) {
|
||||
this._data = new Uint32Array(line._data);
|
||||
}
|
||||
else {
|
||||
this._data.set(line._data);
|
||||
}
|
||||
this.length = line.length;
|
||||
this._combined = {};
|
||||
for (var el in line._combined) {
|
||||
this._combined[el] = line._combined[el];
|
||||
}
|
||||
this.isWrapped = line.isWrapped;
|
||||
};
|
||||
BufferLine.prototype.clone = function () {
|
||||
var newLine = new BufferLine(0);
|
||||
newLine._data = new Uint32Array(this._data);
|
||||
newLine.length = this.length;
|
||||
for (var el in this._combined) {
|
||||
newLine._combined[el] = this._combined[el];
|
||||
}
|
||||
newLine.isWrapped = this.isWrapped;
|
||||
return newLine;
|
||||
};
|
||||
BufferLine.prototype.getTrimmedLength = function () {
|
||||
for (var i = this.length - 1; i >= 0; --i) {
|
||||
if ((this._data[i * CELL_SIZE + 0] & 4194303)) {
|
||||
return i + (this._data[i * CELL_SIZE + 0] >> 22);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
BufferLine.prototype.copyCellsFrom = function (src, srcCol, destCol, length, applyInReverse) {
|
||||
var srcData = src._data;
|
||||
if (applyInReverse) {
|
||||
for (var cell = length - 1; cell >= 0; cell--) {
|
||||
for (var i = 0; i < CELL_SIZE; i++) {
|
||||
this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var cell = 0; cell < length; cell++) {
|
||||
for (var i = 0; i < CELL_SIZE; i++) {
|
||||
this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
var srcCombinedKeys = Object.keys(src._combined);
|
||||
for (var i = 0; i < srcCombinedKeys.length; i++) {
|
||||
var key = parseInt(srcCombinedKeys[i], 10);
|
||||
if (key >= srcCol) {
|
||||
this._combined[key - srcCol + destCol] = src._combined[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
BufferLine.prototype.translateToString = function (trimRight, startCol, endCol) {
|
||||
if (trimRight === void 0) { trimRight = false; }
|
||||
if (startCol === void 0) { startCol = 0; }
|
||||
if (endCol === void 0) { endCol = this.length; }
|
||||
if (trimRight) {
|
||||
endCol = Math.min(endCol, this.getTrimmedLength());
|
||||
}
|
||||
var result = '';
|
||||
while (startCol < endCol) {
|
||||
var content = this._data[startCol * CELL_SIZE + 0];
|
||||
var cp = content & 2097151;
|
||||
result += (content & 2097152) ? this._combined[startCol] : (cp) ? TextDecoder_1.stringFromCodePoint(cp) : exports.WHITESPACE_CELL_CHAR;
|
||||
startCol += (content >> 22) || 1;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
return BufferLine;
|
||||
}());
|
||||
exports.BufferLine = BufferLine;
|
||||
//# sourceMappingURL=BufferLine.js.map
|
||||
12
ports/javascript/node_modules/xterm/lib/core/buffer/BufferReflow.d.ts
generated
vendored
Normal file
12
ports/javascript/node_modules/xterm/lib/core/buffer/BufferReflow.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import { BufferLine } from './BufferLine';
|
||||
import { CircularList } from '../../common/CircularList';
|
||||
import { IBufferLine, ICellData } from '../Types';
|
||||
export interface INewLayoutResult {
|
||||
layout: number[];
|
||||
countRemoved: number;
|
||||
}
|
||||
export declare function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData): number[];
|
||||
export declare function reflowLargerCreateNewLayout(lines: CircularList<IBufferLine>, toRemove: number[]): INewLayoutResult;
|
||||
export declare function reflowLargerApplyNewLayout(lines: CircularList<IBufferLine>, newLayout: number[]): void;
|
||||
export declare function reflowSmallerGetNewLineLengths(wrappedLines: BufferLine[], oldCols: number, newCols: number): number[];
|
||||
export declare function getWrappedLineTrimmedLength(lines: BufferLine[], i: number, cols: number): number;
|
||||
143
ports/javascript/node_modules/xterm/lib/core/buffer/BufferReflow.js
generated
vendored
Normal file
143
ports/javascript/node_modules/xterm/lib/core/buffer/BufferReflow.js
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function reflowLargerGetLinesToRemove(lines, oldCols, newCols, bufferAbsoluteY, nullCell) {
|
||||
var toRemove = [];
|
||||
for (var y = 0; y < lines.length - 1; y++) {
|
||||
var i = y;
|
||||
var nextLine = lines.get(++i);
|
||||
if (!nextLine.isWrapped) {
|
||||
continue;
|
||||
}
|
||||
var wrappedLines = [lines.get(y)];
|
||||
while (i < lines.length && nextLine.isWrapped) {
|
||||
wrappedLines.push(nextLine);
|
||||
nextLine = lines.get(++i);
|
||||
}
|
||||
if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
|
||||
y += wrappedLines.length - 1;
|
||||
continue;
|
||||
}
|
||||
var destLineIndex = 0;
|
||||
var destCol = getWrappedLineTrimmedLength(wrappedLines, destLineIndex, oldCols);
|
||||
var srcLineIndex = 1;
|
||||
var srcCol = 0;
|
||||
while (srcLineIndex < wrappedLines.length) {
|
||||
var srcTrimmedTineLength = getWrappedLineTrimmedLength(wrappedLines, srcLineIndex, oldCols);
|
||||
var srcRemainingCells = srcTrimmedTineLength - srcCol;
|
||||
var destRemainingCells = newCols - destCol;
|
||||
var cellsToCopy = Math.min(srcRemainingCells, destRemainingCells);
|
||||
wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol, destCol, cellsToCopy, false);
|
||||
destCol += cellsToCopy;
|
||||
if (destCol === newCols) {
|
||||
destLineIndex++;
|
||||
destCol = 0;
|
||||
}
|
||||
srcCol += cellsToCopy;
|
||||
if (srcCol === srcTrimmedTineLength) {
|
||||
srcLineIndex++;
|
||||
srcCol = 0;
|
||||
}
|
||||
if (destCol === 0 && destLineIndex !== 0) {
|
||||
if (wrappedLines[destLineIndex - 1].getWidth(newCols - 1) === 2) {
|
||||
wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[destLineIndex - 1], newCols - 1, destCol++, 1, false);
|
||||
wrappedLines[destLineIndex - 1].setCell(newCols - 1, nullCell);
|
||||
}
|
||||
}
|
||||
}
|
||||
wrappedLines[destLineIndex].replaceCells(destCol, newCols, nullCell);
|
||||
var countToRemove = 0;
|
||||
for (var i_1 = wrappedLines.length - 1; i_1 > 0; i_1--) {
|
||||
if (i_1 > destLineIndex || wrappedLines[i_1].getTrimmedLength() === 0) {
|
||||
countToRemove++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (countToRemove > 0) {
|
||||
toRemove.push(y + wrappedLines.length - countToRemove);
|
||||
toRemove.push(countToRemove);
|
||||
}
|
||||
y += wrappedLines.length - 1;
|
||||
}
|
||||
return toRemove;
|
||||
}
|
||||
exports.reflowLargerGetLinesToRemove = reflowLargerGetLinesToRemove;
|
||||
function reflowLargerCreateNewLayout(lines, toRemove) {
|
||||
var layout = [];
|
||||
var nextToRemoveIndex = 0;
|
||||
var nextToRemoveStart = toRemove[nextToRemoveIndex];
|
||||
var countRemovedSoFar = 0;
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (nextToRemoveStart === i) {
|
||||
var countToRemove = toRemove[++nextToRemoveIndex];
|
||||
lines.onDeleteEmitter.fire({
|
||||
index: i - countRemovedSoFar,
|
||||
amount: countToRemove
|
||||
});
|
||||
i += countToRemove - 1;
|
||||
countRemovedSoFar += countToRemove;
|
||||
nextToRemoveStart = toRemove[++nextToRemoveIndex];
|
||||
}
|
||||
else {
|
||||
layout.push(i);
|
||||
}
|
||||
}
|
||||
return {
|
||||
layout: layout,
|
||||
countRemoved: countRemovedSoFar
|
||||
};
|
||||
}
|
||||
exports.reflowLargerCreateNewLayout = reflowLargerCreateNewLayout;
|
||||
function reflowLargerApplyNewLayout(lines, newLayout) {
|
||||
var newLayoutLines = [];
|
||||
for (var i = 0; i < newLayout.length; i++) {
|
||||
newLayoutLines.push(lines.get(newLayout[i]));
|
||||
}
|
||||
for (var i = 0; i < newLayoutLines.length; i++) {
|
||||
lines.set(i, newLayoutLines[i]);
|
||||
}
|
||||
lines.length = newLayout.length;
|
||||
}
|
||||
exports.reflowLargerApplyNewLayout = reflowLargerApplyNewLayout;
|
||||
function reflowSmallerGetNewLineLengths(wrappedLines, oldCols, newCols) {
|
||||
var newLineLengths = [];
|
||||
var cellsNeeded = wrappedLines.map(function (l, i) { return getWrappedLineTrimmedLength(wrappedLines, i, oldCols); }).reduce(function (p, c) { return p + c; });
|
||||
var srcCol = 0;
|
||||
var srcLine = 0;
|
||||
var cellsAvailable = 0;
|
||||
while (cellsAvailable < cellsNeeded) {
|
||||
if (cellsNeeded - cellsAvailable < newCols) {
|
||||
newLineLengths.push(cellsNeeded - cellsAvailable);
|
||||
break;
|
||||
}
|
||||
srcCol += newCols;
|
||||
var oldTrimmedLength = getWrappedLineTrimmedLength(wrappedLines, srcLine, oldCols);
|
||||
if (srcCol > oldTrimmedLength) {
|
||||
srcCol -= oldTrimmedLength;
|
||||
srcLine++;
|
||||
}
|
||||
var endsWithWide = wrappedLines[srcLine].getWidth(srcCol - 1) === 2;
|
||||
if (endsWithWide) {
|
||||
srcCol--;
|
||||
}
|
||||
var lineLength = endsWithWide ? newCols - 1 : newCols;
|
||||
newLineLengths.push(lineLength);
|
||||
cellsAvailable += lineLength;
|
||||
}
|
||||
return newLineLengths;
|
||||
}
|
||||
exports.reflowSmallerGetNewLineLengths = reflowSmallerGetNewLineLengths;
|
||||
function getWrappedLineTrimmedLength(lines, i, cols) {
|
||||
if (i === lines.length - 1) {
|
||||
return lines[i].getTrimmedLength();
|
||||
}
|
||||
var endsInNull = !(lines[i].hasContent(cols - 1)) && lines[i].getWidth(cols - 1) === 1;
|
||||
var followingLineStartsWithWide = lines[i + 1].getWidth(0) === 2;
|
||||
if (endsInNull && followingLineStartsWithWide) {
|
||||
return cols - 1;
|
||||
}
|
||||
return cols;
|
||||
}
|
||||
exports.getWrappedLineTrimmedLength = getWrappedLineTrimmedLength;
|
||||
//# sourceMappingURL=BufferReflow.js.map
|
||||
14
ports/javascript/node_modules/xterm/lib/core/buffer/Marker.d.ts
generated
vendored
Normal file
14
ports/javascript/node_modules/xterm/lib/core/buffer/Marker.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { IEvent } from '../../common/EventEmitter2';
|
||||
import { Disposable } from '../../common/Lifecycle';
|
||||
import { IMarker } from '../Types';
|
||||
export declare class Marker extends Disposable implements IMarker {
|
||||
line: number;
|
||||
private static _nextId;
|
||||
private _id;
|
||||
isDisposed: boolean;
|
||||
readonly id: number;
|
||||
private _onDispose;
|
||||
readonly onDispose: IEvent<void>;
|
||||
constructor(line: number);
|
||||
dispose(): void;
|
||||
}
|
||||
49
ports/javascript/node_modules/xterm/lib/core/buffer/Marker.js
generated
vendored
Normal file
49
ports/javascript/node_modules/xterm/lib/core/buffer/Marker.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var EventEmitter2_1 = require("../../common/EventEmitter2");
|
||||
var Lifecycle_1 = require("../../common/Lifecycle");
|
||||
var Marker = (function (_super) {
|
||||
__extends(Marker, _super);
|
||||
function Marker(line) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.line = line;
|
||||
_this._id = Marker._nextId++;
|
||||
_this.isDisposed = false;
|
||||
_this._onDispose = new EventEmitter2_1.EventEmitter2();
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Marker.prototype, "id", {
|
||||
get: function () { return this._id; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Marker.prototype, "onDispose", {
|
||||
get: function () { return this._onDispose.event; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Marker.prototype.dispose = function () {
|
||||
if (this.isDisposed) {
|
||||
return;
|
||||
}
|
||||
this.isDisposed = true;
|
||||
this._onDispose.fire();
|
||||
};
|
||||
Marker._nextId = 1;
|
||||
return Marker;
|
||||
}(Lifecycle_1.Disposable));
|
||||
exports.Marker = Marker;
|
||||
//# sourceMappingURL=Marker.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user