diff --git a/meerschaum/api/__init__.py b/meerschaum/api/__init__.py
index 932b08d9..bf4278da 100644
--- a/meerschaum/api/__init__.py
+++ b/meerschaum/api/__init__.py
@@ -11,6 +11,9 @@
from meerschaum import __version__ as version
__version__ = version
+__doc__ = """
+The Meerschaum Web API lets you access and control your data over the Internet.
+"""
from meerschaum.config import get_config
from meerschaum.config.static import _static_config
@@ -113,7 +116,41 @@ def get_pipe(connector_keys, metric_key, location_key, refresh=False):
return pipes(refresh=refresh)[connector_keys][metric_key][location_key]
return p
-app = fastapi.FastAPI(title='Meerschaum API')
+app = fastapi.FastAPI(
+ title = 'Meerschaum API',
+ description = __doc__,
+ version = __version__,
+ contact = {
+ 'name': 'Bennett Meares',
+ 'url': 'https://meerschaum.io',
+ },
+ license_info = {
+ 'name': 'Apache 2.0',
+ 'url': 'https://www.apache.org/licenses/LICENSE-2.0.html',
+ },
+ open_api_tags = [{
+ 'name': 'Pipes',
+ 'description': 'Access pipes by indexing their keys.',
+ }, {
+ 'name': 'Actions',
+ 'description': 'Perform actions via the API.',
+ }, {
+ 'name': 'Connectors',
+ 'description': 'Get information about the registered connectors.'
+ }, {
+ 'name': 'Users',
+ 'description': 'Access, register, and delete users.',
+ }, {
+ 'name': 'Plugins',
+ 'description': 'Access, register, and delete plugins.',
+ }, {
+ 'name': 'Misc',
+ 'description': 'Miscellaneous endpoints.',
+ }, {
+ 'name': 'Version',
+ 'description': 'Version information.'
+ }],
+)
(
fastapi_responses,
diff --git a/meerschaum/api/dash/components.py b/meerschaum/api/dash/components.py
index 2b36e842..dc485160 100644
--- a/meerschaum/api/dash/components.py
+++ b/meerschaum/api/dash/components.py
@@ -96,8 +96,10 @@ def build_cards_grid(cards: List[dbc.Card], num_columns: int = 3) -> html.Div:
if i % num_columns == 0:
rows_childrens.append([])
rows_childrens[-1].append(dbc.Col(card))
- for i in range((len(cards) + 1) % num_columns):
- rows_childrens[-1].append(dbc.Col())
+ ### Append mising columns to keep the grid shape.
+ if rows_childrens and len(rows_childrens[-1]) != num_columns:
+ for i in range(num_columns - len(rows_childrens[-1])):
+ rows_childrens[-1].append(dbc.Col())
_rows = [dbc.Row(children) for children in rows_childrens]
rows = []
for r in _rows:
diff --git a/meerschaum/api/resources/static/js/node_modules/.package-lock.json b/meerschaum/api/resources/static/js/node_modules/.package-lock.json
deleted file mode 100644
index 53a56cdc..00000000
--- a/meerschaum/api/resources/static/js/node_modules/.package-lock.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "js",
- "version": "1.0.0",
- "lockfileVersion": 2,
- "requires": true,
- "packages": {
- "node_modules/xterm": {
- "version": "4.14.1",
- "resolved": "https://registry.npmjs.org/xterm/-/xterm-4.14.1.tgz",
- "integrity": "sha512-jgzNg5BuGPwq5/M4dGnmbghZvHx2jaj+9crSEt15bV34Za49VziBmCu7zIy88zUKKiGTxeo7aVzirFSJArIMFw=="
- }
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/.eslintrc.json b/meerschaum/api/resources/static/js/node_modules/xterm/.eslintrc.json
deleted file mode 100644
index 427c7a16..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/.eslintrc.json
+++ /dev/null
@@ -1,178 +0,0 @@
-{
- "env": {
- "browser": true,
- "es6": true,
- "node": true
- },
- "parser": "@typescript-eslint/parser",
- "parserOptions": {
- "project": [
- "src/browser/tsconfig.json",
- "src/common/tsconfig.json",
- "src/headless/tsconfig.json",
- "test/api/tsconfig.json",
- "test/benchmark/tsconfig.json",
- "addons/xterm-addon-attach/src/tsconfig.json",
- "addons/xterm-addon-attach/test/tsconfig.json",
- "addons/xterm-addon-fit/src/tsconfig.json",
- "addons/xterm-addon-fit/test/tsconfig.json",
- "addons/xterm-addon-ligatures/src/tsconfig.json",
- "addons/xterm-addon-search/src/tsconfig.json",
- "addons/xterm-addon-search/test/tsconfig.json",
- "addons/xterm-addon-serialize/src/tsconfig.json",
- "addons/xterm-addon-serialize/test/tsconfig.json",
- "addons/xterm-addon-serialize/benchmark/tsconfig.json",
- "addons/xterm-addon-unicode11/src/tsconfig.json",
- "addons/xterm-addon-unicode11/test/tsconfig.json",
- "addons/xterm-addon-web-links/src/tsconfig.json",
- "addons/xterm-addon-web-links/test/tsconfig.json",
- "addons/xterm-addon-webgl/src/tsconfig.json",
- "addons/xterm-addon-webgl/test/tsconfig.json"
- ],
- "sourceType": "module"
- },
- "ignorePatterns": [
- "**/typings/*.d.ts",
- "**/node_modules",
- "**/*.js"
- ],
- "plugins": [
- "@typescript-eslint"
- ],
- "rules": {
- "no-extra-semi": "error",
- "@typescript-eslint/array-type": [
- "warn",
- {
- "default": "array",
- "readonly": "generic"
- }
- ],
- "@typescript-eslint/consistent-type-assertions": "warn",
- "@typescript-eslint/consistent-type-definitions": "warn",
- "@typescript-eslint/explicit-function-return-type": [
- "warn",
- {
- "allowExpressions": true
- }
- ],
- "@typescript-eslint/explicit-member-accessibility": [
- "warn",
- {
- "accessibility": "explicit",
- "overrides": {
- "constructors": "off"
- }
- }
- ],
- "@typescript-eslint/indent": [
- "warn",
- 2
- ],
- "@typescript-eslint/member-delimiter-style": [
- "warn",
- {
- "multiline": {
- "delimiter": "semi",
- "requireLast": true
- },
- "singleline": {
- "delimiter": "comma",
- "requireLast": false
- }
- }
- ],
- "@typescript-eslint/naming-convention": [
- "warn",
- { "selector": "default", "format": ["camelCase"] },
- // variableLike
- { "selector": "variable", "format": ["camelCase", "UPPER_CASE"] },
- { "selector": "variable", "filter": "^I.+Service$", "format": ["PascalCase"], "prefix": ["I"] },
- // memberLike
- { "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" },
- { "selector": "memberLike", "modifiers": ["protected"], "format": ["camelCase"], "leadingUnderscore": "require" },
- { "selector": "enumMember", "format": ["UPPER_CASE"] },
- // memberLike - Allow enum-like objects to use UPPER_CASE
- { "selector": "property", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"] },
- { "selector": "method", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"] },
- // typeLike
- { "selector": "typeLike", "format": ["PascalCase"] },
- { "selector": "interface", "format": ["PascalCase"], "prefix": ["I"] }
- ],
- "@typescript-eslint/prefer-namespace-keyword": "warn",
- "@typescript-eslint/type-annotation-spacing": "warn",
- "@typescript-eslint/quotes": [
- "warn",
- "single",
- { "allowTemplateLiterals": true }
- ],
- "@typescript-eslint/semi": [
- "warn",
- "always"
- ],
- "comma-dangle": [
- "warn",
- {
- "objects": "never",
- "arrays": "never",
- "functions": "never"
- }
- ],
- "curly": [
- "warn",
- "multi-line"
- ],
- "eol-last": "warn",
- "eqeqeq": [
- "warn",
- "always"
- ],
- "keyword-spacing": "warn",
- "new-parens": "warn",
- "no-duplicate-imports": "warn",
- "no-else-return": [
- "warn",
- {
- "allowElseIf": false
- }
- ],
- "no-eval": "warn",
- "no-irregular-whitespace": "warn",
- "no-restricted-imports": [
- "warn",
- {
- "patterns": [
- ".*\\/out\\/.*"
- ]
- }
- ],
- "no-trailing-spaces": "warn",
- "no-unsafe-finally": "warn",
- "no-var": "warn",
- "one-var": [
- "warn",
- "never"
- ],
- "object-curly-spacing": [
- "warn",
- "always"
- ],
- "prefer-const": "warn",
- "spaced-comment": [
- "warn",
- "always",
- {
- "markers": ["/"],
- "exceptions": ["-"]
- }
- ]
- },
- "overrides": [
- {
- "files": ["**/*.test.ts"],
- "rules": {
- "object-curly-spacing": "off"
- }
- }
- ]
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/LICENSE b/meerschaum/api/resources/static/js/node_modules/xterm/LICENSE
deleted file mode 100644
index 4472336c..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-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.
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/README.md b/meerschaum/api/resources/static/js/node_modules/xterm/README.md
deleted file mode 100644
index 720e703c..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/README.md
+++ /dev/null
@@ -1,216 +0,0 @@
-# [](https://xtermjs.org)
-
-[](https://dev.azure.com/xtermjs/xterm.js/_build/latest?definitionId=3)
-
-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`, including support for curses-based apps and mouse events.
-- **Performant**: 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 and minimum contrast ratio support can be turned on.
-- **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:
-
-```bash
-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 `
` 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
-
-
-
-
-
-
-
-
-
-
-
-```
-
-### Importing
-
-The recommended way to load xterm.js is via the ES6 module syntax:
-
-```javascript
-import { Terminal } from 'xterm';
-```
-
-### Addons
-
-⚠️ *This section describes the new addon format introduced in v3.14.0, see [here](https://github.com/xtermjs/xterm.js/blob/3.14.2/README.md#addons) for the instructions on the old format*
-
-Addons are separate modules that extend the `Terminal` by building on the [xterm.js API](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts). To use an addon, you first need to install it in your project:
-
-```bash
-npm i -S xterm-addon-web-links
-```
-
-Then import the addon, instantiate it and call `Terminal.loadAddon`:
-
-```ts
-import { Terminal } from 'xterm';
-import { WebLinksAddon } from 'xterm-addon-web-links';
-
-const terminal = new Terminal();
-// Load WebLinksAddon on terminal, this is all that's needed to get web links
-// working in the terminal.
-terminal.loadAddon(new WebLinksAddon());
-```
-
-The xterm.js team maintains the following addons, but anyone can build them:
-
-- [`xterm-addon-attach`](https://github.com/xtermjs/xterm.js/tree/master/addons/xterm-addon-attach): Attaches to a server running a process via a websocket
-- [`xterm-addon-fit`](https://github.com/xtermjs/xterm.js/tree/master/addons/xterm-addon-fit): Fits the terminal to the containing element
-- [`xterm-addon-search`](https://github.com/xtermjs/xterm.js/tree/master/addons/xterm-addon-search): Adds search functionality
-- [`xterm-addon-web-links`](https://github.com/xtermjs/xterm.js/tree/master/addons/xterm-addon-web-links): Adds web link detection and interaction
-
-## Browser Support
-
-Since xterm.js is typically implemented as a developer tool, only modern browsers are supported officially. Specifically the latest versions of *Chrome*, *Edge*, *Firefox*, and *Safari*.
-
-We also partially support *Internet Explorer 11*, meaning xterm.js should work for the most part, but we reserve the right to not provide workarounds specifically for it unless it's absolutely necessary to get the basic input/output flow working.
-
-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.
-
-### Node.js Support
-
-We also publish [`xterm-headless`](https://www.npmjs.com/package/xterm-headless) which is a stripped down version of xterm.js that runs in Node.js. An example use case for this is to keep track of a terminal's state where the process is running and using the serialize addon so it can get all state restored upon reconnection.
-
-## 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.
-- [**Next Tech**](https://next.tech "Next Tech"): 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 scalable 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.
-- [**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.
-- [**NgTerminal**](https://github.com/qwefgh90/ng-terminal): NgTerminal is a web terminal that leverages xterm.js on Angular 7+. You can easily add it into your application by adding `
` into your component.
-- [**tty-share**](https://tty-share.com): Extremely simple terminal sharing over the Internet.
-- [**Ten Hands**](https://github.com/saisandeepvaddi/ten-hands): One place to run your command-line tasks.
-- [**WebAssembly.sh**](https://webassembly.sh): A WebAssembly WASI browser terminal
-- [**Gus**](https://gus.jp): A shared coding pad where you can run Python with xterm.js
-- [**Linode**](https://linode.com): Linode uses xterm.js to provide users a web console for their Linode instances.
-- [**FluffOS**](https://www.fluffos.info): Active maintained LPMUD driver with websocket support.
-- [**x-terminal**](https://atom.io/packages/x-terminal): Atom plugin for providing terminals inside your Atom workspace.
-- [**CoCalc**](https://cocalc.com/): Lots of free software pre-installed, to chat, collaborate, develop, program, publish, research, share, teach, in C++, HTML, Julia, Jupyter, LaTeX, Markdown, Python, R, SageMath, Scala, ...
-- [**Dank Domain**](https://www.DDgame.us/): Open source multiuser medieval game supporting old & new terminal emulation.
-- [**DockerStacks**](https://docker-stacks.com/): Local LAMP/LEMP development studio
-- [**Codecademy**](https://codecademy.com/): Uses xterm.js in its courses on Bash.
-- [**Laravel Ssh Web Client**](https://github.com/roke22/Laravel-ssh-client): Laravel server inventory with ssh web client to connect at server using xterm.js
-- [**Repl.it**](https://repl.it): Collaborative browser based IDE with support for 50+ different languages.
-- [**TeleType**](https://github.com/akshaykmr/TeleType): cli tool that allows you to share your terminal online conveniently. Show off mad cli-fu, help a colleague, teach, or troubleshoot.
-- [**Intervue**](https://www.intervue.io): Pair programming for interviews. Multiple programming languages are supported, with results displayed by xterm.js.
-- [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP, and Database services.
-- [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner.
-- [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes.
-- [**NxShell**](https://github.com/nxshell/nxshell): An easy to use new terminal for SSH.
-- [**gifcast**](https://dstein64.github.io/gifcast/): Converts an asciinema cast to an animated GIF.
-- [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js.
-- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease.
-- [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech).
-- [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone.
-- [**HashiCorp Nomad**](https://www.nomadproject.io/): A container orchestrator with the ability to connect to remote tasks via a web interface using websockets and xterm.js.
-- [**TermPair**](https://github.com/cs01/termpair): View and control terminals from your browser with end-to-end encryption
-- [**gdbgui**](https://github.com/cs01/gdbgui): Browser-based frontend to gdb (gnu debugger)
-- [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 on 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:
-
-```bash
-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 to verify 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 set up xterm.js for development.
-
-## License Agreement
-
-If you contribute code to this project, you implicitly allow 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)
-Copyright (c) 2014-2017, SourceLair, Private Company ([www.sourcelair.com](https://www.sourcelair.com/home)) (MIT License)
-Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/css/xterm.css b/meerschaum/api/resources/static/js/node_modules/xterm/css/xterm.css
deleted file mode 100644
index 3fab18bd..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/css/xterm.css
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * 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 {
- 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: 5;
-}
-
-.xterm .xterm-helper-textarea {
- padding: 0;
- border: 0;
- margin: 0;
- /* 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: -5;
- /** 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: 10;
- 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;
-}
-
-.xterm-strikethrough {
- text-decoration: line-through;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/headless/README.md b/meerschaum/api/resources/static/js/node_modules/xterm/headless/README.md
deleted file mode 100644
index 1d2d6156..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/headless/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# [](https://xtermjs.org)
-
-⚠ This package is experimental
-
-`xterm-headless` is a headless terminal that can be run in node.js. This is useful in combination with the frontend [`xterm`](https://www.npmjs.com/package/xterm) for example to keep track of a terminal's state on a remote server where the process is hosted.
-
-## Getting Started
-
-First, you need to install the module, we ship exclusively through npm, so you need that installed and then add xterm.js as a dependency by running:
-
-```sh
-npm install xterm-headless
-```
-
-Then import as you would a regular node package. The recommended way to load `xterm-headless` is with TypeScript and the ES6 module syntax:
-
-```javascript
-import { Terminal } from 'xterm-headless';
-```
-
-## API
-
-The full API for `xterm-headless` is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm-headless.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.
-
-### Addons
-
-Addons in `xterm-headless` work the [same as in `xterm`](https://github.com/xtermjs/xterm.js/blob/master/README.md#addons) with the one caveat being that the addon needs to be packaged for node.js and not use any DOM APIs.
-
-Currently no official addons are packaged on npm.
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/headless/lib-headless/xterm-headless.js b/meerschaum/api/resources/static/js/node_modules/xterm/headless/lib-headless/xterm-headless.js
deleted file mode 100644
index 2cb636d5..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/headless/lib-headless/xterm-headless.js
+++ /dev/null
@@ -1,2 +0,0 @@
-(()=>{"use strict";var e={349:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;var i=r(460),n=function(){function e(e){this._maxLength=e,this.onDeleteEmitter=new i.EventEmitter,this.onInsertEmitter=new i.EventEmitter,this.onTrimEmitter=new i.EventEmitter,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}return Object.defineProperty(e.prototype,"onDelete",{get:function(){return this.onDeleteEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onInsert",{get:function(){return this.onInsertEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTrim",{get:function(){return this.onTrimEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxLength",{get:function(){return this._maxLength},set:function(e){if(this._maxLength!==e){for(var t=new Array(e),r=0;r
this._length)for(var t=this._length;t=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(n=0;nthis._maxLength){var s=this._length+r.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=r.length},e.prototype.trimStart=function(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)},e.prototype.shiftElements=function(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(var i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));var n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.clone=void 0,t.clone=function e(t,r){if(void 0===r&&(r=5),"object"!=typeof t)return t;var i=Array.isArray(t)?[]:{};for(var n in t)i[n]=r<=1?t[n]:t[n]&&e(t[n],r-1);return i}},969:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;var s=r(844),o=r(585),a=r(348),c=r(866),f=r(744),u=r(302),h=r(83),l=r(460),_=r(753),p=r(730),d=r(480),v=r(994),g=r(282),y=r(435),b=r(981),S=!1,m=function(e){function t(t){var r=e.call(this)||this;return r._onBinary=new l.EventEmitter,r._onData=new l.EventEmitter,r._onLineFeed=new l.EventEmitter,r._onResize=new l.EventEmitter,r._onScroll=new l.EventEmitter,r._instantiationService=new a.InstantiationService,r.optionsService=new u.OptionsService(t),r._instantiationService.setService(o.IOptionsService,r.optionsService),r._bufferService=r.register(r._instantiationService.createInstance(f.BufferService)),r._instantiationService.setService(o.IBufferService,r._bufferService),r._logService=r._instantiationService.createInstance(c.LogService),r._instantiationService.setService(o.ILogService,r._logService),r.coreService=r.register(r._instantiationService.createInstance(h.CoreService,(function(){return r.scrollToBottom()}))),r._instantiationService.setService(o.ICoreService,r.coreService),r.coreMouseService=r._instantiationService.createInstance(_.CoreMouseService),r._instantiationService.setService(o.ICoreMouseService,r.coreMouseService),r._dirtyRowService=r._instantiationService.createInstance(p.DirtyRowService),r._instantiationService.setService(o.IDirtyRowService,r._dirtyRowService),r.unicodeService=r._instantiationService.createInstance(d.UnicodeService),r._instantiationService.setService(o.IUnicodeService,r.unicodeService),r._charsetService=r._instantiationService.createInstance(v.CharsetService),r._instantiationService.setService(o.ICharsetService,r._charsetService),r._inputHandler=new y.InputHandler(r._bufferService,r._charsetService,r.coreService,r._dirtyRowService,r._logService,r.optionsService,r.coreMouseService,r.unicodeService),r.register(l.forwardEvent(r._inputHandler.onLineFeed,r._onLineFeed)),r.register(r._inputHandler),r.register(l.forwardEvent(r._bufferService.onResize,r._onResize)),r.register(l.forwardEvent(r.coreService.onData,r._onData)),r.register(l.forwardEvent(r.coreService.onBinary,r._onBinary)),r.register(r.optionsService.onOptionChange((function(e){return r._updateOptions(e)}))),r.register(r._bufferService.onScroll((function(e){r._onScroll.fire({position:r._bufferService.buffer.ydisp,source:0}),r._dirtyRowService.markRangeDirty(r._bufferService.buffer.scrollTop,r._bufferService.buffer.scrollBottom)}))),r.register(r._inputHandler.onScroll((function(e){r._onScroll.fire({position:r._bufferService.buffer.ydisp,source:0}),r._dirtyRowService.markRangeDirty(r._bufferService.buffer.scrollTop,r._bufferService.buffer.scrollBottom)}))),r._writeBuffer=new b.WriteBuffer((function(e,t){return r._inputHandler.parse(e,t)})),r}return n(t,e),Object.defineProperty(t.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onData",{get:function(){return this._onData.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onResize",{get:function(){return this._onResize.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){var e=this;return this._onScrollApi||(this._onScrollApi=new l.EventEmitter,this.register(this._onScroll.event((function(t){var r;null===(r=e._onScrollApi)||void 0===r||r.fire(t.position)})))),this._onScrollApi.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cols",{get:function(){return this._bufferService.cols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._bufferService.rows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buffers",{get:function(){return this._bufferService.buffers},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;this._isDisposed||(e.prototype.dispose.call(this),null===(t=this._windowsMode)||void 0===t||t.dispose(),this._windowsMode=void 0)},t.prototype.write=function(e,t){this._writeBuffer.write(e,t)},t.prototype.writeSync=function(e,t){this._logService.logLevel<=o.LogLevelEnum.WARN&&!S&&(this._logService.warn("writeSync is unreliable and will be removed soon."),S=!0),this._writeBuffer.writeSync(e,t)},t.prototype.resize=function(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,f.MINIMUM_COLS),t=Math.max(t,f.MINIMUM_ROWS),this._bufferService.resize(e,t))},t.prototype.scroll=function(e,t){void 0===t&&(t=!1),this._bufferService.scroll(e,t)},t.prototype.scrollLines=function(e,t,r){this._bufferService.scrollLines(e,t,r)},t.prototype.scrollPages=function(e){this._bufferService.scrollPages(e)},t.prototype.scrollToTop=function(){this._bufferService.scrollToTop()},t.prototype.scrollToBottom=function(){this._bufferService.scrollToBottom()},t.prototype.scrollToLine=function(e){this._bufferService.scrollToLine(e)},t.prototype.registerEscHandler=function(e,t){return this._inputHandler.registerEscHandler(e,t)},t.prototype.registerDcsHandler=function(e,t){return this._inputHandler.registerDcsHandler(e,t)},t.prototype.registerCsiHandler=function(e,t){return this._inputHandler.registerCsiHandler(e,t)},t.prototype.registerOscHandler=function(e,t){return this._inputHandler.registerOscHandler(e,t)},t.prototype._setup=function(){this.optionsService.options.windowsMode&&this._enableWindowsMode()},t.prototype.reset=function(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()},t.prototype._updateOptions=function(e){var t;switch(e){case"scrollback":this.buffers.resize(this.cols,this.rows);break;case"windowsMode":this.optionsService.options.windowsMode?this._enableWindowsMode():(null===(t=this._windowsMode)||void 0===t||t.dispose(),this._windowsMode=void 0)}},t.prototype._enableWindowsMode=function(){var e=this;if(!this._windowsMode){var t=[];t.push(this.onLineFeed(g.updateWindowsModeWrappedState.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},(function(){return g.updateWindowsModeWrappedState(e._bufferService),!1}))),this._windowsMode={dispose:function(){for(var e=0,r=t;e{Object.defineProperty(t,"__esModule",{value:!0}),t.forwardEvent=t.EventEmitter=void 0;var r=function(){function e(){this._listeners=[],this._disposed=!1}return Object.defineProperty(e.prototype,"event",{get:function(){var e=this;return this._event||(this._event=function(t){return e._listeners.push(t),{dispose:function(){if(!e._disposed)for(var r=0;r24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}!function(e){e[e.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",e[e.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"}(s=t.WindowsOptionsReportType||(t.WindowsOptionsReportType={}));var w=function(){function e(e,t,r,i){this._bufferService=e,this._coreService=t,this._logService=r,this._optionsService=i,this._data=new Uint32Array(0)}return e.prototype.hook=function(e){this._data=new Uint32Array(0)},e.prototype.put=function(e,t,r){this._data=u.concat(this._data,e.subarray(t,r))},e.prototype.unhook=function(e){if(!e)return this._data=new Uint32Array(0),!0;var t=h.utf32ToString(this._data);switch(this._data=new Uint32Array(0),t){case'"q':this._coreService.triggerDataEvent(o.C0.ESC+'P1$r0"q'+o.C0.ESC+"\\");break;case'"p':this._coreService.triggerDataEvent(o.C0.ESC+'P1$r61;1"p'+o.C0.ESC+"\\");break;case"r":var r=this._bufferService.buffer.scrollTop+1+";"+(this._bufferService.buffer.scrollBottom+1)+"r";this._coreService.triggerDataEvent(o.C0.ESC+"P1$r"+r+o.C0.ESC+"\\");break;case"m":this._coreService.triggerDataEvent(o.C0.ESC+"P1$r0m"+o.C0.ESC+"\\");break;case" q":var i={block:2,underline:4,bar:6}[this._optionsService.options.cursorStyle];i-=this._optionsService.options.cursorBlink?1:0,this._coreService.triggerDataEvent(o.C0.ESC+"P1$r"+i+" q"+o.C0.ESC+"\\");break;default:this._logService.debug("Unknown DCS $q %s",t),this._coreService.triggerDataEvent(o.C0.ESC+"P0$r"+o.C0.ESC+"\\")}return!0},e}(),A=function(e){function t(t,r,i,n,s,f,u,p,v){void 0===v&&(v=new c.EscapeSequenceParser);var g=e.call(this)||this;g._bufferService=t,g._charsetService=r,g._coreService=i,g._dirtyRowService=n,g._logService=s,g._optionsService=f,g._coreMouseService=u,g._unicodeService=p,g._parser=v,g._parseBuffer=new Uint32Array(4096),g._stringDecoder=new h.StringToUtf32,g._utf8Decoder=new h.Utf8ToUtf32,g._workCell=new d.CellData,g._windowTitle="",g._iconName="",g._windowTitleStack=[],g._iconNameStack=[],g._curAttrData=l.DEFAULT_ATTR_DATA.clone(),g._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone(),g._onRequestBell=new _.EventEmitter,g._onRequestRefreshRows=new _.EventEmitter,g._onRequestReset=new _.EventEmitter,g._onRequestSyncScrollBar=new _.EventEmitter,g._onRequestWindowsOptionsReport=new _.EventEmitter,g._onA11yChar=new _.EventEmitter,g._onA11yTab=new _.EventEmitter,g._onCursorMove=new _.EventEmitter,g._onLineFeed=new _.EventEmitter,g._onScroll=new _.EventEmitter,g._onTitleChange=new _.EventEmitter,g._onAnsiColorChange=new _.EventEmitter,g._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},g.register(g._parser),g._activeBuffer=g._bufferService.buffer,g.register(g._bufferService.buffers.onBufferActivate((function(e){return g._activeBuffer=e.activeBuffer}))),g._parser.setCsiHandlerFallback((function(e,t){g._logService.debug("Unknown CSI code: ",{identifier:g._parser.identToString(e),params:t.toArray()})})),g._parser.setEscHandlerFallback((function(e){g._logService.debug("Unknown ESC code: ",{identifier:g._parser.identToString(e)})})),g._parser.setExecuteHandlerFallback((function(e){g._logService.debug("Unknown EXECUTE code: ",{code:e})})),g._parser.setOscHandlerFallback((function(e,t,r){g._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:r})})),g._parser.setDcsHandlerFallback((function(e,t,r){"HOOK"===t&&(r=r.toArray()),g._logService.debug("Unknown DCS code: ",{identifier:g._parser.identToString(e),action:t,payload:r})})),g._parser.setPrintHandler((function(e,t,r){return g.print(e,t,r)})),g._parser.registerCsiHandler({final:"@"},(function(e){return g.insertChars(e)})),g._parser.registerCsiHandler({intermediates:" ",final:"@"},(function(e){return g.scrollLeft(e)})),g._parser.registerCsiHandler({final:"A"},(function(e){return g.cursorUp(e)})),g._parser.registerCsiHandler({intermediates:" ",final:"A"},(function(e){return g.scrollRight(e)})),g._parser.registerCsiHandler({final:"B"},(function(e){return g.cursorDown(e)})),g._parser.registerCsiHandler({final:"C"},(function(e){return g.cursorForward(e)})),g._parser.registerCsiHandler({final:"D"},(function(e){return g.cursorBackward(e)})),g._parser.registerCsiHandler({final:"E"},(function(e){return g.cursorNextLine(e)})),g._parser.registerCsiHandler({final:"F"},(function(e){return g.cursorPrecedingLine(e)})),g._parser.registerCsiHandler({final:"G"},(function(e){return g.cursorCharAbsolute(e)})),g._parser.registerCsiHandler({final:"H"},(function(e){return g.cursorPosition(e)})),g._parser.registerCsiHandler({final:"I"},(function(e){return g.cursorForwardTab(e)})),g._parser.registerCsiHandler({final:"J"},(function(e){return g.eraseInDisplay(e)})),g._parser.registerCsiHandler({prefix:"?",final:"J"},(function(e){return g.eraseInDisplay(e)})),g._parser.registerCsiHandler({final:"K"},(function(e){return g.eraseInLine(e)})),g._parser.registerCsiHandler({prefix:"?",final:"K"},(function(e){return g.eraseInLine(e)})),g._parser.registerCsiHandler({final:"L"},(function(e){return g.insertLines(e)})),g._parser.registerCsiHandler({final:"M"},(function(e){return g.deleteLines(e)})),g._parser.registerCsiHandler({final:"P"},(function(e){return g.deleteChars(e)})),g._parser.registerCsiHandler({final:"S"},(function(e){return g.scrollUp(e)})),g._parser.registerCsiHandler({final:"T"},(function(e){return g.scrollDown(e)})),g._parser.registerCsiHandler({final:"X"},(function(e){return g.eraseChars(e)})),g._parser.registerCsiHandler({final:"Z"},(function(e){return g.cursorBackwardTab(e)})),g._parser.registerCsiHandler({final:"`"},(function(e){return g.charPosAbsolute(e)})),g._parser.registerCsiHandler({final:"a"},(function(e){return g.hPositionRelative(e)})),g._parser.registerCsiHandler({final:"b"},(function(e){return g.repeatPrecedingCharacter(e)})),g._parser.registerCsiHandler({final:"c"},(function(e){return g.sendDeviceAttributesPrimary(e)})),g._parser.registerCsiHandler({prefix:">",final:"c"},(function(e){return g.sendDeviceAttributesSecondary(e)})),g._parser.registerCsiHandler({final:"d"},(function(e){return g.linePosAbsolute(e)})),g._parser.registerCsiHandler({final:"e"},(function(e){return g.vPositionRelative(e)})),g._parser.registerCsiHandler({final:"f"},(function(e){return g.hVPosition(e)})),g._parser.registerCsiHandler({final:"g"},(function(e){return g.tabClear(e)})),g._parser.registerCsiHandler({final:"h"},(function(e){return g.setMode(e)})),g._parser.registerCsiHandler({prefix:"?",final:"h"},(function(e){return g.setModePrivate(e)})),g._parser.registerCsiHandler({final:"l"},(function(e){return g.resetMode(e)})),g._parser.registerCsiHandler({prefix:"?",final:"l"},(function(e){return g.resetModePrivate(e)})),g._parser.registerCsiHandler({final:"m"},(function(e){return g.charAttributes(e)})),g._parser.registerCsiHandler({final:"n"},(function(e){return g.deviceStatus(e)})),g._parser.registerCsiHandler({prefix:"?",final:"n"},(function(e){return g.deviceStatusPrivate(e)})),g._parser.registerCsiHandler({intermediates:"!",final:"p"},(function(e){return g.softReset(e)})),g._parser.registerCsiHandler({intermediates:" ",final:"q"},(function(e){return g.setCursorStyle(e)})),g._parser.registerCsiHandler({final:"r"},(function(e){return g.setScrollRegion(e)})),g._parser.registerCsiHandler({final:"s"},(function(e){return g.saveCursor(e)})),g._parser.registerCsiHandler({final:"t"},(function(e){return g.windowOptions(e)})),g._parser.registerCsiHandler({final:"u"},(function(e){return g.restoreCursor(e)})),g._parser.registerCsiHandler({intermediates:"'",final:"}"},(function(e){return g.insertColumns(e)})),g._parser.registerCsiHandler({intermediates:"'",final:"~"},(function(e){return g.deleteColumns(e)})),g._parser.setExecuteHandler(o.C0.BEL,(function(){return g.bell()})),g._parser.setExecuteHandler(o.C0.LF,(function(){return g.lineFeed()})),g._parser.setExecuteHandler(o.C0.VT,(function(){return g.lineFeed()})),g._parser.setExecuteHandler(o.C0.FF,(function(){return g.lineFeed()})),g._parser.setExecuteHandler(o.C0.CR,(function(){return g.carriageReturn()})),g._parser.setExecuteHandler(o.C0.BS,(function(){return g.backspace()})),g._parser.setExecuteHandler(o.C0.HT,(function(){return g.tab()})),g._parser.setExecuteHandler(o.C0.SO,(function(){return g.shiftOut()})),g._parser.setExecuteHandler(o.C0.SI,(function(){return g.shiftIn()})),g._parser.setExecuteHandler(o.C1.IND,(function(){return g.index()})),g._parser.setExecuteHandler(o.C1.NEL,(function(){return g.nextLine()})),g._parser.setExecuteHandler(o.C1.HTS,(function(){return g.tabSet()})),g._parser.registerOscHandler(0,new y.OscHandler((function(e){return g.setTitle(e),g.setIconName(e),!0}))),g._parser.registerOscHandler(1,new y.OscHandler((function(e){return g.setIconName(e)}))),g._parser.registerOscHandler(2,new y.OscHandler((function(e){return g.setTitle(e)}))),g._parser.registerOscHandler(4,new y.OscHandler((function(e){return g.setAnsiColor(e)}))),g._parser.registerEscHandler({final:"7"},(function(){return g.saveCursor()})),g._parser.registerEscHandler({final:"8"},(function(){return g.restoreCursor()})),g._parser.registerEscHandler({final:"D"},(function(){return g.index()})),g._parser.registerEscHandler({final:"E"},(function(){return g.nextLine()})),g._parser.registerEscHandler({final:"H"},(function(){return g.tabSet()})),g._parser.registerEscHandler({final:"M"},(function(){return g.reverseIndex()})),g._parser.registerEscHandler({final:"="},(function(){return g.keypadApplicationMode()})),g._parser.registerEscHandler({final:">"},(function(){return g.keypadNumericMode()})),g._parser.registerEscHandler({final:"c"},(function(){return g.fullReset()})),g._parser.registerEscHandler({final:"n"},(function(){return g.setgLevel(2)})),g._parser.registerEscHandler({final:"o"},(function(){return g.setgLevel(3)})),g._parser.registerEscHandler({final:"|"},(function(){return g.setgLevel(3)})),g._parser.registerEscHandler({final:"}"},(function(){return g.setgLevel(2)})),g._parser.registerEscHandler({final:"~"},(function(){return g.setgLevel(1)})),g._parser.registerEscHandler({intermediates:"%",final:"@"},(function(){return g.selectDefaultCharset()})),g._parser.registerEscHandler({intermediates:"%",final:"G"},(function(){return g.selectDefaultCharset()}));var b=function(e){S._parser.registerEscHandler({intermediates:"(",final:e},(function(){return g.selectCharset("("+e)})),S._parser.registerEscHandler({intermediates:")",final:e},(function(){return g.selectCharset(")"+e)})),S._parser.registerEscHandler({intermediates:"*",final:e},(function(){return g.selectCharset("*"+e)})),S._parser.registerEscHandler({intermediates:"+",final:e},(function(){return g.selectCharset("+"+e)})),S._parser.registerEscHandler({intermediates:"-",final:e},(function(){return g.selectCharset("-"+e)})),S._parser.registerEscHandler({intermediates:".",final:e},(function(){return g.selectCharset("."+e)})),S._parser.registerEscHandler({intermediates:"/",final:e},(function(){return g.selectCharset("/"+e)}))},S=this;for(var m in a.CHARSETS)b(m);return g._parser.registerEscHandler({intermediates:"#",final:"8"},(function(){return g.screenAlignmentPattern()})),g._parser.setErrorHandler((function(e){return g._logService.error("Parsing error: ",e),e})),g._parser.registerDcsHandler({intermediates:"$",final:"q"},new w(g._bufferService,g._coreService,g._logService,g._optionsService)),g}return n(t,e),Object.defineProperty(t.prototype,"onRequestBell",{get:function(){return this._onRequestBell.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestReset",{get:function(){return this._onRequestReset.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestSyncScrollBar",{get:function(){return this._onRequestSyncScrollBar.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestWindowsOptionsReport",{get:function(){return this._onRequestWindowsOptionsReport.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yChar",{get:function(){return this._onA11yChar.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yTab",{get:function(){return this._onA11yTab.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTitleChange",{get:function(){return this._onTitleChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onAnsiColorChange",{get:function(){return this._onAnsiColorChange.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype._preserveStack=function(e,t,r,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=i},t.prototype._logSlowResolvingAsync=function(e){this._logService.logLevel<=g.LogLevelEnum.WARN&&Promise.race([e,new Promise((function(e,t){return setTimeout((function(){return t("#SLOW_TIMEOUT")}),5e3)}))]).catch((function(e){if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")}))},t.prototype.parse=function(e,t){var r,i=this._activeBuffer.x,n=this._activeBuffer.y,s=0,o=this._parseStack.paused;if(o){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>m&&(s=this._parseStack.position+m)}if(this._logService.debug("parsing data",e),this._parseBuffer.lengthm)for(var a=s;a0&&2===l.getWidth(this._activeBuffer.x-1)&&l.setCellFromCodePoint(this._activeBuffer.x-1,0,1,u.fg,u.bg,u.extended);for(var _=t;_=a)if(c){for(;this._activeBuffer.x=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=a-1,2===n)continue;if(f&&(l.insertCells(this._activeBuffer.x,n,this._activeBuffer.getNullCell(u),u),2===l.getWidth(a-1)&&l.setCellFromCodePoint(a-1,p.NULL_CELL_CODE,p.NULL_CELL_WIDTH,u.fg,u.bg,u.extended)),l.setCellFromCodePoint(this._activeBuffer.x++,i,n,u.fg,u.bg,u.extended),n>0)for(;--n;)l.setCellFromCodePoint(this._activeBuffer.x++,0,0,u.fg,u.bg,u.extended)}else l.getWidth(this._activeBuffer.x-1)?l.addCodepointToCell(this._activeBuffer.x-1,i):l.addCodepointToCell(this._activeBuffer.x-2,i)}r-t>0&&(l.loadCell(this._activeBuffer.x-1,this._workCell),2===this._workCell.getWidth()||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x 0&&0===l.getWidth(this._activeBuffer.x)&&!l.hasContent(this._activeBuffer.x)&&l.setCellFromCodePoint(this._activeBuffer.x,0,1,u.fg,u.bg,u.extended),this._dirtyRowService.markDirty(this._activeBuffer.y)},t.prototype.registerCsiHandler=function(e,t){var r=this;return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,(function(e){return!C(e.params[0],r._optionsService.options.windowOptions)||t(e)}))},t.prototype.registerDcsHandler=function(e,t){return this._parser.registerDcsHandler(e,new b.DcsHandler(t))},t.prototype.registerEscHandler=function(e,t){return this._parser.registerEscHandler(e,t)},t.prototype.registerOscHandler=function(e,t){return this._parser.registerOscHandler(e,new y.OscHandler(t))},t.prototype.bell=function(){return this._onRequestBell.fire(),!0},t.prototype.lineFeed=function(){return this._dirtyRowService.markDirty(this._activeBuffer.y),this._optionsService.options.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowService.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0},t.prototype.carriageReturn=function(){return this._activeBuffer.x=0,!0},t.prototype.backspace=function(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(null===(e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))||void 0===e?void 0:e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;var t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0},t.prototype.tab=function(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;var e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.options.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0},t.prototype.shiftOut=function(){return this._charsetService.setgLevel(1),!0},t.prototype.shiftIn=function(){return this._charsetService.setgLevel(0),!0},t.prototype._restrictCursor=function(e){void 0===e&&(e=this._bufferService.cols-1),this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowService.markDirty(this._activeBuffer.y)},t.prototype._setCursor=function(e,t){this._dirtyRowService.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowService.markDirty(this._activeBuffer.y)},t.prototype._moveCursor=function(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)},t.prototype.cursorUp=function(e){var t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0},t.prototype.cursorDown=function(e){var t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0},t.prototype.cursorForward=function(e){return this._moveCursor(e.params[0]||1,0),!0},t.prototype.cursorBackward=function(e){return this._moveCursor(-(e.params[0]||1),0),!0},t.prototype.cursorNextLine=function(e){return this.cursorDown(e),this._activeBuffer.x=0,!0},t.prototype.cursorPrecedingLine=function(e){return this.cursorUp(e),this._activeBuffer.x=0,!0},t.prototype.cursorCharAbsolute=function(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0},t.prototype.cursorPosition=function(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0},t.prototype.charPosAbsolute=function(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0},t.prototype.hPositionRelative=function(e){return this._moveCursor(e.params[0]||1,0),!0},t.prototype.linePosAbsolute=function(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0},t.prototype.vPositionRelative=function(e){return this._moveCursor(0,e.params[0]||1),!0},t.prototype.hVPosition=function(e){return this.cursorPosition(e),!0},t.prototype.tabClear=function(e){var t=e.params[0];return 0===t?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===t&&(this._activeBuffer.tabs={}),!0},t.prototype.cursorForwardTab=function(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;for(var t=e.params[0]||1;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0},t.prototype.cursorBackwardTab=function(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;for(var t=e.params[0]||1;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0},t.prototype._eraseInBufferLine=function(e,t,r,i){void 0===i&&(i=!1);var n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i&&(n.isWrapped=!1)},t.prototype._resetBufferLine=function(e){var t=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);t.fill(this._activeBuffer.getNullCell(this._eraseAttrData())),t.isWrapped=!1},t.prototype.eraseInDisplay=function(e){var t;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(t=this._activeBuffer.y,this._dirtyRowService.markDirty(t),this._eraseInBufferLine(t++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x);t=this._bufferService.cols&&(this._activeBuffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 2:for(t=this._bufferService.rows,this._dirtyRowService.markDirty(t-1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 3:var r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0))}return!0},t.prototype.eraseInLine=function(e){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols)}return this._dirtyRowService.markDirty(this._activeBuffer.y),!0},t.prototype.insertLines=function(e){this._restrictCursor();var t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(o.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(o.C0.ESC+"[?6c")),!0},t.prototype.sendDeviceAttributesSecondary=function(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(o.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(o.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c")),!0},t.prototype._is=function(e){return 0===(this._optionsService.options.termName+"").indexOf(e)},t.prototype.setMode=function(e){for(var t=0;t=2||2===i[1]&&s+n>=5)break;i[1]&&(n=1)}while(++s+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,0===e&&(t.fg&=-268435457),t.updateExtended()},t.prototype.charAttributes=function(e){if(1===e.length&&0===e.params[0])return this._curAttrData.fg=l.DEFAULT_ATTR_DATA.fg,this._curAttrData.bg=l.DEFAULT_ATTR_DATA.bg,!0;for(var t,r=e.length,i=this._curAttrData,n=0;n=30&&t<=37?(i.fg&=-50331904,i.fg|=16777216|t-30):t>=40&&t<=47?(i.bg&=-50331904,i.bg|=16777216|t-40):t>=90&&t<=97?(i.fg&=-50331904,i.fg|=16777224|t-90):t>=100&&t<=107?(i.bg&=-50331904,i.bg|=16777224|t-100):0===t?(i.fg=l.DEFAULT_ATTR_DATA.fg,i.bg=l.DEFAULT_ATTR_DATA.bg):1===t?i.fg|=134217728:3===t?i.bg|=67108864:4===t?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):5===t?i.fg|=536870912:7===t?i.fg|=67108864:8===t?i.fg|=1073741824:9===t?i.fg|=2147483648:2===t?i.bg|=134217728:21===t?this._processUnderline(2,i):22===t?(i.fg&=-134217729,i.bg&=-134217729):23===t?i.bg&=-67108865:24===t?i.fg&=-268435457:25===t?i.fg&=-536870913:27===t?i.fg&=-67108865:28===t?i.fg&=-1073741825:29===t?i.fg&=2147483647:39===t?(i.fg&=-67108864,i.fg|=16777215&l.DEFAULT_ATTR_DATA.fg):49===t?(i.bg&=-67108864,i.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):38===t||48===t||58===t?n+=this._extractColor(e,n,i):59===t?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):100===t?(i.fg&=-67108864,i.fg|=16777215&l.DEFAULT_ATTR_DATA.fg,i.bg&=-67108864,i.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",t);return!0},t.prototype.deviceStatus=function(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(o.C0.ESC+"[0n");break;case 6:var t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(o.C0.ESC+"["+t+";"+r+"R")}return!0},t.prototype.deviceStatusPrivate=function(e){switch(e.params[0]){case 6:var t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(o.C0.ESC+"[?"+t+";"+r+"R")}return!0},t.prototype.softReset=function(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0},t.prototype.setCursorStyle=function(e){var t=e.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}var r=t%2==1;return this._optionsService.options.cursorBlink=r,!0},t.prototype.setScrollRegion=function(e){var t,r=e.params[0]||1;return(e.length<2||(t=e.params[1])>this._bufferService.rows||0===t)&&(t=this._bufferService.rows),t>r&&(this._activeBuffer.scrollTop=r-1,this._activeBuffer.scrollBottom=t-1,this._setCursor(0,0)),!0},t.prototype.windowOptions=function(e){if(!C(e.params[0],this._optionsService.options.windowOptions))return!0;var t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==t&&this._onRequestWindowsOptionsReport.fire(s.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(s.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(o.C0.ESC+"[8;"+this._bufferService.rows+";"+this._bufferService.cols+"t");break;case 22:0!==t&&2!==t||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),0!==t&&1!==t||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:0!==t&&2!==t||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),0!==t&&1!==t||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0},t.prototype.saveCursor=function(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0},t.prototype.restoreCursor=function(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0},t.prototype.setTitle=function(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0},t.prototype.setIconName=function(e){return this._iconName=e,!0},t.prototype._parseAnsiColorChange=function(e){for(var t,r={colors:[]},i=/(\d+);rgb:([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})/gi;null!==(t=i.exec(e));)r.colors.push({colorIndex:parseInt(t[1]),red:parseInt(t[2],16),green:parseInt(t[3],16),blue:parseInt(t[4],16)});return 0===r.colors.length?null:r},t.prototype.setAnsiColor=function(e){var t=this._parseAnsiColorChange(e);return t?this._onAnsiColorChange.fire(t):this._logService.warn("Expected format ;rgb:// but got data: "+e),!0},t.prototype.nextLine=function(){return this._activeBuffer.x=0,this.index(),!0},t.prototype.keypadApplicationMode=function(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0},t.prototype.keypadNumericMode=function(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0},t.prototype.selectDefaultCharset=function(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,a.DEFAULT_CHARSET),!0},t.prototype.selectCharset=function(e){return 2!==e.length?(this.selectDefaultCharset(),!0):("/"===e[0]||this._charsetService.setgCharset(S[e[0]],a.CHARSETS[e[1]]||a.DEFAULT_CHARSET),!0)},t.prototype.index=function(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0},t.prototype.tabSet=function(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0},t.prototype.reverseIndex=function(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){var e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0},t.prototype.fullReset=function(){return this._parser.reset(),this._onRequestReset.fire(),!0},t.prototype.reset=function(){this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone()},t.prototype._eraseAttrData=function(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal},t.prototype.setgLevel=function(e){return this._charsetService.setgLevel(e),!0},t.prototype.screenAlignmentPattern=function(){var e=new d.CellData;e.content=1<<22|"E".charCodeAt(0),e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(var t=0;t{Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.Disposable=void 0;var r=function(){function e(){this._disposables=[],this._isDisposed=!1}return e.prototype.dispose=function(){this._isDisposed=!0;for(var e=0,t=this._disposables;e{Object.defineProperty(t,"__esModule",{value:!0}),t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.isSafari=t.isFirefox=void 0;var r="undefined"==typeof navigator,i=r?"node":navigator.userAgent,n=r?"node":navigator.platform;t.isFirefox=i.includes("Firefox"),t.isSafari=/^((?!chrome|android).)*safari/i.test(i),t.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(n),t.isIpad="iPad"===n,t.isIphone="iPhone"===n,t.isWindows=["Windows","Win16","Win32","WinCE"].includes(n),t.isLinux=n.indexOf("Linux")>=0},273:(e,t)=>{function r(e,t,r,i){if(void 0===r&&(r=0),void 0===i&&(i=e.length),r>=e.length)return e;r=(e.length+r)%e.length,i=i>=e.length?e.length:(e.length+i)%e.length;for(var n=r;n{Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=void 0;var i=r(643);t.updateWindowsModeWrappedState=function(e){var t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1),r=null==t?void 0:t.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&r&&(n.isWrapped=r[i.CHAR_DATA_CODE_INDEX]!==i.NULL_CELL_CODE&&r[i.CHAR_DATA_CODE_INDEX]!==i.WHITESPACE_CELL_CODE)}},734:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;var r=function(){function e(){this.fg=0,this.bg=0,this.extended=new i}return e.toColorRGB=function(e){return[e>>>16&255,e>>>8&255,255&e]},e.fromColorRGB=function(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},e.prototype.clone=function(){var t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t},e.prototype.isInverse=function(){return 67108864&this.fg},e.prototype.isBold=function(){return 134217728&this.fg},e.prototype.isUnderline=function(){return 268435456&this.fg},e.prototype.isBlink=function(){return 536870912&this.fg},e.prototype.isInvisible=function(){return 1073741824&this.fg},e.prototype.isItalic=function(){return 67108864&this.bg},e.prototype.isDim=function(){return 134217728&this.bg},e.prototype.isStrikethrough=function(){return 2147483648&this.fg},e.prototype.getFgColorMode=function(){return 50331648&this.fg},e.prototype.getBgColorMode=function(){return 50331648&this.bg},e.prototype.isFgRGB=function(){return 50331648==(50331648&this.fg)},e.prototype.isBgRGB=function(){return 50331648==(50331648&this.bg)},e.prototype.isFgPalette=function(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)},e.prototype.isBgPalette=function(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)},e.prototype.isFgDefault=function(){return 0==(50331648&this.fg)},e.prototype.isBgDefault=function(){return 0==(50331648&this.bg)},e.prototype.isAttributeDefault=function(){return 0===this.fg&&0===this.bg},e.prototype.getFgColor=function(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}},e.prototype.getBgColor=function(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}},e.prototype.hasExtendedAttrs=function(){return 268435456&this.bg},e.prototype.updateExtended=function(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456},e.prototype.getUnderlineColor=function(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()},e.prototype.getUnderlineColorMode=function(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()},e.prototype.isUnderlineColorRGB=function(){return 268435456&this.bg&&~this.extended.underlineColor?50331648==(50331648&this.extended.underlineColor):this.isFgRGB()},e.prototype.isUnderlineColorPalette=function(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()},e.prototype.isUnderlineColorDefault=function(){return 268435456&this.bg&&~this.extended.underlineColor?0==(50331648&this.extended.underlineColor):this.isFgDefault()},e.prototype.getUnderlineStyle=function(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0},e}();t.AttributeData=r;var i=function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=-1),this.underlineStyle=e,this.underlineColor=t}return e.prototype.clone=function(){return new e(this.underlineStyle,this.underlineColor)},e.prototype.isEmpty=function(){return 0===this.underlineStyle},e}();t.ExtendedAttrs=i},92:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferStringIterator=t.Buffer=t.MAX_BUFFER_SIZE=void 0;var i=r(349),n=r(437),s=r(511),o=r(643),a=r(634),c=r(863),f=r(116),u=r(734);t.MAX_BUFFER_SIZE=4294967295;var h=function(){function e(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.savedY=0,this.savedX=0,this.savedCurAttrData=n.DEFAULT_ATTR_DATA.clone(),this.savedCharset=f.DEFAULT_CHARSET,this.markers=[],this._nullCell=s.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]),this._whitespaceCell=s.CellData.fromCharData([0,o.WHITESPACE_CELL_CHAR,o.WHITESPACE_CELL_WIDTH,o.WHITESPACE_CELL_CODE]),this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}return e.prototype.getNullCell=function(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new u.ExtendedAttrs),this._nullCell},e.prototype.getWhitespaceCell=function(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new u.ExtendedAttrs),this._whitespaceCell},e.prototype.getBlankLine=function(e,t){return new n.BufferLine(this._bufferService.cols,this.getNullCell(e),t)},Object.defineProperty(e.prototype,"hasScrollback",{get:function(){return this._hasScrollback&&this.lines.maxLength>this._rows},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCursorInViewport",{get:function(){var e=this.ybase+this.y-this.ydisp;return e>=0&&et.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:r},e.prototype.fillViewportRows=function(e){if(0===this.lines.length){void 0===e&&(e=n.DEFAULT_ATTR_DATA);for(var t=this._rows;t--;)this.lines.push(this.getBlankLine(e))}},e.prototype.clear=function(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()},e.prototype.resize=function(e,t){var r=this.getNullCell(n.DEFAULT_ATTR_DATA),i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new n.BufferLine(e,r)));else for(a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(s=0;sthis._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))},e.prototype._reflowLarger=function(e,t){var r=a.reflowLargerGetLinesToRemove(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(n.DEFAULT_ATTR_DATA));if(r.length>0){var i=a.reflowLargerCreateNewLayout(this.lines,r);a.reflowLargerApplyNewLayout(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}},e.prototype._reflowLargerAdjustViewport=function(e,t,r){for(var i=this.getNullCell(n.DEFAULT_ATTR_DATA),s=r;s-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length=0;o--){var c=this.lines.get(o);if(!(!c||!c.isWrapped&&c.getTrimmedLength()<=e)){for(var f=[c];c.isWrapped&&o>0;)c=this.lines.get(--o),f.unshift(c);var u=this.ybase+this.y;if(!(u>=o&&u0&&(i.push({start:o+f.length+s,newLines:d}),s+=d.length),f.push.apply(f,d);var y=_.length-1,b=_[y];0===b&&(b=_[--y]);for(var S=f.length-p-1,m=l;S>=0;){var C=Math.min(m,b);if(f[y].copyCellsFrom(f[S],m-C,b-C,C,!0),0==(b-=C)&&(b=_[--y]),0==(m-=C)){S--;var w=Math.max(S,0);m=a.getWrappedLineTrimmedLength(f,w,this._cols)}}for(v=0;v0;)0===this.ybase?this.y0){var B=[],E=[];for(v=0;v=0;v--)if(L&&L.start>D+O){for(var x=L.newLines.length-1;x>=0;x--)this.lines.set(v--,L.newLines[x]);v++,B.push({index:D+1,amount:L.newLines.length}),O+=L.newLines.length,L=i[++P]}else this.lines.set(v,E[D--]);var k=0;for(v=B.length-1;v>=0;v--)B[v].index+=k,this.lines.onInsertEmitter.fire(B[v]),k+=B[v].amount;var H=Math.max(0,T+s-this.lines.maxLength);H>0&&this.lines.onTrimEmitter.fire(H)}},e.prototype.stringIndexToBufferIndex=function(e,t,r){for(void 0===r&&(r=!1);t;){var i=this.lines.get(e);if(!i)return[-1,-1];for(var n=r?i.getTrimmedLength():i.length,s=0;s0&&this.lines.get(t).isWrapped;)t--;for(;r+10;);return e>=this._cols?this._cols-1:e<0?0:e},e.prototype.nextStop=function(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e},e.prototype.addMarker=function(e){var t=this,r=new c.Marker(e);return this.markers.push(r),r.register(this.lines.onTrim((function(e){r.line-=e,r.line<0&&r.dispose()}))),r.register(this.lines.onInsert((function(e){r.line>=e.index&&(r.line+=e.amount)}))),r.register(this.lines.onDelete((function(e){r.line>=e.index&&r.linee.index&&(r.line-=e.amount)}))),r.register(r.onDispose((function(){return t._removeMarker(r)}))),r},e.prototype._removeMarker=function(e){this.markers.splice(this.markers.indexOf(e),1)},e.prototype.iterator=function(e,t,r,i,n){return new l(this,e,t,r,i,n)},e}();t.Buffer=h;var l=function(){function e(e,t,r,i,n,s){void 0===r&&(r=0),void 0===i&&(i=e.lines.length),void 0===n&&(n=0),void 0===s&&(s=0),this._buffer=e,this._trimRight=t,this._startIndex=r,this._endIndex=i,this._startOverscan=n,this._endOverscan=s,this._startIndex<0&&(this._startIndex=0),this._endIndex>this._buffer.lines.length&&(this._endIndex=this._buffer.lines.length),this._current=this._startIndex}return e.prototype.hasNext=function(){return this._currentthis._endIndex+this._endOverscan&&(e.last=this._endIndex+this._endOverscan),e.first=Math.max(e.first,0),e.last=Math.min(e.last,this._buffer.lines.length);for(var t="",r=e.first;r<=e.last;++r)t+=this._buffer.translateBufferLineToString(r,this._trimRight);return this._current=e.last+1,{range:e,content:t}},e}();t.BufferStringIterator=l},437:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;var i=r(482),n=r(643),s=r(511),o=r(734);t.DEFAULT_ATTR_DATA=Object.freeze(new o.AttributeData);var a=function(){function e(e,t,r){void 0===r&&(r=!1),this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);for(var i=t||s.CellData.fromCharData([0,n.NULL_CELL_CHAR,n.NULL_CELL_WIDTH,n.NULL_CELL_CODE]),o=0;o>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):r]},e.prototype.set=function(e,t){this._data[3*e+1]=t[n.CHAR_DATA_ATTR_INDEX],t[n.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[n.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[n.CHAR_DATA_WIDTH_INDEX]<<22},e.prototype.getWidth=function(e){return this._data[3*e+0]>>22},e.prototype.hasWidth=function(e){return 12582912&this._data[3*e+0]},e.prototype.getFg=function(e){return this._data[3*e+1]},e.prototype.getBg=function(e){return this._data[3*e+2]},e.prototype.hasContent=function(e){return 4194303&this._data[3*e+0]},e.prototype.getCodePoint=function(e){var t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t},e.prototype.isCombined=function(e){return 2097152&this._data[3*e+0]},e.prototype.getString=function(e){var t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?i.stringFromCodePoint(2097151&t):""},e.prototype.loadCell=function(e,t){var r=3*e;return t.content=this._data[r+0],t.fg=this._data[r+1],t.bg=this._data[r+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t},e.prototype.setCell=function(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg},e.prototype.setCellFromCodePoint=function(e,t,r,i,n,s){268435456&n&&(this._extendedAttrs[e]=s),this._data[3*e+0]=t|r<<22,this._data[3*e+1]=i,this._data[3*e+2]=n},e.prototype.addCodepointToCell=function(e,t){var r=this._data[3*e+0];2097152&r?this._combined[e]+=i.stringFromCodePoint(t):(2097151&r?(this._combined[e]=i.stringFromCodePoint(2097151&r)+i.stringFromCodePoint(t),r&=-2097152,r|=2097152):r=t|1<<22,this._data[3*e+0]=r)},e.prototype.insertCells=function(e,t,r,i){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodePoint(e-1,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0,(null==i?void 0:i.extended)||new o.ExtendedAttrs),t=0;--a)this.setCell(e+t+a,this.loadCell(e+a,n));for(a=0;athis.length){var r=new Uint32Array(3*e);this.length&&(3*e=e&&delete this._combined[s]}}else this._data=new Uint32Array(0),this._combined={};this.length=e}},e.prototype.fill=function(e){this._combined={},this._extendedAttrs={};for(var t=0;t=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0},e.prototype.copyCellsFrom=function(e,t,r,i,n){var s=e._data;if(n)for(var o=i-1;o>=0;o--)for(var a=0;a<3;a++)this._data[3*(r+o)+a]=s[3*(t+o)+a];else for(o=0;o=t&&(this._combined[f-t+r]=e._combined[f])}},e.prototype.translateToString=function(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=0),void 0===r&&(r=this.length),e&&(r=Math.min(r,this.getTrimmedLength()));for(var s="";t>22||1}return s},e}();t.BufferLine=a},634:(e,t)=>{function r(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();var i=!e[t].hasContent(r-1)&&1===e[t].getWidth(r-1),n=2===e[t+1].getWidth(0);return i&&n?r-1:r}Object.defineProperty(t,"__esModule",{value:!0}),t.getWrappedLineTrimmedLength=t.reflowSmallerGetNewLineLengths=t.reflowLargerApplyNewLayout=t.reflowLargerCreateNewLayout=t.reflowLargerGetLinesToRemove=void 0,t.reflowLargerGetLinesToRemove=function(e,t,i,n,s){for(var o=[],a=0;a=a&&n0&&(S>h||0===u[S].getTrimmedLength());S--)b++;b>0&&(o.push(a+u.length-b),o.push(b)),a+=u.length-1}}}return o},t.reflowLargerCreateNewLayout=function(e,t){for(var r=[],i=0,n=t[i],s=0,o=0;of&&(o-=f,a++);var u=2===e[a].getWidth(o-1);u&&o--;var h=u?i-1:i;n.push(h),c+=h}return n},t.getWrappedLineTrimmedLength=r},295:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;var s=r(92),o=r(460),a=function(e){function t(t,r){var i=e.call(this)||this;return i._optionsService=t,i._bufferService=r,i._onBufferActivate=i.register(new o.EventEmitter),i.reset(),i}return n(t,e),Object.defineProperty(t.prototype,"onBufferActivate",{get:function(){return this._onBufferActivate.event},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this._normal=new s.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new s.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()},Object.defineProperty(t.prototype,"alt",{get:function(){return this._alt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"active",{get:function(){return this._activeBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},enumerable:!1,configurable:!0}),t.prototype.activateNormalBuffer=function(){this._activeBuffer!==this._normal&&(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}))},t.prototype.activateAltBuffer=function(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),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}))},t.prototype.resize=function(e,t){this._normal.resize(e,t),this._alt.resize(e,t)},t.prototype.setupTabStops=function(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)},t}(r(844).Disposable);t.BufferSet=a},511:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CellData=void 0;var s=r(482),o=r(643),a=r(734),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.content=0,t.fg=0,t.bg=0,t.extended=new a.ExtendedAttrs,t.combinedData="",t}return n(t,e),t.fromCharData=function(e){var r=new t;return r.setFromCharData(e),r},t.prototype.isCombined=function(){return 2097152&this.content},t.prototype.getWidth=function(){return this.content>>22},t.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?s.stringFromCodePoint(2097151&this.content):""},t.prototype.getCode=function(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content},t.prototype.setFromCharData=function(e){this.fg=e[o.CHAR_DATA_ATTR_INDEX],this.bg=0;var t=!1;if(e[o.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(2===e[o.CHAR_DATA_CHAR_INDEX].length){var r=e[o.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=r&&r<=56319){var i=e[o.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i&&i<=57343?this.content=1024*(r-55296)+i-56320+65536|e[o.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[o.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[o.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[o.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[o.CHAR_DATA_WIDTH_INDEX]<<22)},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(a.AttributeData);t.CellData=c},643:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=256,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR="",t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=" ",t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},863:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;var s=r(460),o=function(e){function t(r){var i=e.call(this)||this;return i.line=r,i._id=t._nextId++,i.isDisposed=!1,i._onDispose=new s.EventEmitter,i}return n(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{get:function(){return this._onDispose.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),e.prototype.dispose.call(this))},t._nextId=1,t}(r(844).Disposable);t.Marker=o},116:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},t.CHARSETS.A={"#":"£"},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},t.CHARSETS.C=t.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},t.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},t.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},t.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},t.CHARSETS.E=t.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},t.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},t.CHARSETS.H=t.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},584:(e,t)=>{var r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.C1=t.C0=void 0,(i=t.C0||(t.C0={})).NUL="\0",i.SOH="",i.STX="",i.ETX="",i.EOT="",i.ENQ="",i.ACK="",i.BEL="",i.BS="\b",i.HT="\t",i.LF="\n",i.VT="\v",i.FF="\f",i.CR="\r",i.SO="",i.SI="",i.DLE="",i.DC1="",i.DC2="",i.DC3="",i.DC4="",i.NAK="",i.SYN="",i.ETB="",i.CAN="",i.EM="",i.SUB="",i.ESC="",i.FS="",i.GS="",i.RS="",i.US="",i.SP=" ",i.DEL="",(r=t.C1||(t.C1={})).PAD="",r.HOP="",r.BPH="",r.NBH="",r.IND="",r.NEL="
",r.SSA="",r.ESA="",r.HTS="",r.HTJ="",r.VTS="",r.PLD="",r.PLU="",r.RI="",r.SS2="",r.SS3="",r.DCS="",r.PU1="",r.PU2="",r.STS="",r.CCH="",r.MW="",r.SPA="",r.EPA="",r.SOS="",r.SGCI="",r.SCI="",r.CSI="",r.ST="",r.OSC="",r.PM="",r.APC=""},482:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=e.length);for(var i="",n=t;n65535?(s-=65536,i+=String.fromCharCode(55296+(s>>10))+String.fromCharCode(s%1024+56320)):i+=String.fromCharCode(s)}return i};var r=function(){function e(){this._interim=0}return e.prototype.clear=function(){this._interim=0},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i=0,n=0;this._interim&&(56320<=(a=e.charCodeAt(n++))&&a<=57343?t[i++]=1024*(this._interim-55296)+a-56320+65536:(t[i++]=this._interim,t[i++]=a),this._interim=0);for(var s=n;s=r)return this._interim=o,i;var a;56320<=(a=e.charCodeAt(s))&&a<=57343?t[i++]=1024*(o-55296)+a-56320+65536:(t[i++]=o,t[i++]=a)}else 65279!==o&&(t[i++]=o)}return i},e}();t.StringToUtf32=r;var i=function(){function e(){this.interim=new Uint8Array(3)}return e.prototype.clear=function(){this.interim.fill(0)},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i,n,s,o,a=0,c=0,f=0;if(this.interim[0]){var u=!1,h=this.interim[0];h&=192==(224&h)?31:224==(240&h)?15:7;for(var l=0,_=void 0;(_=63&this.interim[++l])&&l<4;)h<<=6,h|=_;for(var p=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,d=p-l;f=r)return 0;if(128!=(192&(_=e[f++]))){f--,u=!0;break}this.interim[l++]=_,h<<=6,h|=63&_}u||(2===p?h<128?f--:t[a++]=h:3===p?h<2048||h>=55296&&h<=57343||65279===h||(t[a++]=h):h<65536||h>1114111||(t[a++]=h)),this.interim.fill(0)}for(var v=r-4,g=f;g=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if((c=(31&i)<<6|63&n)<128){g--;continue}t[a++]=c}else if(224==(240&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(s=e[g++]))){g--;continue}if((c=(15&i)<<12|(63&n)<<6|63&s)<2048||c>=55296&&c<=57343||65279===c)continue;t[a++]=c}else if(240==(248&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(s=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,this.interim[2]=s,a;if(128!=(192&(o=e[g++]))){g--;continue}if((c=(7&i)<<18|(63&n)<<12|(63&s)<<6|63&o)<65536||c>1114111)continue;t[a++]=c}}return a},e}();t.Utf8ToUtf32=i},225:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;var i,n=r(273),s=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],o=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],a=function(){function e(){if(this.version="6",!i){i=new Uint8Array(65536),n.fill(i,1),i[0]=0,n.fill(i,0,1,32),n.fill(i,0,127,160),n.fill(i,2,4352,4448),i[9001]=2,i[9002]=2,n.fill(i,2,11904,42192),i[12351]=1,n.fill(i,2,44032,55204),n.fill(i,2,63744,64256),n.fill(i,2,65040,65050),n.fill(i,2,65072,65136),n.fill(i,2,65280,65377),n.fill(i,2,65504,65511);for(var e=0;et[n][1])return!1;for(;n>=i;)if(e>t[r=i+n>>1][1])i=r+1;else{if(!(e=131072&&e<=196605||e>=196608&&e<=262141?2:1},e}();t.UnicodeV6=a},981:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;var r="undefined"==typeof queueMicrotask?function(e){Promise.resolve().then(e)}:queueMicrotask,i=function(){function e(e){this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0}return e.prototype.writeSync=function(e,t){if(void 0!==t&&this._syncCalls>t)this._syncCalls=0;else if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){var r;for(this._isSyncWriting=!0;r=this._writeBuffer.shift();){this._action(r);var i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}},e.prototype.write=function(e,t){var r=this;if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");this._writeBuffer.length||(this._bufferOffset=0,setTimeout((function(){return r._innerWrite()}))),this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)},e.prototype._innerWrite=function(e,t){var i=this;void 0===e&&(e=0),void 0===t&&(t=!0);for(var n=e||Date.now();this._writeBuffer.length>this._bufferOffset;){var s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o)return void o.catch((function(e){return r((function(){throw e})),Promise.resolve(!1)})).then((function(e){return Date.now()-n>=12?setTimeout((function(){return i._innerWrite(0,e)})):i._innerWrite(n,e)}));var a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,Date.now()-n>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((function(){return i._innerWrite()}))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0)},e}();t.WriteBuffer=i},770:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},351:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;var i=r(482),n=r(742),s=r(770),o=[],a=function(){function e(){this._handlers=Object.create(null),this._active=o,this._ident=0,this._handlerFb=function(){},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}return e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){},this._active=o},e.prototype.registerHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.reset=function(){if(this._active.length)for(var e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=o,this._ident=0},e.prototype.hook=function(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||o,this._active.length)for(var r=this._active.length-1;r>=0;r--)this._active[r].hook(t);else this._handlerFb(this._ident,"HOOK",t)},e.prototype.put=function(e,t,r){if(this._active.length)for(var n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r);else this._handlerFb(this._ident,"PUT",i.utf32ToString(e,t,r))},e.prototype.unhook=function(e,t){if(void 0===t&&(t=!0),this._active.length){var r=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;i>=0&&!0!==(r=this._active[i].unhook(e));i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if((r=this._active[i].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}else this._handlerFb(this._ident,"UNHOOK",e);this._active=o,this._ident=0},e}();t.DcsParser=a;var c=new n.Params;c.addParam(0);var f=function(){function e(e){this._handler=e,this._data="",this._params=c,this._hitLimit=!1}return e.prototype.hook=function(e){this._params=e.length>1||e.params[0]?e.clone():c,this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,r){this._hitLimit||(this._data+=i.utf32ToString(e,t,r),this._data.length>s.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.unhook=function(e){var t=this,r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data,this._params))instanceof Promise)return r.then((function(e){return t._params=c,t._data="",t._hitLimit=!1,e}));return this._params=c,this._data="",this._hitLimit=!1,r},e}();t.DcsHandler=f},15:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;var s=r(844),o=r(273),a=r(742),c=r(242),f=r(351),u=function(){function e(e){this.table=new Uint8Array(e)}return e.prototype.setDefault=function(e,t){o.fill(this.table,e<<4|t)},e.prototype.add=function(e,t,r,i){this.table[t<<8|e]=r<<4|i},e.prototype.addMany=function(e,t,r,i){for(var n=0;n1)throw new Error("only one byte as prefix supported");if((r=e.prefix.charCodeAt(0))&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(var i=0;in||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=n}}if(1!==e.final.length)throw new Error("final must be a single byte");var s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error("final must be in range "+t[0]+" .. "+t[1]);return(r<<=8)|s},r.prototype.identToString=function(e){for(var t=[];e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")},r.prototype.dispose=function(){this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null),this._oscParser.dispose(),this._dcsParser.dispose()},r.prototype.setPrintHandler=function(e){this._printHandler=e},r.prototype.clearPrintHandler=function(){this._printHandler=this._printHandlerFb},r.prototype.registerEscHandler=function(e,t){var r=this._identifier(e,[48,126]);void 0===this._escHandlers[r]&&(this._escHandlers[r]=[]);var i=this._escHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.clearEscHandler=function(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]},r.prototype.setEscHandlerFallback=function(e){this._escHandlerFb=e},r.prototype.setExecuteHandler=function(e,t){this._executeHandlers[e.charCodeAt(0)]=t},r.prototype.clearExecuteHandler=function(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]},r.prototype.setExecuteHandlerFallback=function(e){this._executeHandlerFb=e},r.prototype.registerCsiHandler=function(e,t){var r=this._identifier(e);void 0===this._csiHandlers[r]&&(this._csiHandlers[r]=[]);var i=this._csiHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.clearCsiHandler=function(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]},r.prototype.setCsiHandlerFallback=function(e){this._csiHandlerFb=e},r.prototype.registerDcsHandler=function(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)},r.prototype.clearDcsHandler=function(e){this._dcsParser.clearHandler(this._identifier(e))},r.prototype.setDcsHandlerFallback=function(e){this._dcsParser.setHandlerFallback(e)},r.prototype.registerOscHandler=function(e,t){return this._oscParser.registerHandler(e,t)},r.prototype.clearOscHandler=function(e){this._oscParser.clearHandler(e)},r.prototype.setOscHandlerFallback=function(e){this._oscParser.setHandlerFallback(e)},r.prototype.setErrorHandler=function(e){this._errorHandler=e},r.prototype.clearErrorHandler=function(){this._errorHandler=this._errorHandlerFb},r.prototype.reset=function(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])},r.prototype._preserveStack=function(e,t,r,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=i,this._parseStack.chunkPos=n},r.prototype.parse=function(e,t,r){var i,n=0,s=0,o=0;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===r||1===this._parseStack.state)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");var a=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===r&&c>-1)for(;c>=0&&!0!==(i=a[c](this._params));c--)if(i instanceof Promise)return this._parseStack.handlerPos=c,i;this._parseStack.handlers=[];break;case 4:if(!1===r&&c>-1)for(;c>=0&&!0!==(i=a[c]());c--)if(i instanceof Promise)return this._parseStack.handlerPos=c,i;this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],i=this._dcsParser.unhook(24!==n&&26!==n,r))return i;27===n&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],i=this._oscParser.end(24!==n&&26!==n,r))return i;27===n&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(var f=o;f>4){case 2:for(var u=f+1;;++u){if(u>=t||(n=e[u])<32||n>126&&n=t||(n=e[u])<32||n>126&&n=t||(n=e[u])<32||n>126&&n=t||(n=e[u])<32||n>126&&n=0&&!0!==(i=a[l](this._params));l--)if(i instanceof Promise)return this._preserveStack(3,a,l,s,f),i;l<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingCodepoint=0;break;case 8:do{switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}}while(++f47&&n<60);f--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:for(var _=this._escHandlers[this._collect<<8|n],p=_?_.length-1:-1;p>=0&&!0!==(i=_[p]());p--)if(i instanceof Promise)return this._preserveStack(4,_,p,s,f),i;p<0&&this._escHandlerFb(this._collect<<8|n),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(var d=f+1;;++d)if(d>=t||24===(n=e[d])||26===n||27===n||n>127&&n=t||(n=e[v])<32||n>127&&n{Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;var i=r(770),n=r(482),s=[],o=function(){function e(){this._state=0,this._active=s,this._id=-1,this._handlers=Object.create(null),this._handlerFb=function(){},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}return e.prototype.registerHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){},this._active=s},e.prototype.reset=function(){if(2===this._state)for(var e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=s,this._id=-1,this._state=0},e.prototype._start=function(){if(this._active=this._handlers[this._id]||s,this._active.length)for(var e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")},e.prototype._put=function(e,t,r){if(this._active.length)for(var i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,r);else this._handlerFb(this._id,"PUT",n.utf32ToString(e,t,r))},e.prototype.start=function(){this.reset(),this._state=1},e.prototype.put=function(e,t,r){if(3!==this._state){if(1===this._state)for(;t0&&this._put(e,t,r)}},e.prototype.end=function(e,t){if(void 0===t&&(t=!0),0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){var r=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;i>=0&&!0!==(r=this._active[i].end(e));i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if((r=this._active[i].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}else this._handlerFb(this._id,"END",e);this._active=s,this._id=-1,this._state=0}},e}();t.OscParser=o;var a=function(){function e(e){this._handler=e,this._data="",this._hitLimit=!1}return e.prototype.start=function(){this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,r){this._hitLimit||(this._data+=n.utf32ToString(e,t,r),this._data.length>i.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.end=function(e){var t=this,r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data))instanceof Promise)return r.then((function(e){return t._data="",t._hitLimit=!1,e}));return this._data="",this._hitLimit=!1,r},e}();t.OscHandler=a},742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Params=void 0;var r=2147483647,i=function(){function e(e,t){if(void 0===e&&(e=32),void 0===t&&(t=32),this.maxLength=e,this.maxSubParamsLength=t,t>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}return e.fromArray=function(t){var r=new e;if(!t.length)return r;for(var i=t[0]instanceof Array?1:0;i>8,i=255&this._subParamsIdx[t];i-r>0&&e.push(Array.prototype.slice.call(this._subParams,r,i))}return e},e.prototype.reset=function(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1},e.prototype.addParam=function(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>r?r:e}},e.prototype.addSubParam=function(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>r?r:e,this._subParamsIdx[this.length-1]++}},e.prototype.hasSubParams=function(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0},e.prototype.getSubParams=function(e){var t=this._subParamsIdx[e]>>8,r=255&this._subParamsIdx[e];return r-t>0?this._subParams.subarray(t,r):null},e.prototype.getSubParamsAll=function(){for(var e={},t=0;t>8,i=255&this._subParamsIdx[t];i-r>0&&(e[t]=this._subParams.slice(r,i))}return e},e.prototype.addDigit=function(e){var t;if(!(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)){var i=this._digitIsSub?this._subParams:this.params,n=i[t-1];i[t-1]=~n?Math.min(10*n+e,r):e}},e}();t.Params=i},741:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0;var r=function(){function e(){this._addons=[]}return e.prototype.dispose=function(){for(var e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()},e.prototype.loadAddon=function(e,t){var r=this,i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=function(){return r._wrappedAddonDispose(i)},t.activate(e)},e.prototype._wrappedAddonDispose=function(e){if(!e.isDisposed){for(var t=-1,r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferApiView=void 0;var i=r(785),n=r(511),s=function(){function e(e,t){this._buffer=e,this.type=t}return e.prototype.init=function(e){return this._buffer=e,this},Object.defineProperty(e.prototype,"cursorY",{get:function(){return this._buffer.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cursorX",{get:function(){return this._buffer.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportY",{get:function(){return this._buffer.ydisp},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseY",{get:function(){return this._buffer.ybase},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._buffer.lines.length},enumerable:!1,configurable:!0}),e.prototype.getLine=function(e){var t=this._buffer.lines.get(e);if(t)return new i.BufferLineApiView(t)},e.prototype.getNullCell=function(){return new n.CellData},e}();t.BufferApiView=s},785:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLineApiView=void 0;var i=r(511),n=function(){function e(e){this._line=e}return Object.defineProperty(e.prototype,"isWrapped",{get:function(){return this._line.isWrapped},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._line.length},enumerable:!1,configurable:!0}),e.prototype.getCell=function(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new i.CellData)},e.prototype.translateToString=function(e,t,r){return this._line.translateToString(e,t,r)},e}();t.BufferLineApiView=n},285:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferNamespaceApi=void 0;var i=r(771),n=r(460),s=function(){function e(e){var t=this;this._core=e,this._onBufferChange=new n.EventEmitter,this._normal=new i.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new i.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((function(){return t._onBufferChange.fire(t.active)}))}return Object.defineProperty(e.prototype,"onBufferChange",{get:function(){return this._onBufferChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"active",{get:function(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal.init(this._core.buffers.normal)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alternate",{get:function(){return this._alternate.init(this._core.buffers.alt)},enumerable:!1,configurable:!0}),e}();t.BufferNamespaceApi=s},975:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ParserApi=void 0;var r=function(){function e(e){this._core=e}return e.prototype.registerCsiHandler=function(e,t){return this._core.registerCsiHandler(e,(function(e){return t(e.toArray())}))},e.prototype.addCsiHandler=function(e,t){return this.registerCsiHandler(e,t)},e.prototype.registerDcsHandler=function(e,t){return this._core.registerDcsHandler(e,(function(e,r){return t(e,r.toArray())}))},e.prototype.addDcsHandler=function(e,t){return this.registerDcsHandler(e,t)},e.prototype.registerEscHandler=function(e,t){return this._core.registerEscHandler(e,t)},e.prototype.addEscHandler=function(e,t){return this.registerEscHandler(e,t)},e.prototype.registerOscHandler=function(e,t){return this._core.registerOscHandler(e,t)},e.prototype.addOscHandler=function(e,t){return this.registerOscHandler(e,t)},e}();t.ParserApi=r},90:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeApi=void 0;var r=function(){function e(e){this._core=e}return e.prototype.register=function(e){this._core.unicodeService.register(e)},Object.defineProperty(e.prototype,"versions",{get:function(){return this._core.unicodeService.versions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeVersion",{get:function(){return this._core.unicodeService.activeVersion},set:function(e){this._core.unicodeService.activeVersion=e},enumerable:!1,configurable:!0}),e}();t.UnicodeApi=r},744:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},o=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;var a=r(585),c=r(295),f=r(460),u=r(844);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;var h=function(e){function r(r){var i=e.call(this)||this;return i._optionsService=r,i.isUserScrolling=!1,i._onResize=new f.EventEmitter,i._onScroll=new f.EventEmitter,i.cols=Math.max(r.options.cols||0,t.MINIMUM_COLS),i.rows=Math.max(r.options.rows||0,t.MINIMUM_ROWS),i.buffers=new c.BufferSet(r,i),i}return n(r,e),Object.defineProperty(r.prototype,"onResize",{get:function(){return this._onResize.event},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){e.prototype.dispose.call(this),this.buffers.dispose()},r.prototype.resize=function(e,t){this.cols=e,this.rows=t,this.buffers.resize(e,t),this.buffers.setupTabStops(this.cols),this._onResize.fire({cols:e,rows:t})},r.prototype.reset=function(){this.buffers.reset(),this.isUserScrolling=!1},r.prototype.scroll=function(e,t){void 0===t&&(t=!1);var r,i=this.buffer;(r=this._cachedBlankLine)&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=i.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;var n=i.ybase+i.scrollTop,s=i.ybase+i.scrollBottom;if(0===i.scrollTop){var o=i.lines.isFull;s===i.lines.length-1?o?i.lines.recycle().copyFrom(r):i.lines.push(r.clone()):i.lines.splice(s+1,0,r.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{var a=s-n+1;i.lines.shiftElements(n+1,a-1,-1),i.lines.set(s,r.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)},r.prototype.scrollLines=function(e,t,r){var i=this.buffer;if(e<0){if(0===i.ydisp)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);var n=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),n!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))},r.prototype.scrollPages=function(e){this.scrollLines(e*(this.rows-1))},r.prototype.scrollToTop=function(){this.scrollLines(-this.buffer.ydisp)},r.prototype.scrollToBottom=function(){this.scrollLines(this.buffer.ybase-this.buffer.ydisp)},r.prototype.scrollToLine=function(e){var t=e-this.buffer.ydisp;0!==t&&this.scrollLines(t)},s([o(0,a.IOptionsService)],r)}(u.Disposable);t.BufferService=h},994:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0;var r=function(){function e(){this.glevel=0,this._charsets=[]}return e.prototype.reset=function(){this.charset=void 0,this._charsets=[],this.glevel=0},e.prototype.setgLevel=function(e){this.glevel=e,this.charset=this._charsets[e]},e.prototype.setgCharset=function(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)},e}();t.CharsetService=r},753:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;var s=r(585),o=r(460),a={NONE:{events:0,restrict:function(){return!1}},X10:{events:1,restrict:function(e){return 4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)}},VT200:{events:19,restrict:function(e){return 32!==e.action}},DRAG:{events:23,restrict:function(e){return 32!==e.action||3!==e.button}},ANY:{events:31,restrict:function(e){return!0}}};function c(e,t){var r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(r|=64,r|=e.action):(r|=3&e.button,4&e.button&&(r|=64),8&e.button&&(r|=128),32===e.action?r|=32:0!==e.action||t||(r|=3)),r}var f=String.fromCharCode,u={DEFAULT:function(e){var t=[c(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":"[M"+f(t[0])+f(t[1])+f(t[2])},SGR:function(e){var t=0===e.action&&4!==e.button?"m":"M";return"[<"+c(e,!0)+";"+e.col+";"+e.row+t}},h=function(){function e(e,t){this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._onProtocolChange=new o.EventEmitter,this._lastEvent=null;for(var r=0,i=Object.keys(a);r=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows)return!1;if(4===e.button&&32===e.action)return!1;if(3===e.button&&32!==e.action)return!1;if(4!==e.button&&(2===e.action||3===e.action))return!1;if(e.col++,e.row++,32===e.action&&this._lastEvent&&this._compareEvents(this._lastEvent,e))return!1;if(!this._protocols[this._activeProtocol].restrict(e))return!1;var t=this._encodings[this._activeEncoding](e);return t&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0},e.prototype.explainEvents=function(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}},e.prototype._compareEvents=function(e,t){return e.col===t.col&&e.row===t.row&&e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift},i([n(0,s.IBufferService),n(1,s.ICoreService)],e)}();t.CoreMouseService=h},83:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},o=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;var a=r(585),c=r(460),f=r(439),u=r(844),h=Object.freeze({insertMode:!1}),l=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),_=function(e){function t(t,r,i,n){var s=e.call(this)||this;return s._bufferService=r,s._logService=i,s._optionsService=n,s.isCursorInitialized=!1,s.isCursorHidden=!1,s._onData=s.register(new c.EventEmitter),s._onUserInput=s.register(new c.EventEmitter),s._onBinary=s.register(new c.EventEmitter),s._scrollToBottom=t,s.register({dispose:function(){return s._scrollToBottom=void 0}}),s.modes=f.clone(h),s.decPrivateModes=f.clone(l),s}return n(t,e),Object.defineProperty(t.prototype,"onData",{get:function(){return this._onData.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onUserInput",{get:function(){return this._onUserInput.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this.modes=f.clone(h),this.decPrivateModes=f.clone(l)},t.prototype.triggerDataEvent=function(e,t){if(void 0===t&&(t=!1),!this._optionsService.options.disableStdin){var r=this._bufferService.buffer;r.ybase!==r.ydisp&&this._scrollToBottom(),t&&this._onUserInput.fire(),this._logService.debug('sending data "'+e+'"',(function(){return e.split("").map((function(e){return e.charCodeAt(0)}))})),this._onData.fire(e)}},t.prototype.triggerBinaryEvent=function(e){this._optionsService.options.disableStdin||(this._logService.debug('sending binary "'+e+'"',(function(){return e.split("").map((function(e){return e.charCodeAt(0)}))})),this._onBinary.fire(e))},s([o(1,a.IBufferService),o(2,a.ILogService),o(3,a.IOptionsService)],t)}(u.Disposable);t.CoreService=_},730:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirtyRowService=void 0;var s=r(585),o=function(){function e(e){this._bufferService=e,this.clearRange()}return Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!1,configurable:!0}),e.prototype.clearRange=function(){this._start=this._bufferService.buffer.y,this._end=this._bufferService.buffer.y},e.prototype.markDirty=function(e){ethis._end&&(this._end=e)},e.prototype.markRangeDirty=function(e,t){if(e>t){var r=e;e=t,t=r}ethis._end&&(this._end=t)},e.prototype.markAllDirty=function(){this.markRangeDirty(0,this._bufferService.rows-1)},i([n(0,s.IBufferService)],e)}();t.DirtyRowService=o},348:function(e,t,r){var i=this&&this.__spreadArray||function(e,t){for(var r=0,i=t.length,n=e.length;r0?n[0].index:t.length;if(t.length!==h)throw new Error("[createInstance] First service dependency of "+e.name+" at position "+(h+1)+" conflicts with "+t.length+" static arguments");return new(e.bind.apply(e,i([void 0],i(i([],t),o))))},e}();t.InstantiationService=a},866:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}},s=this&&this.__spreadArray||function(e,t){for(var r=0,i=t.length,n=e.length;r{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=t.DEFAULT_BELL_SOUND=void 0;var i=r(460),n=r(114),s=r(439);t.DEFAULT_BELL_SOUND="data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",t.DEFAULT_OPTIONS=Object.freeze({cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,customGlyphs:!0,bellSound:t.DEFAULT_BELL_SOUND,bellStyle:"none",drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",lineHeight:1,linkTooltipHoverDuration:500,letterSpacing:0,logLevel:"info",scrollback:1e3,scrollSensitivity:1,screenReaderMode:!1,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!0,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:n.isMac,rendererType:"canvas",windowOptions:{},windowsMode:!1,wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1});var o=["normal","bold","100","200","300","400","500","600","700","800","900"],a=["cols","rows"],c=function(){function e(e){this._onOptionChange=new i.EventEmitter,this.options=s.clone(t.DEFAULT_OPTIONS);for(var r=0,n=Object.keys(e);r{function r(e,t,r){t.di$target===t?t.di$dependencies.push({id:e,index:r}):(t.di$dependencies=[{id:e,index:r}],t.di$target=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0,t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e.di$dependencies||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);var i=function(e,t,n){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");r(i,e,n)};return i.toString=function(){return e},t.serviceRegistry.set(e,i),i}},585:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IUnicodeService=t.LogLevelEnum=t.IOptionsService=t.ILogService=t.IInstantiationService=t.IDirtyRowService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;var i,n=r(343);t.IBufferService=n.createDecorator("BufferService"),t.ICoreMouseService=n.createDecorator("CoreMouseService"),t.ICoreService=n.createDecorator("CoreService"),t.ICharsetService=n.createDecorator("CharsetService"),t.IDirtyRowService=n.createDecorator("DirtyRowService"),t.IInstantiationService=n.createDecorator("InstantiationService"),t.ILogService=n.createDecorator("LogService"),t.IOptionsService=n.createDecorator("OptionsService"),(i=t.LogLevelEnum||(t.LogLevelEnum={}))[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.OFF=4]="OFF",t.IUnicodeService=n.createDecorator("UnicodeService")},480:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;var i=r(460),n=r(225),s=function(){function e(){this._providers=Object.create(null),this._active="",this._onChange=new i.EventEmitter;var e=new n.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}return Object.defineProperty(e.prototype,"onChange",{get:function(){return this._onChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"versions",{get:function(){return Object.keys(this._providers)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeVersion",{get:function(){return this._active},set:function(e){if(!this._providers[e])throw new Error('unknown Unicode version "'+e+'"');this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)},enumerable:!1,configurable:!0}),e.prototype.register=function(e){this._providers[e.version]=e},e.prototype.wcwidth=function(e){return this._activeProvider.wcwidth(e)},e.prototype.getStringCellWidth=function(e){for(var t=0,r=e.length,i=0;i=r)return t+this.wcwidth(n);var s=e.charCodeAt(i);56320<=s&&s<=57343?n=1024*(n-55296)+s-56320+65536:t+=this.wcwidth(s)}t+=this.wcwidth(n)}return t},e}();t.UnicodeService=s},781:function(e,t,r){var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;var s=r(437),o=r(969),a=r(460),c=function(e){function t(t){void 0===t&&(t={});var r=e.call(this,t)||this;return r._onBell=new a.EventEmitter,r._onCursorMove=new a.EventEmitter,r._onTitleChange=new a.EventEmitter,r._onA11yCharEmitter=new a.EventEmitter,r._onA11yTabEmitter=new a.EventEmitter,r._setup(),r.register(r._inputHandler.onRequestBell((function(){return r.bell()}))),r.register(r._inputHandler.onRequestReset((function(){return r.reset()}))),r.register(a.forwardEvent(r._inputHandler.onCursorMove,r._onCursorMove)),r.register(a.forwardEvent(r._inputHandler.onTitleChange,r._onTitleChange)),r.register(a.forwardEvent(r._inputHandler.onA11yChar,r._onA11yCharEmitter)),r.register(a.forwardEvent(r._inputHandler.onA11yTab,r._onA11yTabEmitter)),r}return n(t,e),Object.defineProperty(t.prototype,"options",{get:function(){return this.optionsService.options},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBell",{get:function(){return this._onBell.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTitleChange",{get:function(){return this._onTitleChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yChar",{get:function(){return this._onA11yCharEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yTab",{get:function(){return this._onA11yTabEmitter.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this._isDisposed||(e.prototype.dispose.call(this),this.write=function(){})},Object.defineProperty(t.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!1,configurable:!0}),t.prototype._updateOptions=function(t){switch(e.prototype._updateOptions.call(this,t),t){case"tabStopWidth":this.buffers.setupTabStops()}},Object.defineProperty(t.prototype,"markers",{get:function(){return this.buffer.markers},enumerable:!1,configurable:!0}),t.prototype.addMarker=function(e){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)},t.prototype.bell=function(){this._onBell.fire()},t.prototype.resize=function(t,r){t===this.cols&&r===this.rows||e.prototype.resize.call(this,t,r)},t.prototype.clear=function(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(var e=1;e{var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.Terminal=void 0;var t=r(285),n=r(975),s=r(90),o=r(781),a=r(741),c=function(){function e(e){this._core=new o.Terminal(e),this._addonManager=new a.AddonManager}return e.prototype._checkProposedApi=function(){if(!this._core.optionsService.options.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")},Object.defineProperty(e.prototype,"onBell",{get:function(){return this._core.onBell},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBinary",{get:function(){return this._core.onBinary},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCursorMove",{get:function(){return this._core.onCursorMove},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onData",{get:function(){return this._core.onData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onLineFeed",{get:function(){return this._core.onLineFeed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onResize",{get:function(){return this._core.onResize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScroll",{get:function(){return this._core.onScroll},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTitleChange",{get:function(){return this._core.onTitleChange},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parser",{get:function(){return this._checkProposedApi(),this._parser||(this._parser=new n.ParserApi(this._core)),this._parser},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unicode",{get:function(){return this._checkProposedApi(),new s.UnicodeApi(this._core)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._core.rows},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cols",{get:function(){return this._core.cols},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._checkProposedApi(),this._buffer||(this._buffer=new t.BufferNamespaceApi(this._core)),this._buffer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"markers",{get:function(){return this._checkProposedApi(),this._core.markers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"modes",{get:function(){var e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,wraparoundMode:e.wraparound}},enumerable:!1,configurable:!0}),e.prototype.resize=function(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)},e.prototype.registerMarker=function(e){return this._checkProposedApi(),this._verifyIntegers(e),this._core.addMarker(e)},e.prototype.addMarker=function(e){return this.registerMarker(e)},e.prototype.dispose=function(){this._addonManager.dispose(),this._core.dispose()},e.prototype.scrollLines=function(e){this._verifyIntegers(e),this._core.scrollLines(e)},e.prototype.scrollPages=function(e){this._verifyIntegers(e),this._core.scrollPages(e)},e.prototype.scrollToTop=function(){this._core.scrollToTop()},e.prototype.scrollToBottom=function(){this._core.scrollToBottom()},e.prototype.scrollToLine=function(e){this._verifyIntegers(e),this._core.scrollToLine(e)},e.prototype.clear=function(){this._core.clear()},e.prototype.write=function(e,t){this._core.write(e,t)},e.prototype.writeUtf8=function(e,t){this._core.write(e,t)},e.prototype.writeln=function(e,t){this._core.write(e),this._core.write("\r\n",t)},e.prototype.getOption=function(e){return this._core.optionsService.getOption(e)},e.prototype.setOption=function(e,t){this._core.optionsService.setOption(e,t)},e.prototype.reset=function(){this._core.reset()},e.prototype.loadAddon=function(e){return this._addonManager.loadAddon(this,e)},e.prototype._verifyIntegers=function(){for(var e=[],t=0;t {
- (listener: (arg1: T, arg2: U) => any): IDisposable;
- }
-
- /**
- * Represents a specific line in the terminal that is tracked when scrollback
- * is trimmed and lines are added or removed. This is a single line that may
- * be part of a larger wrapped line.
- */
- export interface IMarker extends IDisposable {
- /**
- * A unique identifier for this marker.
- */
- readonly id: number;
-
- /**
- * Whether this marker is disposed.
- */
- readonly isDisposed: boolean;
-
- /**
- * The actual line index in the buffer at this point in time. This is set to
- * -1 if the marker has been disposed.
- */
- readonly line: number;
-
- /**
- * Event listener to get notified when the marker gets disposed. Automatic disposal
- * might happen for a marker, that got invalidated by scrolling out or removal of
- * a line from the buffer.
- */
- onDispose: IEvent;
- }
-
- /**
- * The set of localizable strings.
- */
- export interface ILocalizableStrings {
- /**
- * The aria label for the underlying input textarea for the terminal.
- */
- promptLabel: string;
-
- /**
- * Announcement for when line reading is suppressed due to too many lines
- * being printed to the terminal when `screenReaderMode` is enabled.
- */
- tooMuchOutput: string;
- }
-
- /**
- * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t).
- *
- * Most settings have no default implementation, as they heavily rely on
- * the embedding environment.
- *
- * To implement a feature, create a custom CSI hook like this:
- * ```ts
- * term.parser.addCsiHandler({final: 't'}, params => {
- * const ps = params[0];
- * switch (ps) {
- * case XY:
- * ... // your implementation for option XY
- * return true; // signal Ps=XY was handled
- * }
- * return false; // any Ps that was not handled
- * });
- * ```
- *
- * Note on security:
- * Most features are meant to deal with some information of the host machine
- * where the terminal runs on. This is seen as a security risk possibly leaking
- * sensitive data of the host to the program in the terminal. Therefore all options
- * (even those without a default implementation) are guarded by the boolean flag
- * and disabled by default.
- */
- export interface IWindowOptions {
- /**
- * Ps=1 De-iconify window.
- * No default implementation.
- */
- restoreWin?: boolean;
- /**
- * Ps=2 Iconify window.
- * No default implementation.
- */
- minimizeWin?: boolean;
- /**
- * Ps=3 ; x ; y
- * Move window to [x, y].
- * No default implementation.
- */
- setWinPosition?: boolean;
- /**
- * Ps = 4 ; height ; width
- * Resize the window to given `height` and `width` in pixels.
- * Omitted parameters should reuse the current height or width.
- * Zero parameters should use the display's height or width.
- * No default implementation.
- */
- setWinSizePixels?: boolean;
- /**
- * Ps=5 Raise the window to the front of the stacking order.
- * No default implementation.
- */
- raiseWin?: boolean;
- /**
- * Ps=6 Lower the xterm window to the bottom of the stacking order.
- * No default implementation.
- */
- lowerWin?: boolean;
- /** Ps=7 Refresh the window. */
- refreshWin?: boolean;
- /**
- * Ps = 8 ; height ; width
- * Resize the text area to given height and width in characters.
- * Omitted parameters should reuse the current height or width.
- * Zero parameters use the display's height or width.
- * No default implementation.
- */
- setWinSizeChars?: boolean;
- /**
- * Ps=9 ; 0 Restore maximized window.
- * Ps=9 ; 1 Maximize window (i.e., resize to screen size).
- * Ps=9 ; 2 Maximize window vertically.
- * Ps=9 ; 3 Maximize window horizontally.
- * No default implementation.
- */
- maximizeWin?: boolean;
- /**
- * Ps=10 ; 0 Undo full-screen mode.
- * Ps=10 ; 1 Change to full-screen.
- * Ps=10 ; 2 Toggle full-screen.
- * No default implementation.
- */
- fullscreenWin?: boolean;
- /** Ps=11 Report xterm window state.
- * If the xterm window is non-iconified, it returns "CSI 1 t".
- * If the xterm window is iconified, it returns "CSI 2 t".
- * No default implementation.
- */
- getWinState?: boolean;
- /**
- * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t".
- * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t".
- * No default implementation.
- */
- getWinPosition?: boolean;
- /**
- * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t".
- * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t".
- * Has a default implementation.
- */
- getWinSizePixels?: boolean;
- /**
- * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t".
- * No default implementation.
- */
- getScreenSizePixels?: boolean;
- /**
- * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t".
- * Has a default implementation.
- */
- getCellSizePixels?: boolean;
- /**
- * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t".
- * Has a default implementation.
- */
- getWinSizeChars?: boolean;
- /**
- * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t".
- * No default implementation.
- */
- getScreenSizeChars?: boolean;
- /**
- * Ps=20 Report xterm window's icon label. Result is "OSC L label ST".
- * No default implementation.
- */
- getIconTitle?: boolean;
- /**
- * Ps=21 Report xterm window's title. Result is "OSC l label ST".
- * No default implementation.
- */
- getWinTitle?: boolean;
- /**
- * Ps=22 ; 0 Save xterm icon and window title on stack.
- * Ps=22 ; 1 Save xterm icon title on stack.
- * Ps=22 ; 2 Save xterm window title on stack.
- * All variants have a default implementation.
- */
- pushTitle?: boolean;
- /**
- * Ps=23 ; 0 Restore xterm icon and window title from stack.
- * Ps=23 ; 1 Restore xterm icon title from stack.
- * Ps=23 ; 2 Restore xterm window title from stack.
- * All variants have a default implementation.
- */
- popTitle?: boolean;
- /**
- * Ps>=24 Resize to Ps lines (DECSLPP).
- * DECSLPP is not implemented. This settings is also used to
- * enable / disable DECCOLM (earlier variant of DECSLPP).
- */
- setWinLines?: boolean;
- }
-
- /**
- * The class that represents an xterm.js terminal.
- */
- export class Terminal implements IDisposable {
- /**
- * The number of rows in the terminal's viewport. Use
- * `ITerminalOptions.rows` to set this in the constructor and
- * `Terminal.resize` for when the terminal exists.
- */
- readonly rows: number;
-
- /**
- * The number of columns in the terminal's viewport. Use
- * `ITerminalOptions.cols` to set this in the constructor and
- * `Terminal.resize` for when the terminal exists.
- */
- readonly cols: number;
-
- /**
- * (EXPERIMENTAL) The terminal's current buffer, this might be either the
- * normal buffer or the alt buffer depending on what's running in the
- * terminal.
- */
- readonly buffer: IBufferNamespace;
-
- /**
- * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
- * buffer is active this will always return [].
- */
- readonly markers: ReadonlyArray;
-
- /**
- * (EXPERIMENTAL) Get the parser interface to register
- * custom escape sequence handlers.
- */
- readonly parser: IParser;
-
- /**
- * (EXPERIMENTAL) Get the Unicode handling interface
- * to register and switch Unicode version.
- */
- readonly unicode: IUnicodeHandling;
-
- /**
- * Gets the terminal modes as set by SM/DECSET.
- */
- readonly modes: IModes;
-
- /**
- * Natural language strings that can be localized.
- */
- static strings: ILocalizableStrings;
-
- /**
- * Creates a new `Terminal` object.
- *
- * @param options An object containing a set of options.
- */
- constructor(options?: ITerminalOptions);
-
- /**
- * Adds an event listener for when the bell is triggered.
- * @returns an `IDisposable` to stop listening.
- */
- onBell: IEvent;
-
- /**
- * Adds an event listener for when a binary event fires. This is used to
- * enable non UTF-8 conformant binary messages to be sent to the backend.
- * Currently this is only used for a certain type of mouse reports that
- * happen to be not UTF-8 compatible.
- * The event value is a JS string, pass it to the underlying pty as
- * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`.
- * @returns an `IDisposable` to stop listening.
- */
- onBinary: IEvent;
-
- /**
- * Adds an event listener for the cursor moves.
- * @returns an `IDisposable` to stop listening.
- */
- onCursorMove: IEvent;
-
- /**
- * Adds an event listener for when a data event fires. This happens for
- * example when the user types or pastes into the terminal. The event value
- * is whatever `string` results, in a typical setup, this should be passed
- * on to the backing pty.
- * @returns an `IDisposable` to stop listening.
- */
- onData: IEvent;
-
- /**
- * Adds an event listener for when a line feed is added.
- * @returns an `IDisposable` to stop listening.
- */
- onLineFeed: IEvent;
-
- /**
- * Adds an event listener for when the terminal is resized. The event value
- * contains the new size.
- * @returns an `IDisposable` to stop listening.
- */
- onResize: IEvent<{ cols: number, rows: number }>;
-
- /**
- * Adds an event listener for when a scroll occurs. The event value is the
- * new position of the viewport.
- * @returns an `IDisposable` to stop listening.
- */
- onScroll: IEvent;
-
- /**
- * Adds an event listener for when an OSC 0 or OSC 2 title change occurs.
- * The event value is the new title.
- * @returns an `IDisposable` to stop listening.
- */
- onTitleChange: IEvent;
-
- /**
- * Resizes the terminal. It's best practice to debounce calls to resize,
- * this will help ensure that the pty can respond to the resize event
- * before another one occurs.
- * @param x The number of columns to resize to.
- * @param y The number of rows to resize to.
- */
- resize(columns: number, rows: number): void;
-
- /**
- * (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the
- * alt buffer is active, undefined is returned.
- * @param cursorYOffset The y position offset of the marker from the cursor.
- * @returns The new marker or undefined.
- */
- registerMarker(cursorYOffset: number): IMarker | undefined;
-
- /**
- * @deprecated use `registerMarker` instead.
- */
- addMarker(cursorYOffset: number): IMarker | undefined;
-
- /*
- * Disposes of the terminal, detaching it from the DOM and removing any
- * active listeners.
- */
- dispose(): void;
-
- /**
- * Scroll the display of the terminal
- * @param amount The number of lines to scroll down (negative scroll up).
- */
- scrollLines(amount: number): void;
-
- /**
- * Scroll the display of the terminal by a number of pages.
- * @param pageCount The number of pages to scroll (negative scrolls up).
- */
- scrollPages(pageCount: number): void;
-
- /**
- * Scrolls the display of the terminal to the top.
- */
- scrollToTop(): void;
-
- /**
- * Scrolls the display of the terminal to the bottom.
- */
- scrollToBottom(): void;
-
- /**
- * Scrolls to a line within the buffer.
- * @param line The 0-based line index to scroll to.
- */
- scrollToLine(line: number): void;
-
- /**
- * Clear the entire buffer, making the prompt line the new first line.
- */
- clear(): void;
-
- /**
- * Write data to the terminal.
- * @param data The data to write to the terminal. This can either be raw
- * bytes given as Uint8Array from the pty or a string. Raw bytes will always
- * be treated as UTF-8 encoded, string data as UTF-16.
- * @param callback Optional callback that fires when the data was processed
- * by the parser.
- */
- write(data: string | Uint8Array, callback?: () => void): void;
-
- /**
- * Writes data to the terminal, followed by a break line character (\n).
- * @param data The data to write to the terminal. This can either be raw
- * bytes given as Uint8Array from the pty or a string. Raw bytes will always
- * be treated as UTF-8 encoded, string data as UTF-16.
- * @param callback Optional callback that fires when the data was processed
- * by the parser.
- */
- writeln(data: string | Uint8Array, callback?: () => void): void;
-
- /**
- * Write UTF8 data to the terminal.
- * @param data The data to write to the terminal.
- * @param callback Optional callback when data was processed.
- * @deprecated use `write` instead
- */
- writeUtf8(data: Uint8Array, callback?: () => void): void;
-
- /**
- * Retrieves an option's value from the terminal.
- * @param key The option key.
- */
- getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
- /**
- * Retrieves an option's value from the terminal.
- * @param key The option key.
- */
- getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean;
- /**
- * Retrieves an option's value from the terminal.
- * @param key The option key.
- */
- getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
- /**
- * Retrieves an option's value from the terminal.
- * @param key The option key.
- */
- getOption(key: string): any;
-
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'logLevel', value: LogLevel): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'theme', value: ITheme): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: 'cols' | 'rows', value: number): void;
- /**
- * Sets an option on the terminal.
- * @param key The option key.
- * @param value The option value.
- */
- setOption(key: string, value: any): void;
-
- /**
- * Perform a full reset (RIS, aka '\x1bc').
- */
- reset(): void;
-
- /**
- * Loads an addon into this instance of xterm.js.
- * @param addon The addon to load.
- */
- loadAddon(addon: ITerminalAddon): void;
- }
-
- /**
- * An addon that can provide additional functionality to the terminal.
- */
- export interface ITerminalAddon extends IDisposable {
- /**
- * This is called when the addon is activated.
- */
- activate(terminal: Terminal): void;
- }
-
- /**
- * An object representing a selection within the terminal.
- */
- interface ISelectionPosition {
- /**
- * The start column of the selection.
- */
- startColumn: number;
-
- /**
- * The start row of the selection.
- */
- startRow: number;
-
- /**
- * The end column of the selection.
- */
- endColumn: number;
-
- /**
- * The end row of the selection.
- */
- endRow: number;
- }
-
- /**
- * An object representing a range within the viewport of the terminal.
- */
- export interface IViewportRange {
- /**
- * The start of the range.
- */
- start: IViewportRangePosition;
-
- /**
- * The end of the range.
- */
- end: IViewportRangePosition;
- }
-
- /**
- * An object representing a cell position within the viewport of the terminal.
- */
- interface IViewportRangePosition {
- /**
- * The x position of the cell. This is a 0-based index that refers to the
- * space in between columns, not the column itself. Index 0 refers to the
- * left side of the viewport, index `Terminal.cols` refers to the right side
- * of the viewport. This can be thought of as how a cursor is positioned in
- * a text editor.
- */
- x: number;
-
- /**
- * The y position of the cell. This is a 0-based index that refers to a
- * specific row.
- */
- y: number;
- }
-
- /**
- * A range within a buffer.
- */
- interface IBufferRange {
- /**
- * The start position of the range.
- */
- start: IBufferCellPosition;
-
- /**
- * The end position of the range.
- */
- end: IBufferCellPosition;
- }
-
- /**
- * A position within a buffer.
- */
- interface IBufferCellPosition {
- /**
- * The x position within the buffer.
- */
- x: number;
-
- /**
- * The y position within the buffer.
- */
- y: number;
- }
-
- /**
- * Represents a terminal buffer.
- */
- interface IBuffer {
- /**
- * The type of the buffer.
- */
- readonly type: 'normal' | 'alternate';
-
- /**
- * The y position of the cursor. This ranges between `0` (when the
- * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the
- * last row).
- */
- readonly cursorY: number;
-
- /**
- * The x position of the cursor. This ranges between `0` (left side) and
- * `Terminal.cols` (after last cell of the row).
- */
- readonly cursorX: number;
-
- /**
- * The line within the buffer where the top of the viewport is.
- */
- readonly viewportY: number;
-
- /**
- * The line within the buffer where the top of the bottom page is (when
- * fully scrolled down).
- */
- readonly baseY: number;
-
- /**
- * The amount of lines in the buffer.
- */
- readonly length: number;
-
- /**
- * Gets a line from the buffer, or undefined if the line index does not
- * exist.
- *
- * Note that the result of this function should be used immediately after
- * calling as when the terminal updates it could lead to unexpected
- * behavior.
- *
- * @param y The line index to get.
- */
- getLine(y: number): IBufferLine | undefined;
-
- /**
- * Creates an empty cell object suitable as a cell reference in
- * `line.getCell(x, cell)`. Use this to avoid costly recreation of
- * cell objects when dealing with tons of cells.
- */
- getNullCell(): IBufferCell;
- }
-
- /**
- * Represents the terminal's set of buffers.
- */
- interface IBufferNamespace {
- /**
- * The active buffer, this will either be the normal or alternate buffers.
- */
- readonly active: IBuffer;
-
- /**
- * The normal buffer.
- */
- readonly normal: IBuffer;
-
- /**
- * The alternate buffer, this becomes the active buffer when an application
- * enters this mode via DECSET (`CSI ? 4 7 h`)
- */
- readonly alternate: IBuffer;
-
- /**
- * Adds an event listener for when the active buffer changes.
- * @returns an `IDisposable` to stop listening.
- */
- onBufferChange: IEvent;
- }
-
- /**
- * Represents a line in the terminal's buffer.
- */
- interface IBufferLine {
- /**
- * Whether the line is wrapped from the previous line.
- */
- readonly isWrapped: boolean;
-
- /**
- * The length of the line, all call to getCell beyond the length will result
- * in `undefined`.
- */
- readonly length: number;
-
- /**
- * Gets a cell from the line, or undefined if the line index does not exist.
- *
- * Note that the result of this function should be used immediately after
- * calling as when the terminal updates it could lead to unexpected
- * behavior.
- *
- * @param x The character index to get.
- * @param cell Optional cell object to load data into for performance
- * reasons. This is mainly useful when every cell in the buffer is being
- * looped over to avoid creating new objects for every cell.
- */
- getCell(x: number, cell?: IBufferCell): IBufferCell | undefined;
-
- /**
- * Gets the line as a string. Note that this is gets only the string for the
- * line, not taking isWrapped into account.
- *
- * @param trimRight Whether to trim any whitespace at the right of the line.
- * @param startColumn The column to start from (inclusive).
- * @param endColumn The column to end at (exclusive).
- */
- translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
- }
-
- /**
- * Represents a single cell in the terminal's buffer.
- */
- interface IBufferCell {
- /**
- * The width of the character. Some examples:
- *
- * - `1` for most cells.
- * - `2` for wide character like CJK glyphs.
- * - `0` for cells immediately following cells with a width of `2`.
- */
- getWidth(): number;
-
- /**
- * The character(s) within the cell. Examples of what this can contain:
- *
- * - A normal width character
- * - A wide character (eg. CJK)
- * - An emoji
- */
- getChars(): string;
-
- /**
- * Gets the UTF32 codepoint of single characters, if content is a combined
- * string it returns the codepoint of the last character in the string.
- */
- getCode(): number;
-
- /**
- * Gets the number representation of the foreground color mode, this can be
- * used to perform quick comparisons of 2 cells to see if they're the same.
- * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode
- * a cell is.
- */
- getFgColorMode(): number;
-
- /**
- * Gets the number representation of the background color mode, this can be
- * used to perform quick comparisons of 2 cells to see if they're the same.
- * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode
- * a cell is.
- */
- getBgColorMode(): number;
-
- /**
- * Gets a cell's foreground color number, this differs depending on what the
- * color mode of the cell is:
- *
- * - Default: This should be 0, representing the default foreground color
- * (CSI 39 m).
- * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m,
- * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m).
- * - RGB: A hex value representing a 'true color': 0xRRGGBB.
- * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb)
- */
- getFgColor(): number;
-
- /**
- * Gets a cell's background color number, this differs depending on what the
- * color mode of the cell is:
- *
- * - Default: This should be 0, representing the default background color
- * (CSI 49 m).
- * - Palette: This is a number from 0 to 255 of ANSI colors
- * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m).
- * - RGB: A hex value representing a 'true color': 0xRRGGBB
- * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb)
- */
- getBgColor(): number;
-
- /** Whether the cell has the bold attribute (CSI 1 m). */
- isBold(): number;
- /** Whether the cell has the inverse attribute (CSI 3 m). */
- isItalic(): number;
- /** Whether the cell has the inverse attribute (CSI 2 m). */
- isDim(): number;
- /** Whether the cell has the underline attribute (CSI 4 m). */
- isUnderline(): number;
- /** Whether the cell has the inverse attribute (CSI 5 m). */
- isBlink(): number;
- /** Whether the cell has the inverse attribute (CSI 7 m). */
- isInverse(): number;
- /** Whether the cell has the inverse attribute (CSI 8 m). */
- isInvisible(): number;
-
- /** Whether the cell is using the RGB foreground color mode. */
- isFgRGB(): boolean;
- /** Whether the cell is using the RGB background color mode. */
- isBgRGB(): boolean;
- /** Whether the cell is using the palette foreground color mode. */
- isFgPalette(): boolean;
- /** Whether the cell is using the palette background color mode. */
- isBgPalette(): boolean;
- /** Whether the cell is using the default foreground color mode. */
- isFgDefault(): boolean;
- /** Whether the cell is using the default background color mode. */
- isBgDefault(): boolean;
-
- /** Whether the cell has the default attribute (no color or style). */
- isAttributeDefault(): boolean;
- }
-
- /**
- * Data type to register a CSI, DCS or ESC callback in the parser
- * in the form:
- * ESC I..I F
- * CSI Prefix P..P I..I F
- * DCS Prefix P..P I..I F data_bytes ST
- *
- * with these rules/restrictions:
- * - prefix can only be used with CSI and DCS
- * - only one leading prefix byte is recognized by the parser
- * before any other parameter bytes (P..P)
- * - intermediate bytes are recognized up to 2
- *
- * For custom sequences make sure to read ECMA-48 and the resources at
- * vt100.net to not clash with existing sequences or reserved address space.
- * General recommendations:
- * - use private address space (see ECMA-48)
- * - use max one intermediate byte (technically not limited by the spec,
- * in practice there are no sequences with more than one intermediate byte,
- * thus parsers might get confused with more intermediates)
- * - test against other common emulators to check whether they escape/ignore
- * the sequence correctly
- *
- * Notes: OSC command registration is handled differently (see addOscHandler)
- * APC, PM or SOS is currently not supported.
- */
- export interface IFunctionIdentifier {
- /**
- * Optional prefix byte, must be in range \x3c .. \x3f.
- * Usable in CSI and DCS.
- */
- prefix?: string;
- /**
- * Optional intermediate bytes, must be in range \x20 .. \x2f.
- * Usable in CSI, DCS and ESC.
- */
- intermediates?: string;
- /**
- * Final byte, must be in range \x40 .. \x7e for CSI and DCS,
- * \x30 .. \x7e for ESC.
- */
- final: string;
- }
-
- /**
- * Allows hooking into the parser for custom handling of escape sequences.
- */
- export interface IParser {
- /**
- * Adds a handler for CSI escape sequences.
- * @param id Specifies the function identifier under which the callback
- * gets registered, e.g. {final: 'm'} for SGR.
- * @param callback The function to handle the sequence. The callback is
- * called with the numerical params. If the sequence has subparams the
- * array will contain subarrays with their numercial values.
- * Return true if the sequence was handled; false if we should try
- * a previous handler (set by addCsiHandler or setCsiHandler).
- * The most recently added handler is tried first.
- * @return An IDisposable you can call to remove this handler.
- */
- registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable;
-
- /**
- * Adds a handler for DCS escape sequences.
- * @param id Specifies the function identifier under which the callback
- * gets registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS.
- * @param callback The function to handle the sequence. Note that the
- * function will only be called once if the sequence finished sucessfully.
- * There is currently no way to intercept smaller data chunks, data chunks
- * will be stored up until the sequence is finished. Since DCS sequences
- * are not limited by the amount of data this might impose a problem for
- * big payloads. Currently xterm.js limits DCS payload to 10 MB
- * which should give enough room for most use cases.
- * The function gets the payload and numerical parameters as arguments.
- * Return true if the sequence was handled; false if we should try
- * a previous handler (set by addDcsHandler or setDcsHandler).
- * The most recently added handler is tried first.
- * @return An IDisposable you can call to remove this handler.
- */
- registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable;
-
- /**
- * Adds a handler for ESC escape sequences.
- * @param id Specifies the function identifier under which the callback
- * gets registered, e.g. {intermediates: '%' final: 'G'} for
- * default charset selection.
- * @param callback The function to handle the sequence.
- * Return true if the sequence was handled; false if we should try
- * a previous handler (set by addEscHandler or setEscHandler).
- * The most recently added handler is tried first.
- * @return An IDisposable you can call to remove this handler.
- */
- registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable;
-
- /**
- * Adds a handler for OSC escape sequences.
- * @param ident The number (first parameter) of the sequence.
- * @param callback The function to handle the sequence. Note that the
- * function will only be called once if the sequence finished sucessfully.
- * There is currently no way to intercept smaller data chunks, data chunks
- * will be stored up until the sequence is finished. Since OSC sequences
- * are not limited by the amount of data this might impose a problem for
- * big payloads. Currently xterm.js limits OSC payload to 10 MB
- * which should give enough room for most use cases.
- * The callback is called with OSC data string.
- * Return true if the sequence was handled; false if we should try
- * a previous handler (set by addOscHandler or setOscHandler).
- * The most recently added handler is tried first.
- * @return An IDisposable you can call to remove this handler.
- */
- registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable;
- }
-
- /**
- * (EXPERIMENTAL) Unicode version provider.
- * Used to register custom Unicode versions with `Terminal.unicode.register`.
- */
- export interface IUnicodeVersionProvider {
- /**
- * String indicating the Unicode version provided.
- */
- readonly version: string;
-
- /**
- * Unicode version dependent wcwidth implementation.
- */
- wcwidth(codepoint: number): 0 | 1 | 2;
- }
-
- /**
- * (EXPERIMENTAL) Unicode handling interface.
- */
- export interface IUnicodeHandling {
- /**
- * Register a custom Unicode version provider.
- */
- register(provider: IUnicodeVersionProvider): void;
-
- /**
- * Registered Unicode versions.
- */
- readonly versions: ReadonlyArray;
-
- /**
- * Getter/setter for active Unicode version.
- */
- activeVersion: string;
- }
-
- /**
- * Terminal modes as set by SM/DECSET.
- */
- export interface IModes {
- /**
- * Application Cursor Keys (DECCKM): `CSI ? 1 h`
- */
- readonly applicationCursorKeysMode: boolean;
- /**
- * Application Keypad Mode (DECNKM): `CSI ? 6 6 h`
- */
- readonly applicationKeypadMode: boolean;
- /**
- * Bracketed Paste Mode: `CSI ? 2 0 0 4 h`
- */
- readonly bracketedPasteMode: boolean;
- /**
- * Insert Mode (IRM): `CSI 4 h`
- */
- readonly insertMode: boolean;
- /**
- * Mouse Tracking, this can be one of the following:
- * - none: This is the default value and can be reset with DECRST
- * - x10: Send Mouse X & Y on button press `CSI ? 9 h`
- * - vt200: Send Mouse X & Y on button press and release `CSI ? 1 0 0 0 h`
- * - drag: Use Cell Motion Mouse Tracking `CSI ? 1 0 0 2 h`
- * - any: Use All Motion Mouse Tracking `CSI ? 1 0 0 3 h`
- */
- readonly mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any';
- /**
- * Origin Mode (DECOM): `CSI ? 6 h`
- */
- readonly originMode: boolean;
- /**
- * Reverse-wraparound Mode: `CSI ? 4 5 h`
- */
- readonly reverseWraparoundMode: boolean;
- /**
- * Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h`
- */
- readonly sendFocusMode: boolean;
- /**
- * Auto-Wrap Mode (DECAWM): `CSI ? 7 h`
- */
- readonly wraparoundMode: boolean
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/package.json b/meerschaum/api/resources/static/js/node_modules/xterm/package.json
deleted file mode 100644
index 8ad89fca..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/package.json
+++ /dev/null
@@ -1,75 +0,0 @@
-{
- "name": "xterm",
- "description": "Full xterm terminal, in your browser",
- "version": "4.14.1",
- "main": "lib/xterm.js",
- "style": "css/xterm.css",
- "types": "typings/xterm.d.ts",
- "repository": "https://github.com/xtermjs/xterm.js",
- "license": "MIT",
- "scripts": {
- "prepackage": "npm run build",
- "package": "webpack",
- "package-headless": "webpack --config ./webpack.config.headless.js",
- "postpackage-headless": "node ./bin/package_headless.js",
- "start": "node demo/start",
- "start-debug": "node --inspect-brk demo/start",
- "lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts src/ addons/",
- "test": "npm run test-unit",
- "posttest": "npm run lint",
- "test-api": "npm run test-api-chromium",
- "test-api-chromium": "node ./bin/test_api.js --browser=chromium --timeout=20000",
- "test-api-firefox": "node ./bin/test_api.js --browser=firefox --timeout=20000",
- "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000",
- "test-unit": "node ./bin/test.js",
- "test-unit-coverage": "node ./bin/test.js --coverage",
- "test-unit-dev": "cross-env NODE_PATH='./out' mocha",
- "build": "tsc -b ./tsconfig.all.json",
- "prepare": "npm run setup",
- "setup": "npm run build",
- "presetup": "node ./bin/install-addons.js",
- "prepublishOnly": "npm run package",
- "watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput",
- "benchmark": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json",
- "benchmark-baseline": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --baseline out-test/benchmark/test/benchmark/*benchmark.js",
- "benchmark-eval": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --eval out-test/benchmark/test/benchmark/*benchmark.js",
- "clean": "rm -rf lib out addons/*/lib addons/*/out",
- "vtfeatures": "node bin/extract_vtfeatures.js src/**/*.ts src/*.ts"
- },
- "devDependencies": {
- "@types/chai": "^4.2.18",
- "@types/debug": "^4.1.5",
- "@types/deep-equal": "^1.0.1",
- "@types/glob": "^7.1.3",
- "@types/jsdom": "^16.2.10",
- "@types/mocha": "^8.2.2",
- "@types/node": "^14.14.44",
- "@types/utf8": "^2.1.6",
- "@types/webpack": "^5.28.0",
- "@types/ws": "^7.4.4",
- "@typescript-eslint/eslint-plugin": "^4.23.0",
- "@typescript-eslint/parser": "^4.23.0",
- "chai": "^4.3.4",
- "cross-env": "^7.0.3",
- "deep-equal": "^2.0.5",
- "eslint": "^7.26.0",
- "express": "^4.17.1",
- "express-ws": "^4.0.0",
- "glob": "^7.1.7",
- "jsdom": "^16.5.3",
- "mocha": "^8.4.0",
- "mustache": "^4.2.0",
- "node-pty": "^0.10.1",
- "nyc": "^15.1.0",
- "playwright": "^1.11.0",
- "source-map-loader": "^2.0.1",
- "source-map-support": "^0.5.19",
- "ts-loader": "^9.1.2",
- "typescript": "^4.2.4",
- "utf8": "^3.0.0",
- "webpack": "^5.37.0",
- "webpack-cli": "^4.7.0",
- "ws": "^7.4.5",
- "xterm-benchmark": "^0.2.1"
- }
-}
\ No newline at end of file
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/AccessibilityManager.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/AccessibilityManager.ts
deleted file mode 100644
index 1be3342d..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/AccessibilityManager.ts
+++ /dev/null
@@ -1,300 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import * as Strings from 'browser/LocalizableStrings';
-import { ITerminal, IRenderDebouncer } from 'browser/Types';
-import { IBuffer } from 'common/buffer/Types';
-import { isMac } from 'common/Platform';
-import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer';
-import { addDisposableDomListener } from 'browser/Lifecycle';
-import { Disposable } from 'common/Lifecycle';
-import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
-import { IRenderService } from 'browser/services/Services';
-import { removeElementFromParent } from 'browser/Dom';
-
-const MAX_ROWS_TO_READ = 20;
-
-const enum BoundaryPosition {
- TOP,
- BOTTOM
-}
-
-export class AccessibilityManager extends Disposable {
- private _accessibilityTreeRoot: HTMLElement;
- private _rowContainer: HTMLElement;
- private _rowElements: HTMLElement[];
- private _liveRegion: HTMLElement;
- private _liveRegionLineCount: number = 0;
-
- private _renderRowsDebouncer: IRenderDebouncer;
- private _screenDprMonitor: ScreenDprMonitor;
-
- private _topBoundaryFocusListener: (e: FocusEvent) => void;
- private _bottomBoundaryFocusListener: (e: FocusEvent) => void;
-
- /**
- * This queue has a character pushed to it for keys that are pressed, if the
- * next character added to the terminal is equal to the key char then it is
- * not announced (added to live region) because it has already been announced
- * by the textarea event (which cannot be canceled). There are some race
- * condition cases if there is typing while data is streaming, but this covers
- * the main case of typing into the prompt and inputting the answer to a
- * question (Y/N, etc.).
- */
- private _charsToConsume: string[] = [];
-
- private _charsToAnnounce: string = '';
-
- constructor(
- private readonly _terminal: ITerminal,
- private readonly _renderService: IRenderService
- ) {
- super();
- this._accessibilityTreeRoot = document.createElement('div');
- this._accessibilityTreeRoot.classList.add('xterm-accessibility');
-
- this._rowContainer = document.createElement('div');
- this._rowContainer.setAttribute('role', 'list');
- this._rowContainer.classList.add('xterm-accessibility-tree');
- this._rowElements = [];
- for (let i = 0; i < this._terminal.rows; i++) {
- this._rowElements[i] = this._createAccessibilityTreeNode();
- this._rowContainer.appendChild(this._rowElements[i]);
- }
-
- this._topBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.TOP);
- this._bottomBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.BOTTOM);
- 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 TimeBasedDebouncer(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);
-
- if (!this._terminal.element) {
- throw new Error('Cannot enable accessibility before Terminal.open');
- }
- this._terminal.element.insertAdjacentElement('afterbegin', this._accessibilityTreeRoot);
-
- this.register(this._renderRowsDebouncer);
- this.register(this._terminal.onResize(e => this._onResize(e.rows)));
- this.register(this._terminal.onRender(e => this._refreshRows(e.start, e.end)));
- this.register(this._terminal.onScroll(() => this._refreshRows()));
- // Line feed is an issue as the prompt won't be read out after a command is run
- this.register(this._terminal.onA11yChar(char => this._onChar(char)));
- this.register(this._terminal.onLineFeed(() => this._onChar('\n')));
- this.register(this._terminal.onA11yTab(spaceCount => this._onTab(spaceCount)));
- this.register(this._terminal.onKey(e => this._onKey(e.key)));
- this.register(this._terminal.onBlur(() => this._clearLiveRegion()));
- this.register(this._renderService.onDimensionsChange(() => this._refreshRowsDimensions()));
-
- this._screenDprMonitor = new ScreenDprMonitor();
- this.register(this._screenDprMonitor);
- this._screenDprMonitor.setListener(() => this._refreshRowsDimensions());
- // This shouldn't be needed on modern browsers but is present in case the
- // media query that drives the ScreenDprMonitor isn't supported
- this.register(addDisposableDomListener(window, 'resize', () => this._refreshRowsDimensions()));
- }
-
- public dispose(): void {
- super.dispose();
- removeElementFromParent(this._accessibilityTreeRoot);
- this._rowElements.length = 0;
- }
-
- private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {
- const boundaryElement = e.target as HTMLElement;
- const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2];
-
- // Don't scroll if the buffer top has reached the end in that direction
- const posInSet = boundaryElement.getAttribute('aria-posinset');
- const lastRowPos = position === BoundaryPosition.TOP ? '1' : `${this._terminal.buffer.lines.length}`;
- if (posInSet === lastRowPos) {
- return;
- }
-
- // Don't scroll when the last focused item was not the second row (focus is going the other
- // direction)
- if (e.relatedTarget !== beforeBoundaryElement) {
- return;
- }
-
- // Remove old boundary element from array
- let topBoundaryElement: HTMLElement;
- let bottomBoundaryElement: HTMLElement;
- if (position === BoundaryPosition.TOP) {
- topBoundaryElement = boundaryElement;
- bottomBoundaryElement = this._rowElements.pop()!;
- this._rowContainer.removeChild(bottomBoundaryElement);
- } else {
- topBoundaryElement = this._rowElements.shift()!;
- bottomBoundaryElement = boundaryElement;
- this._rowContainer.removeChild(topBoundaryElement);
- }
-
- // Remove listeners from old boundary elements
- topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener);
- bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener);
-
- // Add new element to array/DOM
- if (position === BoundaryPosition.TOP) {
- const newElement = this._createAccessibilityTreeNode();
- this._rowElements.unshift(newElement);
- this._rowContainer.insertAdjacentElement('afterbegin', newElement);
- } else {
- const newElement = this._createAccessibilityTreeNode();
- this._rowElements.push(newElement);
- this._rowContainer.appendChild(newElement);
- }
-
- // Add listeners to new boundary elements
- this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);
- this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
-
- // Scroll up
- this._terminal.scrollLines(position === BoundaryPosition.TOP ? -1 : 1);
-
- // Focus new boundary before element
- this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2].focus();
-
- // Prevent the standard behavior
- e.preventDefault();
- e.stopImmediatePropagation();
- }
-
- private _onResize(rows: number): void {
- // Remove bottom boundary listener
- this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener);
-
- // Grow rows as required
- for (let i = this._rowContainer.children.length; i < this._terminal.rows; i++) {
- this._rowElements[i] = this._createAccessibilityTreeNode();
- this._rowContainer.appendChild(this._rowElements[i]);
- }
- // Shrink rows as required
- while (this._rowElements.length > rows) {
- this._rowContainer.removeChild(this._rowElements.pop()!);
- }
-
- // Add bottom boundary listener
- this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
-
- this._refreshRowsDimensions();
- }
-
- private _createAccessibilityTreeNode(): HTMLElement {
- const element = document.createElement('div');
- element.setAttribute('role', 'listitem');
- element.tabIndex = -1;
- this._refreshRowDimensions(element);
- return element;
- }
-
- private _onTab(spaceCount: number): void {
- for (let i = 0; i < spaceCount; i++) {
- this._onChar(' ');
- }
- }
-
- private _onChar(char: string): void {
- if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) {
- if (this._charsToConsume.length > 0) {
- // Have the screen reader ignore the char if it was just input
- const 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;
- }
- }
-
- // Only detach/attach on mac as otherwise messages can go unaccounced
- if (isMac) {
- if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
- setTimeout(() => {
- this._accessibilityTreeRoot.appendChild(this._liveRegion);
- }, 0);
- }
- }
- }
- }
-
- private _clearLiveRegion(): void {
- this._liveRegion.textContent = '';
- this._liveRegionLineCount = 0;
-
- // Only detach/attach on mac as otherwise messages can go unaccounced
- if (isMac) {
- removeElementFromParent(this._liveRegion);
- }
- }
-
- private _onKey(keyChar: string): void {
- this._clearLiveRegion();
- this._charsToConsume.push(keyChar);
- }
-
- private _refreshRows(start?: number, end?: number): void {
- this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);
- }
-
- private _renderRows(start: number, end: number): void {
- const buffer: IBuffer = this._terminal.buffer;
- const setSize = buffer.lines.length.toString();
- for (let i = start; i <= end; i++) {
- const lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);
- const posInSet = (buffer.ydisp + i + 1).toString();
- const element = this._rowElements[i];
- if (element) {
- if (lineData.length === 0) {
- element.innerText = '\u00a0';
- } else {
- element.textContent = lineData;
- }
- element.setAttribute('aria-posinset', posInSet);
- element.setAttribute('aria-setsize', setSize);
- }
- }
- this._announceCharacters();
- }
-
- private _refreshRowsDimensions(): void {
- if (!this._renderService.dimensions.actualCellHeight) {
- return;
- }
- if (this._rowElements.length !== this._terminal.rows) {
- this._onResize(this._terminal.rows);
- }
- for (let i = 0; i < this._terminal.rows; i++) {
- this._refreshRowDimensions(this._rowElements[i]);
- }
- }
-
- private _refreshRowDimensions(element: HTMLElement): void {
- element.style.height = `${this._renderService.dimensions.actualCellHeight}px`;
- }
-
- private _announceCharacters(): void {
- if (this._charsToAnnounce.length === 0) {
- return;
- }
- this._liveRegion.textContent += this._charsToAnnounce;
- this._charsToAnnounce = '';
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Clipboard.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Clipboard.ts
deleted file mode 100644
index 29e865c8..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Clipboard.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Copyright (c) 2016 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ISelectionService } from 'browser/services/Services';
-import { ICoreService } from 'common/services/Services';
-
-/**
- * Prepares text to be pasted into the terminal by normalizing the line endings
- * @param text The pasted text that needs processing before inserting into the terminal
- */
-export function prepareTextForTerminal(text: string): string {
- return text.replace(/\r?\n/g, '\r');
-}
-
-/**
- * Bracket text for paste, if necessary, as per https://cirw.in/blog/bracketed-paste
- * @param text The pasted text to bracket
- */
-export function bracketTextForPaste(text: string, bracketedPasteMode: boolean): string {
- if (bracketedPasteMode) {
- return '\x1b[200~' + text + '\x1b[201~';
- }
- return text;
-}
-
-/**
- * Binds copy functionality to the given terminal.
- * @param ev The original copy event to be handled
- */
-export function copyHandler(ev: ClipboardEvent, selectionService: ISelectionService): void {
- if (ev.clipboardData) {
- ev.clipboardData.setData('text/plain', selectionService.selectionText);
- }
- // Prevent or the original text will be copied.
- ev.preventDefault();
-}
-
-/**
- * Redirect the clipboard's data to the terminal's input handler.
- * @param ev The original paste event to be handled
- * @param term The terminal on which to apply the handled paste event
- */
-export function handlePasteEvent(ev: ClipboardEvent, textarea: HTMLTextAreaElement, coreService: ICoreService): void {
- ev.stopPropagation();
- if (ev.clipboardData) {
- const text = ev.clipboardData.getData('text/plain');
- paste(text, textarea, coreService);
- }
-}
-
-export function paste(text: string, textarea: HTMLTextAreaElement, coreService: ICoreService): void {
- text = prepareTextForTerminal(text);
- text = bracketTextForPaste(text, coreService.decPrivateModes.bracketedPasteMode);
- coreService.triggerDataEvent(text, true);
- textarea.value = '';
-}
-
-/**
- * Moves the textarea under the mouse cursor and focuses it.
- * @param ev The original right click event to be handled.
- * @param textarea The terminal's textarea.
- */
-export function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextAreaElement, screenElement: HTMLElement): void {
-
- // Calculate textarea position relative to the screen element
- const pos = screenElement.getBoundingClientRect();
- const left = ev.clientX - pos.left - 10;
- const top = ev.clientY - pos.top - 10;
-
- // Bring textarea at the cursor position
- textarea.style.width = '20px';
- textarea.style.height = '20px';
- textarea.style.left = `${left}px`;
- textarea.style.top = `${top}px`;
- textarea.style.zIndex = '1000';
-
- textarea.focus();
-}
-
-/**
- * Bind to right-click event and allow right-click copy and paste.
- * @param ev The original right click event to be handled.
- * @param textarea The terminal's textarea.
- * @param selectionService The terminal's selection manager.
- * @param shouldSelectWord If true and there is no selection the current word will be selected
- */
-export function rightClickHandler(ev: MouseEvent, textarea: HTMLTextAreaElement, screenElement: HTMLElement, selectionService: ISelectionService, shouldSelectWord: boolean): void {
- moveTextAreaUnderMouseCursor(ev, textarea, screenElement);
-
- if (shouldSelectWord) {
- selectionService.rightClickSelect(ev);
- }
-
- // Get textarea ready to copy from the context menu
- textarea.value = selectionService.selectionText;
- textarea.select();
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Color.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Color.ts
deleted file mode 100644
index c43c5eb5..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Color.ts
+++ /dev/null
@@ -1,228 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IColor } from 'browser/Types';
-
-/**
- * Helper functions where the source type is "channels" (individual color channels as numbers).
- */
-export namespace channels {
- export function toCss(r: number, g: number, b: number, a?: number): string {
- if (a !== undefined) {
- return `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}${toPaddedHex(a)}`;
- }
- return `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}`;
- }
-
- export function toRgba(r: number, g: number, b: number, a: number = 0xFF): number {
- // >>> 0 forces an unsigned int
- return (r << 24 | g << 16 | b << 8 | a) >>> 0;
- }
-}
-
-/**
- * Helper functions where the source type is `IColor`.
- */
-export namespace color {
- export function blend(bg: IColor, fg: IColor): IColor {
- const a = (fg.rgba & 0xFF) / 255;
- if (a === 1) {
- return {
- css: fg.css,
- rgba: fg.rgba
- };
- }
- const fgR = (fg.rgba >> 24) & 0xFF;
- const fgG = (fg.rgba >> 16) & 0xFF;
- const fgB = (fg.rgba >> 8) & 0xFF;
- const bgR = (bg.rgba >> 24) & 0xFF;
- const bgG = (bg.rgba >> 16) & 0xFF;
- const bgB = (bg.rgba >> 8) & 0xFF;
- const r = bgR + Math.round((fgR - bgR) * a);
- const g = bgG + Math.round((fgG - bgG) * a);
- const b = bgB + Math.round((fgB - bgB) * a);
- const css = channels.toCss(r, g, b);
- const rgba = channels.toRgba(r, g, b);
- return { css, rgba };
- }
-
- export function isOpaque(color: IColor): boolean {
- return (color.rgba & 0xFF) === 0xFF;
- }
-
- export function ensureContrastRatio(bg: IColor, fg: IColor, ratio: number): IColor | undefined {
- const result = rgba.ensureContrastRatio(bg.rgba, fg.rgba, ratio);
- if (!result) {
- return undefined;
- }
- return rgba.toColor(
- (result >> 24 & 0xFF),
- (result >> 16 & 0xFF),
- (result >> 8 & 0xFF)
- );
- }
-
- export function opaque(color: IColor): IColor {
- const rgbaColor = (color.rgba | 0xFF) >>> 0;
- const [r, g, b] = rgba.toChannels(rgbaColor);
- return {
- css: channels.toCss(r, g, b),
- rgba: rgbaColor
- };
- }
-
- export function opacity(color: IColor, opacity: number): IColor {
- const a = Math.round(opacity * 0xFF);
- const [r, g, b] = rgba.toChannels(color.rgba);
- return {
- css: channels.toCss(r, g, b, a),
- rgba: channels.toRgba(r, g, b, a)
- };
- }
-}
-
-/**
- * Helper functions where the source type is "css" (string: '#rgb', '#rgba', '#rrggbb', '#rrggbbaa').
- */
-export namespace css {
- export function toColor(css: string): IColor {
- switch (css.length) {
- case 7: // #rrggbb
- return {
- css,
- rgba: (parseInt(css.slice(1), 16) << 8 | 0xFF) >>> 0
- };
- case 9: // #rrggbbaa
- return {
- css,
- rgba: parseInt(css.slice(1), 16) >>> 0
- };
- }
- throw new Error('css.toColor: Unsupported css format');
- }
-}
-
-/**
- * Helper functions where the source type is "rgb" (number: 0xrrggbb).
- */
-export namespace rgb {
- /**
- * Gets the relative luminance of an RGB color, this is useful in determining the contrast ratio
- * between two colors.
- * @param rgb The color to use.
- * @see https://www.w3.org/TR/WCAG20/#relativeluminancedef
- */
- export function relativeLuminance(rgb: number): number {
- return relativeLuminance2(
- (rgb >> 16) & 0xFF,
- (rgb >> 8 ) & 0xFF,
- (rgb ) & 0xFF);
- }
-
- /**
- * Gets the relative luminance of an RGB color, this is useful in determining the contrast ratio
- * between two colors.
- * @param r The red channel (0x00 to 0xFF).
- * @param g The green channel (0x00 to 0xFF).
- * @param b The blue channel (0x00 to 0xFF).
- * @see https://www.w3.org/TR/WCAG20/#relativeluminancedef
- */
- export function relativeLuminance2(r: number, g: number, b: number): number {
- const rs = r / 255;
- const gs = g / 255;
- const bs = b / 255;
- const rr = rs <= 0.03928 ? rs / 12.92 : Math.pow((rs + 0.055) / 1.055, 2.4);
- const rg = gs <= 0.03928 ? gs / 12.92 : Math.pow((gs + 0.055) / 1.055, 2.4);
- const rb = bs <= 0.03928 ? bs / 12.92 : Math.pow((bs + 0.055) / 1.055, 2.4);
- return rr * 0.2126 + rg * 0.7152 + rb * 0.0722;
- }
-}
-
-/**
- * Helper functions where the source type is "rgba" (number: 0xrrggbbaa).
- */
-export namespace rgba {
- export function ensureContrastRatio(bgRgba: number, fgRgba: number, ratio: number): number | undefined {
- const bgL = rgb.relativeLuminance(bgRgba >> 8);
- const fgL = rgb.relativeLuminance(fgRgba >> 8);
- const cr = contrastRatio(bgL, fgL);
- if (cr < ratio) {
- if (fgL < bgL) {
- return reduceLuminance(bgRgba, fgRgba, ratio);
- }
- return increaseLuminance(bgRgba, fgRgba, ratio);
- }
- return undefined;
- }
-
- export function reduceLuminance(bgRgba: number, fgRgba: number, ratio: number): number {
- // This is a naive but fast approach to reducing luminance as converting to
- // HSL and back is expensive
- const bgR = (bgRgba >> 24) & 0xFF;
- const bgG = (bgRgba >> 16) & 0xFF;
- const bgB = (bgRgba >> 8) & 0xFF;
- let fgR = (fgRgba >> 24) & 0xFF;
- let fgG = (fgRgba >> 16) & 0xFF;
- let fgB = (fgRgba >> 8) & 0xFF;
- let cr = contrastRatio(rgb.relativeLuminance2(fgR, fgB, fgG), rgb.relativeLuminance2(bgR, bgG, bgB));
- while (cr < ratio && (fgR > 0 || fgG > 0 || fgB > 0)) {
- // Reduce by 10% until the ratio is hit
- fgR -= Math.max(0, Math.ceil(fgR * 0.1));
- fgG -= Math.max(0, Math.ceil(fgG * 0.1));
- fgB -= Math.max(0, Math.ceil(fgB * 0.1));
- cr = contrastRatio(rgb.relativeLuminance2(fgR, fgB, fgG), rgb.relativeLuminance2(bgR, bgG, bgB));
- }
- return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;
- }
-
- export function increaseLuminance(bgRgba: number, fgRgba: number, ratio: number): number {
- // This is a naive but fast approach to increasing luminance as converting to
- // HSL and back is expensive
- const bgR = (bgRgba >> 24) & 0xFF;
- const bgG = (bgRgba >> 16) & 0xFF;
- const bgB = (bgRgba >> 8) & 0xFF;
- let fgR = (fgRgba >> 24) & 0xFF;
- let fgG = (fgRgba >> 16) & 0xFF;
- let fgB = (fgRgba >> 8) & 0xFF;
- let cr = contrastRatio(rgb.relativeLuminance2(fgR, fgB, fgG), rgb.relativeLuminance2(bgR, bgG, bgB));
- while (cr < ratio && (fgR < 0xFF || fgG < 0xFF || fgB < 0xFF)) {
- // Increase by 10% until the ratio is hit
- fgR = Math.min(0xFF, fgR + Math.ceil((255 - fgR) * 0.1));
- fgG = Math.min(0xFF, fgG + Math.ceil((255 - fgG) * 0.1));
- fgB = Math.min(0xFF, fgB + Math.ceil((255 - fgB) * 0.1));
- cr = contrastRatio(rgb.relativeLuminance2(fgR, fgB, fgG), rgb.relativeLuminance2(bgR, bgG, bgB));
- }
- return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;
- }
-
- export function toChannels(value: number): [number, number, number, number] {
- return [(value >> 24) & 0xFF, (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF];
- }
-
- export function toColor(r: number, g: number, b: number): IColor {
- return {
- css: channels.toCss(r, g, b),
- rgba: channels.toRgba(r, g, b)
- };
- }
-}
-
-export function toPaddedHex(c: number): string {
- const s = c.toString(16);
- return s.length < 2 ? '0' + s : s;
-}
-
-/**
- * Gets the contrast ratio between two relative luminance values.
- * @param l1 The first relative luminance.
- * @param l2 The first relative luminance.
- * @see https://www.w3.org/TR/WCAG20/#contrast-ratiodef
- */
-export function contrastRatio(l1: number, l2: number): number {
- if (l1 < l2) {
- return (l2 + 0.05) / (l1 + 0.05);
- }
- return (l1 + 0.05) / (l2 + 0.05);
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ColorContrastCache.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ColorContrastCache.ts
deleted file mode 100644
index b96b66cc..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ColorContrastCache.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IColor, IColorContrastCache } from 'browser/Types';
-
-export class ColorContrastCache implements IColorContrastCache {
- private _color: { [bg: number]: { [fg: number]: IColor | null | undefined } | undefined } = {};
- private _rgba: { [bg: number]: { [fg: number]: string | null | undefined } | undefined } = {};
-
- public clear(): void {
- this._color = {};
- this._rgba = {};
- }
-
- public setCss(bg: number, fg: number, value: string | null): void {
- if (!this._rgba[bg]) {
- this._rgba[bg] = {};
- }
- this._rgba[bg]![fg] = value;
- }
-
- public getCss(bg: number, fg: number): string | null | undefined {
- return this._rgba[bg] ? this._rgba[bg]![fg] : undefined;
- }
-
- public setColor(bg: number, fg: number, value: IColor | null): void {
- if (!this._color[bg]) {
- this._color[bg] = {};
- }
- this._color[bg]![fg] = value;
- }
-
- public getColor(bg: number, fg: number): IColor | null | undefined {
- return this._color[bg] ? this._color[bg]![fg] : undefined;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ColorManager.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ColorManager.ts
deleted file mode 100644
index b6950d28..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ColorManager.ts
+++ /dev/null
@@ -1,213 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IColorManager, IColor, IColorSet, IColorContrastCache } from 'browser/Types';
-import { ITheme } from 'common/services/Services';
-import { channels, color, css } from 'browser/Color';
-import { ColorContrastCache } from 'browser/ColorContrastCache';
-
-const DEFAULT_FOREGROUND = css.toColor('#ffffff');
-const DEFAULT_BACKGROUND = css.toColor('#000000');
-const DEFAULT_CURSOR = css.toColor('#ffffff');
-const DEFAULT_CURSOR_ACCENT = css.toColor('#000000');
-const DEFAULT_SELECTION = {
- css: 'rgba(255, 255, 255, 0.3)',
- rgba: 0xFFFFFF4D
-};
-
-// An IIFE to generate DEFAULT_ANSI_COLORS.
-export const DEFAULT_ANSI_COLORS = Object.freeze((() => {
- const colors = [
- // dark:
- css.toColor('#2e3436'),
- css.toColor('#cc0000'),
- css.toColor('#4e9a06'),
- css.toColor('#c4a000'),
- css.toColor('#3465a4'),
- css.toColor('#75507b'),
- css.toColor('#06989a'),
- css.toColor('#d3d7cf'),
- // bright:
- css.toColor('#555753'),
- css.toColor('#ef2929'),
- css.toColor('#8ae234'),
- css.toColor('#fce94f'),
- css.toColor('#729fcf'),
- css.toColor('#ad7fa8'),
- css.toColor('#34e2e2'),
- css.toColor('#eeeeec')
- ];
-
- // Fill in the remaining 240 ANSI colors.
- // Generate colors (16-231)
- const v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
- for (let i = 0; i < 216; i++) {
- const r = v[(i / 36) % 6 | 0];
- const g = v[(i / 6) % 6 | 0];
- const b = v[i % 6];
- colors.push({
- css: channels.toCss(r, g, b),
- rgba: channels.toRgba(r, g, b)
- });
- }
-
- // Generate greys (232-255)
- for (let i = 0; i < 24; i++) {
- const c = 8 + i * 10;
- colors.push({
- css: channels.toCss(c, c, c),
- rgba: channels.toRgba(c, c, c)
- });
- }
-
- return colors;
-})());
-
-/**
- * Manages the source of truth for a terminal's colors.
- */
-export class ColorManager implements IColorManager {
- public colors: IColorSet;
- private _ctx: CanvasRenderingContext2D;
- private _litmusColor: CanvasGradient;
- private _contrastCache: IColorContrastCache;
-
- constructor(document: Document, public allowTransparency: boolean) {
- const canvas = document.createElement('canvas');
- canvas.width = 1;
- canvas.height = 1;
- const ctx = canvas.getContext('2d');
- if (!ctx) {
- throw new Error('Could not get rendering context');
- }
- this._ctx = ctx;
- this._ctx.globalCompositeOperation = 'copy';
- this._litmusColor = this._ctx.createLinearGradient(0, 0, 1, 1);
- this._contrastCache = new ColorContrastCache();
- this.colors = {
- foreground: DEFAULT_FOREGROUND,
- background: DEFAULT_BACKGROUND,
- cursor: DEFAULT_CURSOR,
- cursorAccent: DEFAULT_CURSOR_ACCENT,
- selectionTransparent: DEFAULT_SELECTION,
- selectionOpaque: color.blend(DEFAULT_BACKGROUND, DEFAULT_SELECTION),
- ansi: DEFAULT_ANSI_COLORS.slice(),
- contrastCache: this._contrastCache
- };
- }
-
- public onOptionsChange(key: string): void {
- if (key === 'minimumContrastRatio') {
- this._contrastCache.clear();
- }
- }
-
- /**
- * Sets the terminal's theme.
- * @param theme The theme to use. If a partial theme is provided then default
- * colors will be used where colors are not defined.
- */
- public setTheme(theme: ITheme = {}): void {
- this.colors.foreground = this._parseColor(theme.foreground, DEFAULT_FOREGROUND);
- this.colors.background = this._parseColor(theme.background, DEFAULT_BACKGROUND);
- this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);
- this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);
- this.colors.selectionTransparent = this._parseColor(theme.selection, DEFAULT_SELECTION, true);
- this.colors.selectionOpaque = color.blend(this.colors.background, this.colors.selectionTransparent);
- /**
- * If selection color is opaque, blend it with background with 0.3 opacity
- * Issue #2737
- */
- if (color.isOpaque(this.colors.selectionTransparent)) {
- const opacity = 0.3;
- this.colors.selectionTransparent = color.opacity(this.colors.selectionTransparent, opacity);
- }
- this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);
- this.colors.ansi[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);
- this.colors.ansi[2] = this._parseColor(theme.green, DEFAULT_ANSI_COLORS[2]);
- this.colors.ansi[3] = this._parseColor(theme.yellow, DEFAULT_ANSI_COLORS[3]);
- this.colors.ansi[4] = this._parseColor(theme.blue, DEFAULT_ANSI_COLORS[4]);
- this.colors.ansi[5] = this._parseColor(theme.magenta, DEFAULT_ANSI_COLORS[5]);
- this.colors.ansi[6] = this._parseColor(theme.cyan, DEFAULT_ANSI_COLORS[6]);
- this.colors.ansi[7] = this._parseColor(theme.white, DEFAULT_ANSI_COLORS[7]);
- this.colors.ansi[8] = this._parseColor(theme.brightBlack, DEFAULT_ANSI_COLORS[8]);
- this.colors.ansi[9] = this._parseColor(theme.brightRed, DEFAULT_ANSI_COLORS[9]);
- this.colors.ansi[10] = this._parseColor(theme.brightGreen, DEFAULT_ANSI_COLORS[10]);
- this.colors.ansi[11] = this._parseColor(theme.brightYellow, DEFAULT_ANSI_COLORS[11]);
- this.colors.ansi[12] = this._parseColor(theme.brightBlue, DEFAULT_ANSI_COLORS[12]);
- this.colors.ansi[13] = this._parseColor(theme.brightMagenta, DEFAULT_ANSI_COLORS[13]);
- this.colors.ansi[14] = this._parseColor(theme.brightCyan, DEFAULT_ANSI_COLORS[14]);
- this.colors.ansi[15] = this._parseColor(theme.brightWhite, DEFAULT_ANSI_COLORS[15]);
- // Clear our the cache
- this._contrastCache.clear();
- }
-
- private _parseColor(
- css: string | undefined,
- fallback: IColor,
- allowTransparency: boolean = this.allowTransparency
- ): IColor {
- if (css === undefined) {
- return fallback;
- }
-
- // If parsing the value results in failure, then it must be ignored, and the attribute must
- // retain its previous value.
- // -- https://html.spec.whatwg.org/multipage/canvas.html#fill-and-stroke-styles
- this._ctx.fillStyle = this._litmusColor;
- this._ctx.fillStyle = css;
- if (typeof this._ctx.fillStyle !== 'string') {
- console.warn(`Color: ${css} is invalid using fallback ${fallback.css}`);
- return fallback;
- }
-
- this._ctx.fillRect(0, 0, 1, 1);
- const data = this._ctx.getImageData(0, 0, 1, 1).data;
-
- // Check if the printed color was transparent
- if (data[3] !== 0xFF) {
- if (!allowTransparency) {
- // Ideally we'd just ignore the alpha channel, but...
- //
- // Browsers may not give back exactly the same RGB values we put in, because most/all
- // convert the color to a pre-multiplied representation. getImageData converts that back to
- // a un-premultipled representation, but the precision loss may make the RGB channels unuable
- // on their own.
- //
- // E.g. In Chrome #12345610 turns into #10305010, and in the extreme case, 0xFFFFFF00 turns
- // into 0x00000000.
- //
- // "Note: Due to the lossy nature of converting to and from premultiplied alpha color values,
- // pixels that have just been set using putImageData() might be returned to an equivalent
- // getImageData() as different values."
- // -- https://html.spec.whatwg.org/multipage/canvas.html#pixel-manipulation
- //
- // So let's just use the fallback color in this case instead.
- console.warn(
- `Color: ${css} is using transparency, but allowTransparency is false. ` +
- `Using fallback ${fallback.css}.`
- );
- return fallback;
- }
-
- // https://html.spec.whatwg.org/multipage/canvas.html#serialisation-of-a-color
- // the color value has alpha less than 1.0, and the string is the color value in the CSS rgba()
- const [r, g, b, a] = this._ctx.fillStyle.substring(5, this._ctx.fillStyle.length - 1).split(',').map(component => Number(component));
- const alpha = Math.round(a * 255);
- const rgba: number = channels.toRgba(r, g, b, alpha);
- return {
- rgba,
- css
- };
- }
-
- return {
- // https://html.spec.whatwg.org/multipage/canvas.html#serialisation-of-a-color
- // if it has alpha equal to 1.0, then the string is a lowercase six-digit hex value, prefixed with a "#" character
- css: this._ctx.fillStyle,
- rgba: channels.toRgba(data[0], data[1], data[2], data[3])
- };
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Dom.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Dom.ts
deleted file mode 100644
index c558a8b1..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Dom.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Copyright (c) 2020 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-export function removeElementFromParent(...elements: (HTMLElement | undefined)[]): void {
- for (const e of elements) {
- e?.parentElement?.removeChild(e);
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Lifecycle.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Lifecycle.ts
deleted file mode 100644
index 6e841794..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Lifecycle.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IDisposable } from 'common/Types';
-
-/**
- * Adds a disposable listener to a node in the DOM, returning the disposable.
- * @param type The event type.
- * @param handler The handler for the listener.
- */
-export function addDisposableDomListener(
- node: Element | Window | Document,
- type: string,
- handler: (e: any) => void,
- options?: boolean | AddEventListenerOptions
-): IDisposable {
- node.addEventListener(type, handler, options);
- let disposed = false;
- return {
- dispose: () => {
- if (disposed) {
- return;
- }
- disposed = true;
- node.removeEventListener(type, handler, options);
- }
- };
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Linkifier.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Linkifier.ts
deleted file mode 100644
index b17d66a8..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Linkifier.ts
+++ /dev/null
@@ -1,356 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, IMouseZoneManager, IMouseZone, IRegisteredLinkMatcher } from 'browser/Types';
-import { IBufferStringIteratorResult } from 'common/buffer/Types';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-import { ILogService, IBufferService, IOptionsService, IUnicodeService } from 'common/services/Services';
-
-/**
- * Limit of the unwrapping line expansion (overscan) at the top and bottom
- * of the actual viewport in ASCII characters.
- * A limit of 2000 should match most sane urls.
- */
-const OVERSCAN_CHAR_LIMIT = 2000;
-
-/**
- * The Linkifier applies links to rows shortly after they have been refreshed.
- */
-export class Linkifier implements ILinkifier {
- /**
- * The time to wait after a row is changed before it is linkified. This prevents
- * the costly operation of searching every row multiple times, potentially a
- * huge amount of times.
- */
- protected static _timeBeforeLatency = 200;
-
- protected _linkMatchers: IRegisteredLinkMatcher[] = [];
-
- private _mouseZoneManager: IMouseZoneManager | undefined;
- private _element: HTMLElement | undefined;
-
- private _rowsTimeoutId: number | undefined;
- private _nextLinkMatcherId = 0;
- private _rowsToLinkify: { start: number | undefined, end: number | undefined };
-
- private _onShowLinkUnderline = new EventEmitter();
- public get onShowLinkUnderline(): IEvent { return this._onShowLinkUnderline.event; }
- private _onHideLinkUnderline = new EventEmitter();
- public get onHideLinkUnderline(): IEvent { return this._onHideLinkUnderline.event; }
- private _onLinkTooltip = new EventEmitter();
- public get onLinkTooltip(): IEvent { return this._onLinkTooltip.event; }
-
- constructor(
- @IBufferService protected readonly _bufferService: IBufferService,
- @ILogService private readonly _logService: ILogService,
- @IUnicodeService private readonly _unicodeService: IUnicodeService
- ) {
- this._rowsToLinkify = {
- start: undefined,
- end: undefined
- };
- }
-
- /**
- * Attaches the linkifier to the DOM, enabling linkification.
- * @param mouseZoneManager The mouse zone manager to register link zones with.
- */
- public attachToDom(element: HTMLElement, mouseZoneManager: IMouseZoneManager): void {
- this._element = element;
- this._mouseZoneManager = mouseZoneManager;
- }
-
- /**
- * Queue linkification on a set of rows.
- * @param start The row to linkify from (inclusive).
- * @param end The row to linkify to (inclusive).
- */
- public linkifyRows(start: number, end: number): void {
- // Don't attempt linkify if not yet attached to DOM
- if (!this._mouseZoneManager) {
- return;
- }
-
- // Increase range to linkify
- if (this._rowsToLinkify.start === undefined || this._rowsToLinkify.end === undefined) {
- 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);
- }
-
- // Clear out any existing links on this row range
- this._mouseZoneManager.clearAll(start, end);
-
- // Restart timer
- if (this._rowsTimeoutId) {
- clearTimeout(this._rowsTimeoutId);
- }
-
- // Cannot use window.setTimeout since tests need to run in node
- this._rowsTimeoutId = setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency) as any as number;
- }
-
- /**
- * Linkifies the rows requested.
- */
- private _linkifyRows(): void {
- this._rowsTimeoutId = undefined;
- const buffer = this._bufferService.buffer;
-
- if (this._rowsToLinkify.start === undefined || this._rowsToLinkify.end === undefined) {
- this._logService.debug('_rowToLinkify was unset before _linkifyRows was called');
- return;
- }
-
- // Ensure the start row exists
- const absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start;
- if (absoluteRowIndexStart >= buffer.lines.length) {
- return;
- }
-
- // Invalidate bad end row values (if a resize happened)
- const absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._bufferService.rows) + 1;
-
- // Iterate over the range of unwrapped content strings within start..end
- // (excluding).
- // _doLinkifyRow gets full unwrapped lines with the start row as buffer offset
- // for every matcher.
- // The unwrapping is needed to also match content that got wrapped across
- // several buffer lines. To avoid a worst case scenario where the whole buffer
- // contains just a single unwrapped string we limit this line expansion beyond
- // the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom.
- // This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT
- // chars will not match anymore at the viewport borders.
- const overscanLineLimit = Math.ceil(OVERSCAN_CHAR_LIMIT / this._bufferService.cols);
- const iterator = this._bufferService.buffer.iterator(
- false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
- while (iterator.hasNext()) {
- const lineData: IBufferStringIteratorResult = iterator.next();
- for (let i = 0; i < this._linkMatchers.length; i++) {
- this._doLinkifyRow(lineData.range.first, lineData.content, this._linkMatchers[i]);
- }
- }
-
- this._rowsToLinkify.start = undefined;
- this._rowsToLinkify.end = undefined;
- }
-
- /**
- * Registers a link matcher, allowing custom link patterns to be matched and
- * handled.
- * @param regex The regular expression to search for. Specifically, this
- * searches the textContent of the rows. You will want to use \s to match a
- * space ' ' character for example.
- * @param handler The callback when the link is called.
- * @param options Options for the link matcher.
- * @return The ID of the new matcher, this can be used to deregister.
- */
- public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options: ILinkMatcherOptions = {}): number {
- if (!handler) {
- throw new Error('handler must be defined');
- }
- const matcher: IRegisteredLinkMatcher = {
- id: this._nextLinkMatcherId++,
- regex,
- 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;
- }
-
- /**
- * Inserts a link matcher to the list in the correct position based on the
- * priority of each link matcher. New link matchers of equal priority are
- * considered after older link matchers.
- * @param matcher The link matcher to be added.
- */
- private _addLinkMatcherToList(matcher: IRegisteredLinkMatcher): void {
- if (this._linkMatchers.length === 0) {
- this._linkMatchers.push(matcher);
- return;
- }
-
- for (let 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);
- }
-
- /**
- * Deregisters a link matcher if it has been registered.
- * @param matcherId The link matcher's ID (returned after register)
- * @return Whether a link matcher was found and deregistered.
- */
- public deregisterLinkMatcher(matcherId: number): boolean {
- for (let i = 0; i < this._linkMatchers.length; i++) {
- if (this._linkMatchers[i].id === matcherId) {
- this._linkMatchers.splice(i, 1);
- return true;
- }
- }
- return false;
- }
-
- /**
- * Linkifies a row given a specific handler.
- * @param rowIndex The row index to linkify (absolute index).
- * @param text string content of the unwrapped row.
- * @param matcher The link matcher for this line.
- */
- private _doLinkifyRow(rowIndex: number, text: string, matcher: ILinkMatcher): void {
- // clone regex to do a global search on text
- const rex = new RegExp(matcher.regex.source, (matcher.regex.flags || '') + 'g');
- let match;
- let stringIndex = -1;
- while ((match = rex.exec(text)) !== null) {
- const uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];
- if (!uri) {
- // something matched but does not comply with the given matchIndex
- // since this is most likely a bug the regex itself we simply do nothing here
- this._logService.debug('match found without corresponding matchIndex', match, matcher);
- break;
- }
-
- // Get index, match.index is for the outer match which includes negated chars
- // therefore we cannot use match.index directly, instead we search the position
- // of the match group in text again
- // also correct regex and string search offsets for the next loop run
- stringIndex = text.indexOf(uri, stringIndex + 1);
- rex.lastIndex = stringIndex + uri.length;
- if (stringIndex < 0) {
- // invalid stringIndex (should not have happened)
- break;
- }
-
- // get the buffer index as [absolute row, col] for the match
- const bufferIndex = this._bufferService.buffer.stringIndexToBufferIndex(rowIndex, stringIndex);
- if (bufferIndex[0] < 0) {
- // invalid bufferIndex (should not have happened)
- break;
- }
-
- const line = this._bufferService.buffer.lines.get(bufferIndex[0]);
- if (!line) {
- break;
- }
-
- const attr = line.getFg(bufferIndex[1]);
- const fg = attr ? (attr >> 9) & 0x1ff : undefined;
-
- if (matcher.validationCallback) {
- matcher.validationCallback(uri, isValid => {
- // Discard link if the line has already changed
- if (this._rowsTimeoutId) {
- return;
- }
- if (isValid) {
- this._addLink(bufferIndex[1], bufferIndex[0] - this._bufferService.buffer.ydisp, uri, matcher, fg);
- }
- });
- } else {
- this._addLink(bufferIndex[1], bufferIndex[0] - this._bufferService.buffer.ydisp, uri, matcher, fg);
- }
- }
- }
-
- /**
- * Registers a link to the mouse zone manager.
- * @param x The column the link starts.
- * @param y The row the link is on.
- * @param uri The URI of the link.
- * @param matcher The link matcher for the link.
- * @param fg The link color for hover event.
- */
- private _addLink(x: number, y: number, uri: string, matcher: ILinkMatcher, fg: number | undefined): void {
- if (!this._mouseZoneManager || !this._element) {
- return;
- }
- // FIXME: get cell length from buffer to avoid mismatch after Unicode version change
- const width = this._unicodeService.getStringCellWidth(uri);
- const x1 = x % this._bufferService.cols;
- const y1 = y + Math.floor(x / this._bufferService.cols);
- let x2 = (x1 + width) % this._bufferService.cols;
- let y2 = y1 + Math.floor((x1 + width) / this._bufferService.cols);
- if (x2 === 0) {
- x2 = this._bufferService.cols;
- y2--;
- }
-
- this._mouseZoneManager.add(new MouseZone(
- x1 + 1,
- y1 + 1,
- x2 + 1,
- y2 + 1,
- e => {
- if (matcher.handler) {
- return matcher.handler(e, uri);
- }
- const newWindow = window.open();
- if (newWindow) {
- newWindow.opener = null;
- newWindow.location.href = uri;
- } else {
- console.warn('Opening link blocked as opener could not be cleared');
- }
- },
- () => {
- this._onShowLinkUnderline.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));
- this._element!.classList.add('xterm-cursor-pointer');
- },
- e => {
- this._onLinkTooltip.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));
- if (matcher.hoverTooltipCallback) {
- // Note that IViewportRange use 1-based coordinates to align with escape sequences such
- // as CUP which use 1,1 as the default for row/col
- matcher.hoverTooltipCallback(e, uri, { start: { x: x1, y: y1 }, end: { x: x2, y: y2 } });
- }
- },
- () => {
- this._onHideLinkUnderline.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));
- this._element!.classList.remove('xterm-cursor-pointer');
- if (matcher.hoverLeaveCallback) {
- matcher.hoverLeaveCallback();
- }
- },
- e => {
- if (matcher.willLinkActivate) {
- return matcher.willLinkActivate(e, uri);
- }
- return true;
- }
- ));
- }
-
- private _createLinkHoverEvent(x1: number, y1: number, x2: number, y2: number, fg: number | undefined): ILinkifierEvent {
- return { x1, y1, x2, y2, cols: this._bufferService.cols, fg };
- }
-}
-
-export class MouseZone implements IMouseZone {
- constructor(
- public x1: number,
- public y1: number,
- public x2: number,
- public y2: number,
- public clickCallback: (e: MouseEvent) => any,
- public hoverCallback: (e: MouseEvent) => any,
- public tooltipCallback: (e: MouseEvent) => any,
- public leaveCallback: () => void,
- public willLinkActivate: (e: MouseEvent) => boolean
- ) {
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Linkifier2.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Linkifier2.ts
deleted file mode 100644
index 89542936..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Linkifier2.ts
+++ /dev/null
@@ -1,392 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ILinkifier2, ILinkProvider, IBufferCellPosition, ILink, ILinkifierEvent, ILinkDecorations, ILinkWithState } from 'browser/Types';
-import { IDisposable } from 'common/Types';
-import { IMouseService, IRenderService } from './services/Services';
-import { IBufferService } from 'common/services/Services';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-import { Disposable, getDisposeArrayDisposable, disposeArray } from 'common/Lifecycle';
-import { addDisposableDomListener } from 'browser/Lifecycle';
-
-export class Linkifier2 extends Disposable implements ILinkifier2 {
- private _element: HTMLElement | undefined;
- private _mouseService: IMouseService | undefined;
- private _renderService: IRenderService | undefined;
- private _linkProviders: ILinkProvider[] = [];
- public get currentLink(): ILinkWithState | undefined { return this._currentLink; }
- protected _currentLink: ILinkWithState | undefined;
- private _lastMouseEvent: MouseEvent | undefined;
- private _linkCacheDisposables: IDisposable[] = [];
- private _lastBufferCell: IBufferCellPosition | undefined;
- private _isMouseOut: boolean = true;
- private _activeProviderReplies: Map | undefined;
- private _activeLine: number = -1;
-
- private _onShowLinkUnderline = this.register(new EventEmitter());
- public get onShowLinkUnderline(): IEvent { return this._onShowLinkUnderline.event; }
- private _onHideLinkUnderline = this.register(new EventEmitter());
- public get onHideLinkUnderline(): IEvent { return this._onHideLinkUnderline.event; }
-
- constructor(
- @IBufferService private readonly _bufferService: IBufferService
- ) {
- super();
- this.register(getDisposeArrayDisposable(this._linkCacheDisposables));
- }
-
- public registerLinkProvider(linkProvider: ILinkProvider): IDisposable {
- this._linkProviders.push(linkProvider);
- return {
- dispose: () => {
- // Remove the link provider from the list
- const providerIndex = this._linkProviders.indexOf(linkProvider);
-
- if (providerIndex !== -1) {
- this._linkProviders.splice(providerIndex, 1);
- }
- }
- };
- }
-
- public attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void {
- this._element = element;
- this._mouseService = mouseService;
- this._renderService = renderService;
-
- this.register(addDisposableDomListener(this._element, 'mouseleave', () => {
- this._isMouseOut = true;
- this._clearCurrentLink();
- }));
- this.register(addDisposableDomListener(this._element, 'mousemove', this._onMouseMove.bind(this)));
- this.register(addDisposableDomListener(this._element, 'click', this._onClick.bind(this)));
- }
-
- private _onMouseMove(event: MouseEvent): void {
- this._lastMouseEvent = event;
-
- if (!this._element || !this._mouseService) {
- return;
- }
-
- const position = this._positionFromMouseEvent(event, this._element, this._mouseService);
- if (!position) {
- return;
- }
- this._isMouseOut = false;
-
- // Ignore the event if it's an embedder created hover widget
- const composedPath = event.composedPath() as HTMLElement[];
- for (let i = 0; i < composedPath.length; i++) {
- const target = composedPath[i];
- // Hit Terminal.element, break and continue
- if (target.classList.contains('xterm')) {
- break;
- }
- // It's a hover, don't respect hover event
- if (target.classList.contains('xterm-hover')) {
- return;
- }
- }
-
- if (!this._lastBufferCell || (position.x !== this._lastBufferCell.x || position.y !== this._lastBufferCell.y)) {
- this._onHover(position);
- this._lastBufferCell = position;
- }
- }
-
- private _onHover(position: IBufferCellPosition): void {
- // TODO: This currently does not cache link provider results across wrapped lines, activeLine should be something like `activeRange: {startY, endY}`
- // Check if we need to clear the link
- if (this._activeLine !== position.y) {
- this._clearCurrentLink();
- this._askForLink(position, false);
- return;
- }
-
- // Check the if the link is in the mouse position
- const isCurrentLinkInPosition = this._currentLink && this._linkAtPosition(this._currentLink.link, position);
- if (!isCurrentLinkInPosition) {
- this._clearCurrentLink();
- this._askForLink(position, true);
- }
- }
-
- private _askForLink(position: IBufferCellPosition, useLineCache: boolean): void {
- if (!this._activeProviderReplies || !useLineCache) {
- this._activeProviderReplies?.forEach(reply => {
- reply?.forEach(linkWithState => {
- if (linkWithState.link.dispose) {
- linkWithState.link.dispose();
- }
- });
- });
- this._activeProviderReplies = new Map();
- this._activeLine = position.y;
- }
- let linkProvided = false;
-
- // There is no link cached, so ask for one
- this._linkProviders.forEach((linkProvider, i) => {
- if (useLineCache) {
- const existingReply = this._activeProviderReplies?.get(i);
- // If there isn't a reply, the provider hasn't responded yet.
-
- // TODO: If there isn't a reply yet it means that the provider is still resolving. Ensuring
- // provideLinks isn't triggered again saves ILink.hover firing twice though. This probably
- // needs promises to get fixed
- if (existingReply) {
- linkProvided = this._checkLinkProviderResult(i, position, linkProvided);
- }
- } else {
- linkProvider.provideLinks(position.y, (links: ILink[] | undefined) => {
- if (this._isMouseOut) {
- return;
- }
- const linksWithState: ILinkWithState[] | undefined = links?.map(link => ({ link }));
- this._activeProviderReplies?.set(i, linksWithState);
- linkProvided = this._checkLinkProviderResult(i, position, linkProvided);
-
- // If all providers have responded, remove lower priority links that intersect ranges of
- // higher priority links
- if (this._activeProviderReplies?.size === this._linkProviders.length) {
- this._removeIntersectingLinks(position.y, this._activeProviderReplies);
- }
- });
- }
- });
- }
-
- private _removeIntersectingLinks(y: number, replies: Map): void {
- const occupiedCells = new Set();
- for (let i = 0; i < replies.size; i++) {
- const providerReply = replies.get(i);
- if (!providerReply) {
- continue;
- }
- for (let i = 0; i < providerReply.length; i++) {
- const linkWithState = providerReply[i];
- const startX = linkWithState.link.range.start.y < y ? 0 : linkWithState.link.range.start.x;
- const endX = linkWithState.link.range.end.y > y ? this._bufferService.cols : linkWithState.link.range.end.x;
- for (let x = startX; x <= endX; x++) {
- if (occupiedCells.has(x)) {
- providerReply.splice(i--, 1);
- break;
- }
- occupiedCells.add(x);
- }
- }
- }
- }
-
- private _checkLinkProviderResult(index: number, position: IBufferCellPosition, linkProvided: boolean): boolean {
- if (!this._activeProviderReplies) {
- return linkProvided;
- }
-
- const links = this._activeProviderReplies.get(index);
-
- // Check if every provider before this one has come back undefined
- let hasLinkBefore = false;
- for (let j = 0; j < index; j++) {
- if (!this._activeProviderReplies.has(j) || this._activeProviderReplies.get(j)) {
- hasLinkBefore = true;
- }
- }
-
- // If all providers with higher priority came back undefined, then this provider's link for
- // the position should be used
- if (!hasLinkBefore && links) {
- const linkAtPosition = links.find(link => this._linkAtPosition(link.link, position));
- if (linkAtPosition) {
- linkProvided = true;
- this._handleNewLink(linkAtPosition);
- }
- }
-
- // Check if all the providers have responded
- if (this._activeProviderReplies.size === this._linkProviders.length && !linkProvided) {
- // Respect the order of the link providers
- for (let j = 0; j < this._activeProviderReplies.size; j++) {
- const currentLink = this._activeProviderReplies.get(j)?.find(link => this._linkAtPosition(link.link, position));
- if (currentLink) {
- linkProvided = true;
- this._handleNewLink(currentLink);
- break;
- }
- }
- }
-
- return linkProvided;
- }
-
- private _onClick(event: MouseEvent): void {
- if (!this._element || !this._mouseService || !this._currentLink) {
- return;
- }
-
- const position = this._positionFromMouseEvent(event, this._element, this._mouseService);
-
- if (!position) {
- return;
- }
-
- if (this._linkAtPosition(this._currentLink.link, position)) {
- this._currentLink.link.activate(event, this._currentLink.link.text);
- }
- }
-
- private _clearCurrentLink(startRow?: number, endRow?: number): void {
- if (!this._element || !this._currentLink || !this._lastMouseEvent) {
- return;
- }
-
- // If we have a start and end row, check that the link is within it
- if (!startRow || !endRow || (this._currentLink.link.range.start.y >= startRow && this._currentLink.link.range.end.y <= endRow)) {
- this._linkLeave(this._element, this._currentLink.link, this._lastMouseEvent);
- this._currentLink = undefined;
- disposeArray(this._linkCacheDisposables);
- }
- }
-
- private _handleNewLink(linkWithState: ILinkWithState): void {
- if (!this._element || !this._lastMouseEvent || !this._mouseService) {
- return;
- }
-
- const position = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService);
-
- if (!position) {
- return;
- }
-
- // Trigger hover if the we have a link at the position
- if (this._linkAtPosition(linkWithState.link, position)) {
- this._currentLink = linkWithState;
- this._currentLink.state = {
- decorations: {
- underline: linkWithState.link.decorations === undefined ? true : linkWithState.link.decorations.underline,
- pointerCursor: linkWithState.link.decorations === undefined ? true : linkWithState.link.decorations.pointerCursor
- },
- isHovered: true
- };
- this._linkHover(this._element, linkWithState.link, this._lastMouseEvent);
-
- // Add listener for tracking decorations changes
- linkWithState.link.decorations = {} as ILinkDecorations;
- Object.defineProperties(linkWithState.link.decorations, {
- pointerCursor: {
- get: () => this._currentLink?.state?.decorations.pointerCursor,
- set: v => {
- if (this._currentLink?.state && this._currentLink.state.decorations.pointerCursor !== v) {
- this._currentLink.state.decorations.pointerCursor = v;
- if (this._currentLink.state.isHovered) {
- this._element?.classList.toggle('xterm-cursor-pointer', v);
- }
- }
- }
- },
- underline: {
- get: () => this._currentLink?.state?.decorations.underline,
- set: v => {
- if (this._currentLink?.state && this._currentLink?.state?.decorations.underline !== v) {
- this._currentLink.state.decorations.underline = v;
- if (this._currentLink.state.isHovered) {
- this._fireUnderlineEvent(linkWithState.link, v);
- }
- }
- }
- }
- });
-
- // Add listener for rerendering
- if (this._renderService) {
- this._linkCacheDisposables.push(this._renderService.onRenderedBufferChange(e => {
- // When start is 0 a scroll most likely occurred, make sure links above the fold also get
- // cleared.
- const start = e.start === 0 ? 0 : e.start + 1 + this._bufferService.buffer.ydisp;
- this._clearCurrentLink(start, e.end + 1 + this._bufferService.buffer.ydisp);
- }));
- }
- }
- }
-
- protected _linkHover(element: HTMLElement, link: ILink, event: MouseEvent): void {
- if (this._currentLink?.state) {
- this._currentLink.state.isHovered = true;
- if (this._currentLink.state.decorations.underline) {
- this._fireUnderlineEvent(link, true);
- }
- if (this._currentLink.state.decorations.pointerCursor) {
- element.classList.add('xterm-cursor-pointer');
- }
- }
-
- if (link.hover) {
- link.hover(event, link.text);
- }
- }
-
- private _fireUnderlineEvent(link: ILink, showEvent: boolean): void {
- const range = link.range;
- const scrollOffset = this._bufferService.buffer.ydisp;
- const event = this._createLinkUnderlineEvent(range.start.x - 1, range.start.y - scrollOffset - 1, range.end.x, range.end.y - scrollOffset - 1, undefined);
- const emitter = showEvent ? this._onShowLinkUnderline : this._onHideLinkUnderline;
- emitter.fire(event);
- }
-
- protected _linkLeave(element: HTMLElement, link: ILink, event: MouseEvent): void {
- if (this._currentLink?.state) {
- this._currentLink.state.isHovered = false;
- if (this._currentLink.state.decorations.underline) {
- this._fireUnderlineEvent(link, false);
- }
- if (this._currentLink.state.decorations.pointerCursor) {
- element.classList.remove('xterm-cursor-pointer');
- }
- }
-
- if (link.leave) {
- link.leave(event, link.text);
- }
- }
-
- /**
- * Check if the buffer position is within the link
- * @param link
- * @param position
- */
- private _linkAtPosition(link: ILink, position: IBufferCellPosition): boolean {
- const sameLine = link.range.start.y === link.range.end.y;
- const wrappedFromLeft = link.range.start.y < position.y;
- const wrappedToRight = link.range.end.y > position.y;
-
- // If the start and end have the same y, then the position must be between start and end x
- // If not, then handle each case seperately, depending on which way it wraps
- return ((sameLine && link.range.start.x <= position.x && link.range.end.x >= position.x) ||
- (wrappedFromLeft && link.range.end.x >= position.x) ||
- (wrappedToRight && link.range.start.x <= position.x) ||
- (wrappedFromLeft && wrappedToRight)) &&
- link.range.start.y <= position.y &&
- link.range.end.y >= position.y;
- }
-
- /**
- * Get the buffer position from a mouse event
- * @param event
- */
- private _positionFromMouseEvent(event: MouseEvent, element: HTMLElement, mouseService: IMouseService): IBufferCellPosition | undefined {
- const coords = mouseService.getCoords(event, element, this._bufferService.cols, this._bufferService.rows);
- if (!coords) {
- return;
- }
-
- return { x: coords[0], y: coords[1] + this._bufferService.buffer.ydisp };
- }
-
- private _createLinkUnderlineEvent(x1: number, y1: number, x2: number, y2: number, fg: number | undefined): ILinkifierEvent {
- return { x1, y1, x2, y2, cols: this._bufferService.cols, fg };
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/LocalizableStrings.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/LocalizableStrings.ts
deleted file mode 100644
index c0a904cb..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/LocalizableStrings.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-// eslint-disable-next-line prefer-const
-export let promptLabel = 'Terminal input';
-
-// eslint-disable-next-line prefer-const
-export let tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/MouseZoneManager.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/MouseZoneManager.ts
deleted file mode 100644
index b6740157..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/MouseZoneManager.ts
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { Disposable } from 'common/Lifecycle';
-import { addDisposableDomListener } from 'browser/Lifecycle';
-import { IMouseService, ISelectionService } from 'browser/services/Services';
-import { IMouseZoneManager, IMouseZone } from 'browser/Types';
-import { IBufferService, IOptionsService } from 'common/services/Services';
-
-/**
- * The MouseZoneManager allows components to register zones within the terminal
- * that trigger hover and click callbacks.
- *
- * This class was intentionally made not so robust initially as the only case it
- * needed to support was single-line links which never overlap. Improvements can
- * be made in the future.
- */
-export class MouseZoneManager extends Disposable implements IMouseZoneManager {
- private _zones: IMouseZone[] = [];
-
- private _areZonesActive: boolean = false;
- private _mouseMoveListener: (e: MouseEvent) => any;
- private _mouseLeaveListener: (e: MouseEvent) => any;
- private _clickListener: (e: MouseEvent) => any;
-
- private _tooltipTimeout: number | undefined;
- private _currentZone: IMouseZone | undefined;
- private _lastHoverCoords: [number | undefined, number | undefined] = [undefined, undefined];
- private _initialSelectionLength: number = 0;
-
- constructor(
- private readonly _element: HTMLElement,
- private readonly _screenElement: HTMLElement,
- @IBufferService private readonly _bufferService: IBufferService,
- @IMouseService private readonly _mouseService: IMouseService,
- @ISelectionService private readonly _selectionService: ISelectionService,
- @IOptionsService private readonly _optionsService: IOptionsService
- ) {
- super();
-
- this.register(addDisposableDomListener(this._element, 'mousedown', e => this._onMouseDown(e)));
-
- // These events are expensive, only listen to it when mouse zones are active
- this._mouseMoveListener = e => this._onMouseMove(e);
- this._mouseLeaveListener = e => this._onMouseLeave(e);
- this._clickListener = e => this._onClick(e);
- }
-
- public dispose(): void {
- super.dispose();
- this._deactivate();
- }
-
- public add(zone: IMouseZone): void {
- this._zones.push(zone);
- if (this._zones.length === 1) {
- this._activate();
- }
- }
-
- public clearAll(start?: number, end?: number): void {
- // Exit if there's nothing to clear
- if (this._zones.length === 0) {
- return;
- }
-
- // Clear all if start/end weren't set
- if (!start || !end) {
- start = 0;
- end = this._bufferService.rows - 1;
- }
-
- // Iterate through zones and clear them out if they're within the range
- for (let i = 0; i < this._zones.length; i++) {
- const 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 = undefined;
- }
- this._zones.splice(i--, 1);
- }
- }
-
- // Deactivate the mouse zone manager if all the zones have been removed
- if (this._zones.length === 0) {
- this._deactivate();
- }
- }
-
- private _activate(): void {
- if (!this._areZonesActive) {
- this._areZonesActive = true;
- this._element.addEventListener('mousemove', this._mouseMoveListener);
- this._element.addEventListener('mouseleave', this._mouseLeaveListener);
- this._element.addEventListener('click', this._clickListener);
- }
- }
-
- private _deactivate(): void {
- if (this._areZonesActive) {
- this._areZonesActive = false;
- this._element.removeEventListener('mousemove', this._mouseMoveListener);
- this._element.removeEventListener('mouseleave', this._mouseLeaveListener);
- this._element.removeEventListener('click', this._clickListener);
- }
- }
-
- private _onMouseMove(e: MouseEvent): void {
- // TODO: Ideally this would only clear the hover state when the mouse moves
- // outside of the mouse zone
- if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {
- this._onHover(e);
- // Record the current coordinates
- this._lastHoverCoords = [e.pageX, e.pageY];
- }
- }
-
- private _onHover(e: MouseEvent): void {
- const zone = this._findZoneEventAt(e);
-
- // Do nothing if the zone is the same
- if (zone === this._currentZone) {
- return;
- }
-
- // Fire the hover end callback and cancel any existing timer if a new zone
- // is being hovered
- if (this._currentZone) {
- this._currentZone.leaveCallback();
- this._currentZone = undefined;
- if (this._tooltipTimeout) {
- clearTimeout(this._tooltipTimeout);
- }
- }
-
- // Exit if there is not zone
- if (!zone) {
- return;
- }
- this._currentZone = zone;
-
- // Trigger the hover callback
- if (zone.hoverCallback) {
- zone.hoverCallback(e);
- }
-
- // Restart the tooltip timeout
- this._tooltipTimeout = window.setTimeout(() => this._onTooltip(e), this._optionsService.options.linkTooltipHoverDuration);
- }
-
- private _onTooltip(e: MouseEvent): void {
- this._tooltipTimeout = undefined;
- const zone = this._findZoneEventAt(e);
- zone?.tooltipCallback(e);
- }
-
- private _onMouseDown(e: MouseEvent): void {
- // Store current terminal selection length, to check if we're performing
- // a selection operation
- this._initialSelectionLength = this._getSelectionLength();
-
- // Ignore the event if there are no zones active
- if (!this._areZonesActive) {
- return;
- }
-
- // Find the active zone, prevent event propagation if found to prevent other
- // components from handling the mouse event.
- const zone = this._findZoneEventAt(e);
- if (zone?.willLinkActivate(e)) {
- e.preventDefault();
- e.stopImmediatePropagation();
- }
- }
-
- private _onMouseLeave(e: MouseEvent): void {
- // Fire the hover end callback and cancel any existing timer if the mouse
- // leaves the terminal element
- if (this._currentZone) {
- this._currentZone.leaveCallback();
- this._currentZone = undefined;
- if (this._tooltipTimeout) {
- clearTimeout(this._tooltipTimeout);
- }
- }
- }
-
- private _onClick(e: MouseEvent): void {
- // Find the active zone and click it if found and no selection was
- // being performed
- const zone = this._findZoneEventAt(e);
- const currentSelectionLength = this._getSelectionLength();
-
- if (zone && currentSelectionLength === this._initialSelectionLength) {
- zone.clickCallback(e);
- e.preventDefault();
- e.stopImmediatePropagation();
- }
- }
-
- private _getSelectionLength(): number {
- const selectionText = this._selectionService.selectionText;
- return selectionText ? selectionText.length : 0;
- }
-
- private _findZoneEventAt(e: MouseEvent): IMouseZone | undefined {
- const coords = this._mouseService.getCoords(e, this._screenElement, this._bufferService.cols, this._bufferService.rows);
- if (!coords) {
- return undefined;
- }
- const x = coords[0];
- const y = coords[1];
- for (let i = 0; i < this._zones.length; i++) {
- const zone = this._zones[i];
- if (zone.y1 === zone.y2) {
- // Single line link
- if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {
- return zone;
- }
- } else {
- // Multi-line link
- if ((y === zone.y1 && x >= zone.x1) ||
- (y === zone.y2 && x < zone.x2) ||
- (y > zone.y1 && y < zone.y2)) {
- return zone;
- }
- }
- }
- return undefined;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/RenderDebouncer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/RenderDebouncer.ts
deleted file mode 100644
index 02521070..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/RenderDebouncer.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderDebouncer } from 'browser/Types';
-
-/**
- * Debounces calls to render terminal rows using animation frames.
- */
-export class RenderDebouncer implements IRenderDebouncer {
- private _rowStart: number | undefined;
- private _rowEnd: number | undefined;
- private _rowCount: number | undefined;
- private _animationFrame: number | undefined;
-
- constructor(
- private _renderCallback: (start: number, end: number) => void
- ) {
- }
-
- public dispose(): void {
- if (this._animationFrame) {
- window.cancelAnimationFrame(this._animationFrame);
- this._animationFrame = undefined;
- }
- }
-
- public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void {
- this._rowCount = rowCount;
- // Get the min/max row start/end for the arg values
- rowStart = rowStart !== undefined ? rowStart : 0;
- rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1;
- // Set the properties to the updated values
- this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart;
- this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd;
-
- if (this._animationFrame) {
- return;
- }
-
- this._animationFrame = window.requestAnimationFrame(() => this._innerRefresh());
- }
-
- private _innerRefresh(): void {
- // Make sure values are set
- if (this._rowStart === undefined || this._rowEnd === undefined || this._rowCount === undefined) {
- return;
- }
-
- // Clamp values
- const start = Math.max(this._rowStart, 0);
- const end = Math.min(this._rowEnd, this._rowCount - 1);
-
- // Reset debouncer (this happens before render callback as the render could trigger it again)
- this._rowStart = undefined;
- this._rowEnd = undefined;
- this._animationFrame = undefined;
-
- // Run render callback
- this._renderCallback(start, end);
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ScreenDprMonitor.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ScreenDprMonitor.ts
deleted file mode 100644
index 27ae231f..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/ScreenDprMonitor.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { Disposable } from 'common/Lifecycle';
-
-export type ScreenDprListener = (newDevicePixelRatio?: number, oldDevicePixelRatio?: number) => void;
-
-/**
- * The screen device pixel ratio monitor allows listening for when the
- * window.devicePixelRatio value changes. This is done not with polling but with
- * the use of window.matchMedia to watch media queries. When the event fires,
- * the listener will be reattached using a different media query to ensure that
- * any further changes will register.
- *
- * The listener should fire on both window zoom changes and switching to a
- * monitor with a different DPI.
- */
-export class ScreenDprMonitor extends Disposable {
- private _currentDevicePixelRatio: number = window.devicePixelRatio;
- private _outerListener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | undefined;
- private _listener: ScreenDprListener | undefined;
- private _resolutionMediaMatchList: MediaQueryList | undefined;
-
- public setListener(listener: ScreenDprListener): void {
- if (this._listener) {
- this.clearListener();
- }
- this._listener = listener;
- this._outerListener = () => {
- if (!this._listener) {
- return;
- }
- this._listener(window.devicePixelRatio, this._currentDevicePixelRatio);
- this._updateDpr();
- };
- this._updateDpr();
- }
-
- public dispose(): void {
- super.dispose();
- this.clearListener();
- }
-
- private _updateDpr(): void {
- if (!this._outerListener) {
- return;
- }
-
- // Clear listeners for old DPR
- this._resolutionMediaMatchList?.removeListener(this._outerListener);
-
- // Add listeners for new DPR
- this._currentDevicePixelRatio = window.devicePixelRatio;
- this._resolutionMediaMatchList = window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);
- this._resolutionMediaMatchList.addListener(this._outerListener);
- }
-
- public clearListener(): void {
- if (!this._resolutionMediaMatchList || !this._listener || !this._outerListener) {
- return;
- }
- this._resolutionMediaMatchList.removeListener(this._outerListener);
- this._resolutionMediaMatchList = undefined;
- this._listener = undefined;
- this._outerListener = undefined;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Terminal.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Terminal.ts
deleted file mode 100644
index d28be5bf..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Terminal.ts
+++ /dev/null
@@ -1,1345 +0,0 @@
-/**
- * Copyright (c) 2014 The xterm.js authors. All rights reserved.
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
- * @license MIT
- *
- * 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.
- *
- * Terminal Emulation References:
- * http://vt100.net/
- * http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
- * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- * http://invisible-island.net/vttest/
- * http://www.inwap.com/pdp10/ansicode.txt
- * http://linux.die.net/man/4/console_codes
- * http://linux.die.net/man/7/urxvt
- */
-
-import { ICompositionHelper, ITerminal, IBrowser, CustomKeyEventHandler, ILinkifier, IMouseZoneManager, LinkMatcherHandler, ILinkMatcherOptions, IViewport, ILinkifier2, CharacterJoinerHandler } from 'browser/Types';
-import { IRenderer } from 'browser/renderer/Types';
-import { CompositionHelper } from 'browser/input/CompositionHelper';
-import { Viewport } from 'browser/Viewport';
-import { rightClickHandler, moveTextAreaUnderMouseCursor, handlePasteEvent, copyHandler, paste } from 'browser/Clipboard';
-import { C0 } from 'common/data/EscapeSequences';
-import { WindowsOptionsReportType } from '../common/InputHandler';
-import { Renderer } from 'browser/renderer/Renderer';
-import { Linkifier } from 'browser/Linkifier';
-import { SelectionService } from 'browser/services/SelectionService';
-import * as Browser from 'common/Platform';
-import { addDisposableDomListener } from 'browser/Lifecycle';
-import * as Strings from 'browser/LocalizableStrings';
-import { SoundService } from 'browser/services/SoundService';
-import { MouseZoneManager } from 'browser/MouseZoneManager';
-import { AccessibilityManager } from './AccessibilityManager';
-import { ITheme, IMarker, IDisposable, ISelectionPosition, ILinkProvider } from 'xterm';
-import { DomRenderer } from 'browser/renderer/dom/DomRenderer';
-import { IKeyboardEvent, KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions, ScrollSource, IAnsiColorChangeEvent } from 'common/Types';
-import { evaluateKeyboardEvent } from 'common/input/Keyboard';
-import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
-import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
-import { ColorManager } from 'browser/ColorManager';
-import { RenderService } from 'browser/services/RenderService';
-import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService, ICharacterJoinerService } from 'browser/services/Services';
-import { CharSizeService } from 'browser/services/CharSizeService';
-import { IBuffer } from 'common/buffer/Types';
-import { MouseService } from 'browser/services/MouseService';
-import { Linkifier2 } from 'browser/Linkifier2';
-import { CoreBrowserService } from 'browser/services/CoreBrowserService';
-import { CoreTerminal } from 'common/CoreTerminal';
-import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services';
-import { rgba } from 'browser/Color';
-import { CharacterJoinerService } from 'browser/services/CharacterJoinerService';
-
-// Let it work inside Node.js for automated testing purposes.
-const document: Document = (typeof window !== 'undefined') ? window.document : null as any;
-
-export class Terminal extends CoreTerminal implements ITerminal {
- public textarea: HTMLTextAreaElement | undefined;
- public element: HTMLElement | undefined;
- public screenElement: HTMLElement | undefined;
-
- private _document: Document | undefined;
- private _viewportScrollArea: HTMLElement | undefined;
- private _viewportElement: HTMLElement | undefined;
- private _helperContainer: HTMLElement | undefined;
- private _compositionView: HTMLElement | undefined;
-
- // private _visualBellTimer: number;
-
- public browser: IBrowser = Browser as any;
-
- // TODO: We should remove options once components adopt optionsService
- public get options(): IInitializedTerminalOptions { return this.optionsService.options; }
-
- private _customKeyEventHandler: CustomKeyEventHandler | undefined;
-
- // browser services
- private _charSizeService: ICharSizeService | undefined;
- private _mouseService: IMouseService | undefined;
- private _renderService: IRenderService | undefined;
- private _characterJoinerService: ICharacterJoinerService | undefined;
- private _selectionService: ISelectionService | undefined;
- private _soundService: ISoundService | undefined;
-
- /**
- * Records whether the keydown event has already been handled and triggered a data event, if so
- * the keypress event should not trigger a data event but should still print to the textarea so
- * screen readers will announce it.
- */
- private _keyDownHandled: boolean = false;
-
- /**
- * Records whether the keypress event has already been handled and triggered a data event, if so
- * the input event should not trigger a data event but should still print to the textarea so
- * screen readers will announce it.
- */
- private _keyPressHandled: boolean = false;
-
- /**
- * Records whether there has been a keydown event for a dead key without a corresponding keydown
- * event for the composed/alternative character. If we cancel the keydown event for the dead key,
- * no events will be emitted for the final character.
- */
- private _unprocessedDeadKey: boolean = false;
-
- public linkifier: ILinkifier;
- public linkifier2: ILinkifier2;
- public viewport: IViewport | undefined;
- private _compositionHelper: ICompositionHelper | undefined;
- private _mouseZoneManager: IMouseZoneManager | undefined;
- private _accessibilityManager: AccessibilityManager | undefined;
- private _colorManager: ColorManager | undefined;
- private _theme: ITheme | undefined;
-
- private _onCursorMove = new EventEmitter();
- public get onCursorMove(): IEvent { return this._onCursorMove.event; }
- private _onKey = new EventEmitter<{ key: string, domEvent: KeyboardEvent }>();
- public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._onKey.event; }
- private _onRender = new EventEmitter<{ start: number, end: number }>();
- public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }
- private _onSelectionChange = new EventEmitter();
- public get onSelectionChange(): IEvent { return this._onSelectionChange.event; }
- private _onTitleChange = new EventEmitter();
- public get onTitleChange(): IEvent { return this._onTitleChange.event; }
- private _onBell = new EventEmitter();
- public get onBell(): IEvent { return this._onBell.event; }
-
- private _onFocus = new EventEmitter();
- public get onFocus(): IEvent { return this._onFocus.event; }
- private _onBlur = new EventEmitter();
- public get onBlur(): IEvent { return this._onBlur.event; }
- private _onA11yCharEmitter = new EventEmitter();
- public get onA11yChar(): IEvent { return this._onA11yCharEmitter.event; }
- private _onA11yTabEmitter = new EventEmitter();
- public get onA11yTab(): IEvent { return this._onA11yTabEmitter.event; }
-
- /**
- * Creates a new `Terminal` object.
- *
- * @param options An object containing a set of options, the available options are:
- * - `cursorBlink` (boolean): Whether the terminal cursor blinks
- * - `cols` (number): The number of columns of the terminal (horizontal size)
- * - `rows` (number): The number of rows of the terminal (vertical size)
- *
- * @public
- * @class Xterm Xterm
- * @alias module:xterm/src/xterm
- */
- constructor(
- options: ITerminalOptions = {}
- ) {
- super(options);
-
- this._setup();
-
- this.linkifier = this._instantiationService.createInstance(Linkifier);
- this.linkifier2 = this.register(this._instantiationService.createInstance(Linkifier2));
-
- // Setup InputHandler listeners
- this.register(this._inputHandler.onRequestBell(() => this.bell()));
- this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end)));
- this.register(this._inputHandler.onRequestReset(() => this.reset()));
- this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type)));
- this.register(this._inputHandler.onAnsiColorChange((event) => this._changeAnsiColor(event)));
- this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove));
- this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange));
- this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
- this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
-
- // Setup listeners
- this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows)));
- }
-
- private _changeAnsiColor(event: IAnsiColorChangeEvent): void {
- if (!this._colorManager) { return; }
-
- for (const ansiColor of event.colors) {
- const color = rgba.toColor(ansiColor.red, ansiColor.green, ansiColor.blue);
-
- this._colorManager!.colors.ansi[ansiColor.colorIndex] = color;
- }
-
- this._renderService?.setColors(this._colorManager!.colors);
- this.viewport?.onThemeChange(this._colorManager!.colors);
- }
-
- public dispose(): void {
- if (this._isDisposed) {
- return;
- }
- super.dispose();
- this._renderService?.dispose();
- this._customKeyEventHandler = undefined;
- this.write = () => { };
- this.element?.parentNode?.removeChild(this.element);
- }
-
- protected _setup(): void {
- super._setup();
-
- this._customKeyEventHandler = undefined;
- }
-
- /**
- * Convenience property to active buffer.
- */
- public get buffer(): IBuffer {
- return this.buffers.active;
- }
-
- /**
- * Focus the terminal. Delegates focus handling to the terminal's DOM element.
- */
- public focus(): void {
- if (this.textarea) {
- this.textarea.focus({ preventScroll: true });
- }
- }
-
- protected _updateOptions(key: string): void {
- super._updateOptions(key);
-
- // TODO: These listeners should be owned by individual components
- switch (key) {
- case 'fontFamily':
- case 'fontSize':
- // When the font changes the size of the cells may change which requires a renderer clear
- this._renderService?.clear();
- this._charSizeService?.measure();
- break;
- case 'cursorBlink':
- case 'cursorStyle':
- // The DOM renderer needs a row refresh to update the cursor styles
- this.refresh(this.buffer.y, this.buffer.y);
- break;
- case 'customGlyphs':
- case 'drawBoldTextInBrightColors':
- case 'letterSpacing':
- case 'lineHeight':
- case 'fontWeight':
- case 'fontWeightBold':
- case 'minimumContrastRatio':
- // When the font changes the size of the cells may change which requires a renderer clear
- if (this._renderService) {
- this._renderService.clear();
- this._renderService.onResize(this.cols, this.rows);
- this.refresh(0, this.rows - 1);
- }
- break;
- case 'rendererType':
- if (this._renderService) {
- this._renderService.setRenderer(this._createRenderer());
- this._renderService.onResize(this.cols, this.rows);
- }
- break;
- case 'scrollback':
- this.viewport?.syncScrollArea();
- break;
- case 'screenReaderMode':
- if (this.optionsService.options.screenReaderMode) {
- if (!this._accessibilityManager && this._renderService) {
- this._accessibilityManager = new AccessibilityManager(this, this._renderService);
- }
- } else {
- this._accessibilityManager?.dispose();
- this._accessibilityManager = undefined;
- }
- break;
- case 'tabStopWidth': this.buffers.setupTabStops(); break;
- case 'theme':
- this._setTheme(this.optionsService.options.theme);
- break;
- }
- }
-
- /**
- * Binds the desired focus behavior on a given terminal object.
- */
- private _onTextAreaFocus(ev: KeyboardEvent): void {
- if (this.coreService.decPrivateModes.sendFocus) {
- this.coreService.triggerDataEvent(C0.ESC + '[I');
- }
- this.updateCursorStyle(ev);
- this.element!.classList.add('focus');
- this._showCursor();
- this._onFocus.fire();
- }
-
- /**
- * Blur the terminal, calling the blur function on the terminal's underlying
- * textarea.
- */
- public blur(): void {
- return this.textarea?.blur();
- }
-
- /**
- * Binds the desired blur behavior on a given terminal object.
- */
- private _onTextAreaBlur(): void {
- // Text can safely be removed on blur. Doing it earlier could interfere with
- // screen readers reading it out.
- this.textarea!.value = '';
- this.refresh(this.buffer.y, this.buffer.y);
- if (this.coreService.decPrivateModes.sendFocus) {
- this.coreService.triggerDataEvent(C0.ESC + '[O');
- }
- this.element!.classList.remove('focus');
- this._onBlur.fire();
- }
-
- private _syncTextArea(): void {
- if (!this.textarea || !this.buffer.isCursorInViewport || this._compositionHelper!.isComposing || !this._renderService) {
- return;
- }
- const cursorY = this.buffer.ybase + this.buffer.y;
- const bufferLine = this.buffer.lines.get(cursorY);
- if (!bufferLine) {
- return;
- }
- const cursorX = Math.min(this.buffer.x, this.cols - 1);
- const cellHeight = this._renderService.dimensions.actualCellHeight;
- const width = bufferLine.getWidth(cursorX);
- const cellWidth = this._renderService.dimensions.actualCellWidth * width;
- const cursorTop = this.buffer.y * this._renderService.dimensions.actualCellHeight;
- const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth;
-
- // Sync the textarea to the exact position of the composition view so the IME knows where the
- // text is.
- this.textarea.style.left = cursorLeft + 'px';
- this.textarea.style.top = cursorTop + 'px';
- this.textarea.style.width = cellWidth + 'px';
- this.textarea.style.height = cellHeight + 'px';
- this.textarea.style.lineHeight = cellHeight + 'px';
- this.textarea.style.zIndex = '-5';
- }
-
- /**
- * Initialize default behavior
- */
- private _initGlobal(): void {
- this._bindKeys();
-
- // Bind clipboard functionality
- this.register(addDisposableDomListener(this.element!, 'copy', (event: ClipboardEvent) => {
- // If mouse events are active it means the selection manager is disabled and
- // copy should be handled by the host program.
- if (!this.hasSelection()) {
- return;
- }
- copyHandler(event, this._selectionService!);
- }));
- const pasteHandlerWrapper = (event: ClipboardEvent): void => handlePasteEvent(event, this.textarea!, this.coreService);
- this.register(addDisposableDomListener(this.textarea!, 'paste', pasteHandlerWrapper));
- this.register(addDisposableDomListener(this.element!, 'paste', pasteHandlerWrapper));
-
- // Handle right click context menus
- if (Browser.isFirefox) {
- // Firefox doesn't appear to fire the contextmenu event on right click
- this.register(addDisposableDomListener(this.element!, 'mousedown', (event: MouseEvent) => {
- if (event.button === 2) {
- rightClickHandler(event, this.textarea!, this.screenElement!, this._selectionService!, this.options.rightClickSelectsWord);
- }
- }));
- } else {
- this.register(addDisposableDomListener(this.element!, 'contextmenu', (event: MouseEvent) => {
- rightClickHandler(event, this.textarea!, this.screenElement!, this._selectionService!, this.options.rightClickSelectsWord);
- }));
- }
-
- // Move the textarea under the cursor when middle clicking on Linux to ensure
- // middle click to paste selection works. This only appears to work in Chrome
- // at the time is writing.
- if (Browser.isLinux) {
- // Use auxclick event over mousedown the latter doesn't seem to work. Note
- // that the regular click event doesn't fire for the middle mouse button.
- this.register(addDisposableDomListener(this.element!, 'auxclick', (event: MouseEvent) => {
- if (event.button === 1) {
- moveTextAreaUnderMouseCursor(event, this.textarea!, this.screenElement!);
- }
- }));
- }
- }
-
- /**
- * Apply key handling to the terminal
- */
- private _bindKeys(): void {
- this.register(addDisposableDomListener(this.textarea!, 'keyup', (ev: KeyboardEvent) => this._keyUp(ev), true));
- this.register(addDisposableDomListener(this.textarea!, 'keydown', (ev: KeyboardEvent) => this._keyDown(ev), true));
- this.register(addDisposableDomListener(this.textarea!, 'keypress', (ev: KeyboardEvent) => this._keyPress(ev), true));
- this.register(addDisposableDomListener(this.textarea!, 'compositionstart', () => this._compositionHelper!.compositionstart()));
- this.register(addDisposableDomListener(this.textarea!, 'compositionupdate', (e: CompositionEvent) => this._compositionHelper!.compositionupdate(e)));
- this.register(addDisposableDomListener(this.textarea!, 'compositionend', () => this._compositionHelper!.compositionend()));
- this.register(addDisposableDomListener(this.textarea!, 'input', (ev: InputEvent) => this._inputEvent(ev), true));
- this.register(this.onRender(() => this._compositionHelper!.updateCompositionElements()));
- this.register(this.onRender(e => this._queueLinkification(e.start, e.end)));
- }
-
- /**
- * Opens the terminal within an element.
- *
- * @param parent The element to create the terminal within.
- */
- public open(parent: HTMLElement): void {
- if (!parent) {
- throw new Error('Terminal requires a parent element.');
- }
-
- if (!parent.isConnected) {
- this._logService.debug('Terminal.open was called on an element that was not attached to the DOM');
- }
-
- this._document = parent.ownerDocument!;
-
- // Create main element container
- this.element = this._document.createElement('div');
- this.element.dir = 'ltr'; // xterm.css assumes LTR
- this.element.classList.add('terminal');
- this.element.classList.add('xterm');
- this.element.setAttribute('tabindex', '0');
- parent.appendChild(this.element);
-
- // Performance: Use a document fragment to build the terminal
- // viewport and helper elements detached from the DOM
- const fragment = document.createDocumentFragment();
- this._viewportElement = document.createElement('div');
- this._viewportElement.classList.add('xterm-viewport');
- fragment.appendChild(this._viewportElement);
- this._viewportScrollArea = document.createElement('div');
- this._viewportScrollArea.classList.add('xterm-scroll-area');
- this._viewportElement.appendChild(this._viewportScrollArea);
-
- this.screenElement = document.createElement('div');
- this.screenElement.classList.add('xterm-screen');
- // Create the container that will hold helpers like the textarea for
- // capturing DOM Events. Then produce the helpers.
- this._helperContainer = document.createElement('div');
- this._helperContainer.classList.add('xterm-helpers');
- this.screenElement.appendChild(this._helperContainer);
- fragment.appendChild(this.screenElement);
-
- this.textarea = document.createElement('textarea');
- this.textarea.classList.add('xterm-helper-textarea');
- this.textarea.setAttribute('aria-label', Strings.promptLabel);
- this.textarea.setAttribute('aria-multiline', 'false');
- this.textarea.setAttribute('autocorrect', 'off');
- this.textarea.setAttribute('autocapitalize', 'off');
- this.textarea.setAttribute('spellcheck', 'false');
- this.textarea.tabIndex = 0;
- this.register(addDisposableDomListener(this.textarea, 'focus', (ev: KeyboardEvent) => this._onTextAreaFocus(ev)));
- this.register(addDisposableDomListener(this.textarea, 'blur', () => this._onTextAreaBlur()));
- this._helperContainer.appendChild(this.textarea);
-
- const coreBrowserService = this._instantiationService.createInstance(CoreBrowserService, this.textarea);
- this._instantiationService.setService(ICoreBrowserService, coreBrowserService);
-
- this._charSizeService = this._instantiationService.createInstance(CharSizeService, this._document, this._helperContainer);
- this._instantiationService.setService(ICharSizeService, this._charSizeService);
-
- this._theme = this.options.theme || this._theme;
- this._colorManager = new ColorManager(document, this.options.allowTransparency);
- this.register(this.optionsService.onOptionChange(e => this._colorManager!.onOptionsChange(e)));
- this._colorManager.setTheme(this._theme);
-
- this._characterJoinerService = this._instantiationService.createInstance(CharacterJoinerService);
- this._instantiationService.setService(ICharacterJoinerService, this._characterJoinerService);
-
- const renderer = this._createRenderer();
- this._renderService = this.register(this._instantiationService.createInstance(RenderService, renderer, this.rows, this.screenElement));
- this._instantiationService.setService(IRenderService, this._renderService);
- this.register(this._renderService.onRenderedBufferChange(e => this._onRender.fire(e)));
- this.onResize(e => this._renderService!.resize(e.cols, e.rows));
-
- this._compositionView = document.createElement('div');
- this._compositionView.classList.add('composition-view');
- this._compositionHelper = this._instantiationService.createInstance(CompositionHelper, this.textarea, this._compositionView);
- this._helperContainer.appendChild(this._compositionView);
-
- // Performance: Add viewport and helper elements from the fragment
- this.element.appendChild(fragment);
-
- this._soundService = this._instantiationService.createInstance(SoundService);
- this._instantiationService.setService(ISoundService, this._soundService);
- this._mouseService = this._instantiationService.createInstance(MouseService);
- this._instantiationService.setService(IMouseService, this._mouseService);
-
- this.viewport = this._instantiationService.createInstance(Viewport,
- (amount: number) => this.scrollLines(amount, true, ScrollSource.VIEWPORT),
- this._viewportElement,
- this._viewportScrollArea
- );
- this.viewport.onThemeChange(this._colorManager.colors);
- this.register(this._inputHandler.onRequestSyncScrollBar(() => this.viewport!.syncScrollArea()));
- this.register(this.viewport);
-
- this.register(this.onCursorMove(() => {
- this._renderService!.onCursorMove();
- this._syncTextArea();
- }));
- this.register(this.onResize(() => this._renderService!.onResize(this.cols, this.rows)));
- this.register(this.onBlur(() => this._renderService!.onBlur()));
- this.register(this.onFocus(() => this._renderService!.onFocus()));
- this.register(this._renderService.onDimensionsChange(() => this.viewport!.syncScrollArea()));
-
- this._selectionService = this.register(this._instantiationService.createInstance(SelectionService,
- this.element,
- this.screenElement,
- this.linkifier2
- ));
- this._instantiationService.setService(ISelectionService, this._selectionService);
- this.register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent)));
- this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire()));
- this.register(this._selectionService.onRequestRedraw(e => this._renderService!.onSelectionChanged(e.start, e.end, e.columnSelectMode)));
- this.register(this._selectionService.onLinuxMouseSelection(text => {
- // If there's a new selection, put it into the textarea, focus and select it
- // in order to register it as a selection on the OS. This event is fired
- // only on Linux to enable middle click to paste selection.
- this.textarea!.value = text;
- this.textarea!.focus();
- this.textarea!.select();
- }));
- this.register(this._onScroll.event(ev => {
- this.viewport!.syncScrollArea();
- this._selectionService!.refresh();
- }));
- this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this._selectionService!.refresh()));
-
- this._mouseZoneManager = this._instantiationService.createInstance(MouseZoneManager, this.element, this.screenElement);
- this.register(this._mouseZoneManager);
- this.register(this.onScroll(() => this._mouseZoneManager!.clearAll()));
- this.linkifier.attachToDom(this.element, this._mouseZoneManager);
- this.linkifier2.attachToDom(this.element, this._mouseService, this._renderService);
-
- // This event listener must be registered aftre MouseZoneManager is created
- this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e)));
-
- // apply mouse event classes set by escape codes before terminal was attached
- if (this.coreMouseService.areMouseEventsActive) {
- this._selectionService.disable();
- this.element.classList.add('enable-mouse-events');
- } else {
- this._selectionService.enable();
- }
-
- if (this.options.screenReaderMode) {
- // Note that this must be done *after* the renderer is created in order to
- // ensure the correct order of the dprchange event
- this._accessibilityManager = new AccessibilityManager(this, this._renderService);
- }
-
- // Measure the character size
- this._charSizeService.measure();
-
- // Setup loop that draws to screen
- this.refresh(0, this.rows - 1);
-
- // Initialize global actions that need to be taken on the document.
- this._initGlobal();
-
- // Listen for mouse events and translate
- // them into terminal mouse protocols.
- this.bindMouse();
- }
-
- private _createRenderer(): IRenderer {
- switch (this.options.rendererType) {
- case 'canvas': return this._instantiationService.createInstance(Renderer, this._colorManager!.colors, this.screenElement!, this.linkifier, this.linkifier2);
- case 'dom': return this._instantiationService.createInstance(DomRenderer, this._colorManager!.colors, this.element!, this.screenElement!, this._viewportElement!, this.linkifier, this.linkifier2);
- default: throw new Error(`Unrecognized rendererType "${this.options.rendererType}"`);
- }
- }
-
- /**
- * Sets the theme on the renderer. The renderer must have been initialized.
- * @param theme The theme to set.
- */
- private _setTheme(theme: ITheme): void {
- this._theme = theme;
- this._colorManager?.setTheme(theme);
- this._renderService?.setColors(this._colorManager!.colors);
- this.viewport?.onThemeChange(this._colorManager!.colors);
- }
-
- /**
- * Bind certain mouse events to the terminal.
- * By default only 3 button + wheel up/down is ativated. For higher buttons
- * no mouse report will be created. Typically the standard actions will be active.
- *
- * There are several reasons not to enable support for higher buttons/wheel:
- * - Button 4 and 5 are typically used for history back and forward navigation,
- * there is no straight forward way to supress/intercept those standard actions.
- * - Support for higher buttons does not work in some platform/browser combinations.
- * - Left/right wheel was not tested.
- * - Emulators vary in mouse button support, typically only 3 buttons and
- * wheel up/down work reliable.
- *
- * TODO: Move mouse event code into its own file.
- */
- public bindMouse(): void {
- const self = this;
- const el = this.element!;
-
- // send event to CoreMouseService
- function sendEvent(ev: MouseEvent | WheelEvent): boolean {
- // get mouse coordinates
- const pos = self._mouseService!.getRawByteCoords(ev, self.screenElement!, self.cols, self.rows);
- if (!pos) {
- return false;
- }
-
- let but: CoreMouseButton;
- let action: CoreMouseAction | undefined;
- switch ((ev as any).overrideType || ev.type) {
- case 'mousemove':
- action = CoreMouseAction.MOVE;
- if (ev.buttons === undefined) {
- // buttons is not supported on macOS, try to get a value from button instead
- but = CoreMouseButton.NONE;
- if (ev.button !== undefined) {
- but = ev.button < 3 ? ev.button : CoreMouseButton.NONE;
- }
- } else {
- // according to MDN buttons only reports up to button 5 (AUX2)
- but = ev.buttons & 1 ? CoreMouseButton.LEFT :
- ev.buttons & 4 ? CoreMouseButton.MIDDLE :
- ev.buttons & 2 ? CoreMouseButton.RIGHT :
- CoreMouseButton.NONE; // fallback to NONE
- }
- break;
- case 'mouseup':
- action = CoreMouseAction.UP;
- but = ev.button < 3 ? ev.button : CoreMouseButton.NONE;
- break;
- case 'mousedown':
- action = CoreMouseAction.DOWN;
- but = ev.button < 3 ? ev.button : CoreMouseButton.NONE;
- break;
- case 'wheel':
- // only UP/DOWN wheel events are respected
- if ((ev as WheelEvent).deltaY !== 0) {
- action = (ev as WheelEvent).deltaY < 0 ? CoreMouseAction.UP : CoreMouseAction.DOWN;
- }
- but = CoreMouseButton.WHEEL;
- break;
- default:
- // dont handle other event types by accident
- return false;
- }
-
- // exit if we cannot determine valid button/action values
- // do nothing for higher buttons than wheel
- if (action === undefined || but === undefined || but > CoreMouseButton.WHEEL) {
- return false;
- }
-
- return self.coreMouseService.triggerMouseEvent({
- col: pos.x - 33, // FIXME: why -33 here?
- row: pos.y - 33,
- button: but,
- action,
- ctrl: ev.ctrlKey,
- alt: ev.altKey,
- shift: ev.shiftKey
- });
- }
-
- /**
- * Event listener state handling.
- * We listen to the onProtocolChange event of CoreMouseService and put
- * requested listeners in `requestedEvents`. With this the listeners
- * have all bits to do the event listener juggling.
- * Note: 'mousedown' currently is "always on" and not managed
- * by onProtocolChange.
- */
- const requestedEvents: { [key: string]: ((ev: Event) => void) | null } = {
- mouseup: null,
- wheel: null,
- mousedrag: null,
- mousemove: null
- };
- const eventListeners: { [key: string]: (ev: any) => void | boolean } = {
- mouseup: (ev: MouseEvent) => {
- sendEvent(ev);
- if (!ev.buttons) {
- // if no other button is held remove global handlers
- this._document!.removeEventListener('mouseup', requestedEvents.mouseup!);
- if (requestedEvents.mousedrag) {
- this._document!.removeEventListener('mousemove', requestedEvents.mousedrag);
- }
- }
- return this.cancel(ev);
- },
- wheel: (ev: WheelEvent) => {
- sendEvent(ev);
- ev.preventDefault();
- return this.cancel(ev);
- },
- mousedrag: (ev: MouseEvent) => {
- // deal only with move while a button is held
- if (ev.buttons) {
- sendEvent(ev);
- }
- },
- mousemove: (ev: MouseEvent) => {
- // deal only with move without any button
- if (!ev.buttons) {
- sendEvent(ev);
- }
- }
- };
- this.register(this.coreMouseService.onProtocolChange(events => {
- // apply global changes on events
- if (events) {
- if (this.optionsService.options.logLevel === 'debug') {
- this._logService.debug('Binding to mouse events:', this.coreMouseService.explainEvents(events));
- }
- this.element!.classList.add('enable-mouse-events');
- this._selectionService!.disable();
- } else {
- this._logService.debug('Unbinding from mouse events.');
- this.element!.classList.remove('enable-mouse-events');
- this._selectionService!.enable();
- }
-
- // add/remove handlers from requestedEvents
-
- if (!(events & CoreMouseEventType.MOVE)) {
- el.removeEventListener('mousemove', requestedEvents.mousemove!);
- requestedEvents.mousemove = null;
- } else if (!requestedEvents.mousemove) {
- el.addEventListener('mousemove', eventListeners.mousemove);
- requestedEvents.mousemove = eventListeners.mousemove;
- }
-
- if (!(events & CoreMouseEventType.WHEEL)) {
- el.removeEventListener('wheel', requestedEvents.wheel!);
- requestedEvents.wheel = null;
- } else if (!requestedEvents.wheel) {
- el.addEventListener('wheel', eventListeners.wheel, { passive: false });
- requestedEvents.wheel = eventListeners.wheel;
- }
-
- if (!(events & CoreMouseEventType.UP)) {
- this._document!.removeEventListener('mouseup', requestedEvents.mouseup!);
- requestedEvents.mouseup = null;
- } else if (!requestedEvents.mouseup) {
- requestedEvents.mouseup = eventListeners.mouseup;
- }
-
- if (!(events & CoreMouseEventType.DRAG)) {
- this._document!.removeEventListener('mousemove', requestedEvents.mousedrag!);
- requestedEvents.mousedrag = null;
- } else if (!requestedEvents.mousedrag) {
- requestedEvents.mousedrag = eventListeners.mousedrag;
- }
- }));
- // force initial onProtocolChange so we dont miss early mouse requests
- this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol;
-
- /**
- * "Always on" event listeners.
- */
- this.register(addDisposableDomListener(el, 'mousedown', (ev: MouseEvent) => {
- ev.preventDefault();
- this.focus();
-
- // Don't send the mouse button to the pty if mouse events are disabled or
- // if the selection manager is having selection forced (ie. a modifier is
- // held).
- if (!this.coreMouseService.areMouseEventsActive || this._selectionService!.shouldForceSelection(ev)) {
- return;
- }
-
- sendEvent(ev);
-
- // Register additional global handlers which should keep reporting outside
- // of the terminal element.
- // Note: Other emulators also do this for 'mousedown' while a button
- // is held, we currently limit 'mousedown' to the terminal only.
- if (requestedEvents.mouseup) {
- this._document!.addEventListener('mouseup', requestedEvents.mouseup);
- }
- if (requestedEvents.mousedrag) {
- this._document!.addEventListener('mousemove', requestedEvents.mousedrag);
- }
-
- return this.cancel(ev);
- }));
-
- this.register(addDisposableDomListener(el, 'wheel', (ev: WheelEvent) => {
- if (!requestedEvents.wheel) {
- // Convert wheel events into up/down events when the buffer does not have scrollback, this
- // enables scrolling in apps hosted in the alt buffer such as vim or tmux.
- if (!this.buffer.hasScrollback) {
- const amount = this.viewport!.getLinesScrolled(ev);
-
- // Do nothing if there's no vertical scroll
- if (amount === 0) {
- return;
- }
-
- // Construct and send sequences
- const sequence = C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B');
- let data = '';
- for (let i = 0; i < Math.abs(amount); i++) {
- data += sequence;
- }
- this.coreService.triggerDataEvent(data, true);
- }
- return;
- }
- }, { passive: true }));
-
- // allow wheel scrolling in
- // the shell for example
- this.register(addDisposableDomListener(el, 'wheel', (ev: WheelEvent) => {
- if (requestedEvents.wheel) return;
- if (!this.viewport!.onWheel(ev)) {
- return this.cancel(ev);
- }
- }, { passive: false }));
-
- this.register(addDisposableDomListener(el, 'touchstart', (ev: TouchEvent) => {
- if (this.coreMouseService.areMouseEventsActive) return;
- this.viewport!.onTouchStart(ev);
- return this.cancel(ev);
- }, { passive: true }));
-
- this.register(addDisposableDomListener(el, 'touchmove', (ev: TouchEvent) => {
- if (this.coreMouseService.areMouseEventsActive) return;
- if (!this.viewport!.onTouchMove(ev)) {
- return this.cancel(ev);
- }
- }, { passive: false }));
- }
-
-
- /**
- * Tells the renderer to refresh terminal content between two rows (inclusive) at the next
- * opportunity.
- * @param start The row to start from (between 0 and this.rows - 1).
- * @param end The row to end at (between start and this.rows - 1).
- */
- public refresh(start: number, end: number): void {
- this._renderService?.refreshRows(start, end);
- }
-
- /**
- * Queues linkification for the specified rows.
- * @param start The row to start from (between 0 and this.rows - 1).
- * @param end The row to end at (between start and this.rows - 1).
- */
- private _queueLinkification(start: number, end: number): void {
- this.linkifier?.linkifyRows(start, end);
- }
-
- /**
- * Change the cursor style for different selection modes
- */
- public updateCursorStyle(ev: KeyboardEvent): void {
- if (this._selectionService?.shouldColumnSelect(ev)) {
- this.element!.classList.add('column-select');
- } else {
- this.element!.classList.remove('column-select');
- }
- }
-
- /**
- * Display the cursor element
- */
- private _showCursor(): void {
- if (!this.coreService.isCursorInitialized) {
- this.coreService.isCursorInitialized = true;
- this.refresh(this.buffer.y, this.buffer.y);
- }
- }
-
- public scrollLines(disp: number, suppressScrollEvent?: boolean, source = ScrollSource.TERMINAL): void {
- super.scrollLines(disp, suppressScrollEvent, source);
- this.refresh(0, this.rows - 1);
- }
-
- public paste(data: string): void {
- paste(data, this.textarea!, this.coreService);
- }
-
- /**
- * Attaches a custom key event handler which is run before keys are processed,
- * giving consumers of xterm.js ultimate control as to what keys should be
- * processed by the terminal and what keys should not.
- * @param customKeyEventHandler The custom KeyboardEvent handler to attach.
- * This is a function that takes a KeyboardEvent, allowing consumers to stop
- * propagation and/or prevent the default action. The function returns whether
- * the event should be processed by xterm.js.
- */
- public attachCustomKeyEventHandler(customKeyEventHandler: CustomKeyEventHandler): void {
- this._customKeyEventHandler = customKeyEventHandler;
- }
-
- /**
- * Registers a link matcher, allowing custom link patterns to be matched and
- * handled.
- * @param regex The regular expression to search for, specifically
- * this searches the textContent of the rows. You will want to use \s to match
- * a space ' ' character for example.
- * @param handler The callback when the link is called.
- * @param options Options for the link matcher.
- * @return The ID of the new matcher, this can be used to deregister.
- */
- public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number {
- const matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);
- this.refresh(0, this.rows - 1);
- return matcherId;
- }
-
- /**
- * Deregisters a link matcher if it has been registered.
- * @param matcherId The link matcher's ID (returned after register)
- */
- public deregisterLinkMatcher(matcherId: number): void {
- if (this.linkifier.deregisterLinkMatcher(matcherId)) {
- this.refresh(0, this.rows - 1);
- }
- }
-
- public registerLinkProvider(linkProvider: ILinkProvider): IDisposable {
- return this.linkifier2.registerLinkProvider(linkProvider);
- }
-
- public registerCharacterJoiner(handler: CharacterJoinerHandler): number {
- if (!this._characterJoinerService) {
- throw new Error('Terminal must be opened first');
- }
- const joinerId = this._characterJoinerService.register(handler);
- this.refresh(0, this.rows - 1);
- return joinerId;
- }
-
- public deregisterCharacterJoiner(joinerId: number): void {
- if (!this._characterJoinerService) {
- throw new Error('Terminal must be opened first');
- }
- if (this._characterJoinerService.deregister(joinerId)) {
- this.refresh(0, this.rows - 1);
- }
- }
-
- public get markers(): IMarker[] {
- return this.buffer.markers;
- }
-
- public addMarker(cursorYOffset: number): IMarker | undefined {
- // Disallow markers on the alt buffer
- if (this.buffer !== this.buffers.normal) {
- return;
- }
-
- return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset);
- }
-
- /**
- * Gets whether the terminal has an active selection.
- */
- public hasSelection(): boolean {
- return this._selectionService ? this._selectionService.hasSelection : false;
- }
-
- /**
- * Selects text within the terminal.
- * @param column The column the selection starts at..
- * @param row The row the selection starts at.
- * @param length The length of the selection.
- */
- public select(column: number, row: number, length: number): void {
- this._selectionService!.setSelection(column, row, length);
- }
-
- /**
- * Gets the terminal's current selection, this is useful for implementing copy
- * behavior outside of xterm.js.
- */
- public getSelection(): string {
- return this._selectionService ? this._selectionService.selectionText : '';
- }
-
- public getSelectionPosition(): ISelectionPosition | undefined {
- if (!this._selectionService || !this._selectionService.hasSelection) {
- return undefined;
- }
-
- return {
- startColumn: this._selectionService.selectionStart![0],
- startRow: this._selectionService.selectionStart![1],
- endColumn: this._selectionService.selectionEnd![0],
- endRow: this._selectionService.selectionEnd![1]
- };
- }
-
- /**
- * Clears the current terminal selection.
- */
- public clearSelection(): void {
- this._selectionService?.clearSelection();
- }
-
- /**
- * Selects all text within the terminal.
- */
- public selectAll(): void {
- this._selectionService?.selectAll();
- }
-
- public selectLines(start: number, end: number): void {
- this._selectionService?.selectLines(start, end);
- }
-
- /**
- * Handle a keydown event
- * Key Resources:
- * - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
- * @param ev The keydown event to be handled.
- */
- protected _keyDown(event: KeyboardEvent): boolean | undefined {
- this._keyDownHandled = false;
-
- if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {
- return false;
- }
-
- if (!this._compositionHelper!.keydown(event)) {
- if (this.buffer.ybase !== this.buffer.ydisp) {
- this._bufferService.scrollToBottom();
- }
- return false;
- }
-
- if (event.key === 'Dead' || event.key === 'AltGraph') {
- this._unprocessedDeadKey = true;
- }
-
- const result = evaluateKeyboardEvent(event, this.coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta);
-
- this.updateCursorStyle(event);
-
- if (result.type === KeyboardResultType.PAGE_DOWN || result.type === KeyboardResultType.PAGE_UP) {
- const scrollCount = this.rows - 1;
- this.scrollLines(result.type === KeyboardResultType.PAGE_UP ? -scrollCount : scrollCount);
- return this.cancel(event, true);
- }
-
- if (result.type === KeyboardResultType.SELECT_ALL) {
- this.selectAll();
- }
-
- if (this._isThirdLevelShift(this.browser, event)) {
- return true;
- }
-
- if (result.cancel) {
- // The event is canceled at the end already, is this necessary?
- this.cancel(event, true);
- }
-
- if (!result.key) {
- return true;
- }
-
- if (this._unprocessedDeadKey) {
- this._unprocessedDeadKey = false;
- return true;
- }
-
- // If ctrl+c or enter is being sent, clear out the textarea. This is done so that screen readers
- // will announce deleted characters. This will not work 100% of the time but it should cover
- // most scenarios.
- if (result.key === C0.ETX || result.key === C0.CR) {
- this.textarea!.value = '';
- }
-
- this._onKey.fire({ key: result.key, domEvent: event });
- this._showCursor();
- this.coreService.triggerDataEvent(result.key, true);
-
- // Cancel events when not in screen reader mode so events don't get bubbled up and handled by
- // other listeners. When screen reader mode is enabled, this could cause issues if the event
- // is handled at a higher level, this is a compromise in order to echo keys to the screen
- // reader.
- if (!this.optionsService.options.screenReaderMode) {
- return this.cancel(event, true);
- }
-
- this._keyDownHandled = true;
- }
-
- private _isThirdLevelShift(browser: IBrowser, ev: KeyboardEvent): boolean {
- const thirdLevelKey =
- (browser.isMac && !this.options.macOptionIsMeta && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||
- (browser.isWindows && ev.altKey && ev.ctrlKey && !ev.metaKey) ||
- (browser.isWindows && ev.getModifierState('AltGraph'));
-
- if (ev.type === 'keypress') {
- return thirdLevelKey;
- }
-
- // Don't invoke for arrows, pageDown, home, backspace, etc. (on non-keypress events)
- return thirdLevelKey && (!ev.keyCode || ev.keyCode > 47);
- }
-
- protected _keyUp(ev: KeyboardEvent): void {
- if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
- return;
- }
-
- if (!wasModifierKeyOnlyEvent(ev)) {
- this.focus();
- }
-
- this.updateCursorStyle(ev);
- this._keyPressHandled = false;
- }
-
- /**
- * Handle a keypress event.
- * Key Resources:
- * - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
- * @param ev The keypress event to be handled.
- */
- protected _keyPress(ev: KeyboardEvent): boolean {
- let key;
-
- this._keyPressHandled = false;
-
- if (this._keyDownHandled) {
- return false;
- }
-
- if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
- return false;
- }
-
- this.cancel(ev);
-
- if (ev.charCode) {
- key = ev.charCode;
- } else if (ev.which === null || ev.which === undefined) {
- key = ev.keyCode;
- } else if (ev.which !== 0 && ev.charCode !== 0) {
- key = ev.which;
- } else {
- return false;
- }
-
- if (!key || (
- (ev.altKey || ev.ctrlKey || ev.metaKey) && !this._isThirdLevelShift(this.browser, ev)
- )) {
- return false;
- }
-
- key = String.fromCharCode(key);
-
- this._onKey.fire({ key, domEvent: ev });
- this._showCursor();
- this.coreService.triggerDataEvent(key, true);
-
- this._keyPressHandled = true;
-
- return true;
- }
-
- /**
- * Handle an input event.
- * Key Resources:
- * - https://developer.mozilla.org/en-US/docs/Web/API/InputEvent
- * @param ev The input event to be handled.
- */
- protected _inputEvent(ev: InputEvent): boolean {
- // Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to
- // support reading out character input which can doubling up input characters
- if (ev.data && ev.inputType === 'insertText' && !this.optionsService.options.screenReaderMode) {
- if (this._keyPressHandled) {
- return false;
- }
-
- const text = ev.data;
- this.coreService.triggerDataEvent(text, true);
-
- this.cancel(ev);
- return true;
- }
-
- return false;
- }
-
- /**
- * Ring the bell.
- * Note: We could do sweet things with webaudio here
- */
- public bell(): void {
- if (this._soundBell()) {
- this._soundService?.playBellSound();
- }
-
- this._onBell.fire();
-
- // if (this._visualBell()) {
- // this.element.classList.add('visual-bell-active');
- // clearTimeout(this._visualBellTimer);
- // this._visualBellTimer = window.setTimeout(() => {
- // this.element.classList.remove('visual-bell-active');
- // }, 200);
- // }
- }
-
- /**
- * Resizes the terminal.
- *
- * @param x The number of columns to resize to.
- * @param y The number of rows to resize to.
- */
- public resize(x: number, y: number): void {
- if (x === this.cols && y === this.rows) {
- // Check if we still need to measure the char size (fixes #785).
- if (this._charSizeService && !this._charSizeService.hasValidSize) {
- this._charSizeService.measure();
- }
- return;
- }
-
- super.resize(x, y);
- }
-
- private _afterResize(x: number, y: number): void {
- this._charSizeService?.measure();
-
- // Sync the scroll area to make sure scroll events don't fire and scroll the viewport to an
- // invalid location
- this.viewport?.syncScrollArea(true);
- }
-
- /**
- * Clear the entire buffer, making the prompt line the new first line.
- */
- public clear(): void {
- if (this.buffer.ybase === 0 && this.buffer.y === 0) {
- // Don't clear if it's already clear
- return;
- }
- this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y)!);
- this.buffer.lines.length = 1;
- this.buffer.ydisp = 0;
- this.buffer.ybase = 0;
- this.buffer.y = 0;
- for (let i = 1; i < this.rows; i++) {
- this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA));
- }
- this.refresh(0, this.rows - 1);
- this._onScroll.fire({ position: this.buffer.ydisp, source: ScrollSource.TERMINAL });
- }
-
- /**
- * Reset terminal.
- * Note: Calling this directly from JS is synchronous but does not clear
- * input buffers and does not reset the parser, thus the terminal will
- * continue to apply pending input data.
- * If you need in band reset (synchronous with input data) consider
- * using DECSTR (soft reset, CSI ! p) or RIS instead (hard reset, ESC c).
- */
- public reset(): void {
- /**
- * Since _setup handles a full terminal creation, we have to carry forward
- * a few things that should not reset.
- */
- this.options.rows = this.rows;
- this.options.cols = this.cols;
- const customKeyEventHandler = this._customKeyEventHandler;
-
- this._setup();
- super.reset();
- this._selectionService?.reset();
-
- // reattach
- this._customKeyEventHandler = customKeyEventHandler;
-
- // do a full screen refresh
- this.refresh(0, this.rows - 1);
- this.viewport?.syncScrollArea();
- }
-
- private _reportWindowsOptions(type: WindowsOptionsReportType): void {
- if (!this._renderService) {
- return;
- }
-
- switch (type) {
- case WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:
- const canvasWidth = this._renderService.dimensions.scaledCanvasWidth.toFixed(0);
- const canvasHeight = this._renderService.dimensions.scaledCanvasHeight.toFixed(0);
- this.coreService.triggerDataEvent(`${C0.ESC}[4;${canvasHeight};${canvasWidth}t`);
- break;
- case WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:
- const cellWidth = this._renderService.dimensions.scaledCellWidth.toFixed(0);
- const cellHeight = this._renderService.dimensions.scaledCellHeight.toFixed(0);
- this.coreService.triggerDataEvent(`${C0.ESC}[6;${cellHeight};${cellWidth}t`);
- break;
- }
- }
-
- // TODO: Remove cancel function and cancelEvents option
- public cancel(ev: Event, force?: boolean): boolean | undefined {
- if (!this.options.cancelEvents && !force) {
- return;
- }
- ev.preventDefault();
- ev.stopPropagation();
- return false;
- }
-
- private _visualBell(): boolean {
- return false;
- // return this.options.bellStyle === 'visual' ||
- // this.options.bellStyle === 'both';
- }
-
- private _soundBell(): boolean {
- return this.options.bellStyle === 'sound';
- // return this.options.bellStyle === 'sound' ||
- // this.options.bellStyle === 'both';
- }
-}
-
-/**
- * Helpers
- */
-
-function wasModifierKeyOnlyEvent(ev: KeyboardEvent): boolean {
- return ev.keyCode === 16 || // Shift
- ev.keyCode === 17 || // Ctrl
- ev.keyCode === 18; // Alt
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/TimeBasedDebouncer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/TimeBasedDebouncer.ts
deleted file mode 100644
index 707e25cb..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/TimeBasedDebouncer.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second
-
-import { IRenderDebouncer } from 'browser/Types';
-
-/**
- * Debounces calls to update screen readers to update at most once configurable interval of time.
- */
-export class TimeBasedDebouncer implements IRenderDebouncer {
- private _rowStart: number | undefined;
- private _rowEnd: number | undefined;
- private _rowCount: number | undefined;
-
- // The last moment that the Terminal was refreshed at
- private _lastRefreshMs = 0;
- // Whether a trailing refresh should be triggered due to a refresh request that was throttled
- private _additionalRefreshRequested = false;
-
- private _refreshTimeoutID: number | undefined;
-
- constructor(
- private _renderCallback: (start: number, end: number) => void,
- private readonly _debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS
- ) {
- }
-
- public dispose(): void {
- if (this._refreshTimeoutID) {
- clearTimeout(this._refreshTimeoutID);
- }
- }
-
- public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void {
- this._rowCount = rowCount;
- // Get the min/max row start/end for the arg values
- rowStart = rowStart !== undefined ? rowStart : 0;
- rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1;
- // Set the properties to the updated values
- this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart;
- this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd;
-
- // Only refresh if the time since last refresh is above a threshold, otherwise wait for
- // enough time to pass before refreshing again.
- const refreshRequestTime: number = Date.now();
- if (refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS) {
- // Enough time has lapsed since the last refresh; refresh immediately
- this._lastRefreshMs = refreshRequestTime;
- this._innerRefresh();
- } else if (!this._additionalRefreshRequested) {
- // This is the first additional request throttled; set up trailing refresh
- const elapsed = refreshRequestTime - this._lastRefreshMs;
- const waitPeriodBeforeTrailingRefresh = this._debounceThresholdMS - elapsed;
- this._additionalRefreshRequested = true;
-
- this._refreshTimeoutID = window.setTimeout(() => {
- this._lastRefreshMs = Date.now();
- this._innerRefresh();
- this._additionalRefreshRequested = false;
- this._refreshTimeoutID = undefined; // No longer need to clear the timeout
- }, waitPeriodBeforeTrailingRefresh);
- }
- }
-
- private _innerRefresh(): void {
- // Make sure values are set
- if (this._rowStart === undefined || this._rowEnd === undefined || this._rowCount === undefined) {
- return;
- }
-
- // Clamp values
- const start = Math.max(this._rowStart, 0);
- const end = Math.min(this._rowEnd, this._rowCount - 1);
-
- // Reset debouncer (this happens before render callback as the render could trigger it again)
- this._rowStart = undefined;
- this._rowEnd = undefined;
-
- // Run render callback
- this._renderCallback(start, end);
- }
-}
-
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Types.d.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Types.d.ts
deleted file mode 100644
index 0d74b39f..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Types.d.ts
+++ /dev/null
@@ -1,315 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IDisposable, IMarker, ISelectionPosition } from 'xterm';
-import { IEvent } from 'common/EventEmitter';
-import { ICoreTerminal, CharData, ITerminalOptions } from 'common/Types';
-import { IMouseService, IRenderService } from './services/Services';
-import { IBuffer, IBufferSet } from 'common/buffer/Types';
-import { IFunctionIdentifier, IParams } from 'common/parser/Types';
-
-export interface ITerminal extends IPublicTerminal, ICoreTerminal {
- element: HTMLElement | undefined;
- screenElement: HTMLElement | undefined;
- browser: IBrowser;
- buffer: IBuffer;
- viewport: IViewport | undefined;
- // TODO: We should remove options once components adopt optionsService
- options: ITerminalOptions;
- linkifier: ILinkifier;
- linkifier2: ILinkifier2;
-
- onBlur: IEvent;
- onFocus: IEvent;
- onA11yChar: IEvent;
- onA11yTab: IEvent;
-
- cancel(ev: Event, force?: boolean): boolean | void;
-}
-
-// Portions of the public API that are required by the internal Terminal
-export interface IPublicTerminal extends IDisposable {
- textarea: HTMLTextAreaElement | undefined;
- rows: number;
- cols: number;
- buffer: IBuffer;
- markers: IMarker[];
- onCursorMove: IEvent;
- onData: IEvent;
- onBinary: IEvent;
- onKey: IEvent<{ key: string, domEvent: KeyboardEvent }>;
- onLineFeed: IEvent;
- onScroll: IEvent;
- onSelectionChange: IEvent;
- onRender: IEvent<{ start: number, end: number }>;
- onResize: IEvent<{ cols: number, rows: number }>;
- onTitleChange: IEvent;
- onBell: IEvent;
- blur(): void;
- focus(): void;
- resize(columns: number, rows: number): void;
- open(parent: HTMLElement): void;
- attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void;
- registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable;
- registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable;
- registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable;
- registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable;
- registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number;
- deregisterLinkMatcher(matcherId: number): void;
- registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
- registerCharacterJoiner(handler: (text: string) => [number, number][]): number;
- deregisterCharacterJoiner(joinerId: number): void;
- addMarker(cursorYOffset: number): IMarker | undefined;
- hasSelection(): boolean;
- getSelection(): string;
- getSelectionPosition(): ISelectionPosition | undefined;
- clearSelection(): void;
- select(column: number, row: number, length: number): void;
- selectAll(): void;
- selectLines(start: number, end: number): void;
- dispose(): void;
- scrollLines(amount: number): void;
- scrollPages(pageCount: number): void;
- scrollToTop(): void;
- scrollToBottom(): void;
- scrollToLine(line: number): void;
- clear(): void;
- write(data: string | Uint8Array, callback?: () => void): void;
- paste(data: string): void;
- refresh(start: number, end: number): void;
- reset(): void;
-}
-
-export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean;
-
-export type LineData = CharData[];
-
-export interface ICompositionHelper {
- readonly isComposing: boolean;
- compositionstart(): void;
- compositionupdate(ev: CompositionEvent): void;
- compositionend(): void;
- updateCompositionElements(dontRecurse?: boolean): void;
- keydown(ev: KeyboardEvent): boolean;
-}
-
-export interface IBrowser {
- isNode: boolean;
- userAgent: string;
- platform: string;
- isFirefox: boolean;
- isMac: boolean;
- isIpad: boolean;
- isIphone: boolean;
- isWindows: boolean;
-}
-
-export interface IColorManager {
- colors: IColorSet;
- onOptionsChange(key: string): void;
-}
-
-export interface IColor {
- css: string;
- rgba: number; // 32-bit int with rgba in each byte
-}
-
-export interface IColorSet {
- foreground: IColor;
- background: IColor;
- cursor: IColor;
- cursorAccent: IColor;
- selectionTransparent: IColor;
- /** The selection blended on top of background. */
- selectionOpaque: IColor;
- ansi: IColor[];
- contrastCache: IColorContrastCache;
-}
-
-export interface IColorContrastCache {
- clear(): void;
- setCss(bg: number, fg: number, value: string | null): void;
- getCss(bg: number, fg: number): string | null | undefined;
- setColor(bg: number, fg: number, value: IColor | null): void;
- getColor(bg: number, fg: number): IColor | null | undefined;
-}
-
-export interface IPartialColorSet {
- foreground: IColor;
- background: IColor;
- cursor?: IColor;
- cursorAccent?: IColor;
- selection?: IColor;
- ansi: IColor[];
-}
-
-export interface IViewport extends IDisposable {
- scrollBarWidth: number;
- syncScrollArea(immediate?: boolean): void;
- getLinesScrolled(ev: WheelEvent): number;
- onWheel(ev: WheelEvent): boolean;
- onTouchStart(ev: TouchEvent): void;
- onTouchMove(ev: TouchEvent): boolean;
- onThemeChange(colors: IColorSet): void;
-}
-
-export interface IViewportRange {
- start: IViewportRangePosition;
- end: IViewportRangePosition;
-}
-
-export interface IViewportRangePosition {
- x: number;
- y: number;
-}
-
-export type LinkMatcherHandler = (event: MouseEvent, uri: string) => void;
-export type LinkMatcherHoverTooltipCallback = (event: MouseEvent, uri: string, position: IViewportRange) => void;
-export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
-
-export interface ILinkMatcher {
- id: number;
- regex: RegExp;
- handler: LinkMatcherHandler;
- hoverTooltipCallback?: LinkMatcherHoverTooltipCallback;
- hoverLeaveCallback?: () => void;
- matchIndex?: number;
- validationCallback?: LinkMatcherValidationCallback;
- priority?: number;
- willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
-}
-
-export interface IRegisteredLinkMatcher extends ILinkMatcher {
- priority: number;
-}
-
-export interface ILinkifierEvent {
- x1: number;
- y1: number;
- x2: number;
- y2: number;
- cols: number;
- fg: number | undefined;
-}
-
-export interface ILinkifier {
- onShowLinkUnderline: IEvent;
- onHideLinkUnderline: IEvent;
- onLinkTooltip: IEvent;
-
- attachToDom(element: HTMLElement, mouseZoneManager: IMouseZoneManager): void;
- linkifyRows(start: number, end: number): void;
- registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number;
- deregisterLinkMatcher(matcherId: number): boolean;
-}
-
-interface ILinkState {
- decorations: ILinkDecorations;
- isHovered: boolean;
-}
-export interface ILinkWithState {
- link: ILink;
- state?: ILinkState;
-}
-
-export interface ILinkifier2 {
- onShowLinkUnderline: IEvent;
- onHideLinkUnderline: IEvent;
- readonly currentLink: ILinkWithState | undefined;
-
- attachToDom(element: HTMLElement, mouseService: IMouseService, renderService: IRenderService): void;
- registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
-}
-
-export interface ILinkMatcherOptions {
- /**
- * The index of the link from the regex.match(text) call. This defaults to 0
- * (for regular expressions without capture groups).
- */
- matchIndex?: number;
- /**
- * A callback that validates an individual link, returning true if valid and
- * false if invalid.
- */
- validationCallback?: LinkMatcherValidationCallback;
- /**
- * A callback that fires when the mouse hovers over a link.
- */
- tooltipCallback?: LinkMatcherHoverTooltipCallback;
- /**
- * A callback that fires when the mouse leaves a link that was hovered.
- */
- leaveCallback?: () => void;
- /**
- * The priority of the link matcher, this defines the order in which the link
- * matcher is evaluated relative to others, from highest to lowest. The
- * default value is 0.
- */
- priority?: number;
- /**
- * A callback that fires when the mousedown and click events occur that
- * determines whether a link will be activated upon click. This enables
- * only activating a link when a certain modifier is held down, if not the
- * mouse event will continue propagation (eg. double click to select word).
- */
- willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
-}
-
-export interface IMouseZoneManager extends IDisposable {
- add(zone: IMouseZone): void;
- clearAll(start?: number, end?: number): void;
-}
-
-export interface IMouseZone {
- x1: number;
- x2: number;
- y1: number;
- y2: number;
- clickCallback: (e: MouseEvent) => any;
- hoverCallback: (e: MouseEvent) => any | undefined;
- tooltipCallback: (e: MouseEvent) => any | undefined;
- leaveCallback: () => any | undefined;
- willLinkActivate: (e: MouseEvent) => boolean;
-}
-
-interface ILinkProvider {
- provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void;
-}
-
-interface ILink {
- range: IBufferRange;
- text: string;
- decorations?: ILinkDecorations;
- activate(event: MouseEvent, text: string): void;
- hover?(event: MouseEvent, text: string): void;
- leave?(event: MouseEvent, text: string): void;
- dispose?(): void;
-}
-
-interface ILinkDecorations {
- pointerCursor: boolean;
- underline: boolean;
-}
-
-interface IBufferRange {
- start: IBufferCellPosition;
- end: IBufferCellPosition;
-}
-
-interface IBufferCellPosition {
- x: number;
- y: number;
-}
-
-export type CharacterJoinerHandler = (text: string) => [number, number][];
-
-export interface ICharacterJoiner {
- id: number;
- handler: CharacterJoinerHandler;
-}
-
-export interface IRenderDebouncer extends IDisposable {
- refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Viewport.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Viewport.ts
deleted file mode 100644
index 3c9bea4c..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/Viewport.ts
+++ /dev/null
@@ -1,291 +0,0 @@
-/**
- * Copyright (c) 2016 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { Disposable } from 'common/Lifecycle';
-import { addDisposableDomListener } from 'browser/Lifecycle';
-import { IColorSet, IViewport } from 'browser/Types';
-import { ICharSizeService, IRenderService } from 'browser/services/Services';
-import { IBufferService, IOptionsService } from 'common/services/Services';
-import { IBuffer } from 'common/buffer/Types';
-import { IRenderDimensions } from 'browser/renderer/Types';
-
-const FALLBACK_SCROLL_BAR_WIDTH = 15;
-
-/**
- * Represents the viewport of a terminal, the visible area within the larger buffer of output.
- * Logic for the virtual scroll bar is included in this object.
- */
-export class Viewport extends Disposable implements IViewport {
- public scrollBarWidth: number = 0;
- private _currentRowHeight: number = 0;
- private _currentScaledCellHeight: number = 0;
- private _lastRecordedBufferLength: number = 0;
- private _lastRecordedViewportHeight: number = 0;
- private _lastRecordedBufferHeight: number = 0;
- private _lastTouchY: number = 0;
- private _lastScrollTop: number = 0;
- private _lastHadScrollBar: boolean = false;
- private _activeBuffer: IBuffer;
- private _renderDimensions: IRenderDimensions;
-
- // Stores a partial line amount when scrolling, this is used to keep track of how much of a line
- // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a
- // quick fix and could have a more robust solution in place that reset the value when needed.
- private _wheelPartialScroll: number = 0;
-
- private _refreshAnimationFrame: number | null = null;
- private _ignoreNextScrollEvent: boolean = false;
-
- constructor(
- private readonly _scrollLines: (amount: number) => void,
- private readonly _viewportElement: HTMLElement,
- private readonly _scrollArea: HTMLElement,
- @IBufferService private readonly _bufferService: IBufferService,
- @IOptionsService private readonly _optionsService: IOptionsService,
- @ICharSizeService private readonly _charSizeService: ICharSizeService,
- @IRenderService private readonly _renderService: IRenderService
- ) {
- super();
-
- // Measure the width of the scrollbar. If it is 0 we can assume it's an OSX overlay scrollbar.
- // Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case,
- // therefore we account for a standard amount to make it visible
- this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
- this._lastHadScrollBar = true;
- this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this)));
-
- // Track properties used in performance critical code manually to avoid using slow getters
- this._activeBuffer = this._bufferService.buffer;
- this.register(this._bufferService.buffers.onBufferActivate(e => this._activeBuffer = e.activeBuffer));
- this._renderDimensions = this._renderService.dimensions;
- this.register(this._renderService.onDimensionsChange(e => this._renderDimensions = e));
-
- // Perform this async to ensure the ICharSizeService is ready.
- setTimeout(() => this.syncScrollArea(), 0);
- }
-
- public onThemeChange(colors: IColorSet): void {
- this._viewportElement.style.backgroundColor = colors.background.css;
- }
-
- /**
- * Refreshes row height, setting line-height, viewport height and scroll area height if
- * necessary.
- */
- private _refresh(immediate: boolean): void {
- if (immediate) {
- this._innerRefresh();
- if (this._refreshAnimationFrame !== null) {
- cancelAnimationFrame(this._refreshAnimationFrame);
- }
- return;
- }
- if (this._refreshAnimationFrame === null) {
- this._refreshAnimationFrame = requestAnimationFrame(() => this._innerRefresh());
- }
- }
-
- private _innerRefresh(): void {
- if (this._charSizeService.height > 0) {
- this._currentRowHeight = this._renderService.dimensions.scaledCellHeight / window.devicePixelRatio;
- this._currentScaledCellHeight = this._renderService.dimensions.scaledCellHeight;
- this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;
- const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.canvasHeight);
- if (this._lastRecordedBufferHeight !== newBufferHeight) {
- this._lastRecordedBufferHeight = newBufferHeight;
- this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';
- }
- }
-
- // Sync scrollTop
- const scrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight;
- if (this._viewportElement.scrollTop !== scrollTop) {
- // Ignore the next scroll event which will be triggered by setting the scrollTop as we do not
- // want this event to scroll the terminal
- this._ignoreNextScrollEvent = true;
- this._viewportElement.scrollTop = scrollTop;
- }
-
- // Update scroll bar width
- if (this._optionsService.options.scrollback === 0) {
- this.scrollBarWidth = 0;
- } else {
- this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
- }
- this._lastHadScrollBar = this.scrollBarWidth > 0;
-
- this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px';
- this._refreshAnimationFrame = null;
- }
-
- /**
- * Updates dimensions and synchronizes the scroll area if necessary.
- */
- public syncScrollArea(immediate: boolean = false): void {
- // If buffer height changed
- if (this._lastRecordedBufferLength !== this._bufferService.buffer.lines.length) {
- this._lastRecordedBufferLength = this._bufferService.buffer.lines.length;
- this._refresh(immediate);
- return;
- }
-
- // If viewport height changed
- if (this._lastRecordedViewportHeight !== this._renderService.dimensions.canvasHeight) {
- this._refresh(immediate);
- return;
- }
-
- // If the buffer position doesn't match last scroll top
- if (this._lastScrollTop !== this._activeBuffer.ydisp * this._currentRowHeight) {
- this._refresh(immediate);
- return;
- }
-
- // If row height changed
- if (this._renderDimensions.scaledCellHeight !== this._currentScaledCellHeight) {
- this._refresh(immediate);
- return;
- }
-
- // If the scroll bar visibility changed
- if (this._lastHadScrollBar !== (this._optionsService.options.scrollback > 0)) {
- this._refresh(immediate);
- }
- }
-
- /**
- * Handles scroll events on the viewport, calculating the new viewport and requesting the
- * terminal to scroll to it.
- * @param ev The scroll event.
- */
- private _onScroll(ev: Event): void {
- // Record current scroll top position
- this._lastScrollTop = this._viewportElement.scrollTop;
-
- // Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt
- // which causes the terminal to scroll the buffer to the top
- if (!this._viewportElement.offsetParent) {
- return;
- }
-
- // Ignore the event if it was flagged to ignore (when the source of the event is from Viewport)
- if (this._ignoreNextScrollEvent) {
- this._ignoreNextScrollEvent = false;
- // Still trigger the scroll so lines get refreshed
- this._scrollLines(0);
- return;
- }
-
- const newRow = Math.round(this._lastScrollTop / this._currentRowHeight);
- const diff = newRow - this._bufferService.buffer.ydisp;
- this._scrollLines(diff);
- }
-
- /**
- * Handles bubbling of scroll event in case the viewport has reached top or bottom
- * @param ev The scroll event.
- * @param amount The amount scrolled
- */
- private _bubbleScroll(ev: Event, amount: number): boolean {
- const scrollPosFromTop = this._viewportElement.scrollTop + this._lastRecordedViewportHeight;
- if ((amount < 0 && this._viewportElement.scrollTop !== 0) ||
- (amount > 0 && scrollPosFromTop < this._lastRecordedBufferHeight)) {
- if (ev.cancelable) {
- ev.preventDefault();
- }
- return false;
- }
- return true;
- }
-
- /**
- * Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual
- * scrolling to `onScroll`, this event needs to be attached manually by the consumer of
- * `Viewport`.
- * @param ev The mouse wheel event.
- */
- public onWheel(ev: WheelEvent): boolean {
- const amount = this._getPixelsScrolled(ev);
- if (amount === 0) {
- return false;
- }
- this._viewportElement.scrollTop += amount;
- return this._bubbleScroll(ev, amount);
- }
-
- private _getPixelsScrolled(ev: WheelEvent): number {
- // Do nothing if it's not a vertical scroll event
- if (ev.deltaY === 0) {
- return 0;
- }
-
- // Fallback to WheelEvent.DOM_DELTA_PIXEL
- let amount = this._applyScrollModifier(ev.deltaY, ev);
- if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
- amount *= this._currentRowHeight;
- } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
- amount *= this._currentRowHeight * this._bufferService.rows;
- }
- return amount;
- }
-
- /**
- * Gets the number of pixels scrolled by the mouse event taking into account what type of delta
- * is being used.
- * @param ev The mouse wheel event.
- */
- public getLinesScrolled(ev: WheelEvent): number {
- // Do nothing if it's not a vertical scroll event
- if (ev.deltaY === 0) {
- return 0;
- }
-
- // Fallback to WheelEvent.DOM_DELTA_LINE
- let amount = this._applyScrollModifier(ev.deltaY, ev);
- if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
- amount /= this._currentRowHeight + 0.0; // Prevent integer division
- 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._bufferService.rows;
- }
- return amount;
- }
-
- private _applyScrollModifier(amount: number, ev: WheelEvent): number {
- const modifier = this._optionsService.options.fastScrollModifier;
- // Multiply the scroll speed when the modifier is down
- if ((modifier === 'alt' && ev.altKey) ||
- (modifier === 'ctrl' && ev.ctrlKey) ||
- (modifier === 'shift' && ev.shiftKey)) {
- return amount * this._optionsService.options.fastScrollSensitivity * this._optionsService.options.scrollSensitivity;
- }
-
- return amount * this._optionsService.options.scrollSensitivity;
- }
-
- /**
- * Handles the touchstart event, recording the touch occurred.
- * @param ev The touch event.
- */
- public onTouchStart(ev: TouchEvent): void {
- this._lastTouchY = ev.touches[0].pageY;
- }
-
- /**
- * Handles the touchmove event, scrolling the viewport if the position shifted.
- * @param ev The touch event.
- */
- public onTouchMove(ev: TouchEvent): boolean {
- const deltaY = this._lastTouchY - ev.touches[0].pageY;
- this._lastTouchY = ev.touches[0].pageY;
- if (deltaY === 0) {
- return false;
- }
- this._viewportElement.scrollTop += deltaY;
- return this._bubbleScroll(ev, deltaY);
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/CompositionHelper.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/CompositionHelper.ts
deleted file mode 100644
index 4e176725..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/CompositionHelper.ts
+++ /dev/null
@@ -1,237 +0,0 @@
-/**
- * Copyright (c) 2016 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderService } from 'browser/services/Services';
-import { IBufferService, ICoreService, IOptionsService } from 'common/services/Services';
-
-interface IPosition {
- start: number;
- end: number;
-}
-
-/**
- * Encapsulates the logic for handling compositionstart, compositionupdate and compositionend
- * events, displaying the in-progress composition to the UI and forwarding the final composition
- * to the handler.
- */
-export class CompositionHelper {
- /**
- * Whether input composition is currently happening, eg. via a mobile keyboard, speech input or
- * IME. This variable determines whether the compositionText should be displayed on the UI.
- */
- private _isComposing: boolean;
- public get isComposing(): boolean { return this._isComposing; }
-
- /**
- * The position within the input textarea's value of the current composition.
- */
- private _compositionPosition: IPosition;
-
- /**
- * Whether a composition is in the process of being sent, setting this to false will cancel any
- * in-progress composition.
- */
- private _isSendingComposition: boolean;
-
- /**
- * Data already sent due to keydown event.
- */
- private _dataAlreadySent: string;
-
- constructor(
- private readonly _textarea: HTMLTextAreaElement,
- private readonly _compositionView: HTMLElement,
- @IBufferService private readonly _bufferService: IBufferService,
- @IOptionsService private readonly _optionsService: IOptionsService,
- @ICoreService private readonly _coreService: ICoreService,
- @IRenderService private readonly _renderService: IRenderService
- ) {
- this._isComposing = false;
- this._isSendingComposition = false;
- this._compositionPosition = { start: 0, end: 0 };
- this._dataAlreadySent = '';
- }
-
- /**
- * Handles the compositionstart event, activating the composition view.
- */
- public compositionstart(): void {
- this._isComposing = true;
- this._compositionPosition.start = this._textarea.value.length;
- this._compositionView.textContent = '';
- this._dataAlreadySent = '';
- this._compositionView.classList.add('active');
- }
-
- /**
- * Handles the compositionupdate event, updating the composition view.
- * @param ev The event.
- */
- public compositionupdate(ev: Pick): void {
- this._compositionView.textContent = ev.data;
- this.updateCompositionElements();
- setTimeout(() => {
- this._compositionPosition.end = this._textarea.value.length;
- }, 0);
- }
-
- /**
- * Handles the compositionend event, hiding the composition view and sending the composition to
- * the handler.
- */
- public compositionend(): void {
- this._finalizeComposition(true);
- }
-
- /**
- * Handles the keydown event, routing any necessary events to the CompositionHelper functions.
- * @param ev The keydown event.
- * @return Whether the Terminal should continue processing the keydown event.
- */
- public keydown(ev: KeyboardEvent): boolean {
- if (this._isComposing || this._isSendingComposition) {
- if (ev.keyCode === 229) {
- // Continue composing if the keyCode is the "composition character"
- return false;
- }
- if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {
- // Continue composing if the keyCode is a modifier key
- return false;
- }
- // Finish composition immediately. This is mainly here for the case where enter is
- // pressed and the handler needs to be triggered before the command is executed.
- this._finalizeComposition(false);
- }
-
- if (ev.keyCode === 229) {
- // If the "composition character" is used but gets to this point it means a non-composition
- // character (eg. numbers and punctuation) was pressed when the IME was active.
- this._handleAnyTextareaChanges();
- return false;
- }
-
- return true;
- }
-
- /**
- * Finalizes the composition, resuming regular input actions. This is called when a composition
- * is ending.
- * @param waitForPropagation Whether to wait for events to propagate before sending
- * the input. This should be false if a non-composition keystroke is entered before the
- * compositionend event is triggered, such as enter, so that the composition is sent before
- * the command is executed.
- */
- private _finalizeComposition(waitForPropagation: boolean): void {
- this._compositionView.classList.remove('active');
- this._isComposing = false;
-
- if (!waitForPropagation) {
- // Cancel any delayed composition send requests and send the input immediately.
- this._isSendingComposition = false;
- const input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end);
- this._coreService.triggerDataEvent(input, true);
- } else {
- // Make a deep copy of the composition position here as a new compositionstart event may
- // fire before the setTimeout executes.
- const currentCompositionPosition = {
- start: this._compositionPosition.start,
- end: this._compositionPosition.end
- };
-
- // Since composition* events happen before the changes take place in the textarea on most
- // browsers, use a setTimeout with 0ms time to allow the native compositionend event to
- // complete. This ensures the correct character is retrieved.
- // This solution was used because:
- // - The compositionend event's data property is unreliable, at least on Chromium
- // - The last compositionupdate event's data property does not always accurately describe
- // the character, a counter example being Korean where an ending consonsant can move to
- // the following character if the following input is a vowel.
- this._isSendingComposition = true;
- setTimeout(() => {
- // Ensure that the input has not already been sent
- if (this._isSendingComposition) {
- this._isSendingComposition = false;
- let input;
- // Add length of data already sent due to keydown event,
- // otherwise input characters can be duplicated. (Issue #3191)
- currentCompositionPosition.start += this._dataAlreadySent.length;
- if (this._isComposing) {
- // Use the end position to get the string if a new composition has started.
- input = this._textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);
- } else {
- // Don't use the end position here in order to pick up any characters after the
- // composition has finished, for example when typing a non-composition character
- // (eg. 2) after a composition character.
- input = this._textarea.value.substring(currentCompositionPosition.start);
- }
- if (input.length > 0) {
- this._coreService.triggerDataEvent(input, true);
- }
- }
- }, 0);
- }
- }
-
- /**
- * Apply any changes made to the textarea after the current event chain is allowed to complete.
- * This should be called when not currently composing but a keydown event with the "composition
- * character" (229) is triggered, in order to allow non-composition text to be entered when an
- * IME is active.
- */
- private _handleAnyTextareaChanges(): void {
- const oldValue = this._textarea.value;
- setTimeout(() => {
- // Ignore if a composition has started since the timeout
- if (!this._isComposing) {
- const newValue = this._textarea.value;
- const diff = newValue.replace(oldValue, '');
- if (diff.length > 0) {
- this._dataAlreadySent = diff;
- this._coreService.triggerDataEvent(diff, true);
- }
- }
- }, 0);
- }
-
- /**
- * Positions the composition view on top of the cursor and the textarea just below it (so the
- * IME helper dialog is positioned correctly).
- * @param dontRecurse Whether to use setTimeout to recursively trigger another update, this is
- * necessary as the IME events across browsers are not consistently triggered.
- */
- public updateCompositionElements(dontRecurse?: boolean): void {
- if (!this._isComposing) {
- return;
- }
-
- if (this._bufferService.buffer.isCursorInViewport) {
- const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1);
-
- const cellHeight = this._renderService.dimensions.actualCellHeight;
- const cursorTop = this._bufferService.buffer.y * this._renderService.dimensions.actualCellHeight;
- const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth;
-
- 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._optionsService.options.fontFamily;
- this._compositionView.style.fontSize = this._optionsService.options.fontSize + 'px';
- // Sync the textarea to the exact position of the composition view so the IME knows where the
- // text is.
- const compositionViewBounds = this._compositionView.getBoundingClientRect();
- this._textarea.style.left = cursorLeft + 'px';
- this._textarea.style.top = cursorTop + 'px';
- // Ensure the text area is at least 1x1, otherwise certain IMEs may break
- this._textarea.style.width = Math.max(compositionViewBounds.width, 1) + 'px';
- this._textarea.style.height = Math.max(compositionViewBounds.height, 1) + 'px';
- this._textarea.style.lineHeight = compositionViewBounds.height + 'px';
- }
-
- if (!dontRecurse) {
- setTimeout(() => this.updateCompositionElements(true), 0);
- }
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/Mouse.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/Mouse.ts
deleted file mode 100644
index 2986fb3c..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/Mouse.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-export function getCoordsRelativeToElement(event: {clientX: number, clientY: number}, element: HTMLElement): [number, number] {
- const rect = element.getBoundingClientRect();
- return [event.clientX - rect.left, event.clientY - rect.top];
-}
-
-/**
- * Gets coordinates within the terminal for a particular mouse event. The result
- * is returned as an array in the form [x, y] instead of an object as it's a
- * little faster and this function is used in some low level code.
- * @param event The mouse event.
- * @param element The terminal's container element.
- * @param colCount The number of columns in the terminal.
- * @param rowCount The number of rows n the terminal.
- * @param isSelection Whether the request is for the selection or not. This will
- * apply an offset to the x value such that the left half of the cell will
- * select that cell and the right half will select the next cell.
- */
-export function getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, hasValidCharSize: boolean, actualCellWidth: number, actualCellHeight: number, isSelection?: boolean): [number, number] | undefined {
- // Coordinates cannot be measured if there are no valid
- if (!hasValidCharSize) {
- return undefined;
- }
-
- const coords = getCoordsRelativeToElement(event, element);
- if (!coords) {
- return undefined;
- }
-
- coords[0] = Math.ceil((coords[0] + (isSelection ? actualCellWidth / 2 : 0)) / actualCellWidth);
- coords[1] = Math.ceil(coords[1] / actualCellHeight);
-
- // Ensure coordinates are within the terminal viewport. Note that selections
- // need an addition point of precision to cover the end point (as characters
- // cover half of one char and half of the next).
- 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;
-}
-
-/**
- * Gets coordinates within the terminal for a particular mouse event, wrapping
- * them to the bounds of the terminal and adding 32 to both the x and y values
- * as expected by xterm.
- */
-export function getRawByteCoords(coords: [number, number] | undefined): { x: number, y: number } | undefined {
- if (!coords) {
- return undefined;
- }
-
- // xterm sends raw bytes and starts at 32 (SP) for each.
- return { x: coords[0] + 32, y: coords[1] + 32 };
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/MoveToCell.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/MoveToCell.ts
deleted file mode 100644
index 25e1844d..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/input/MoveToCell.ts
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { C0 } from 'common/data/EscapeSequences';
-import { IBufferService } from 'common/services/Services';
-
-const enum Direction {
- UP = 'A',
- DOWN = 'B',
- RIGHT = 'C',
- LEFT = 'D'
-}
-
-/**
- * Concatenates all the arrow sequences together.
- * Resets the starting row to an unwrapped row, moves to the requested row,
- * then moves to requested col.
- */
-export function moveToCellSequence(targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
- const startX = bufferService.buffer.x;
- const startY = bufferService.buffer.y;
-
- // The alt buffer should try to navigate between rows
- if (!bufferService.buffer.hasScrollback) {
- return resetStartingRow(startX, startY, targetX, targetY, bufferService, applicationCursor) +
- moveToRequestedRow(startY, targetY, bufferService, applicationCursor) +
- moveToRequestedCol(startX, startY, targetX, targetY, bufferService, applicationCursor);
- }
-
- // Only move horizontally for the normal buffer
- let direction;
- if (startY === targetY) {
- direction = startX > targetX ? Direction.LEFT : Direction.RIGHT;
- return repeat(Math.abs(startX - targetX), sequence(direction, applicationCursor));
- }
- direction = startY > targetY ? Direction.LEFT : Direction.RIGHT;
- const rowDifference = Math.abs(startY - targetY);
- const cellsToMove = colsFromRowEnd(startY > targetY ? targetX : startX, bufferService) +
- (rowDifference - 1) * bufferService.cols + 1 /* wrap around 1 row */ +
- colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService);
- return repeat(cellsToMove, sequence(direction, applicationCursor));
-}
-
-/**
- * Find the number of cols from a row beginning to a col.
- */
-function colsFromRowBeginning(currX: number, bufferService: IBufferService): number {
- return currX - 1;
-}
-
-/**
- * Find the number of cols from a col to row end.
- */
-function colsFromRowEnd(currX: number, bufferService: IBufferService): number {
- return bufferService.cols - currX;
-}
-
-/**
- * If the initial position of the cursor is on a row that is wrapped, move the
- * cursor up to the first row that is not wrapped to have accurate vertical
- * positioning.
- */
-function resetStartingRow(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
- if (moveToRequestedRow(startY, targetY, bufferService, applicationCursor).length === 0) {
- return '';
- }
- return repeat(bufferLine(
- startX, startY, startX,
- startY - wrappedRowsForRow(bufferService, startY), false, bufferService
- ).length, sequence(Direction.LEFT, applicationCursor));
-}
-
-/**
- * Using the reset starting and ending row, move to the requested row,
- * ignoring wrapped rows
- */
-function moveToRequestedRow(startY: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
- const startRow = startY - wrappedRowsForRow(bufferService, startY);
- const endRow = targetY - wrappedRowsForRow(bufferService, targetY);
-
- const rowsToMove = Math.abs(startRow - endRow) - wrappedRowsCount(startY, targetY, bufferService);
-
- return repeat(rowsToMove, sequence(verticalDirection(startY, targetY), applicationCursor));
-}
-
-/**
- * Move to the requested col on the ending row
- */
-function moveToRequestedCol(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
- let startRow;
- if (moveToRequestedRow(startY, targetY, bufferService, applicationCursor).length > 0) {
- startRow = targetY - wrappedRowsForRow(bufferService, targetY);
- } else {
- startRow = startY;
- }
-
- const endRow = targetY;
- const direction = horizontalDirection(startX, startY, targetX, targetY, bufferService, applicationCursor);
-
- return repeat(bufferLine(
- startX, startRow, targetX, endRow,
- direction === Direction.RIGHT, bufferService
- ).length, sequence(direction, applicationCursor));
-}
-
-/**
- * Utility functions
- */
-
-/**
- * Calculates the number of wrapped rows between the unwrapped starting and
- * ending rows. These rows need to ignored since the cursor skips over them.
- */
-function wrappedRowsCount(startY: number, targetY: number, bufferService: IBufferService): number {
- let wrappedRows = 0;
- const startRow = startY - wrappedRowsForRow(bufferService, startY);
- const endRow = targetY - wrappedRowsForRow(bufferService, targetY);
-
- for (let i = 0; i < Math.abs(startRow - endRow); i++) {
- const direction = verticalDirection(startY, targetY) === Direction.UP ? -1 : 1;
- const line = bufferService.buffer.lines.get(startRow + (direction * i));
- if (line && line.isWrapped) {
- wrappedRows++;
- }
- }
-
- return wrappedRows;
-}
-
-/**
- * Calculates the number of wrapped rows that make up a given row.
- * @param currentRow The row to determine how many wrapped rows make it up
- */
-function wrappedRowsForRow(bufferService: IBufferService, currentRow: number): number {
- let rowCount = 0;
- let line = bufferService.buffer.lines.get(currentRow);
- let lineWraps = line && line.isWrapped;
-
- while (lineWraps && currentRow >= 0 && currentRow < bufferService.rows) {
- rowCount++;
- line = bufferService.buffer.lines.get(--currentRow);
- lineWraps = line && line.isWrapped;
- }
-
- return rowCount;
-}
-
-/**
- * Direction determiners
- */
-
-/**
- * Determines if the right or left arrow is needed
- */
-function horizontalDirection(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): Direction {
- let startRow;
- if (moveToRequestedRow(targetX, targetY, bufferService, applicationCursor).length > 0) {
- startRow = targetY - wrappedRowsForRow(bufferService, targetY);
- } else {
- startRow = startY;
- }
-
- if ((startX < targetX &&
- startRow <= targetY) || // down/right or same y/right
- (startX >= targetX &&
- startRow < targetY)) { // down/left or same y/left
- return Direction.RIGHT;
- }
- return Direction.LEFT;
-}
-
-/**
- * Determines if the up or down arrow is needed
- */
-function verticalDirection(startY: number, targetY: number): Direction {
- return startY > targetY ? Direction.UP : Direction.DOWN;
-}
-
-/**
- * Constructs the string of chars in the buffer from a starting row and col
- * to an ending row and col
- * @param startCol The starting column position
- * @param startRow The starting row position
- * @param endCol The ending column position
- * @param endRow The ending row position
- * @param forward Direction to move
- */
-function bufferLine(
- startCol: number,
- startRow: number,
- endCol: number,
- endRow: number,
- forward: boolean,
- bufferService: IBufferService
-): string {
- let currentCol = startCol;
- let currentRow = startRow;
- let bufferStr = '';
-
- while (currentCol !== endCol || currentRow !== endRow) {
- currentCol += forward ? 1 : -1;
-
- if (forward && currentCol > bufferService.cols - 1) {
- bufferStr += bufferService.buffer.translateBufferLineToString(
- currentRow, false, startCol, currentCol
- );
- currentCol = 0;
- startCol = 0;
- currentRow++;
- } else if (!forward && currentCol < 0) {
- bufferStr += bufferService.buffer.translateBufferLineToString(
- currentRow, false, 0, startCol + 1
- );
- currentCol = bufferService.cols - 1;
- startCol = currentCol;
- currentRow--;
- }
- }
-
- return bufferStr + bufferService.buffer.translateBufferLineToString(
- currentRow, false, startCol, currentCol
- );
-}
-
-/**
- * Constructs the escape sequence for clicking an arrow
- * @param direction The direction to move
- */
-function sequence(direction: Direction, applicationCursor: boolean): string {
- const mod = applicationCursor ? 'O' : '[';
- return C0.ESC + mod + direction;
-}
-
-/**
- * Returns a string repeated a given number of times
- * Polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
- * @param count The number of times to repeat the string
- * @param string The string that is to be repeated
- */
-function repeat(count: number, str: string): string {
- count = Math.floor(count);
- let rpt = '';
- for (let i = 0; i < count; i++) {
- rpt += str;
- }
- return rpt;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/public/Terminal.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/public/Terminal.ts
deleted file mode 100644
index a76b1a22..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/public/Terminal.ts
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight, IModes } from 'xterm';
-import { ITerminal } from 'browser/Types';
-import { Terminal as TerminalCore } from 'browser/Terminal';
-import * as Strings from 'browser/LocalizableStrings';
-import { IEvent } from 'common/EventEmitter';
-import { ParserApi } from 'common/public/ParserApi';
-import { UnicodeApi } from 'common/public/UnicodeApi';
-import { AddonManager } from 'common/public/AddonManager';
-import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
-
-export class Terminal implements ITerminalApi {
- private _core: ITerminal;
- private _addonManager: AddonManager;
- private _parser: IParser | undefined;
- private _buffer: BufferNamespaceApi | undefined;
-
- constructor(options?: ITerminalOptions) {
- this._core = new TerminalCore(options);
- this._addonManager = new AddonManager();
- }
-
- private _checkProposedApi(): void {
- if (!this._core.optionsService.options.allowProposedApi) {
- throw new Error('You must set the allowProposedApi option to true to use proposed API');
- }
- }
-
- public get onBell(): IEvent { return this._core.onBell; }
- public get onBinary(): IEvent { return this._core.onBinary; }
- public get onCursorMove(): IEvent { return this._core.onCursorMove; }
- public get onData(): IEvent { return this._core.onData; }
- public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }
- public get onLineFeed(): IEvent { return this._core.onLineFeed; }
- public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; }
- public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }
- public get onScroll(): IEvent { return this._core.onScroll; }
- public get onSelectionChange(): IEvent { return this._core.onSelectionChange; }
- public get onTitleChange(): IEvent { return this._core.onTitleChange; }
-
- public get element(): HTMLElement | undefined { return this._core.element; }
- public get parser(): IParser {
- this._checkProposedApi();
- if (!this._parser) {
- this._parser = new ParserApi(this._core);
- }
- return this._parser;
- }
- public get unicode(): IUnicodeHandling {
- this._checkProposedApi();
- return new UnicodeApi(this._core);
- }
- public get textarea(): HTMLTextAreaElement | undefined { return this._core.textarea; }
- public get rows(): number { return this._core.rows; }
- public get cols(): number { return this._core.cols; }
- public get buffer(): IBufferNamespaceApi {
- this._checkProposedApi();
- if (!this._buffer) {
- this._buffer = new BufferNamespaceApi(this._core);
- }
- return this._buffer;
- }
- public get markers(): ReadonlyArray {
- this._checkProposedApi();
- return this._core.markers;
- }
- public get modes(): IModes {
- const m = this._core.coreService.decPrivateModes;
- let mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any' = 'none';
- switch (this._core.coreMouseService.activeProtocol) {
- case 'X10': mouseTrackingMode = 'x10'; break;
- case 'VT200': mouseTrackingMode = 'vt200'; break;
- case 'DRAG': mouseTrackingMode = 'drag'; break;
- case 'ANY': mouseTrackingMode = 'any'; break;
- }
- return {
- applicationCursorKeysMode: m.applicationCursorKeys,
- applicationKeypadMode: m.applicationKeypad,
- bracketedPasteMode: m.bracketedPasteMode,
- insertMode: this._core.coreService.modes.insertMode,
- mouseTrackingMode: mouseTrackingMode,
- originMode: m.origin,
- reverseWraparoundMode: m.reverseWraparound,
- sendFocusMode: m.sendFocus,
- wraparoundMode: m.wraparound
- };
- }
- public blur(): void {
- this._core.blur();
- }
- public focus(): void {
- this._core.focus();
- }
- public resize(columns: number, rows: number): void {
- this._verifyIntegers(columns, rows);
- this._core.resize(columns, rows);
- }
- public open(parent: HTMLElement): void {
- this._core.open(parent);
- }
- public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {
- this._core.attachCustomKeyEventHandler(customKeyEventHandler);
- }
- public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number {
- this._checkProposedApi();
- return this._core.registerLinkMatcher(regex, handler, options);
- }
- public deregisterLinkMatcher(matcherId: number): void {
- this._checkProposedApi();
- this._core.deregisterLinkMatcher(matcherId);
- }
- public registerLinkProvider(linkProvider: ILinkProvider): IDisposable {
- this._checkProposedApi();
- return this._core.registerLinkProvider(linkProvider);
- }
- public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {
- this._checkProposedApi();
- return this._core.registerCharacterJoiner(handler);
- }
- public deregisterCharacterJoiner(joinerId: number): void {
- this._checkProposedApi();
- this._core.deregisterCharacterJoiner(joinerId);
- }
- public registerMarker(cursorYOffset: number): IMarker | undefined {
- this._checkProposedApi();
- this._verifyIntegers(cursorYOffset);
- return this._core.addMarker(cursorYOffset);
- }
- public addMarker(cursorYOffset: number): IMarker | undefined {
- return this.registerMarker(cursorYOffset);
- }
- public hasSelection(): boolean {
- return this._core.hasSelection();
- }
- public select(column: number, row: number, length: number): void {
- this._verifyIntegers(column, row, length);
- this._core.select(column, row, length);
- }
- public getSelection(): string {
- return this._core.getSelection();
- }
- public getSelectionPosition(): ISelectionPosition | undefined {
- return this._core.getSelectionPosition();
- }
- public clearSelection(): void {
- this._core.clearSelection();
- }
- public selectAll(): void {
- this._core.selectAll();
- }
- public selectLines(start: number, end: number): void {
- this._verifyIntegers(start, end);
- this._core.selectLines(start, end);
- }
- public dispose(): void {
- this._addonManager.dispose();
- this._core.dispose();
- }
- public scrollLines(amount: number): void {
- this._verifyIntegers(amount);
- this._core.scrollLines(amount);
- }
- public scrollPages(pageCount: number): void {
- this._verifyIntegers(pageCount);
- this._core.scrollPages(pageCount);
- }
- public scrollToTop(): void {
- this._core.scrollToTop();
- }
- public scrollToBottom(): void {
- this._core.scrollToBottom();
- }
- public scrollToLine(line: number): void {
- this._verifyIntegers(line);
- this._core.scrollToLine(line);
- }
- public clear(): void {
- this._core.clear();
- }
- public write(data: string | Uint8Array, callback?: () => void): void {
- this._core.write(data, callback);
- }
- public writeUtf8(data: Uint8Array, callback?: () => void): void {
- this._core.write(data, callback);
- }
- public writeln(data: string | Uint8Array, callback?: () => void): void {
- this._core.write(data);
- this._core.write('\r\n', callback);
- }
- public paste(data: string): void {
- this._core.paste(data);
- }
- public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
- public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean;
- public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
- public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight;
- public getOption(key: string): any;
- public getOption(key: any): any {
- return this._core.optionsService.getOption(key);
- }
- public setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
- public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void;
- public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void;
- public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;
- public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;
- public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void;
- public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
- public setOption(key: 'theme', value: ITheme): void;
- public setOption(key: 'cols' | 'rows', value: number): void;
- public setOption(key: string, value: any): void;
- public setOption(key: any, value: any): void {
- this._core.optionsService.setOption(key, value);
- }
- public refresh(start: number, end: number): void {
- this._verifyIntegers(start, end);
- this._core.refresh(start, end);
- }
- public reset(): void {
- this._core.reset();
- }
- public loadAddon(addon: ITerminalAddon): void {
- return this._addonManager.loadAddon(this, addon);
- }
- public static get strings(): ILocalizableStrings {
- return Strings;
- }
-
- private _verifyIntegers(...values: number[]): void {
- for (const value of values) {
- if (value === Infinity || isNaN(value) || value % 1 !== 0) {
- throw new Error('This API only accepts integers');
- }
- }
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/BaseRenderLayer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/BaseRenderLayer.ts
deleted file mode 100644
index 448451d0..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/BaseRenderLayer.ts
+++ /dev/null
@@ -1,514 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderDimensions, IRenderLayer } from 'browser/renderer/Types';
-import { ICellData } from 'common/Types';
-import { DEFAULT_COLOR, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE, Attributes } from 'common/buffer/Constants';
-import { IGlyphIdentifier } from 'browser/renderer/atlas/Types';
-import { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
-import { BaseCharAtlas } from 'browser/renderer/atlas/BaseCharAtlas';
-import { acquireCharAtlas } from 'browser/renderer/atlas/CharAtlasCache';
-import { AttributeData } from 'common/buffer/AttributeData';
-import { IColorSet, IColor } from 'browser/Types';
-import { CellData } from 'common/buffer/CellData';
-import { IBufferService, IOptionsService } from 'common/services/Services';
-import { throwIfFalsy } from 'browser/renderer/RendererUtils';
-import { channels, color, rgba } from 'browser/Color';
-import { removeElementFromParent } from 'browser/Dom';
-import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs';
-
-export abstract class BaseRenderLayer implements IRenderLayer {
- private _canvas: HTMLCanvasElement;
- protected _ctx!: CanvasRenderingContext2D;
- private _scaledCharWidth: number = 0;
- private _scaledCharHeight: number = 0;
- private _scaledCellWidth: number = 0;
- private _scaledCellHeight: number = 0;
- private _scaledCharLeft: number = 0;
- private _scaledCharTop: number = 0;
-
- protected _charAtlas: BaseCharAtlas | undefined;
-
- /**
- * An object that's reused when drawing glyphs in order to reduce GC.
- */
- private _currentGlyphIdentifier: IGlyphIdentifier = {
- chars: '',
- code: 0,
- bg: 0,
- fg: 0,
- bold: false,
- dim: false,
- italic: false
- };
-
- constructor(
- private _container: HTMLElement,
- id: string,
- zIndex: number,
- private _alpha: boolean,
- protected _colors: IColorSet,
- private _rendererId: number,
- protected readonly _bufferService: IBufferService,
- protected readonly _optionsService: IOptionsService
- ) {
- this._canvas = document.createElement('canvas');
- this._canvas.classList.add(`xterm-${id}-layer`);
- this._canvas.style.zIndex = zIndex.toString();
- this._initCanvas();
- this._container.appendChild(this._canvas);
- }
-
- public dispose(): void {
- removeElementFromParent(this._canvas);
- this._charAtlas?.dispose();
- }
-
- private _initCanvas(): void {
- this._ctx = throwIfFalsy(this._canvas.getContext('2d', { alpha: this._alpha }));
- // Draw the background if this is an opaque layer
- if (!this._alpha) {
- this._clearAll();
- }
- }
-
- public onOptionsChanged(): void {}
- public onBlur(): void {}
- public onFocus(): void {}
- public onCursorMove(): void {}
- public onGridChanged(startRow: number, endRow: number): void {}
- public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {}
-
- public setColors(colorSet: IColorSet): void {
- this._refreshCharAtlas(colorSet);
- }
-
- protected _setTransparency(alpha: boolean): void {
- // Do nothing when alpha doesn't change
- if (alpha === this._alpha) {
- return;
- }
-
- // Create new canvas and replace old one
- const oldCanvas = this._canvas;
- this._alpha = alpha;
- // Cloning preserves properties
- this._canvas = this._canvas.cloneNode() as HTMLCanvasElement;
- this._initCanvas();
- this._container.replaceChild(this._canvas, oldCanvas);
-
- // Regenerate char atlas and force a full redraw
- this._refreshCharAtlas(this._colors);
- this.onGridChanged(0, this._bufferService.rows - 1);
- }
-
- /**
- * Refreshes the char atlas, aquiring a new one if necessary.
- * @param colorSet The color set to use for the char atlas.
- */
- private _refreshCharAtlas(colorSet: IColorSet): void {
- if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {
- return;
- }
- this._charAtlas = acquireCharAtlas(this._optionsService.options, this._rendererId, colorSet, this._scaledCharWidth, this._scaledCharHeight);
- this._charAtlas.warmUp();
- }
-
- public resize(dim: IRenderDimensions): void {
- this._scaledCellWidth = dim.scaledCellWidth;
- this._scaledCellHeight = dim.scaledCellHeight;
- this._scaledCharWidth = dim.scaledCharWidth;
- this._scaledCharHeight = dim.scaledCharHeight;
- this._scaledCharLeft = dim.scaledCharLeft;
- this._scaledCharTop = dim.scaledCharTop;
- this._canvas.width = dim.scaledCanvasWidth;
- this._canvas.height = dim.scaledCanvasHeight;
- this._canvas.style.width = `${dim.canvasWidth}px`;
- this._canvas.style.height = `${dim.canvasHeight}px`;
-
- // Draw the background if this is an opaque layer
- if (!this._alpha) {
- this._clearAll();
- }
-
- this._refreshCharAtlas(this._colors);
- }
-
- public abstract reset(): void;
-
- /**
- * Fills 1+ cells completely. This uses the existing fillStyle on the context.
- * @param x The column to start at.
- * @param y The row to start at
- * @param width The number of columns to fill.
- * @param height The number of rows to fill.
- */
- protected _fillCells(x: number, y: number, width: number, height: number): void {
- this._ctx.fillRect(
- x * this._scaledCellWidth,
- y * this._scaledCellHeight,
- width * this._scaledCellWidth,
- height * this._scaledCellHeight);
- }
-
- /**
- * Fills a 1px line (2px on HDPI) at the middle of the cell. This uses the
- * existing fillStyle on the context.
- * @param x The column to fill.
- * @param y The row to fill.
- */
- protected _fillMiddleLineAtCells(x: number, y: number, width: number = 1): void {
- const cellOffset = Math.ceil(this._scaledCellHeight * 0.5);
- this._ctx.fillRect(
- x * this._scaledCellWidth,
- (y + 1) * this._scaledCellHeight - cellOffset - window.devicePixelRatio,
- width * this._scaledCellWidth,
- window.devicePixelRatio);
- }
-
- /**
- * Fills a 1px line (2px on HDPI) at the bottom of the cell. This uses the
- * existing fillStyle on the context.
- * @param x The column to fill.
- * @param y The row to fill.
- */
- protected _fillBottomLineAtCells(x: number, y: number, width: number = 1): void {
- this._ctx.fillRect(
- x * this._scaledCellWidth,
- (y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */,
- width * this._scaledCellWidth,
- window.devicePixelRatio);
- }
-
- /**
- * Fills a 1px line (2px on HDPI) at the left of the cell. This uses the
- * existing fillStyle on the context.
- * @param x The column to fill.
- * @param y The row to fill.
- */
- protected _fillLeftLineAtCell(x: number, y: number, width: number): void {
- this._ctx.fillRect(
- x * this._scaledCellWidth,
- y * this._scaledCellHeight,
- window.devicePixelRatio * width,
- this._scaledCellHeight);
- }
-
- /**
- * Strokes a 1px rectangle (2px on HDPI) around a cell. This uses the existing
- * strokeStyle on the context.
- * @param x The column to fill.
- * @param y The row to fill.
- */
- protected _strokeRectAtCell(x: number, y: number, width: number, height: number): void {
- this._ctx.lineWidth = window.devicePixelRatio;
- this._ctx.strokeRect(
- x * this._scaledCellWidth + window.devicePixelRatio / 2,
- y * this._scaledCellHeight + (window.devicePixelRatio / 2),
- width * this._scaledCellWidth - window.devicePixelRatio,
- (height * this._scaledCellHeight) - window.devicePixelRatio);
- }
-
- /**
- * Clears the entire canvas.
- */
- protected _clearAll(): void {
- if (this._alpha) {
- this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
- } else {
- this._ctx.fillStyle = this._colors.background.css;
- this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);
- }
- }
-
- /**
- * Clears 1+ cells completely.
- * @param x The column to start at.
- * @param y The row to start at.
- * @param width The number of columns to clear.
- * @param height The number of rows to clear.
- */
- protected _clearCells(x: number, y: number, width: number, height: number): void {
- if (this._alpha) {
- this._ctx.clearRect(
- x * this._scaledCellWidth,
- y * this._scaledCellHeight,
- width * this._scaledCellWidth,
- height * this._scaledCellHeight);
- } else {
- this._ctx.fillStyle = this._colors.background.css;
- this._ctx.fillRect(
- x * this._scaledCellWidth,
- y * this._scaledCellHeight,
- width * this._scaledCellWidth,
- height * this._scaledCellHeight);
- }
- }
-
- /**
- * Draws a truecolor character at the cell. The character will be clipped to
- * ensure that it fits with the cell, including the cell to the right if it's
- * a wide character. This uses the existing fillStyle on the context.
- * @param cell The cell data for the character to draw.
- * @param x The column to draw at.
- * @param y The row to draw at.
- * @param color The color of the character.
- */
- protected _fillCharTrueColor(cell: CellData, x: number, y: number): void {
- this._ctx.font = this._getFont(false, false);
- this._ctx.textBaseline = 'ideographic';
- this._clipRow(y);
-
- // Draw custom characters if applicable
- let drawSuccess = false;
- if (this._optionsService.options.customGlyphs !== false) {
- drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight);
- }
-
- // Draw the character
- if (!drawSuccess) {
- this._ctx.fillText(
- cell.getChars(),
- x * this._scaledCellWidth + this._scaledCharLeft,
- y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight);
- }
- }
-
- /**
- * Draws one or more characters at a cell. If possible this will draw using
- * the character atlas to reduce draw time.
- * @param chars The character or characters.
- * @param code The character code.
- * @param width The width of the characters.
- * @param x The column to draw at.
- * @param y The row to draw at.
- * @param fg The foreground color, in the format stored within the attributes.
- * @param bg The background color, in the format stored within the attributes.
- * This is used to validate whether a cached image can be used.
- * @param bold Whether the text is bold.
- */
- protected _drawChars(cell: ICellData, x: number, y: number): void {
- const contrastColor = this._getContrastColor(cell);
-
- // skip cache right away if we draw in RGB
- // Note: to avoid bad runtime JoinedCellData will be skipped
- // in the cache handler itself (atlasDidDraw == false) and
- // fall through to uncached later down below
- if (contrastColor || cell.isFgRGB() || cell.isBgRGB()) {
- this._drawUncachedChars(cell, x, y, contrastColor);
- return;
- }
-
- let fg;
- let bg;
- if (cell.isInverse()) {
- fg = (cell.isBgDefault()) ? INVERTED_DEFAULT_COLOR : cell.getBgColor();
- bg = (cell.isFgDefault()) ? INVERTED_DEFAULT_COLOR : cell.getFgColor();
- } else {
- bg = (cell.isBgDefault()) ? DEFAULT_COLOR : cell.getBgColor();
- fg = (cell.isFgDefault()) ? DEFAULT_COLOR : cell.getFgColor();
- }
-
- const drawInBrightColor = this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8;
-
- fg += drawInBrightColor ? 8 : 0;
- this._currentGlyphIdentifier.chars = cell.getChars() || WHITESPACE_CELL_CHAR;
- this._currentGlyphIdentifier.code = cell.getCode() || WHITESPACE_CELL_CODE;
- this._currentGlyphIdentifier.bg = bg;
- this._currentGlyphIdentifier.fg = fg;
- this._currentGlyphIdentifier.bold = !!cell.isBold();
- this._currentGlyphIdentifier.dim = !!cell.isDim();
- this._currentGlyphIdentifier.italic = !!cell.isItalic();
- const atlasDidDraw = this._charAtlas && this._charAtlas.draw(
- this._ctx,
- this._currentGlyphIdentifier,
- x * this._scaledCellWidth + this._scaledCharLeft,
- y * this._scaledCellHeight + this._scaledCharTop
- );
-
- if (!atlasDidDraw) {
- this._drawUncachedChars(cell, x, y);
- }
- }
-
- /**
- * Draws one or more characters at one or more cells. The character(s) will be
- * clipped to ensure that they fit with the cell(s), including the cell to the
- * right if the last character is a wide character.
- * @param chars The character.
- * @param width The width of the character.
- * @param fg The foreground color, in the format stored within the attributes.
- * @param x The column to draw at.
- * @param y The row to draw at.
- */
- private _drawUncachedChars(cell: ICellData, x: number, y: number, fgOverride?: IColor): void {
- this._ctx.save();
- this._ctx.font = this._getFont(!!cell.isBold(), !!cell.isItalic());
- this._ctx.textBaseline = 'ideographic';
-
- if (cell.isInverse()) {
- if (fgOverride) {
- this._ctx.fillStyle = fgOverride.css;
- } else if (cell.isBgDefault()) {
- this._ctx.fillStyle = color.opaque(this._colors.background).css;
- } else if (cell.isBgRGB()) {
- this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;
- } else {
- let bg = cell.getBgColor();
- if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && bg < 8) {
- bg += 8;
- }
- this._ctx.fillStyle = this._colors.ansi[bg].css;
- }
- } else {
- if (fgOverride) {
- this._ctx.fillStyle = fgOverride.css;
- } else if (cell.isFgDefault()) {
- this._ctx.fillStyle = this._colors.foreground.css;
- } else if (cell.isFgRGB()) {
- this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
- } else {
- let fg = cell.getFgColor();
- if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
- fg += 8;
- }
- this._ctx.fillStyle = this._colors.ansi[fg].css;
- }
- }
-
- this._clipRow(y);
-
- // Apply alpha to dim the character
- if (cell.isDim()) {
- this._ctx.globalAlpha = DIM_OPACITY;
- }
-
- // Draw custom characters if applicable
- let drawSuccess = false;
- if (this._optionsService.options.customGlyphs !== false) {
- drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight);
- }
-
- // Draw the character
- if (!drawSuccess) {
- this._ctx.fillText(
- cell.getChars(),
- x * this._scaledCellWidth + this._scaledCharLeft,
- y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight);
- }
-
- this._ctx.restore();
- }
-
-
- /**
- * Clips a row to ensure no pixels will be drawn outside the cells in the row.
- * @param y The row to clip.
- */
- private _clipRow(y: number): void {
- this._ctx.beginPath();
- this._ctx.rect(
- 0,
- y * this._scaledCellHeight,
- this._bufferService.cols * this._scaledCellWidth,
- this._scaledCellHeight);
- this._ctx.clip();
- }
-
- /**
- * Gets the current font.
- * @param isBold If we should use the bold fontWeight.
- */
- protected _getFont(isBold: boolean, isItalic: boolean): string {
- const fontWeight = isBold ? this._optionsService.options.fontWeightBold : this._optionsService.options.fontWeight;
- const fontStyle = isItalic ? 'italic' : '';
-
- return `${fontStyle} ${fontWeight} ${this._optionsService.options.fontSize * window.devicePixelRatio}px ${this._optionsService.options.fontFamily}`;
- }
-
- private _getContrastColor(cell: CellData): IColor | undefined {
- if (this._optionsService.options.minimumContrastRatio === 1) {
- return undefined;
- }
-
- // Try get from cache first
- const adjustedColor = this._colors.contrastCache.getColor(cell.bg, cell.fg);
- if (adjustedColor !== undefined) {
- return adjustedColor || undefined;
- }
-
- let fgColor = cell.getFgColor();
- let fgColorMode = cell.getFgColorMode();
- let bgColor = cell.getBgColor();
- let bgColorMode = cell.getBgColorMode();
- const isInverse = !!cell.isInverse();
- const isBold = !!cell.isInverse();
- if (isInverse) {
- const temp = fgColor;
- fgColor = bgColor;
- bgColor = temp;
- const temp2 = fgColorMode;
- fgColorMode = bgColorMode;
- bgColorMode = temp2;
- }
-
- const bgRgba = this._resolveBackgroundRgba(bgColorMode, bgColor, isInverse);
- const fgRgba = this._resolveForegroundRgba(fgColorMode, fgColor, isInverse, isBold);
- const result = rgba.ensureContrastRatio(bgRgba, fgRgba, this._optionsService.options.minimumContrastRatio);
-
- if (!result) {
- this._colors.contrastCache.setColor(cell.bg, cell.fg, null);
- return undefined;
- }
-
- const color: IColor = {
- css: channels.toCss(
- (result >> 24) & 0xFF,
- (result >> 16) & 0xFF,
- (result >> 8) & 0xFF
- ),
- rgba: result
- };
- this._colors.contrastCache.setColor(cell.bg, cell.fg, color);
-
- return color;
- }
-
- private _resolveBackgroundRgba(bgColorMode: number, bgColor: number, inverse: boolean): number {
- switch (bgColorMode) {
- case Attributes.CM_P16:
- case Attributes.CM_P256:
- return this._colors.ansi[bgColor].rgba;
- case Attributes.CM_RGB:
- return bgColor << 8;
- case Attributes.CM_DEFAULT:
- default:
- if (inverse) {
- return this._colors.foreground.rgba;
- }
- return this._colors.background.rgba;
- }
- }
-
- private _resolveForegroundRgba(fgColorMode: number, fgColor: number, inverse: boolean, bold: boolean): number {
- switch (fgColorMode) {
- case Attributes.CM_P16:
- case Attributes.CM_P256:
- if (this._optionsService.options.drawBoldTextInBrightColors && bold && fgColor < 8) {
- fgColor += 8;
- }
- return this._colors.ansi[fgColor].rgba;
- case Attributes.CM_RGB:
- return fgColor << 8;
- case Attributes.CM_DEFAULT:
- default:
- if (inverse) {
- return this._colors.background.rgba;
- }
- return this._colors.foreground.rgba;
- }
- }
-}
-
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/CursorRenderLayer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/CursorRenderLayer.ts
deleted file mode 100644
index 65109a80..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/CursorRenderLayer.ts
+++ /dev/null
@@ -1,387 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types';
-import { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer';
-import { ICellData } from 'common/Types';
-import { CellData } from 'common/buffer/CellData';
-import { IColorSet } from 'browser/Types';
-import { IBufferService, IOptionsService, ICoreService } from 'common/services/Services';
-import { IEventEmitter } from 'common/EventEmitter';
-import { ICoreBrowserService } from 'browser/services/Services';
-
-interface ICursorState {
- x: number;
- y: number;
- isFocused: boolean;
- style: string;
- width: number;
-}
-
-/**
- * The time between cursor blinks.
- */
-const BLINK_INTERVAL = 600;
-
-export class CursorRenderLayer extends BaseRenderLayer {
- private _state: ICursorState;
- private _cursorRenderers: {[key: string]: (x: number, y: number, cell: ICellData) => void};
- private _cursorBlinkStateManager: CursorBlinkStateManager | undefined;
- private _cell: ICellData = new CellData();
-
- constructor(
- container: HTMLElement,
- zIndex: number,
- colors: IColorSet,
- rendererId: number,
- private _onRequestRedraw: IEventEmitter,
- @IBufferService bufferService: IBufferService,
- @IOptionsService optionsService: IOptionsService,
- @ICoreService private readonly _coreService: ICoreService,
- @ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService
- ) {
- super(container, 'cursor', zIndex, true, colors, rendererId, bufferService, optionsService);
- this._state = {
- x: 0,
- y: 0,
- isFocused: false,
- style: '',
- width: 0
- };
- this._cursorRenderers = {
- 'bar': this._renderBarCursor.bind(this),
- 'block': this._renderBlockCursor.bind(this),
- 'underline': this._renderUnderlineCursor.bind(this)
- };
- // TODO: Consider initial options? Maybe onOptionsChanged should be called at the end of open?
- }
-
- public dispose(): void {
- if (this._cursorBlinkStateManager) {
- this._cursorBlinkStateManager.dispose();
- this._cursorBlinkStateManager = undefined;
- }
- super.dispose();
- }
-
- public resize(dim: IRenderDimensions): void {
- super.resize(dim);
- // Resizing the canvas discards the contents of the canvas so clear state
- this._state = {
- x: 0,
- y: 0,
- isFocused: false,
- style: '',
- width: 0
- };
- }
-
- public reset(): void {
- this._clearCursor();
- if (this._cursorBlinkStateManager) {
- this._cursorBlinkStateManager.dispose();
- this._cursorBlinkStateManager = undefined;
- this.onOptionsChanged();
- }
- }
-
- public onBlur(): void {
- if (this._cursorBlinkStateManager) {
- this._cursorBlinkStateManager.pause();
- }
- this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
- }
-
- public onFocus(): void {
- if (this._cursorBlinkStateManager) {
- this._cursorBlinkStateManager.resume();
- } else {
- this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
- }
- }
-
- public onOptionsChanged(): void {
- if (this._optionsService.options.cursorBlink) {
- if (!this._cursorBlinkStateManager) {
- this._cursorBlinkStateManager = new CursorBlinkStateManager(this._coreBrowserService.isFocused, () => {
- this._render(true);
- });
- }
- } else {
- this._cursorBlinkStateManager?.dispose();
- this._cursorBlinkStateManager = undefined;
- }
- // Request a refresh from the terminal as management of rendering is being
- // moved back to the terminal
- this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
- }
-
- public onCursorMove(): void {
- if (this._cursorBlinkStateManager) {
- this._cursorBlinkStateManager.restartBlinkAnimation();
- }
- }
-
- public onGridChanged(startRow: number, endRow: number): void {
- if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {
- this._render(false);
- } else {
- this._cursorBlinkStateManager.restartBlinkAnimation();
- }
- }
-
- private _render(triggeredByAnimationFrame: boolean): void {
- // Don't draw the cursor if it's hidden
- if (!this._coreService.isCursorInitialized || this._coreService.isCursorHidden) {
- this._clearCursor();
- return;
- }
-
- const cursorY = this._bufferService.buffer.ybase + this._bufferService.buffer.y;
- const viewportRelativeCursorY = cursorY - this._bufferService.buffer.ydisp;
-
- // Don't draw the cursor if it's off-screen
- if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= this._bufferService.rows) {
- this._clearCursor();
- return;
- }
-
- // in case cursor.x == cols adjust visual cursor to cols - 1
- const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1);
- this._bufferService.buffer.lines.get(cursorY)!.loadCell(cursorX, this._cell);
- if (this._cell.content === undefined) {
- return;
- }
-
- if (!this._coreBrowserService.isFocused) {
- this._clearCursor();
- this._ctx.save();
- this._ctx.fillStyle = this._colors.cursor.css;
- const cursorStyle = this._optionsService.options.cursorStyle;
- if (cursorStyle && cursorStyle !== 'block') {
- this._cursorRenderers[cursorStyle](cursorX, viewportRelativeCursorY, this._cell);
- } else {
- this._renderBlurCursor(cursorX, viewportRelativeCursorY, this._cell);
- }
- this._ctx.restore();
- this._state.x = cursorX;
- this._state.y = viewportRelativeCursorY;
- this._state.isFocused = false;
- this._state.style = cursorStyle;
- this._state.width = this._cell.getWidth();
- return;
- }
-
- // Don't draw the cursor if it's blinking
- if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {
- this._clearCursor();
- return;
- }
-
- if (this._state) {
- // The cursor is already in the correct spot, don't redraw
- if (this._state.x === cursorX &&
- this._state.y === viewportRelativeCursorY &&
- this._state.isFocused === this._coreBrowserService.isFocused &&
- this._state.style === this._optionsService.options.cursorStyle &&
- this._state.width === this._cell.getWidth()) {
- return;
- }
- this._clearCursor();
- }
-
- this._ctx.save();
- this._cursorRenderers[this._optionsService.options.cursorStyle || 'block'](cursorX, viewportRelativeCursorY, this._cell);
- this._ctx.restore();
-
- this._state.x = cursorX;
- this._state.y = viewportRelativeCursorY;
- this._state.isFocused = false;
- this._state.style = this._optionsService.options.cursorStyle;
- this._state.width = this._cell.getWidth();
- }
-
- private _clearCursor(): void {
- if (this._state) {
- // Avoid potential rounding errors when device pixel ratio is less than 1
- if (window.devicePixelRatio < 1) {
- this._clearAll();
- } else {
- this._clearCells(this._state.x, this._state.y, this._state.width, 1);
- }
- this._state = {
- x: 0,
- y: 0,
- isFocused: false,
- style: '',
- width: 0
- };
- }
- }
-
- private _renderBarCursor(x: number, y: number, cell: ICellData): void {
- this._ctx.save();
- this._ctx.fillStyle = this._colors.cursor.css;
- this._fillLeftLineAtCell(x, y, this._optionsService.options.cursorWidth);
- this._ctx.restore();
- }
-
- private _renderBlockCursor(x: number, y: number, cell: ICellData): void {
- this._ctx.save();
- this._ctx.fillStyle = this._colors.cursor.css;
- this._fillCells(x, y, cell.getWidth(), 1);
- this._ctx.fillStyle = this._colors.cursorAccent.css;
- this._fillCharTrueColor(cell, x, y);
- this._ctx.restore();
- }
-
- private _renderUnderlineCursor(x: number, y: number, cell: ICellData): void {
- this._ctx.save();
- this._ctx.fillStyle = this._colors.cursor.css;
- this._fillBottomLineAtCells(x, y);
- this._ctx.restore();
- }
-
- private _renderBlurCursor(x: number, y: number, cell: ICellData): void {
- this._ctx.save();
- this._ctx.strokeStyle = this._colors.cursor.css;
- this._strokeRectAtCell(x, y, cell.getWidth(), 1);
- this._ctx.restore();
- }
-}
-
-class CursorBlinkStateManager {
- public isCursorVisible: boolean;
-
- private _animationFrame: number | undefined;
- private _blinkStartTimeout: number | undefined;
- private _blinkInterval: number | undefined;
-
- /**
- * The time at which the animation frame was restarted, this is used on the
- * next render to restart the timers so they don't need to restart the timers
- * multiple times over a short period.
- */
- private _animationTimeRestarted: number | undefined;
-
- constructor(
- isFocused: boolean,
- private _renderCallback: () => void
- ) {
- this.isCursorVisible = true;
- if (isFocused) {
- this._restartInterval();
- }
- }
-
- public get isPaused(): boolean { return !(this._blinkStartTimeout || this._blinkInterval); }
-
- public dispose(): void {
- if (this._blinkInterval) {
- window.clearInterval(this._blinkInterval);
- this._blinkInterval = undefined;
- }
- if (this._blinkStartTimeout) {
- window.clearTimeout(this._blinkStartTimeout);
- this._blinkStartTimeout = undefined;
- }
- if (this._animationFrame) {
- window.cancelAnimationFrame(this._animationFrame);
- this._animationFrame = undefined;
- }
- }
-
- public restartBlinkAnimation(): void {
- if (this.isPaused) {
- return;
- }
- // Save a timestamp so that the restart can be done on the next interval
- this._animationTimeRestarted = Date.now();
- // Force a cursor render to ensure it's visible and in the correct position
- this.isCursorVisible = true;
- if (!this._animationFrame) {
- this._animationFrame = window.requestAnimationFrame(() => {
- this._renderCallback();
- this._animationFrame = undefined;
- });
- }
- }
-
- private _restartInterval(timeToStart: number = BLINK_INTERVAL): void {
- // Clear any existing interval
- if (this._blinkInterval) {
- window.clearInterval(this._blinkInterval);
- }
-
- // Setup the initial timeout which will hide the cursor, this is done before
- // the regular interval is setup in order to support restarting the blink
- // animation in a lightweight way (without thrashing clearInterval and
- // setInterval).
- this._blinkStartTimeout = window.setTimeout(() => {
- // Check if another animation restart was requested while this was being
- // started
- if (this._animationTimeRestarted) {
- const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);
- this._animationTimeRestarted = undefined;
- if (time > 0) {
- this._restartInterval(time);
- return;
- }
- }
-
- // Hide the cursor
- this.isCursorVisible = false;
- this._animationFrame = window.requestAnimationFrame(() => {
- this._renderCallback();
- this._animationFrame = undefined;
- });
-
- // Setup the blink interval
- this._blinkInterval = window.setInterval(() => {
- // Adjust the animation time if it was restarted
- if (this._animationTimeRestarted) {
- // calc time diff
- // Make restart interval do a setTimeout initially?
- const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);
- this._animationTimeRestarted = undefined;
- this._restartInterval(time);
- return;
- }
-
- // Invert visibility and render
- this.isCursorVisible = !this.isCursorVisible;
- this._animationFrame = window.requestAnimationFrame(() => {
- this._renderCallback();
- this._animationFrame = undefined;
- });
- }, BLINK_INTERVAL);
- }, timeToStart);
- }
-
- public pause(): void {
- this.isCursorVisible = true;
- if (this._blinkInterval) {
- window.clearInterval(this._blinkInterval);
- this._blinkInterval = undefined;
- }
- if (this._blinkStartTimeout) {
- window.clearTimeout(this._blinkStartTimeout);
- this._blinkStartTimeout = undefined;
- }
- if (this._animationFrame) {
- window.cancelAnimationFrame(this._animationFrame);
- this._animationFrame = undefined;
- }
- }
-
- public resume(): void {
- // Clear out any existing timers just in case
- this.pause();
-
- this._animationTimeRestarted = undefined;
- this._restartInterval();
- this.restartBlinkAnimation();
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/CustomGlyphs.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/CustomGlyphs.ts
deleted file mode 100644
index 77562790..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/CustomGlyphs.ts
+++ /dev/null
@@ -1,563 +0,0 @@
-/**
- * Copyright (c) 2021 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { throwIfFalsy } from 'browser/renderer/RendererUtils';
-
-interface IBlockVector {
- x: number;
- y: number;
- w: number;
- h: number;
-}
-
-export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefined } = {
- // Block elements (0x2580-0x2590)
- '▀': [{ x: 0, y: 0, w: 8, h: 4 }], // UPPER HALF BLOCK
- '▁': [{ x: 0, y: 7, w: 8, h: 1 }], // LOWER ONE EIGHTH BLOCK
- '▂': [{ x: 0, y: 6, w: 8, h: 2 }], // LOWER ONE QUARTER BLOCK
- '▃': [{ x: 0, y: 5, w: 8, h: 3 }], // LOWER THREE EIGHTHS BLOCK
- '▄': [{ x: 0, y: 4, w: 8, h: 4 }], // LOWER HALF BLOCK
- '▅': [{ x: 0, y: 3, w: 8, h: 5 }], // LOWER FIVE EIGHTHS BLOCK
- '▆': [{ x: 0, y: 2, w: 8, h: 6 }], // LOWER THREE QUARTERS BLOCK
- '▇': [{ x: 0, y: 1, w: 8, h: 7 }], // LOWER SEVEN EIGHTHS BLOCK
- '█': [{ x: 0, y: 0, w: 8, h: 8 }], // FULL BLOCK
- '▉': [{ x: 0, y: 0, w: 7, h: 8 }], // LEFT SEVEN EIGHTHS BLOCK
- '▊': [{ x: 0, y: 0, w: 6, h: 8 }], // LEFT THREE QUARTERS BLOCK
- '▋': [{ x: 0, y: 0, w: 5, h: 8 }], // LEFT FIVE EIGHTHS BLOCK
- '▌': [{ x: 0, y: 0, w: 4, h: 8 }], // LEFT HALF BLOCK
- '▍': [{ x: 0, y: 0, w: 3, h: 8 }], // LEFT THREE EIGHTHS BLOCK
- '▎': [{ x: 0, y: 0, w: 2, h: 8 }], // LEFT ONE QUARTER BLOCK
- '▏': [{ x: 0, y: 0, w: 1, h: 8 }], // LEFT ONE EIGHTH BLOCK
- '▐': [{ x: 4, y: 0, w: 4, h: 8 }], // RIGHT HALF BLOCK
-
- // Block elements (0x2594-0x2595)
- '▔': [{ x: 0, y: 0, w: 9, h: 1 }], // UPPER ONE EIGHTH BLOCK
- '▕': [{ x: 7, y: 0, w: 1, h: 8 }], // RIGHT ONE EIGHTH BLOCK
-
- // Terminal graphic characters (0x2596-0x259F)
- '▖': [{ x: 0, y: 4, w: 4, h: 4 }], // QUADRANT LOWER LEFT
- '▗': [{ x: 4, y: 4, w: 4, h: 4 }], // QUADRANT LOWER RIGHT
- '▘': [{ x: 0, y: 0, w: 4, h: 4 }], // QUADRANT UPPER LEFT
- '▙': [{ x: 0, y: 0, w: 4, h: 8 }, { x: 0, y: 4, w: 8, h: 4 }], // QUADRANT UPPER LEFT AND LOWER LEFT AND LOWER RIGHT
- '▚': [{ x: 0, y: 0, w: 4, h: 4 }, { x: 4, y: 4, w: 4, h: 4 }], // QUADRANT UPPER LEFT AND LOWER RIGHT
- '▛': [{ x: 0, y: 0, w: 4, h: 8 }, { x: 0, y: 0, w: 4, h: 8 }], // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER LEFT
- '▜': [{ x: 0, y: 0, w: 8, h: 4 }, { x: 4, y: 0, w: 4, h: 8 }], // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER RIGHT
- '▝': [{ x: 4, y: 0, w: 4, h: 4 }], // QUADRANT UPPER RIGHT
- '▞': [{ x: 4, y: 0, w: 4, h: 4 }, { x: 0, y: 4, w: 4, h: 4 }], // QUADRANT UPPER RIGHT AND LOWER LEFT
- '▟': [{ x: 4, y: 0, w: 4, h: 8 }, { x: 0, y: 4, w: 8, h: 4 }], // QUADRANT UPPER RIGHT AND LOWER LEFT AND LOWER RIGHT
-
- // VERTICAL ONE EIGHTH BLOCK-2 through VERTICAL ONE EIGHTH BLOCK-7
- '\u{1FB70}': [{ x: 1, y: 0, w: 1, h: 8 }],
- '\u{1FB71}': [{ x: 2, y: 0, w: 1, h: 8 }],
- '\u{1FB72}': [{ x: 3, y: 0, w: 1, h: 8 }],
- '\u{1FB73}': [{ x: 4, y: 0, w: 1, h: 8 }],
- '\u{1FB74}': [{ x: 5, y: 0, w: 1, h: 8 }],
- '\u{1FB75}': [{ x: 6, y: 0, w: 1, h: 8 }],
-
- // HORIZONTAL ONE EIGHTH BLOCK-2 through HORIZONTAL ONE EIGHTH BLOCK-7
- '\u{1FB76}': [{ x: 0, y: 1, w: 8, h: 1 }],
- '\u{1FB77}': [{ x: 0, y: 2, w: 8, h: 1 }],
- '\u{1FB78}': [{ x: 0, y: 3, w: 8, h: 1 }],
- '\u{1FB79}': [{ x: 0, y: 4, w: 8, h: 1 }],
- '\u{1FB7A}': [{ x: 0, y: 5, w: 8, h: 1 }],
- '\u{1FB7B}': [{ x: 0, y: 6, w: 8, h: 1 }],
-
- // LEFT AND LOWER ONE EIGHTH BLOCK
- '\u{1FB7C}': [{ x: 0, y: 0, w: 1, h: 8 }, { x: 0, y: 7, w: 8, h: 1 }],
- // LEFT AND UPPER ONE EIGHTH BLOCK
- '\u{1FB7D}': [{ x: 0, y: 0, w: 1, h: 8 }, { x: 0, y: 0, w: 8, h: 1 }],
- // RIGHT AND UPPER ONE EIGHTH BLOCK
- '\u{1FB7E}': [{ x: 7, y: 0, w: 1, h: 8 }, { x: 0, y: 0, w: 8, h: 1 }],
- // RIGHT AND LOWER ONE EIGHTH BLOCK
- '\u{1FB7F}': [{ x: 7, y: 0, w: 1, h: 8 }, { x: 0, y: 7, w: 8, h: 1 }],
- // UPPER AND LOWER ONE EIGHTH BLOCK
- '\u{1FB80}': [{ x: 0, y: 0, w: 8, h: 1 }, { x: 0, y: 7, w: 8, h: 1 }],
- // HORIZONTAL ONE EIGHTH BLOCK-1358
- '\u{1FB81}': [{ x: 0, y: 0, w: 8, h: 1 }, { x: 0, y: 2, w: 8, h: 1 }, { x: 0, y: 4, w: 8, h: 1 }, { x: 0, y: 7, w: 8, h: 1 }],
-
- // UPPER ONE QUARTER BLOCK
- '\u{1FB82}': [{ x: 0, y: 0, w: 8, h: 2 }],
- // UPPER THREE EIGHTHS BLOCK
- '\u{1FB83}': [{ x: 0, y: 0, w: 8, h: 3 }],
- // UPPER FIVE EIGHTHS BLOCK
- '\u{1FB84}': [{ x: 0, y: 0, w: 8, h: 5 }],
- // UPPER THREE QUARTERS BLOCK
- '\u{1FB85}': [{ x: 0, y: 0, w: 8, h: 6 }],
- // UPPER SEVEN EIGHTHS BLOCK
- '\u{1FB86}': [{ x: 0, y: 0, w: 8, h: 7 }],
-
- // RIGHT ONE QUARTER BLOCK
- '\u{1FB87}': [{ x: 6, y: 0, w: 2, h: 8 }],
- // RIGHT THREE EIGHTHS B0OCK
- '\u{1FB88}': [{ x: 5, y: 0, w: 3, h: 8 }],
- // RIGHT FIVE EIGHTHS BL0CK
- '\u{1FB89}': [{ x: 3, y: 0, w: 5, h: 8 }],
- // RIGHT THREE QUARTERS 0LOCK
- '\u{1FB8A}': [{ x: 2, y: 0, w: 6, h: 8 }],
- // RIGHT SEVEN EIGHTHS B0OCK
- '\u{1FB8B}': [{ x: 1, y: 0, w: 7, h: 8 }],
-
- // CHECKER BOARD FILL
- '\u{1FB95}': [
- { x: 0, y: 0, w: 2, h: 2 }, { x: 4, y: 0, w: 2, h: 2 },
- { x: 2, y: 2, w: 2, h: 2 }, { x: 6, y: 2, w: 2, h: 2 },
- { x: 0, y: 4, w: 2, h: 2 }, { x: 4, y: 4, w: 2, h: 2 },
- { x: 2, y: 6, w: 2, h: 2 }, { x: 6, y: 6, w: 2, h: 2 }
- ],
- // INVERSE CHECKER BOARD FILL
- '\u{1FB96}': [
- { x: 2, y: 0, w: 2, h: 2 }, { x: 6, y: 0, w: 2, h: 2 },
- { x: 0, y: 2, w: 2, h: 2 }, { x: 4, y: 2, w: 2, h: 2 },
- { x: 2, y: 4, w: 2, h: 2 }, { x: 6, y: 4, w: 2, h: 2 },
- { x: 0, y: 6, w: 2, h: 2 }, { x: 4, y: 6, w: 2, h: 2 }
- ],
- // HEAVY HORIZONTAL FILL (upper middle and lower one quarter block)
- '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }]
-};
-
-type PatternDefinition = number[][];
-
-/**
- * Defines the repeating pattern used by special characters, the pattern is made up of a 2d array of
- * pixel values to be filled (1) or not filled (0).
- */
-const patternCharacterDefinitions: { [key: string]: PatternDefinition | undefined } = {
- // Shade characters (0x2591-0x2593)
- '░': [ // LIGHT SHADE (25%)
- [1, 0, 0, 0],
- [0, 0, 0, 0],
- [0, 0, 1, 0],
- [0, 0, 0, 0]
- ],
- '▒': [ // MEDIUM SHADE (50%)
- [1, 0],
- [0, 0],
- [0, 1],
- [0, 0]
- ],
- '▓': [ // DARK SHADE (75%)
- [0, 1],
- [1, 1],
- [1, 0],
- [1, 1]
- ]
-};
-
-const enum Shapes {
- /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1',
- /** ─ */ LEFT_TO_RIGHT = 'M0,.5 L1,.5',
-
- /** └ */ TOP_TO_RIGHT = 'M.5,0 L.5,.5 L1,.5',
- /** ┘ */ TOP_TO_LEFT = 'M.5,0 L.5,.5 L0,.5',
- /** ┐ */ LEFT_TO_BOTTOM = 'M0,.5 L.5,.5 L.5,1',
- /** ┌ */ RIGHT_TO_BOTTOM = 'M0.5,1 L.5,.5 L1,.5',
-
- /** ╵ */ MIDDLE_TO_TOP = 'M.5,.5 L.5,0',
- /** ╴ */ MIDDLE_TO_LEFT = 'M.5,.5 L0,.5',
- /** ╶ */ MIDDLE_TO_RIGHT = 'M.5,.5 L1,.5',
- /** ╷ */ MIDDLE_TO_BOTTOM = 'M.5,.5 L.5,1',
-
- /** ┴ */ T_TOP = 'M0,.5 L1,.5 M.5,.5 L.5,0',
- /** ┤ */ T_LEFT = 'M.5,0 L.5,1 M.5,.5 L0,.5',
- /** ├ */ T_RIGHT = 'M.5,0 L.5,1 M.5,.5 L1,.5',
- /** ┬ */ T_BOTTOM = 'M0,.5 L1,.5 M.5,.5 L.5,1',
-
- /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1',
-
- /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.4,.5 M.6,.5 L.9,.5', // .2 empty, .3 filled
- /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5', // .1333 empty, .2 filled
- /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5', // .1 empty, .15 filled
- /** ╎ */ TWO_DASHES_VERTICAL = 'M.5,.1 L.5,.4 M.5,.6 L.5,.9',
- /** ┆ */ THREE_DASHES_VERTICAL = 'M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333',
- /** ┊ */ FOUR_DASHES_VERTICAL = 'M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95',
-}
-
-const enum Style {
- NORMAL = 1,
- BOLD = 3
-}
-
-/**
- * This contains the definitions of all box drawing characters in the format of SVG paths (ie. the
- * svg d attribute).
- */
-export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = {
- // Uniform normal and bold
- '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT },
- '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT },
- '│': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM },
- '┃': { [Style.BOLD]: Shapes.TOP_TO_BOTTOM },
- '┌': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM },
- '┏': { [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM },
- '┐': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM },
- '┓': { [Style.BOLD]: Shapes.LEFT_TO_BOTTOM },
- '└': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT },
- '┗': { [Style.BOLD]: Shapes.TOP_TO_RIGHT },
- '┘': { [Style.NORMAL]: Shapes.TOP_TO_LEFT },
- '┛': { [Style.BOLD]: Shapes.TOP_TO_LEFT },
- '├': { [Style.NORMAL]: Shapes.T_RIGHT },
- '┣': { [Style.BOLD]: Shapes.T_RIGHT },
- '┤': { [Style.NORMAL]: Shapes.T_LEFT },
- '┫': { [Style.BOLD]: Shapes.T_LEFT },
- '┬': { [Style.NORMAL]: Shapes.T_BOTTOM },
- '┳': { [Style.BOLD]: Shapes.T_BOTTOM },
- '┴': { [Style.NORMAL]: Shapes.T_TOP },
- '┻': { [Style.BOLD]: Shapes.T_TOP },
- '┼': { [Style.NORMAL]: Shapes.CROSS },
- '╋': { [Style.BOLD]: Shapes.CROSS },
- '╴': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT },
- '╸': { [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '╵': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP },
- '╹': { [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '╶': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT },
- '╺': { [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '╷': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM },
- '╻': { [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
-
- // Double border
- '═': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` },
- '║': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` },
- '╒': { [Style.NORMAL]: (xp, yp) => `M.5,1 L.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` },
- '╓': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},1 L${.5 - xp},.5 L1,.5 M${.5 + xp},.5 L${.5 + xp},1` },
- '╔': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1` },
- '╕': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L.5,${.5 - yp} L.5,1 M0,${.5 + yp} L.5,${.5 + yp}` },
- '╖': { [Style.NORMAL]: (xp, yp) => `M${.5 + xp},1 L${.5 + xp},.5 L0,.5 M${.5 - xp},.5 L${.5 - xp},1` },
- '╗': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M0,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},1` },
- '╘': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 + yp} L1,${.5 + yp} M.5,${.5 - yp} L1,${.5 - yp}` },
- '╙': { [Style.NORMAL]: (xp, yp) => `M1,.5 L${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` },
- '╚': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0 M1,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},0` },
- '╛': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L.5,${.5 + yp} L.5,0 M0,${.5 - yp} L.5,${.5 - yp}` },
- '╜': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 + xp},.5 L${.5 + xp},0 M${.5 - xp},.5 L${.5 - xp},0` },
- '╝': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M0,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},0` },
- '╞': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` },
- '╟': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1 M${.5 + xp},.5 L1,.5` },
- '╠': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` },
- '╡': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M0,${.5 - yp} L.5,${.5 - yp} M0,${.5 + yp} L.5,${.5 + yp}` },
- '╢': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 - xp},.5 M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` },
- '╣': { [Style.NORMAL]: (xp, yp) => `M${.5 + xp},0 L${.5 + xp},1 M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0` },
- '╤': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp} M.5,${.5 + yp} L.5,1` },
- '╥': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},.5 L${.5 - xp},1 M${.5 + xp},.5 L${.5 + xp},1` },
- '╦': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1` },
- '╧': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 - yp} M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` },
- '╨': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` },
- '╩': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L1,${.5 + yp} M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` },
- '╪': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` },
- '╫': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` },
- '╬': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1 M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` },
-
- // Diagonal
- '╱': { [Style.NORMAL]: 'M1,0 L0,1' },
- '╲': { [Style.NORMAL]: 'M0,0 L1,1' },
- '╳': { [Style.NORMAL]: 'M1,0 L0,1 M0,0 L1,1' },
-
- // Mixed weight
- '╼': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '╽': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
- '╾': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '╿': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '┍': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '┎': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
- '┑': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '┒': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
- '┕': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '┖': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '┙': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '┚': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '┝': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '┞': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '┟': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
- '┠': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM },
- '┡': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_RIGHT },
- '┢': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM },
- '┥': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '┦': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '┧': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
- '┨': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM },
- '┩': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT },
- '┪': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM },
- '┭': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '┮': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '┯': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT },
- '┰': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
- '┱': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM },
- '┲': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM },
- '┵': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '┶': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '┷': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.LEFT_TO_RIGHT },
- '┸': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '┹': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_LEFT },
- '┺': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.TOP_TO_RIGHT },
- '┽': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT },
- '┾': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}`, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT },
- '┿': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT },
- '╀': { [Style.NORMAL]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}`, [Style.BOLD]: Shapes.MIDDLE_TO_TOP },
- '╁': { [Style.NORMAL]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM },
- '╂': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM },
- '╃': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT },
- '╄': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_RIGHT },
- '╅': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM },
- '╆': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM },
- '╇': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}` },
- '╈': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}` },
- '╉': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}` },
- '╊': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}` },
-
- // Dashed
- '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL },
- '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL },
- '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL },
- '┅': { [Style.BOLD]: Shapes.THREE_DASHES_HORIZONTAL },
- '┈': { [Style.NORMAL]: Shapes.FOUR_DASHES_HORIZONTAL },
- '┉': { [Style.BOLD]: Shapes.FOUR_DASHES_HORIZONTAL },
- '╎': { [Style.NORMAL]: Shapes.TWO_DASHES_VERTICAL },
- '╏': { [Style.BOLD]: Shapes.TWO_DASHES_VERTICAL },
- '┆': { [Style.NORMAL]: Shapes.THREE_DASHES_VERTICAL },
- '┇': { [Style.BOLD]: Shapes.THREE_DASHES_VERTICAL },
- '┊': { [Style.NORMAL]: Shapes.FOUR_DASHES_VERTICAL },
- '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL },
-
- // Curved
- '╭': { [Style.NORMAL]: 'C.5,1,.5,.5,1,.5' },
- '╮': { [Style.NORMAL]: 'C.5,1,.5,.5,0,.5' },
- '╯': { [Style.NORMAL]: 'C.5,0,.5,.5,0,.5' },
- '╰': { [Style.NORMAL]: 'C.5,0,.5,.5,1,.5' }
-};
-
-/**
- * Try drawing a custom block element or box drawing character, returning whether it was
- * successfully drawn.
- */
-export function tryDrawCustomChar(
- ctx: CanvasRenderingContext2D,
- c: string,
- xOffset: number,
- yOffset: number,
- scaledCellWidth: number,
- scaledCellHeight: number
-): boolean {
- const blockElementDefinition = blockElementDefinitions[c];
- if (blockElementDefinition) {
- drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight);
- return true;
- }
-
- const patternDefinition = patternCharacterDefinitions[c];
- if (patternDefinition) {
- drawPatternChar(ctx, patternDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight);
- return true;
- }
-
- const boxDrawingDefinition = boxDrawingDefinitions[c];
- if (boxDrawingDefinition) {
- drawBoxDrawingChar(ctx, boxDrawingDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight);
- return true;
- }
-
- return false;
-}
-
-function drawBlockElementChar(
- ctx: CanvasRenderingContext2D,
- charDefinition: IBlockVector[],
- xOffset: number,
- yOffset: number,
- scaledCellWidth: number,
- scaledCellHeight: number
-): void {
- for (let i = 0; i < charDefinition.length; i++) {
- const box = charDefinition[i];
- const xEighth = scaledCellWidth / 8;
- const yEighth = scaledCellHeight / 8;
- ctx.fillRect(
- xOffset + box.x * xEighth,
- yOffset + box.y * yEighth,
- box.w * xEighth,
- box.h * yEighth
- );
- }
-}
-
-const cachedPatterns: Map> = new Map();
-
-function drawPatternChar(
- ctx: CanvasRenderingContext2D,
- charDefinition: number[][],
- xOffset: number,
- yOffset: number,
- scaledCellWidth: number,
- scaledCellHeight: number
-): void {
- let patternSet = cachedPatterns.get(charDefinition);
- if (!patternSet) {
- patternSet = new Map();
- cachedPatterns.set(charDefinition, patternSet);
- }
- const fillStyle = ctx.fillStyle;
- if (typeof fillStyle !== 'string') {
- throw new Error(`Unexpected fillStyle type "${fillStyle}"`);
- }
- let pattern = patternSet.get(fillStyle);
- if (!pattern) {
- const width = charDefinition[0].length;
- const height = charDefinition.length;
- const tmpCanvas = document.createElement('canvas');
- tmpCanvas.width = width;
- tmpCanvas.height = height;
- const tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d'));
- const imageData = new ImageData(width, height);
-
- // Extract rgba from fillStyle
- let r: number;
- let g: number;
- let b: number;
- let a: number;
- if (fillStyle.startsWith('#')) {
- r = parseInt(fillStyle.substr(1, 2), 16);
- g = parseInt(fillStyle.substr(3, 2), 16);
- b = parseInt(fillStyle.substr(5, 2), 16);
- a = fillStyle.length > 7 && parseInt(fillStyle.substr(7, 2), 16) || 1;
- } else if (fillStyle.startsWith('rgba')) {
- ([r, g, b, a] = fillStyle.substring(5, fillStyle.length - 1).split(',').map(e => parseFloat(e)));
- } else {
- throw new Error(`Unexpected fillStyle color format "${fillStyle}" when drawing pattern glyph`);
- }
-
- for (let y = 0; y < height; y++) {
- for (let x = 0; x < width; x++) {
- imageData.data[(y * width + x) * 4 ] = r;
- imageData.data[(y * width + x) * 4 + 1] = g;
- imageData.data[(y * width + x) * 4 + 2] = b;
- imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a * 255);
- }
- }
- tmpCtx.putImageData(imageData, 0, 0);
- pattern = throwIfFalsy(ctx.createPattern(tmpCanvas, null));
- patternSet.set(fillStyle, pattern);
- }
- ctx.fillStyle = pattern;
- ctx.fillRect(xOffset, yOffset, scaledCellWidth, scaledCellHeight);
-}
-
-/**
- * Draws the following box drawing characters by mapping a subset of SVG d attribute instructions to
- * canvas draw calls.
- *
- * Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐
- * ┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤
- * │ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘
- * ├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐
- * │ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤
- * └─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘
- *
- * Other:
- * ╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈
- * │ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉
- * ╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋
- *
- * All box drawing characters:
- * ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏
- * ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟
- * ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯
- * ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿
- * ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏
- * ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟
- * ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯
- * ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿
- *
- * ---
- *
- * Box drawing alignment tests: █
- * ▉
- * ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳
- * ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳
- * ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳
- * ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳
- * ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎
- * ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏
- * ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█
- *
- * Source: https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html
- */
-function drawBoxDrawingChar(
- ctx: CanvasRenderingContext2D,
- charDefinition: { [fontWeight: number]: string | ((xp: number, yp: number) => string) },
- xOffset: number,
- yOffset: number,
- scaledCellWidth: number,
- scaledCellHeight: number
-): void {
- ctx.strokeStyle = ctx.fillStyle;
- for (const [fontWeight, instructions] of Object.entries(charDefinition)) {
- ctx.beginPath();
- ctx.lineWidth = window.devicePixelRatio * Number.parseInt(fontWeight);
- let actualInstructions: string;
- if (typeof instructions === 'function') {
- const xp = .15;
- const yp = .15 / scaledCellHeight * scaledCellWidth;
- actualInstructions = instructions(xp, yp);
- } else {
- actualInstructions = instructions;
- }
- for (const instruction of actualInstructions.split(' ')) {
- const type = instruction[0];
- const f = svgToCanvasInstructionMap[type];
- if (!f) {
- console.error(`Could not find drawing instructions for "${type}"`);
- continue;
- }
- const args: string[] = instruction.substring(1).split(',');
- if (!args[0] || !args[1]) {
- continue;
- }
- f(ctx, translateArgs(args, scaledCellWidth, scaledCellHeight, xOffset, yOffset));
- }
- ctx.stroke();
- ctx.closePath();
- }
-}
-
-function clamp(value: number, max: number, min: number = 0): number {
- return Math.max(Math.min(value, max), min);
-}
-
-const svgToCanvasInstructionMap: { [index: string]: any } = {
- 'C': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.bezierCurveTo(args[0], args[1], args[2], args[3], args[4], args[5]),
- 'L': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.lineTo(args[0], args[1]),
- 'M': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.moveTo(args[0], args[1])
-};
-
-function translateArgs(args: string[], cellWidth: number, cellHeight: number, xOffset: number, yOffset: number): number[] {
- const result = args.map(e => parseFloat(e) || parseInt(e));
-
- if (result.length < 2) {
- throw new Error('Too few arguments for instruction');
- }
-
- for (let x = 0; x < result.length; x += 2) {
- // Translate from 0-1 to 0-cellWidth
- result[x] *= cellWidth;
- // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp
- // line at 100% devicePixelRatio
- if (result[x] !== 0) {
- result[x] = clamp(Math.round(result[x] + 0.5) - 0.5, cellWidth, 0);
- }
- // Apply the cell's offset (ie. x*cellWidth)
- result[x] += xOffset;
- }
-
- for (let y = 1; y < result.length; y += 2) {
- // Translate from 0-1 to 0-cellHeight
- result[y] *= cellHeight;
- // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp
- // line at 100% devicePixelRatio
- if (result[y] !== 0) {
- result[y] = clamp(Math.round(result[y] + 0.5) - 0.5, cellHeight, 0);
- }
- // Apply the cell's offset (ie. x*cellHeight)
- result[y] += yOffset;
- }
-
- return result;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/GridCache.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/GridCache.ts
deleted file mode 100644
index b48798d2..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/GridCache.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-export class GridCache {
- public cache: (T | undefined)[][];
-
- public constructor() {
- this.cache = [];
- }
-
- public resize(width: number, height: number): void {
- for (let x = 0; x < width; x++) {
- if (this.cache.length <= x) {
- this.cache.push([]);
- }
- for (let y = this.cache[x].length; y < height; y++) {
- this.cache[x].push(undefined);
- }
- this.cache[x].length = height;
- }
- this.cache.length = width;
- }
-
- public clear(): void {
- for (let x = 0; x < this.cache.length; x++) {
- for (let y = 0; y < this.cache[x].length; y++) {
- this.cache[x][y] = undefined;
- }
- }
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/LinkRenderLayer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/LinkRenderLayer.ts
deleted file mode 100644
index 2492f921..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/LinkRenderLayer.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderDimensions } from 'browser/renderer/Types';
-import { BaseRenderLayer } from './BaseRenderLayer';
-import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
-import { is256Color } from 'browser/renderer/atlas/CharAtlasUtils';
-import { IColorSet, ILinkifierEvent, ILinkifier, ILinkifier2 } from 'browser/Types';
-import { IBufferService, IOptionsService } from 'common/services/Services';
-
-export class LinkRenderLayer extends BaseRenderLayer {
- private _state: ILinkifierEvent | undefined;
-
- constructor(
- container: HTMLElement,
- zIndex: number,
- colors: IColorSet,
- rendererId: number,
- linkifier: ILinkifier,
- linkifier2: ILinkifier2,
- @IBufferService bufferService: IBufferService,
- @IOptionsService optionsService: IOptionsService
- ) {
- super(container, 'link', zIndex, true, colors, rendererId, bufferService, optionsService);
- linkifier.onShowLinkUnderline(e => this._onShowLinkUnderline(e));
- linkifier.onHideLinkUnderline(e => this._onHideLinkUnderline(e));
-
- linkifier2.onShowLinkUnderline(e => this._onShowLinkUnderline(e));
- linkifier2.onHideLinkUnderline(e => this._onHideLinkUnderline(e));
- }
-
- public resize(dim: IRenderDimensions): void {
- super.resize(dim);
- // Resizing the canvas discards the contents of the canvas so clear state
- this._state = undefined;
- }
-
- public reset(): void {
- this._clearCurrentLink();
- }
-
- private _clearCurrentLink(): void {
- if (this._state) {
- this._clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
- const middleRowCount = this._state.y2 - this._state.y1 - 1;
- if (middleRowCount > 0) {
- this._clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
- }
- this._clearCells(0, this._state.y2, this._state.x2, 1);
- this._state = undefined;
- }
- }
-
- private _onShowLinkUnderline(e: ILinkifierEvent): void {
- if (e.fg === INVERTED_DEFAULT_COLOR) {
- this._ctx.fillStyle = this._colors.background.css;
- } else if (e.fg && is256Color(e.fg)) {
- // 256 color support
- this._ctx.fillStyle = this._colors.ansi[e.fg].css;
- } else {
- this._ctx.fillStyle = this._colors.foreground.css;
- }
-
- if (e.y1 === e.y2) {
- // Single line link
- this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
- } else {
- // Multi-line link
- this._fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
- for (let y = e.y1 + 1; y < e.y2; y++) {
- this._fillBottomLineAtCells(0, y, e.cols);
- }
- this._fillBottomLineAtCells(0, e.y2, e.x2);
- }
- this._state = e;
- }
-
- private _onHideLinkUnderline(e: ILinkifierEvent): void {
- this._clearCurrentLink();
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/Renderer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/Renderer.ts
deleted file mode 100644
index d5de40db..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/Renderer.ts
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { TextRenderLayer } from 'browser/renderer/TextRenderLayer';
-import { SelectionRenderLayer } from 'browser/renderer/SelectionRenderLayer';
-import { CursorRenderLayer } from 'browser/renderer/CursorRenderLayer';
-import { IRenderLayer, IRenderer, IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types';
-import { LinkRenderLayer } from 'browser/renderer/LinkRenderLayer';
-import { Disposable } from 'common/Lifecycle';
-import { IColorSet, ILinkifier, ILinkifier2 } from 'browser/Types';
-import { ICharSizeService, ICoreBrowserService } from 'browser/services/Services';
-import { IBufferService, IOptionsService, ICoreService, IInstantiationService } from 'common/services/Services';
-import { removeTerminalFromCache } from 'browser/renderer/atlas/CharAtlasCache';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-
-let nextRendererId = 1;
-
-export class Renderer extends Disposable implements IRenderer {
- private _id = nextRendererId++;
-
- private _renderLayers: IRenderLayer[];
- private _devicePixelRatio: number;
-
- public dimensions: IRenderDimensions;
-
- private _onRequestRedraw = new EventEmitter();
- public get onRequestRedraw(): IEvent { return this._onRequestRedraw.event; }
-
- constructor(
- private _colors: IColorSet,
- private readonly _screenElement: HTMLElement,
- linkifier: ILinkifier,
- linkifier2: ILinkifier2,
- @IInstantiationService instantiationService: IInstantiationService,
- @IBufferService private readonly _bufferService: IBufferService,
- @ICharSizeService private readonly _charSizeService: ICharSizeService,
- @IOptionsService private readonly _optionsService: IOptionsService
- ) {
- super();
- const allowTransparency = this._optionsService.options.allowTransparency;
- this._renderLayers = [
- instantiationService.createInstance(TextRenderLayer, this._screenElement, 0, this._colors, allowTransparency, this._id),
- instantiationService.createInstance(SelectionRenderLayer, this._screenElement, 1, this._colors, this._id),
- instantiationService.createInstance(LinkRenderLayer, this._screenElement, 2, this._colors, this._id, linkifier, linkifier2),
- instantiationService.createInstance(CursorRenderLayer, this._screenElement, 3, this._colors, this._id, this._onRequestRedraw)
- ];
- this.dimensions = {
- scaledCharWidth: 0,
- scaledCharHeight: 0,
- scaledCellWidth: 0,
- scaledCellHeight: 0,
- scaledCharLeft: 0,
- scaledCharTop: 0,
- scaledCanvasWidth: 0,
- scaledCanvasHeight: 0,
- canvasWidth: 0,
- canvasHeight: 0,
- actualCellWidth: 0,
- actualCellHeight: 0
- };
- this._devicePixelRatio = window.devicePixelRatio;
- this._updateDimensions();
- this.onOptionsChanged();
- }
-
- public dispose(): void {
- for (const l of this._renderLayers) {
- l.dispose();
- }
- super.dispose();
- removeTerminalFromCache(this._id);
- }
-
- public onDevicePixelRatioChange(): void {
- // If the device pixel ratio changed, the char atlas needs to be regenerated
- // and the terminal needs to refreshed
- if (this._devicePixelRatio !== window.devicePixelRatio) {
- this._devicePixelRatio = window.devicePixelRatio;
- this.onResize(this._bufferService.cols, this._bufferService.rows);
- }
- }
-
- public setColors(colors: IColorSet): void {
- this._colors = colors;
- // Clear layers and force a full render
- for (const l of this._renderLayers) {
- l.setColors(this._colors);
- l.reset();
- }
- }
-
- public onResize(cols: number, rows: number): void {
- // Update character and canvas dimensions
- this._updateDimensions();
-
- // Resize all render layers
- for (const l of this._renderLayers) {
- l.resize(this.dimensions);
- }
-
- // Resize the screen
- this._screenElement.style.width = `${this.dimensions.canvasWidth}px`;
- this._screenElement.style.height = `${this.dimensions.canvasHeight}px`;
- }
-
- public onCharSizeChanged(): void {
- this.onResize(this._bufferService.cols, this._bufferService.rows);
- }
-
- public onBlur(): void {
- this._runOperation(l => l.onBlur());
- }
-
- public onFocus(): void {
- this._runOperation(l => l.onFocus());
- }
-
- public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {
- this._runOperation(l => l.onSelectionChanged(start, end, columnSelectMode));
- }
-
- public onCursorMove(): void {
- this._runOperation(l => l.onCursorMove());
- }
-
- public onOptionsChanged(): void {
- this._runOperation(l => l.onOptionsChanged());
- }
-
- public clear(): void {
- this._runOperation(l => l.reset());
- }
-
- private _runOperation(operation: (layer: IRenderLayer) => void): void {
- for (const l of this._renderLayers) {
- operation(l);
- }
- }
-
- /**
- * Performs the refresh loop callback, calling refresh only if a refresh is
- * necessary before queueing up the next one.
- */
- public renderRows(start: number, end: number): void {
- for (const l of this._renderLayers) {
- l.onGridChanged(start, end);
- }
- }
-
- /**
- * Recalculates the character and canvas dimensions.
- */
- private _updateDimensions(): void {
- if (!this._charSizeService.hasValidSize) {
- return;
- }
-
- // Calculate the scaled character width. Width is floored as it must be
- // drawn to an integer grid in order for the CharAtlas "stamps" to not be
- // blurry. When text is drawn to the grid not using the CharAtlas, it is
- // clipped to ensure there is no overlap with the next cell.
- this.dimensions.scaledCharWidth = Math.floor(this._charSizeService.width * window.devicePixelRatio);
-
- // Calculate the scaled character height. Height is ceiled in case
- // devicePixelRatio is a floating point number in order to ensure there is
- // enough space to draw the character to the cell.
- this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * window.devicePixelRatio);
-
- // Calculate the scaled cell height, if lineHeight is not 1 then the value
- // will be floored because since lineHeight can never be lower then 1, there
- // is a guarentee that the scaled line height will always be larger than
- // scaled char height.
- this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.options.lineHeight);
-
- // Calculate the y coordinate within a cell that text should draw from in
- // order to draw in the center of a cell.
- this.dimensions.scaledCharTop = this._optionsService.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);
-
- // Calculate the scaled cell width, taking the letterSpacing into account.
- this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.options.letterSpacing);
-
- // Calculate the x coordinate with a cell that text should draw from in
- // order to draw in the center of a cell.
- this.dimensions.scaledCharLeft = Math.floor(this._optionsService.options.letterSpacing / 2);
-
- // Recalculate the canvas dimensions; scaled* define the actual number of
- // pixel in the canvas
- this.dimensions.scaledCanvasHeight = this._bufferService.rows * this.dimensions.scaledCellHeight;
- this.dimensions.scaledCanvasWidth = this._bufferService.cols * this.dimensions.scaledCellWidth;
-
- // The the size of the canvas on the page. It's very important that this
- // rounds to nearest integer and not ceils as browsers often set
- // window.devicePixelRatio as something like 1.100000023841858, when it's
- // actually 1.1. Ceiling causes blurriness as the backing canvas image is 1
- // pixel too large for the canvas element size.
- this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
- this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
-
- // Get the _actual_ dimensions of an individual cell. This needs to be
- // derived from the canvasWidth/Height calculated above which takes into
- // account window.devicePixelRatio. ICharSizeService.width/height by itself
- // is insufficient when the page is not at 100% zoom level as it's measured
- // in CSS pixels, but the actual char size on the canvas can differ.
- this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows;
- this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/RendererUtils.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/RendererUtils.ts
deleted file mode 100644
index 48fd26a4..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/RendererUtils.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-export function throwIfFalsy(value: T | undefined | null): T {
- if (!value) {
- throw new Error('value must not be falsy');
- }
- return value;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/SelectionRenderLayer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/SelectionRenderLayer.ts
deleted file mode 100644
index 9054e3ca..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/SelectionRenderLayer.ts
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderDimensions } from 'browser/renderer/Types';
-import { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer';
-import { IColorSet } from 'browser/Types';
-import { IBufferService, IOptionsService } from 'common/services/Services';
-
-interface ISelectionState {
- start?: [number, number];
- end?: [number, number];
- columnSelectMode?: boolean;
- ydisp?: number;
-}
-
-export class SelectionRenderLayer extends BaseRenderLayer {
- private _state!: ISelectionState;
-
- constructor(
- container: HTMLElement,
- zIndex: number,
- colors: IColorSet,
- rendererId: number,
- @IBufferService bufferService: IBufferService,
- @IOptionsService optionsService: IOptionsService
- ) {
- super(container, 'selection', zIndex, true, colors, rendererId, bufferService, optionsService);
- this._clearState();
- }
-
- private _clearState(): void {
- this._state = {
- start: undefined,
- end: undefined,
- columnSelectMode: undefined,
- ydisp: undefined
- };
- }
-
- public resize(dim: IRenderDimensions): void {
- super.resize(dim);
- // Resizing the canvas discards the contents of the canvas so clear state
- this._clearState();
- }
-
- public reset(): void {
- if (this._state.start && this._state.end) {
- this._clearState();
- this._clearAll();
- }
- }
-
- public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
- // Selection has not changed
- if (!this._didStateChange(start, end, columnSelectMode, this._bufferService.buffer.ydisp)) {
- return;
- }
-
- // Remove all selections
- this._clearAll();
-
- // Selection does not exist
- if (!start || !end) {
- this._clearState();
- return;
- }
-
- // Translate from buffer position to viewport position
- const viewportStartRow = start[1] - this._bufferService.buffer.ydisp;
- const viewportEndRow = end[1] - this._bufferService.buffer.ydisp;
- const viewportCappedStartRow = Math.max(viewportStartRow, 0);
- const viewportCappedEndRow = Math.min(viewportEndRow, this._bufferService.rows - 1);
-
- // No need to draw the selection
- if (viewportCappedStartRow >= this._bufferService.rows || viewportCappedEndRow < 0) {
- this._state.ydisp = this._bufferService.buffer.ydisp;
- return;
- }
-
- this._ctx.fillStyle = this._colors.selectionTransparent.css;
-
- if (columnSelectMode) {
- const startCol = start[0];
- const width = end[0] - startCol;
- const height = viewportCappedEndRow - viewportCappedStartRow + 1;
- this._fillCells(startCol, viewportCappedStartRow, width, height);
- } else {
- // Draw first row
- const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
- const startRowEndCol = viewportCappedStartRow === viewportEndRow ? end[0] : this._bufferService.cols;
- this._fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);
-
- // Draw middle rows
- const middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);
- this._fillCells(0, viewportCappedStartRow + 1, this._bufferService.cols, middleRowsCount);
-
- // Draw final row
- if (viewportCappedStartRow !== viewportCappedEndRow) {
- // Only draw viewportEndRow if it's not the same as viewportStartRow
- const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;
- this._fillCells(0, viewportCappedEndRow, endCol, 1);
- }
- }
-
- // Save state for next render
- this._state.start = [start[0], start[1]];
- this._state.end = [end[0], end[1]];
- this._state.columnSelectMode = columnSelectMode;
- this._state.ydisp = this._bufferService.buffer.ydisp;
- }
-
- private _didStateChange(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean, ydisp: number): boolean {
- return !this._areCoordinatesEqual(start, this._state.start) ||
- !this._areCoordinatesEqual(end, this._state.end) ||
- columnSelectMode !== this._state.columnSelectMode ||
- ydisp !== this._state.ydisp;
- }
-
- private _areCoordinatesEqual(coord1: [number, number] | undefined, coord2: [number, number] | undefined): boolean {
- if (!coord1 || !coord2) {
- return false;
- }
-
- return coord1[0] === coord2[0] && coord1[1] === coord2[1];
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/TextRenderLayer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/TextRenderLayer.ts
deleted file mode 100644
index 59fbb7b1..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/TextRenderLayer.ts
+++ /dev/null
@@ -1,330 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderDimensions } from 'browser/renderer/Types';
-import { CharData, ICellData } from 'common/Types';
-import { GridCache } from 'browser/renderer/GridCache';
-import { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer';
-import { AttributeData } from 'common/buffer/AttributeData';
-import { NULL_CELL_CODE, Content } from 'common/buffer/Constants';
-import { IColorSet } from 'browser/Types';
-import { CellData } from 'common/buffer/CellData';
-import { IOptionsService, IBufferService } from 'common/services/Services';
-import { ICharacterJoinerService } from 'browser/services/Services';
-import { JoinedCellData } from 'browser/services/CharacterJoinerService';
-
-/**
- * This CharData looks like a null character, which will forc a clear and render
- * when the character changes (a regular space ' ' character may not as it's
- * drawn state is a cleared cell).
- */
-// const OVERLAP_OWNED_CHAR_DATA: CharData = [null, '', 0, -1];
-
-export class TextRenderLayer extends BaseRenderLayer {
- private _state: GridCache;
- private _characterWidth: number = 0;
- private _characterFont: string = '';
- private _characterOverlapCache: { [key: string]: boolean } = {};
- private _workCell = new CellData();
-
- constructor(
- container: HTMLElement,
- zIndex: number,
- colors: IColorSet,
- alpha: boolean,
- rendererId: number,
- @IBufferService bufferService: IBufferService,
- @IOptionsService optionsService: IOptionsService,
- @ICharacterJoinerService private readonly _characterJoinerService: ICharacterJoinerService
- ) {
- super(container, 'text', zIndex, alpha, colors, rendererId, bufferService, optionsService);
- this._state = new GridCache();
- }
-
- public resize(dim: IRenderDimensions): void {
- super.resize(dim);
-
- // Clear the character width cache if the font or width has changed
- const terminalFont = this._getFont(false, false);
- if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {
- this._characterWidth = dim.scaledCharWidth;
- this._characterFont = terminalFont;
- this._characterOverlapCache = {};
- }
- // Resizing the canvas discards the contents of the canvas so clear state
- this._state.clear();
- this._state.resize(this._bufferService.cols, this._bufferService.rows);
- }
-
- public reset(): void {
- this._state.clear();
- this._clearAll();
- }
-
- private _forEachCell(
- firstRow: number,
- lastRow: number,
- callback: (
- cell: ICellData,
- x: number,
- y: number
- ) => void
- ): void {
- for (let y = firstRow; y <= lastRow; y++) {
- const row = y + this._bufferService.buffer.ydisp;
- const line = this._bufferService.buffer.lines.get(row);
- const joinedRanges = this._characterJoinerService.getJoinedCharacters(row);
- for (let x = 0; x < this._bufferService.cols; x++) {
- line!.loadCell(x, this._workCell);
- let cell = this._workCell;
-
- // If true, indicates that the current character(s) to draw were joined.
- let isJoined = false;
- let lastCharX = x;
-
- // The character to the left is a wide character, drawing is owned by
- // the char at x-1
- if (cell.getWidth() === 0) {
- continue;
- }
-
- // Process any joined character ranges as needed. Because of how the
- // ranges are produced, we know that they are valid for the characters
- // and attributes of our input.
- if (joinedRanges.length > 0 && x === joinedRanges[0][0]) {
- isJoined = true;
- const range = joinedRanges.shift()!;
-
- // We already know the exact start and end column of the joined range,
- // so we get the string and width representing it directly
- cell = new JoinedCellData(
- this._workCell,
- line!.translateToString(true, range[0], range[1]),
- range[1] - range[0]
- );
-
- // Skip over the cells occupied by this range in the loop
- lastCharX = range[1] - 1;
- }
-
- // If the character is an overlapping char and the character to the
- // right is a space, take ownership of the cell to the right. We skip
- // this check for joined characters because their rendering likely won't
- // yield the same result as rendering the last character individually.
- if (!isJoined && this._isOverlapping(cell)) {
- // If the character is overlapping, we want to force a re-render on every
- // frame. This is specifically to work around the case where two
- // overlaping chars `a` and `b` are adjacent, the cursor is moved to b and a
- // space is added. Without this, the first half of `b` would never
- // get removed, and `a` would not re-render because it thinks it's
- // already in the correct state.
- // this._state.cache[x][y] = OVERLAP_OWNED_CHAR_DATA;
- if (lastCharX < line!.length - 1 && line!.getCodePoint(lastCharX + 1) === NULL_CELL_CODE) {
- // patch width to 2
- cell.content &= ~Content.WIDTH_MASK;
- cell.content |= 2 << Content.WIDTH_SHIFT;
- // this._clearChar(x + 1, y);
- // The overlapping char's char data will force a clear and render when the
- // overlapping char is no longer to the left of the character and also when
- // the space changes to another character.
- // this._state.cache[x + 1][y] = OVERLAP_OWNED_CHAR_DATA;
- }
- }
-
- callback(
- cell,
- x,
- y
- );
-
- x = lastCharX;
- }
- }
- }
-
- /**
- * Draws the background for a specified range of columns. Tries to batch adjacent cells of the
- * same color together to reduce draw calls.
- */
- private _drawBackground(firstRow: number, lastRow: number): void {
- const ctx = this._ctx;
- const cols = this._bufferService.cols;
- let startX: number = 0;
- let startY: number = 0;
- let prevFillStyle: string | null = null;
-
- ctx.save();
-
- this._forEachCell(firstRow, lastRow, (cell, x, y) => {
- // libvte and xterm both draw the background (but not foreground) of invisible characters,
- // so we should too.
- let nextFillStyle = null; // null represents default background color
-
- if (cell.isInverse()) {
- if (cell.isFgDefault()) {
- nextFillStyle = this._colors.foreground.css;
- } else if (cell.isFgRGB()) {
- nextFillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
- } else {
- nextFillStyle = this._colors.ansi[cell.getFgColor()].css;
- }
- } else if (cell.isBgRGB()) {
- nextFillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;
- } else if (cell.isBgPalette()) {
- nextFillStyle = this._colors.ansi[cell.getBgColor()].css;
- }
-
- if (prevFillStyle === null) {
- // This is either the first iteration, or the default background was set. Either way, we
- // don't need to draw anything.
- startX = x;
- startY = y;
- }
-
- if (y !== startY) {
- // our row changed, draw the previous row
- ctx.fillStyle = prevFillStyle || '';
- this._fillCells(startX, startY, cols - startX, 1);
- startX = x;
- startY = y;
- } else if (prevFillStyle !== nextFillStyle) {
- // our color changed, draw the previous characters in this row
- ctx.fillStyle = prevFillStyle || '';
- this._fillCells(startX, startY, x - startX, 1);
- startX = x;
- startY = y;
- }
-
- prevFillStyle = nextFillStyle;
- });
-
- // flush the last color we encountered
- if (prevFillStyle !== null) {
- ctx.fillStyle = prevFillStyle;
- this._fillCells(startX, startY, cols - startX, 1);
- }
-
- ctx.restore();
- }
-
- private _drawForeground(firstRow: number, lastRow: number): void {
- this._forEachCell(firstRow, lastRow, (cell, x, y) => {
- if (cell.isInvisible()) {
- return;
- }
- this._drawChars(cell, x, y);
- if (cell.isUnderline() || cell.isStrikethrough()) {
- this._ctx.save();
-
- if (cell.isInverse()) {
- if (cell.isBgDefault()) {
- this._ctx.fillStyle = this._colors.background.css;
- } else if (cell.isBgRGB()) {
- this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;
- } else {
- let bg = cell.getBgColor();
- if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && bg < 8) {
- bg += 8;
- }
- this._ctx.fillStyle = this._colors.ansi[bg].css;
- }
- } else {
- if (cell.isFgDefault()) {
- this._ctx.fillStyle = this._colors.foreground.css;
- } else if (cell.isFgRGB()) {
- this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
- } else {
- let fg = cell.getFgColor();
- if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
- fg += 8;
- }
- this._ctx.fillStyle = this._colors.ansi[fg].css;
- }
- }
-
- if (cell.isStrikethrough()) {
- this._fillMiddleLineAtCells(x, y, cell.getWidth());
- }
- if (cell.isUnderline()) {
- this._fillBottomLineAtCells(x, y, cell.getWidth());
- }
- this._ctx.restore();
- }
- });
- }
-
- public onGridChanged(firstRow: number, lastRow: number): void {
- // Resize has not been called yet
- if (this._state.cache.length === 0) {
- return;
- }
-
- if (this._charAtlas) {
- this._charAtlas.beginFrame();
- }
-
- this._clearCells(0, firstRow, this._bufferService.cols, lastRow - firstRow + 1);
- this._drawBackground(firstRow, lastRow);
- this._drawForeground(firstRow, lastRow);
- }
-
- public onOptionsChanged(): void {
- this._setTransparency(this._optionsService.options.allowTransparency);
- }
-
- /**
- * Whether a character is overlapping to the next cell.
- */
- private _isOverlapping(cell: ICellData): boolean {
- // Only single cell characters can be overlapping, rendering issues can
- // occur without this check
- if (cell.getWidth() !== 1) {
- return false;
- }
-
- // We assume that any ascii character will not overlap
- if (cell.getCode() < 256) {
- return false;
- }
-
- const chars = cell.getChars();
-
- // Deliver from cache if available
- if (this._characterOverlapCache.hasOwnProperty(chars)) {
- return this._characterOverlapCache[chars];
- }
-
- // Setup the font
- this._ctx.save();
- this._ctx.font = this._characterFont;
-
- // Measure the width of the character, but Math.floor it
- // because that is what the renderer does when it calculates
- // the character dimensions we are comparing against
- const overlaps = Math.floor(this._ctx.measureText(chars).width) > this._characterWidth;
-
- // Restore the original context
- this._ctx.restore();
-
- // Cache and return
- this._characterOverlapCache[chars] = overlaps;
- return overlaps;
- }
-
- /**
- * Clear the charcater at the cell specified.
- * @param x The column of the char.
- * @param y The row of the char.
- */
- // private _clearChar(x: number, y: number): void {
- // let colsToClear = 1;
- // // Clear the adjacent character if it was wide
- // const state = this._state.cache[x][y];
- // if (state && state[CHAR_DATA_WIDTH_INDEX] === 2) {
- // colsToClear = 2;
- // }
- // this.clearCells(x, y, colsToClear, 1);
- // }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/Types.d.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/Types.d.ts
deleted file mode 100644
index fc137bc8..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/Types.d.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IDisposable } from 'common/Types';
-import { IColorSet } from 'browser/Types';
-import { IEvent } from 'common/EventEmitter';
-
-export interface IRenderDimensions {
- scaledCharWidth: number;
- scaledCharHeight: number;
- scaledCellWidth: number;
- scaledCellHeight: number;
- scaledCharLeft: number;
- scaledCharTop: number;
- scaledCanvasWidth: number;
- scaledCanvasHeight: number;
- canvasWidth: number;
- canvasHeight: number;
- actualCellWidth: number;
- actualCellHeight: number;
-}
-
-export interface IRequestRedrawEvent {
- start: number;
- end: number;
-}
-
-/**
- * Note that IRenderer implementations should emit the refresh event after
- * rendering rows to the screen.
- */
-export interface IRenderer extends IDisposable {
- readonly dimensions: IRenderDimensions;
-
- /**
- * Fires when the renderer is requesting to be redrawn on the next animation
- * frame but is _not_ a result of content changing (eg. selection changes).
- */
- readonly onRequestRedraw: IEvent;
-
- dispose(): void;
- setColors(colors: IColorSet): void;
- onDevicePixelRatioChange(): void;
- onResize(cols: number, rows: number): void;
- onCharSizeChanged(): void;
- onBlur(): void;
- onFocus(): void;
- onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
- onCursorMove(): void;
- onOptionsChanged(): void;
- clear(): void;
- renderRows(start: number, end: number): void;
-}
-
-export interface IRenderLayer extends IDisposable {
- /**
- * Called when the terminal loses focus.
- */
- onBlur(): void;
-
- /**
- * * Called when the terminal gets focus.
- */
- onFocus(): void;
-
- /**
- * Called when the cursor is moved.
- */
- onCursorMove(): void;
-
- /**
- * Called when options change.
- */
- onOptionsChanged(): void;
-
- /**
- * Called when the theme changes.
- */
- setColors(colorSet: IColorSet): void;
-
- /**
- * Called when the data in the grid has changed (or needs to be rendered
- * again).
- */
- onGridChanged(startRow: number, endRow: number): void;
-
- /**
- * Calls when the selection changes.
- */
- onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
-
- /**
- * Resize the render layer.
- */
- resize(dim: IRenderDimensions): void;
-
- /**
- * Clear the state of the render layer.
- */
- reset(): void;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/BaseCharAtlas.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/BaseCharAtlas.ts
deleted file mode 100644
index 4ebaaa47..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/BaseCharAtlas.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IGlyphIdentifier } from 'browser/renderer/atlas/Types';
-import { IDisposable } from 'common/Types';
-
-export abstract class BaseCharAtlas implements IDisposable {
- private _didWarmUp: boolean = false;
-
- public dispose(): void { }
-
- /**
- * Perform any work needed to warm the cache before it can be used. May be called multiple times.
- * Implement _doWarmUp instead if you only want to get called once.
- */
- public warmUp(): void {
- if (!this._didWarmUp) {
- this._doWarmUp();
- this._didWarmUp = true;
- }
- }
-
- /**
- * Perform any work needed to warm the cache before it can be used. Used by the default
- * implementation of warmUp(), and will only be called once.
- */
- private _doWarmUp(): void { }
-
- /**
- * Called when we start drawing a new frame.
- *
- * TODO: We rely on this getting called by TextRenderLayer. This should really be called by
- * Renderer instead, but we need to make Renderer the source-of-truth for the char atlas, instead
- * of BaseRenderLayer.
- */
- public beginFrame(): void { }
-
- /**
- * May be called before warmUp finishes, however it is okay for the implementation to
- * do nothing and return false in that case.
- *
- * @param ctx Where to draw the character onto.
- * @param glyph Information about what to draw
- * @param x The position on the context to start drawing at
- * @param y The position on the context to start drawing at
- * @returns The success state. True if we drew the character.
- */
- public abstract draw(
- ctx: CanvasRenderingContext2D,
- glyph: IGlyphIdentifier,
- x: number,
- y: number
- ): boolean;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/CharAtlasCache.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/CharAtlasCache.ts
deleted file mode 100644
index 257835ba..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/CharAtlasCache.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { generateConfig, configEquals } from 'browser/renderer/atlas/CharAtlasUtils';
-import { BaseCharAtlas } from 'browser/renderer/atlas/BaseCharAtlas';
-import { DynamicCharAtlas } from 'browser/renderer/atlas/DynamicCharAtlas';
-import { ICharAtlasConfig } from 'browser/renderer/atlas/Types';
-import { IColorSet } from 'browser/Types';
-import { ITerminalOptions } from 'common/services/Services';
-
-interface ICharAtlasCacheEntry {
- atlas: BaseCharAtlas;
- config: ICharAtlasConfig;
- // N.B. This implementation potentially holds onto copies of the terminal forever, so
- // this may cause memory leaks.
- ownedBy: number[];
-}
-
-const charAtlasCache: ICharAtlasCacheEntry[] = [];
-
-/**
- * Acquires a char atlas, either generating a new one or returning an existing
- * one that is in use by another terminal.
- */
-export function acquireCharAtlas(
- options: ITerminalOptions,
- rendererId: number,
- colors: IColorSet,
- scaledCharWidth: number,
- scaledCharHeight: number
-): BaseCharAtlas {
- const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, options, colors);
-
- // Check to see if the renderer already owns this config
- for (let i = 0; i < charAtlasCache.length; i++) {
- const entry = charAtlasCache[i];
- const ownedByIndex = entry.ownedBy.indexOf(rendererId);
- if (ownedByIndex >= 0) {
- if (configEquals(entry.config, newConfig)) {
- return entry.atlas;
- }
- // The configs differ, release the renderer from the entry
- if (entry.ownedBy.length === 1) {
- entry.atlas.dispose();
- charAtlasCache.splice(i, 1);
- } else {
- entry.ownedBy.splice(ownedByIndex, 1);
- }
- break;
- }
- }
-
- // Try match a char atlas from the cache
- for (let i = 0; i < charAtlasCache.length; i++) {
- const entry = charAtlasCache[i];
- if (configEquals(entry.config, newConfig)) {
- // Add the renderer to the cache entry and return
- entry.ownedBy.push(rendererId);
- return entry.atlas;
- }
- }
-
- const newEntry: ICharAtlasCacheEntry = {
- atlas: new DynamicCharAtlas(
- document,
- newConfig
- ),
- config: newConfig,
- ownedBy: [rendererId]
- };
- charAtlasCache.push(newEntry);
- return newEntry.atlas;
-}
-
-/**
- * Removes a terminal reference from the cache, allowing its memory to be freed.
- */
-export function removeTerminalFromCache(rendererId: number): void {
- for (let i = 0; i < charAtlasCache.length; i++) {
- const index = charAtlasCache[i].ownedBy.indexOf(rendererId);
- if (index !== -1) {
- if (charAtlasCache[i].ownedBy.length === 1) {
- // Remove the cache entry if it's the only renderer
- charAtlasCache[i].atlas.dispose();
- charAtlasCache.splice(i, 1);
- } else {
- // Remove the reference from the cache entry
- charAtlasCache[i].ownedBy.splice(index, 1);
- }
- break;
- }
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/CharAtlasUtils.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/CharAtlasUtils.ts
deleted file mode 100644
index b196b373..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/CharAtlasUtils.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ICharAtlasConfig } from 'browser/renderer/atlas/Types';
-import { DEFAULT_COLOR } from 'common/buffer/Constants';
-import { IColorSet, IPartialColorSet } from 'browser/Types';
-import { ITerminalOptions } from 'common/services/Services';
-
-export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, options: ITerminalOptions, colors: IColorSet): ICharAtlasConfig {
- // null out some fields that don't matter
- const clonedColors: IPartialColorSet = {
- foreground: colors.foreground,
- background: colors.background,
- cursor: undefined,
- cursorAccent: undefined,
- selection: undefined,
- ansi: colors.ansi
- };
- return {
- devicePixelRatio: window.devicePixelRatio,
- scaledCharWidth,
- scaledCharHeight,
- fontFamily: options.fontFamily,
- fontSize: options.fontSize,
- fontWeight: options.fontWeight,
- fontWeightBold: options.fontWeightBold,
- allowTransparency: options.allowTransparency,
- colors: clonedColors
- };
-}
-
-export function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean {
- for (let i = 0; i < a.colors.ansi.length; i++) {
- if (a.colors.ansi[i].rgba !== b.colors.ansi[i].rgba) {
- return false;
- }
- }
- return a.devicePixelRatio === b.devicePixelRatio &&
- a.fontFamily === b.fontFamily &&
- a.fontSize === b.fontSize &&
- a.fontWeight === b.fontWeight &&
- a.fontWeightBold === b.fontWeightBold &&
- a.allowTransparency === b.allowTransparency &&
- a.scaledCharWidth === b.scaledCharWidth &&
- a.scaledCharHeight === b.scaledCharHeight &&
- a.colors.foreground === b.colors.foreground &&
- a.colors.background === b.colors.background;
-}
-
-export function is256Color(colorCode: number): boolean {
- return colorCode < DEFAULT_COLOR;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/Constants.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/Constants.ts
deleted file mode 100644
index 150aad88..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/Constants.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-export const INVERTED_DEFAULT_COLOR = 257;
-export const DIM_OPACITY = 0.5;
-
-export const CHAR_ATLAS_CELL_SPACING = 1;
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/DynamicCharAtlas.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/DynamicCharAtlas.ts
deleted file mode 100644
index a7237878..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/DynamicCharAtlas.ts
+++ /dev/null
@@ -1,394 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
-import { IGlyphIdentifier, ICharAtlasConfig } from 'browser/renderer/atlas/Types';
-import { BaseCharAtlas } from 'browser/renderer/atlas/BaseCharAtlas';
-import { DEFAULT_ANSI_COLORS } from 'browser/ColorManager';
-import { LRUMap } from 'browser/renderer/atlas/LRUMap';
-import { isFirefox, isSafari } from 'common/Platform';
-import { IColor } from 'browser/Types';
-import { throwIfFalsy } from 'browser/renderer/RendererUtils';
-import { color } from 'browser/Color';
-
-// In practice we're probably never going to exhaust a texture this large. For debugging purposes,
-// however, it can be useful to set this to a really tiny value, to verify that LRU eviction works.
-const TEXTURE_WIDTH = 1024;
-const TEXTURE_HEIGHT = 1024;
-
-const TRANSPARENT_COLOR = {
- css: 'rgba(0, 0, 0, 0)',
- rgba: 0
-};
-
-// Drawing to the cache is expensive: If we have to draw more than this number of glyphs to the
-// cache in a single frame, give up on trying to cache anything else, and try to finish the current
-// frame ASAP.
-//
-// This helps to limit the amount of damage a program can do when it would otherwise thrash the
-// cache.
-const FRAME_CACHE_DRAW_LIMIT = 100;
-
-/**
- * The number of milliseconds to wait before generating the ImageBitmap, this is to debounce/batch
- * the operation as window.createImageBitmap is asynchronous.
- */
-const GLYPH_BITMAP_COMMIT_DELAY = 100;
-
-interface IGlyphCacheValue {
- index: number;
- isEmpty: boolean;
- inBitmap: boolean;
-}
-
-export function getGlyphCacheKey(glyph: IGlyphIdentifier): number {
- // Note that this only returns a valid key when code < 256
- // Layout:
- // 0b00000000000000000000000000000001: italic (1)
- // 0b00000000000000000000000000000010: dim (1)
- // 0b00000000000000000000000000000100: bold (1)
- // 0b00000000000000000000111111111000: fg (9)
- // 0b00000000000111111111000000000000: bg (9)
- // 0b00011111111000000000000000000000: code (8)
- // 0b11100000000000000000000000000000: unused (3)
- return glyph.code << 21 | glyph.bg << 12 | glyph.fg << 3 | (glyph.bold ? 0 : 4) + (glyph.dim ? 0 : 2) + (glyph.italic ? 0 : 1);
-}
-
-export class DynamicCharAtlas extends BaseCharAtlas {
- // An ordered map that we're using to keep track of where each glyph is in the atlas texture.
- // It's ordered so that we can determine when to remove the old entries.
- private _cacheMap: LRUMap;
-
- // The texture that the atlas is drawn to
- private _cacheCanvas: HTMLCanvasElement;
- private _cacheCtx: CanvasRenderingContext2D;
-
- // A temporary context that glyphs are drawn to before being transfered to the atlas.
- private _tmpCtx: CanvasRenderingContext2D;
-
- // The number of characters stored in the atlas by width/height
- private _width: number;
- private _height: number;
-
- private _drawToCacheCount: number = 0;
-
- // An array of glyph keys that are waiting on the bitmap to be generated.
- private _glyphsWaitingOnBitmap: IGlyphCacheValue[] = [];
-
- // The timeout that is used to batch bitmap generation so it's not requested for every new glyph.
- private _bitmapCommitTimeout: number | null = null;
-
- // The bitmap to draw from, this is much faster on other browsers than others.
- private _bitmap: ImageBitmap | null = null;
-
- constructor(document: Document, private _config: ICharAtlasConfig) {
- super();
- this._cacheCanvas = document.createElement('canvas');
- this._cacheCanvas.width = TEXTURE_WIDTH;
- this._cacheCanvas.height = TEXTURE_HEIGHT;
- // The canvas needs alpha because we use clearColor to convert the background color to alpha.
- // It might also contain some characters with transparent backgrounds if allowTransparency is
- // set.
- this._cacheCtx = throwIfFalsy(this._cacheCanvas.getContext('2d', { alpha: true }));
-
- const tmpCanvas = document.createElement('canvas');
- tmpCanvas.width = this._config.scaledCharWidth;
- tmpCanvas.height = this._config.scaledCharHeight;
- this._tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d', { alpha: this._config.allowTransparency }));
-
- this._width = Math.floor(TEXTURE_WIDTH / this._config.scaledCharWidth);
- this._height = Math.floor(TEXTURE_HEIGHT / this._config.scaledCharHeight);
- const capacity = this._width * this._height;
- this._cacheMap = new LRUMap(capacity);
- this._cacheMap.prealloc(capacity);
-
- // This is useful for debugging
- // document.body.appendChild(this._cacheCanvas);
- }
-
- public dispose(): void {
- if (this._bitmapCommitTimeout !== null) {
- window.clearTimeout(this._bitmapCommitTimeout);
- this._bitmapCommitTimeout = null;
- }
- }
-
- public beginFrame(): void {
- this._drawToCacheCount = 0;
- }
-
- public draw(
- ctx: CanvasRenderingContext2D,
- glyph: IGlyphIdentifier,
- x: number,
- y: number
- ): boolean {
- // Space is always an empty cell, special case this as it's so common
- if (glyph.code === 32) {
- return true;
- }
-
- // Exit early for uncachable glyphs
- if (!this._canCache(glyph)) {
- return false;
- }
-
- const glyphKey = getGlyphCacheKey(glyph);
- const cacheValue = this._cacheMap.get(glyphKey);
- if (cacheValue !== null && cacheValue !== undefined) {
- this._drawFromCache(ctx, cacheValue, x, y);
- return true;
- }
- if (this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {
- let index;
- if (this._cacheMap.size < this._cacheMap.capacity) {
- index = this._cacheMap.size;
- } else {
- // we're out of space, so our call to set will delete this item
- index = this._cacheMap.peek()!.index;
- }
- const cacheValue = this._drawToCache(glyph, index);
- this._cacheMap.set(glyphKey, cacheValue);
- this._drawFromCache(ctx, cacheValue, x, y);
- return true;
- }
- return false;
- }
-
- private _canCache(glyph: IGlyphIdentifier): boolean {
- // Only cache ascii and extended characters for now, to be safe. In the future, we could do
- // something more complicated to determine the expected width of a character.
- //
- // If we switch the renderer over to webgl at some point, we may be able to use blending modes
- // to draw overlapping glyphs from the atlas:
- // https://github.com/servo/webrender/issues/464#issuecomment-255632875
- // https://webglfundamentals.org/webgl/lessons/webgl-text-texture.html
- return glyph.code < 256;
- }
-
- private _toCoordinateX(index: number): number {
- return (index % this._width) * this._config.scaledCharWidth;
- }
-
- private _toCoordinateY(index: number): number {
- return Math.floor(index / this._width) * this._config.scaledCharHeight;
- }
-
- private _drawFromCache(
- ctx: CanvasRenderingContext2D,
- cacheValue: IGlyphCacheValue,
- x: number,
- y: number
- ): void {
- // We don't actually need to do anything if this is whitespace.
- if (cacheValue.isEmpty) {
- return;
- }
- const cacheX = this._toCoordinateX(cacheValue.index);
- const cacheY = this._toCoordinateY(cacheValue.index);
- ctx.drawImage(
- cacheValue.inBitmap ? this._bitmap! : this._cacheCanvas,
- cacheX,
- cacheY,
- this._config.scaledCharWidth,
- this._config.scaledCharHeight,
- x,
- y,
- this._config.scaledCharWidth,
- this._config.scaledCharHeight
- );
- }
-
- private _getColorFromAnsiIndex(idx: number): IColor {
- if (idx < this._config.colors.ansi.length) {
- return this._config.colors.ansi[idx];
- }
- return DEFAULT_ANSI_COLORS[idx];
- }
-
- private _getBackgroundColor(glyph: IGlyphIdentifier): IColor {
- if (this._config.allowTransparency) {
- // The background color might have some transparency, so we need to render it as fully
- // transparent in the atlas. Otherwise we'd end up drawing the transparent background twice
- // around the anti-aliased edges of the glyph, and it would look too dark.
- return TRANSPARENT_COLOR;
- }
- if (glyph.bg === INVERTED_DEFAULT_COLOR) {
- return this._config.colors.foreground;
- }
- if (glyph.bg < 256) {
- return this._getColorFromAnsiIndex(glyph.bg);
- }
- return this._config.colors.background;
- }
-
- private _getForegroundColor(glyph: IGlyphIdentifier): IColor {
- if (glyph.fg === INVERTED_DEFAULT_COLOR) {
- return color.opaque(this._config.colors.background);
- }
- if (glyph.fg < 256) {
- // 256 color support
- return this._getColorFromAnsiIndex(glyph.fg);
- }
- return this._config.colors.foreground;
- }
-
- // TODO: We do this (or something similar) in multiple places. We should split this off
- // into a shared function.
- private _drawToCache(glyph: IGlyphIdentifier, index: number): IGlyphCacheValue {
- this._drawToCacheCount++;
-
- this._tmpCtx.save();
-
- // draw the background
- const backgroundColor = this._getBackgroundColor(glyph);
- // Use a 'copy' composite operation to clear any existing glyph out of _tmpCtxWithAlpha, regardless of
- // transparency in backgroundColor
- this._tmpCtx.globalCompositeOperation = 'copy';
- this._tmpCtx.fillStyle = backgroundColor.css;
- this._tmpCtx.fillRect(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight);
- this._tmpCtx.globalCompositeOperation = 'source-over';
-
- // draw the foreground/glyph
- const fontWeight = glyph.bold ? this._config.fontWeightBold : this._config.fontWeight;
- const fontStyle = glyph.italic ? 'italic' : '';
- this._tmpCtx.font =
- `${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`;
- this._tmpCtx.textBaseline = 'ideographic';
-
- this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css;
-
- // Apply alpha to dim the character
- if (glyph.dim) {
- this._tmpCtx.globalAlpha = DIM_OPACITY;
- }
- // Draw the character
- this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight);
-
- // clear the background from the character to avoid issues with drawing over the previous
- // character if it extends past it's bounds
- let imageData = this._tmpCtx.getImageData(
- 0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight
- );
- let isEmpty = false;
- if (!this._config.allowTransparency) {
- isEmpty = clearColor(imageData, backgroundColor);
- }
-
- // If this charcater is underscore and empty, shift it up until it is visible, try for a maximum
- // of 5 pixels.
- if (isEmpty && glyph.chars === '_' && !this._config.allowTransparency) {
- for (let offset = 1; offset <= 5; offset++) {
- // Draw the character
- this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight - offset);
-
- // clear the background from the character to avoid issues with drawing over the previous
- // character if it extends past it's bounds
- imageData = this._tmpCtx.getImageData(
- 0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight
- );
- isEmpty = clearColor(imageData, backgroundColor);
- if (!isEmpty) {
- break;
- }
- }
- }
-
- this._tmpCtx.restore();
-
- // copy the data from imageData to _cacheCanvas
- const x = this._toCoordinateX(index);
- const y = this._toCoordinateY(index);
- // putImageData doesn't do any blending, so it will overwrite any existing cache entry for us
- this._cacheCtx.putImageData(imageData, x, y);
-
- // Add the glyph and queue it to the bitmap (if the browser supports it)
- const cacheValue = {
- index,
- isEmpty,
- inBitmap: false
- };
- this._addGlyphToBitmap(cacheValue);
-
- return cacheValue;
- }
-
- private _addGlyphToBitmap(cacheValue: IGlyphCacheValue): void {
- // Support is patchy for createImageBitmap at the moment, pass a canvas back
- // if support is lacking as drawImage works there too. Firefox is also
- // included here as ImageBitmap appears both buggy and has horrible
- // performance (tested on v55).
- if (!('createImageBitmap' in window) || isFirefox || isSafari) {
- return;
- }
-
- // Add the glyph to the queue
- this._glyphsWaitingOnBitmap.push(cacheValue);
-
- // Check if bitmap generation timeout already exists
- if (this._bitmapCommitTimeout !== null) {
- return;
- }
-
- this._bitmapCommitTimeout = window.setTimeout(() => this._generateBitmap(), GLYPH_BITMAP_COMMIT_DELAY);
- }
-
- private _generateBitmap(): void {
- const glyphsMovingToBitmap = this._glyphsWaitingOnBitmap;
- this._glyphsWaitingOnBitmap = [];
- window.createImageBitmap(this._cacheCanvas).then(bitmap => {
- // Set bitmap
- this._bitmap = bitmap;
-
- // Mark all new glyphs as in bitmap, excluding glyphs that came in after
- // the bitmap was requested
- for (let i = 0; i < glyphsMovingToBitmap.length; i++) {
- const value = glyphsMovingToBitmap[i];
- // It doesn't matter if the value was already evicted, it will be
- // released from memory after this block if so.
- value.inBitmap = true;
- }
- });
- this._bitmapCommitTimeout = null;
- }
-}
-
-// This is used for debugging the renderer, just swap out `new DynamicCharAtlas` with
-// `new NoneCharAtlas`.
-export class NoneCharAtlas extends BaseCharAtlas {
- constructor(document: Document, config: ICharAtlasConfig) {
- super();
- }
-
- public draw(
- ctx: CanvasRenderingContext2D,
- glyph: IGlyphIdentifier,
- x: number,
- y: number
- ): boolean {
- return false;
- }
-}
-
-/**
- * Makes a partiicular rgb color in an ImageData completely transparent.
- * @returns True if the result is "empty", meaning all pixels are fully transparent.
- */
-function clearColor(imageData: ImageData, color: IColor): boolean {
- let isEmpty = true;
- const r = color.rgba >>> 24;
- const g = color.rgba >>> 16 & 0xFF;
- const b = color.rgba >>> 8 & 0xFF;
- for (let offset = 0; offset < imageData.data.length; offset += 4) {
- if (imageData.data[offset] === r &&
- imageData.data[offset + 1] === g &&
- imageData.data[offset + 2] === b) {
- imageData.data[offset + 3] = 0;
- } else {
- isEmpty = false;
- }
- }
- return isEmpty;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/LRUMap.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/LRUMap.ts
deleted file mode 100644
index f70962fe..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/LRUMap.ts
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-interface ILinkedListNode {
- prev: ILinkedListNode | null;
- next: ILinkedListNode | null;
- key: number | null;
- value: T | null;
-}
-
-export class LRUMap {
- private _map: { [key: number]: ILinkedListNode } = {};
- private _head: ILinkedListNode | null = null;
- private _tail: ILinkedListNode | null = null;
- private _nodePool: ILinkedListNode[] = [];
- public size: number = 0;
-
- constructor(public capacity: number) { }
-
- private _unlinkNode(node: ILinkedListNode): void {
- const prev = node.prev;
- const next = node.next;
- if (node === this._head) {
- this._head = next;
- }
- if (node === this._tail) {
- this._tail = prev;
- }
- if (prev !== null) {
- prev.next = next;
- }
- if (next !== null) {
- next.prev = prev;
- }
- }
-
- private _appendNode(node: ILinkedListNode): void {
- const tail = this._tail;
- if (tail !== null) {
- tail.next = node;
- }
- node.prev = tail;
- node.next = null;
- this._tail = node;
- if (this._head === null) {
- this._head = node;
- }
- }
-
- /**
- * Preallocate a bunch of linked-list nodes. Allocating these nodes ahead of time means that
- * they're more likely to live next to each other in memory, which seems to improve performance.
- *
- * Each empty object only consumes about 60 bytes of memory, so this is pretty cheap, even for
- * large maps.
- */
- public prealloc(count: number): void {
- const nodePool = this._nodePool;
- for (let i = 0; i < count; i++) {
- nodePool.push({
- prev: null,
- next: null,
- key: null,
- value: null
- });
- }
- }
-
- public get(key: number): T | null {
- // This is unsafe: We're assuming our keyspace doesn't overlap with Object.prototype. However,
- // it's faster than calling hasOwnProperty, and in our case, it would never overlap.
- const node = this._map[key];
- if (node !== undefined) {
- this._unlinkNode(node);
- this._appendNode(node);
- return node.value;
- }
- return null;
- }
-
- /**
- * Gets a value from a key without marking it as the most recently used item.
- */
- public peekValue(key: number): T | null {
- const node = this._map[key];
- if (node !== undefined) {
- return node.value;
- }
- return null;
- }
-
- public peek(): T | null {
- const head = this._head;
- return head === null ? null : head.value;
- }
-
- public set(key: number, value: T): void {
- // This is unsafe: See note above.
- let node = this._map[key];
- if (node !== undefined) {
- // already exists, we just need to mutate it and move it to the end of the list
- node = this._map[key];
- this._unlinkNode(node);
- node.value = value;
- } else if (this.size >= this.capacity) {
- // we're out of space: recycle the head node, move it to the tail
- node = this._head!;
- this._unlinkNode(node);
- delete this._map[node.key!];
- node.key = key;
- node.value = value;
- this._map[key] = node;
- } else {
- // make a new element
- const nodePool = this._nodePool;
- if (nodePool.length > 0) {
- // use a preallocated node if we can
- node = nodePool.pop()!;
- node.key = key;
- node.value = value;
- } else {
- node = {
- prev: null,
- next: null,
- key,
- value
- };
- }
- this._map[key] = node;
- this.size++;
- }
- this._appendNode(node);
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/Types.d.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/Types.d.ts
deleted file mode 100644
index d8bc54c1..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/atlas/Types.d.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { FontWeight } from 'common/services/Services';
-import { IPartialColorSet } from 'browser/Types';
-
-export interface IGlyphIdentifier {
- chars: string;
- code: number;
- bg: number;
- fg: number;
- bold: boolean;
- dim: boolean;
- italic: boolean;
-}
-
-export interface ICharAtlasConfig {
- devicePixelRatio: number;
- fontSize: number;
- fontFamily: string;
- fontWeight: FontWeight;
- fontWeightBold: FontWeight;
- scaledCharWidth: number;
- scaledCharHeight: number;
- allowTransparency: boolean;
- colors: IPartialColorSet;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/dom/DomRenderer.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/dom/DomRenderer.ts
deleted file mode 100644
index d08cf987..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/dom/DomRenderer.ts
+++ /dev/null
@@ -1,400 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderer, IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types';
-import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from 'browser/renderer/dom/DomRendererRowFactory';
-import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
-import { Disposable } from 'common/Lifecycle';
-import { IColorSet, ILinkifierEvent, ILinkifier, ILinkifier2 } from 'browser/Types';
-import { ICharSizeService } from 'browser/services/Services';
-import { IOptionsService, IBufferService, IInstantiationService } from 'common/services/Services';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-import { color } from 'browser/Color';
-import { removeElementFromParent } from 'browser/Dom';
-
-const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';
-const ROW_CONTAINER_CLASS = 'xterm-rows';
-const FG_CLASS_PREFIX = 'xterm-fg-';
-const BG_CLASS_PREFIX = 'xterm-bg-';
-const FOCUS_CLASS = 'xterm-focus';
-const SELECTION_CLASS = 'xterm-selection';
-
-let nextTerminalId = 1;
-
-/**
- * A fallback renderer for when canvas is slow. This is not meant to be
- * particularly fast or feature complete, more just stable and usable for when
- * canvas is not an option.
- */
-export class DomRenderer extends Disposable implements IRenderer {
- private _rowFactory: DomRendererRowFactory;
- private _terminalClass: number = nextTerminalId++;
-
- private _themeStyleElement!: HTMLStyleElement;
- private _dimensionsStyleElement!: HTMLStyleElement;
- private _rowContainer: HTMLElement;
- private _rowElements: HTMLElement[] = [];
- private _selectionContainer: HTMLElement;
-
- public dimensions: IRenderDimensions;
-
- public get onRequestRedraw(): IEvent { return new EventEmitter().event; }
-
- constructor(
- private _colors: IColorSet,
- private readonly _element: HTMLElement,
- private readonly _screenElement: HTMLElement,
- private readonly _viewportElement: HTMLElement,
- private readonly _linkifier: ILinkifier,
- private readonly _linkifier2: ILinkifier2,
- @IInstantiationService instantiationService: IInstantiationService,
- @ICharSizeService private readonly _charSizeService: ICharSizeService,
- @IOptionsService private readonly _optionsService: IOptionsService,
- @IBufferService private readonly _bufferService: IBufferService
- ) {
- super();
- this._rowContainer = document.createElement('div');
- this._rowContainer.classList.add(ROW_CONTAINER_CLASS);
- this._rowContainer.style.lineHeight = 'normal';
- this._rowContainer.setAttribute('aria-hidden', 'true');
- this._refreshRowElements(this._bufferService.cols, this._bufferService.rows);
- this._selectionContainer = document.createElement('div');
- this._selectionContainer.classList.add(SELECTION_CLASS);
- this._selectionContainer.setAttribute('aria-hidden', 'true');
-
- this.dimensions = {
- scaledCharWidth: 0,
- scaledCharHeight: 0,
- scaledCellWidth: 0,
- scaledCellHeight: 0,
- scaledCharLeft: 0,
- scaledCharTop: 0,
- scaledCanvasWidth: 0,
- scaledCanvasHeight: 0,
- canvasWidth: 0,
- canvasHeight: 0,
- actualCellWidth: 0,
- actualCellHeight: 0
- };
- this._updateDimensions();
- this._injectCss();
-
- this._rowFactory = instantiationService.createInstance(DomRendererRowFactory, document, this._colors);
-
- this._element.classList.add(TERMINAL_CLASS_PREFIX + this._terminalClass);
- this._screenElement.appendChild(this._rowContainer);
- this._screenElement.appendChild(this._selectionContainer);
-
- this._linkifier.onShowLinkUnderline(e => this._onLinkHover(e));
- this._linkifier.onHideLinkUnderline(e => this._onLinkLeave(e));
-
- this._linkifier2.onShowLinkUnderline(e => this._onLinkHover(e));
- this._linkifier2.onHideLinkUnderline(e => this._onLinkLeave(e));
- }
-
- public dispose(): void {
- this._element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);
-
- // Outside influences such as React unmounts may manipulate the DOM before our disposal.
- // https://github.com/xtermjs/xterm.js/issues/2960
- removeElementFromParent(this._rowContainer, this._selectionContainer, this._themeStyleElement, this._dimensionsStyleElement);
-
- super.dispose();
- }
-
- private _updateDimensions(): void {
- this.dimensions.scaledCharWidth = this._charSizeService.width * window.devicePixelRatio;
- this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * window.devicePixelRatio);
- this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.options.letterSpacing);
- this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.options.lineHeight);
- this.dimensions.scaledCharLeft = 0;
- this.dimensions.scaledCharTop = 0;
- this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._bufferService.cols;
- this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._bufferService.rows;
- this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
- this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
- this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols;
- this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows;
-
- for (const element of this._rowElements) {
- element.style.width = `${this.dimensions.canvasWidth}px`;
- element.style.height = `${this.dimensions.actualCellHeight}px`;
- element.style.lineHeight = `${this.dimensions.actualCellHeight}px`;
- // Make sure rows don't overflow onto following row
- element.style.overflow = 'hidden';
- }
-
- if (!this._dimensionsStyleElement) {
- this._dimensionsStyleElement = document.createElement('style');
- this._screenElement.appendChild(this._dimensionsStyleElement);
- }
-
- const styles =
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS} span {` +
- ` display: inline-block;` +
- ` height: 100%;` +
- ` vertical-align: top;` +
- ` width: ${this.dimensions.actualCellWidth}px` +
- `}`;
-
- this._dimensionsStyleElement.textContent = styles;
-
- this._selectionContainer.style.height = this._viewportElement.style.height;
- this._screenElement.style.width = `${this.dimensions.canvasWidth}px`;
- this._screenElement.style.height = `${this.dimensions.canvasHeight}px`;
- }
-
- public setColors(colors: IColorSet): void {
- this._colors = colors;
- this._injectCss();
- }
-
- private _injectCss(): void {
- if (!this._themeStyleElement) {
- this._themeStyleElement = document.createElement('style');
- this._screenElement.appendChild(this._themeStyleElement);
- }
-
- // Base CSS
- let styles =
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS} {` +
- ` color: ${this._colors.foreground.css};` +
- ` font-family: ${this._optionsService.options.fontFamily};` +
- ` font-size: ${this._optionsService.options.fontSize}px;` +
- `}`;
- // Text styles
- styles +=
- `${this._terminalSelector} span:not(.${BOLD_CLASS}) {` +
- ` font-weight: ${this._optionsService.options.fontWeight};` +
- `}` +
- `${this._terminalSelector} span.${BOLD_CLASS} {` +
- ` font-weight: ${this._optionsService.options.fontWeightBold};` +
- `}` +
- `${this._terminalSelector} span.${ITALIC_CLASS} {` +
- ` font-style: italic;` +
- `}`;
- // Blink animation
- styles +=
- `@keyframes blink_box_shadow` + `_` + this._terminalClass + ` {` +
- ` 50% {` +
- ` box-shadow: none;` +
- ` }` +
- `}`;
- styles +=
- `@keyframes blink_block` + `_` + this._terminalClass + ` {` +
- ` 0% {` +
- ` background-color: ${this._colors.cursor.css};` +
- ` color: ${this._colors.cursorAccent.css};` +
- ` }` +
- ` 50% {` +
- ` background-color: ${this._colors.cursorAccent.css};` +
- ` color: ${this._colors.cursor.css};` +
- ` }` +
- `}`;
- // Cursor
- styles +=
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS}:not(.${FOCUS_CLASS}) .${CURSOR_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` +
- ` outline: 1px solid ${this._colors.cursor.css};` +
- ` outline-offset: -1px;` +
- `}` +
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_BLINK_CLASS}:not(.${CURSOR_STYLE_BLOCK_CLASS}) {` +
- ` animation: blink_box_shadow` + `_` + this._terminalClass + ` 1s step-end infinite;` +
- `}` +
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_BLINK_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` +
- ` animation: blink_block` + `_` + this._terminalClass + ` 1s step-end infinite;` +
- `}` +
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` +
- ` background-color: ${this._colors.cursor.css};` +
- ` color: ${this._colors.cursorAccent.css};` +
- `}` +
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BAR_CLASS} {` +
- ` box-shadow: ${this._optionsService.options.cursorWidth}px 0 0 ${this._colors.cursor.css} inset;` +
- `}` +
- `${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_UNDERLINE_CLASS} {` +
- ` box-shadow: 0 -1px 0 ${this._colors.cursor.css} inset;` +
- `}`;
- // Selection
- styles +=
- `${this._terminalSelector} .${SELECTION_CLASS} {` +
- ` position: absolute;` +
- ` top: 0;` +
- ` left: 0;` +
- ` z-index: 1;` +
- ` pointer-events: none;` +
- `}` +
- `${this._terminalSelector} .${SELECTION_CLASS} div {` +
- ` position: absolute;` +
- ` background-color: ${this._colors.selectionTransparent.css};` +
- `}`;
- // Colors
- this._colors.ansi.forEach((c, i) => {
- styles +=
- `${this._terminalSelector} .${FG_CLASS_PREFIX}${i} { color: ${c.css}; }` +
- `${this._terminalSelector} .${BG_CLASS_PREFIX}${i} { background-color: ${c.css}; }`;
- });
- styles +=
- `${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { color: ${color.opaque(this._colors.background).css}; }` +
- `${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${this._colors.foreground.css}; }`;
-
- this._themeStyleElement.textContent = styles;
- }
-
- public onDevicePixelRatioChange(): void {
- this._updateDimensions();
- }
-
- private _refreshRowElements(cols: number, rows: number): void {
- // Add missing elements
- for (let i = this._rowElements.length; i <= rows; i++) {
- const row = document.createElement('div');
- this._rowContainer.appendChild(row);
- this._rowElements.push(row);
- }
- // Remove excess elements
- while (this._rowElements.length > rows) {
- this._rowContainer.removeChild(this._rowElements.pop()!);
- }
- }
-
- public onResize(cols: number, rows: number): void {
- this._refreshRowElements(cols, rows);
- this._updateDimensions();
- }
-
- public onCharSizeChanged(): void {
- this._updateDimensions();
- }
-
- public onBlur(): void {
- this._rowContainer.classList.remove(FOCUS_CLASS);
- }
-
- public onFocus(): void {
- this._rowContainer.classList.add(FOCUS_CLASS);
- }
-
- public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
- // Remove all selections
- while (this._selectionContainer.children.length) {
- this._selectionContainer.removeChild(this._selectionContainer.children[0]);
- }
-
- // Selection does not exist
- if (!start || !end) {
- return;
- }
-
- // Translate from buffer position to viewport position
- const viewportStartRow = start[1] - this._bufferService.buffer.ydisp;
- const viewportEndRow = end[1] - this._bufferService.buffer.ydisp;
- const viewportCappedStartRow = Math.max(viewportStartRow, 0);
- const viewportCappedEndRow = Math.min(viewportEndRow, this._bufferService.rows - 1);
-
- // No need to draw the selection
- if (viewportCappedStartRow >= this._bufferService.rows || viewportCappedEndRow < 0) {
- return;
- }
-
- // Create the selections
- const documentFragment = document.createDocumentFragment();
-
- if (columnSelectMode) {
- documentFragment.appendChild(
- this._createSelectionElement(viewportCappedStartRow, start[0], end[0], viewportCappedEndRow - viewportCappedStartRow + 1)
- );
- } else {
- // Draw first row
- const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
- const endCol = viewportCappedStartRow === viewportEndRow ? end[0] : this._bufferService.cols;
- documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol));
- // Draw middle rows
- const middleRowsCount = viewportCappedEndRow - viewportCappedStartRow - 1;
- documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow + 1, 0, this._bufferService.cols, middleRowsCount));
- // Draw final row
- if (viewportCappedStartRow !== viewportCappedEndRow) {
- // Only draw viewportEndRow if it's not the same as viewporttartRow
- const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;
- documentFragment.appendChild(this._createSelectionElement(viewportCappedEndRow, 0, endCol));
- }
- }
- this._selectionContainer.appendChild(documentFragment);
- }
-
- /**
- * Creates a selection element at the specified position.
- * @param row The row of the selection.
- * @param colStart The start column.
- * @param colEnd The end columns.
- */
- private _createSelectionElement(row: number, colStart: number, colEnd: number, rowCount: number = 1): HTMLElement {
- const element = document.createElement('div');
- element.style.height = `${rowCount * this.dimensions.actualCellHeight}px`;
- element.style.top = `${row * this.dimensions.actualCellHeight}px`;
- element.style.left = `${colStart * this.dimensions.actualCellWidth}px`;
- element.style.width = `${this.dimensions.actualCellWidth * (colEnd - colStart)}px`;
- return element;
- }
-
- public onCursorMove(): void {
- // No-op, the cursor is drawn when rows are drawn
- }
-
- public onOptionsChanged(): void {
- // Force a refresh
- this._updateDimensions();
- this._injectCss();
- }
-
- public clear(): void {
- for (const e of this._rowElements) {
- e.innerText = '';
- }
- }
-
- public renderRows(start: number, end: number): void {
- const cursorAbsoluteY = this._bufferService.buffer.ybase + this._bufferService.buffer.y;
- const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1);
- const cursorBlink = this._optionsService.options.cursorBlink;
-
- for (let y = start; y <= end; y++) {
- const rowElement = this._rowElements[y];
- rowElement.innerText = '';
-
- const row = y + this._bufferService.buffer.ydisp;
- const lineData = this._bufferService.buffer.lines.get(row);
- const cursorStyle = this._optionsService.options.cursorStyle;
- rowElement.appendChild(this._rowFactory.createRow(lineData!, row, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols));
- }
- }
-
- private get _terminalSelector(): string {
- return `.${TERMINAL_CLASS_PREFIX}${this._terminalClass}`;
- }
-
- private _onLinkHover(e: ILinkifierEvent): void {
- this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, true);
- }
-
- private _onLinkLeave(e: ILinkifierEvent): void {
- this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, false);
- }
-
- private _setCellUnderline(x: number, x2: number, y: number, y2: number, cols: number, enabled: boolean): void {
- while (x !== x2 || y !== y2) {
- const row = this._rowElements[y];
- if (!row) {
- return;
- }
- const span = row.children[x] as HTMLElement;
- if (span) {
- span.style.textDecoration = enabled ? 'underline' : 'none';
- }
- if (++x >= cols) {
- x = 0;
- y++;
- }
- }
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts
deleted file mode 100644
index a61ebd73..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts
+++ /dev/null
@@ -1,258 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IBufferLine } from 'common/Types';
-import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
-import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants';
-import { CellData } from 'common/buffer/CellData';
-import { IOptionsService } from 'common/services/Services';
-import { color, rgba } from 'browser/Color';
-import { IColorSet, IColor } from 'browser/Types';
-import { ICharacterJoinerService } from 'browser/services/Services';
-import { JoinedCellData } from 'browser/services/CharacterJoinerService';
-
-export const BOLD_CLASS = 'xterm-bold';
-export const DIM_CLASS = 'xterm-dim';
-export const ITALIC_CLASS = 'xterm-italic';
-export const UNDERLINE_CLASS = 'xterm-underline';
-export const STRIKETHROUGH_CLASS = 'xterm-strikethrough';
-export const CURSOR_CLASS = 'xterm-cursor';
-export const CURSOR_BLINK_CLASS = 'xterm-cursor-blink';
-export const CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block';
-export const CURSOR_STYLE_BAR_CLASS = 'xterm-cursor-bar';
-export const CURSOR_STYLE_UNDERLINE_CLASS = 'xterm-cursor-underline';
-
-export class DomRendererRowFactory {
- private _workCell: CellData = new CellData();
-
- constructor(
- private readonly _document: Document,
- private _colors: IColorSet,
- @ICharacterJoinerService private readonly _characterJoinerService: ICharacterJoinerService,
- @IOptionsService private readonly _optionsService: IOptionsService
- ) {
- }
-
- public setColors(colors: IColorSet): void {
- this._colors = colors;
- }
-
- public createRow(lineData: IBufferLine, row: number, isCursorRow: boolean, cursorStyle: string | undefined, cursorX: number, cursorBlink: boolean, cellWidth: number, cols: number): DocumentFragment {
- const fragment = this._document.createDocumentFragment();
-
- const joinedRanges = this._characterJoinerService.getJoinedCharacters(row);
- // Find the line length first, this prevents the need to output a bunch of
- // empty cells at the end. This cannot easily be integrated into the main
- // loop below because of the colCount feature (which can be removed after we
- // properly support reflow and disallow data to go beyond the right-side of
- // the viewport).
- let lineLength = 0;
- for (let x = Math.min(lineData.length, cols) - 1; x >= 0; x--) {
- if (lineData.loadCell(x, this._workCell).getCode() !== NULL_CELL_CODE || (isCursorRow && x === cursorX)) {
- lineLength = x + 1;
- break;
- }
- }
-
- for (let x = 0; x < lineLength; x++) {
- lineData.loadCell(x, this._workCell);
- let width = this._workCell.getWidth();
-
- // The character to the left is a wide character, drawing is owned by the char at x-1
- if (width === 0) {
- continue;
- }
-
- // If true, indicates that the current character(s) to draw were joined.
- let isJoined = false;
- let lastCharX = x;
-
- // Process any joined character ranges as needed. Because of how the
- // ranges are produced, we know that they are valid for the characters
- // and attributes of our input.
- let cell = this._workCell;
- if (joinedRanges.length > 0 && x === joinedRanges[0][0]) {
- isJoined = true;
- const range = joinedRanges.shift()!;
-
- // We already know the exact start and end column of the joined range,
- // so we get the string and width representing it directly
- cell = new JoinedCellData(
- this._workCell,
- lineData.translateToString(true, range[0], range[1]),
- range[1] - range[0]
- );
-
- // Skip over the cells occupied by this range in the loop
- lastCharX = range[1] - 1;
-
- // Recalculate width
- width = cell.getWidth();
- }
-
- const charElement = this._document.createElement('span');
- if (width > 1) {
- charElement.style.width = `${cellWidth * width}px`;
- }
-
- if (isJoined) {
- // Ligatures in the DOM renderer must use display inline, as they may not show with
- // inline-block if they are outside the bounds of the element
- charElement.style.display = 'inline';
-
- // The DOM renderer colors the background of the cursor but for ligatures all cells are
- // joined. The workaround here is to show a cursor around the whole ligature so it shows up,
- // the cursor looks the same when on any character of the ligature though
- if (cursorX >= x && cursorX <= lastCharX) {
- cursorX = x;
- }
- }
-
- if (isCursorRow && x === cursorX) {
- charElement.classList.add(CURSOR_CLASS);
-
- if (cursorBlink) {
- charElement.classList.add(CURSOR_BLINK_CLASS);
- }
-
- switch (cursorStyle) {
- case 'bar':
- charElement.classList.add(CURSOR_STYLE_BAR_CLASS);
- break;
- case 'underline':
- charElement.classList.add(CURSOR_STYLE_UNDERLINE_CLASS);
- break;
- default:
- charElement.classList.add(CURSOR_STYLE_BLOCK_CLASS);
- break;
- }
- }
-
- if (cell.isBold()) {
- charElement.classList.add(BOLD_CLASS);
- }
-
- if (cell.isItalic()) {
- charElement.classList.add(ITALIC_CLASS);
- }
-
- if (cell.isDim()) {
- charElement.classList.add(DIM_CLASS);
- }
-
- if (cell.isUnderline()) {
- charElement.classList.add(UNDERLINE_CLASS);
- }
-
- if (cell.isInvisible()) {
- charElement.textContent = WHITESPACE_CELL_CHAR;
- } else {
- charElement.textContent = cell.getChars() || WHITESPACE_CELL_CHAR;
- }
-
- if (cell.isStrikethrough()) {
- charElement.classList.add(STRIKETHROUGH_CLASS);
- }
-
- let fg = cell.getFgColor();
- let fgColorMode = cell.getFgColorMode();
- let bg = cell.getBgColor();
- let bgColorMode = cell.getBgColorMode();
- const isInverse = !!cell.isInverse();
- if (isInverse) {
- const temp = fg;
- fg = bg;
- bg = temp;
- const temp2 = fgColorMode;
- fgColorMode = bgColorMode;
- bgColorMode = temp2;
- }
-
- // Foreground
- switch (fgColorMode) {
- case Attributes.CM_P16:
- case Attributes.CM_P256:
- if (cell.isBold() && fg < 8 && this._optionsService.options.drawBoldTextInBrightColors) {
- fg += 8;
- }
- if (!this._applyMinimumContrast(charElement, this._colors.background, this._colors.ansi[fg])) {
- charElement.classList.add(`xterm-fg-${fg}`);
- }
- break;
- case Attributes.CM_RGB:
- const color = rgba.toColor(
- (fg >> 16) & 0xFF,
- (fg >> 8) & 0xFF,
- (fg ) & 0xFF
- );
- if (!this._applyMinimumContrast(charElement, this._colors.background, color)) {
- this._addStyle(charElement, `color:#${padStart(fg.toString(16), '0', 6)}`);
- }
- break;
- case Attributes.CM_DEFAULT:
- default:
- if (!this._applyMinimumContrast(charElement, this._colors.background, this._colors.foreground)) {
- if (isInverse) {
- charElement.classList.add(`xterm-fg-${INVERTED_DEFAULT_COLOR}`);
- }
- }
- }
-
- // Background
- switch (bgColorMode) {
- case Attributes.CM_P16:
- case Attributes.CM_P256:
- charElement.classList.add(`xterm-bg-${bg}`);
- break;
- case Attributes.CM_RGB:
- this._addStyle(charElement, `background-color:#${padStart(bg.toString(16), '0', 6)}`);
- break;
- case Attributes.CM_DEFAULT:
- default:
- if (isInverse) {
- charElement.classList.add(`xterm-bg-${INVERTED_DEFAULT_COLOR}`);
- }
- }
-
- fragment.appendChild(charElement);
-
- x = lastCharX;
- }
- return fragment;
- }
-
- private _applyMinimumContrast(element: HTMLElement, bg: IColor, fg: IColor): boolean {
- if (this._optionsService.options.minimumContrastRatio === 1) {
- return false;
- }
-
- // Try get from cache first
- let adjustedColor = this._colors.contrastCache.getColor(this._workCell.bg, this._workCell.fg);
-
- // Calculate and store in cache
- if (adjustedColor === undefined) {
- adjustedColor = color.ensureContrastRatio(bg, fg, this._optionsService.options.minimumContrastRatio);
- this._colors.contrastCache.setColor(this._workCell.bg, this._workCell.fg, adjustedColor ?? null);
- }
-
- if (adjustedColor) {
- this._addStyle(element, `color:${adjustedColor.css}`);
- return true;
- }
-
- return false;
- }
-
- private _addStyle(element: HTMLElement, style: string): void {
- element.setAttribute('style', `${element.getAttribute('style') || ''}${style};`);
- }
-}
-
-function padStart(text: string, padChar: string, length: number): string {
- while (text.length < length) {
- text = padChar + text;
- }
- return text;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/selection/SelectionModel.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/selection/SelectionModel.ts
deleted file mode 100644
index 1420444e..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/selection/SelectionModel.ts
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IBufferService } from 'common/services/Services';
-
-/**
- * Represents a selection within the buffer. This model only cares about column
- * and row coordinates, not wide characters.
- */
-export class SelectionModel {
- /**
- * Whether select all is currently active.
- */
- public isSelectAllActive: boolean = false;
-
- /**
- * The minimal length of the selection from the start position. When double
- * clicking on a word, the word will be selected which makes the selection
- * start at the start of the word and makes this variable the length.
- */
- public selectionStartLength: number = 0;
-
- /**
- * The [x, y] position the selection starts at.
- */
- public selectionStart: [number, number] | undefined;
-
- /**
- * The [x, y] position the selection ends at.
- */
- public selectionEnd: [number, number] | undefined;
-
- constructor(
- private _bufferService: IBufferService
- ) {
- }
-
- /**
- * Clears the current selection.
- */
- public clearSelection(): void {
- this.selectionStart = undefined;
- this.selectionEnd = undefined;
- this.isSelectAllActive = false;
- this.selectionStartLength = 0;
- }
-
- /**
- * The final selection start, taking into consideration select all.
- */
- public get finalSelectionStart(): [number, number] | undefined {
- if (this.isSelectAllActive) {
- return [0, 0];
- }
-
- if (!this.selectionEnd || !this.selectionStart) {
- return this.selectionStart;
- }
-
- return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;
- }
-
- /**
- * The final selection end, taking into consideration select all, double click
- * word selection and triple click line selection.
- */
- public get finalSelectionEnd(): [number, number] | undefined {
- if (this.isSelectAllActive) {
- return [this._bufferService.cols, this._bufferService.buffer.ybase + this._bufferService.rows - 1];
- }
-
- if (!this.selectionStart) {
- return undefined;
- }
-
- // Use the selection start + length if the end doesn't exist or they're reversed
- if (!this.selectionEnd || this.areSelectionValuesReversed()) {
- const startPlusLength = this.selectionStart[0] + this.selectionStartLength;
- if (startPlusLength > this._bufferService.cols) {
- return [startPlusLength % this._bufferService.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._bufferService.cols)];
- }
- return [startPlusLength, this.selectionStart[1]];
- }
-
- // Ensure the the word/line is selected after a double/triple click
- if (this.selectionStartLength) {
- // Select the larger of the two when start and end are on the same line
- if (this.selectionEnd[1] === this.selectionStart[1]) {
- return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];
- }
- }
- return this.selectionEnd;
- }
-
- /**
- * Returns whether the selection start and end are reversed.
- */
- public areSelectionValuesReversed(): boolean {
- const start = this.selectionStart;
- const end = this.selectionEnd;
- if (!start || !end) {
- return false;
- }
- return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);
- }
-
- /**
- * Handle the buffer being trimmed, adjust the selection position.
- * @param amount The amount the buffer is being trimmed.
- * @return Whether a refresh is necessary.
- */
- public onTrim(amount: number): boolean {
- // Adjust the selection position based on the trimmed amount.
- if (this.selectionStart) {
- this.selectionStart[1] -= amount;
- }
- if (this.selectionEnd) {
- this.selectionEnd[1] -= amount;
- }
-
- // The selection has moved off the buffer, clear it.
- if (this.selectionEnd && this.selectionEnd[1] < 0) {
- this.clearSelection();
- return true;
- }
-
- // If the selection start is trimmed, ensure the start column is 0.
- if (this.selectionStart && this.selectionStart[1] < 0) {
- this.selectionStart[1] = 0;
- }
- return false;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/selection/Types.d.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/selection/Types.d.ts
deleted file mode 100644
index 8adfc17c..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/selection/Types.d.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-export interface ISelectionRedrawRequestEvent {
- start: [number, number] | undefined;
- end: [number, number] | undefined;
- columnSelectMode: boolean;
-}
-
-export interface ISelectionRequestScrollLinesEvent {
- amount: number;
- suppressScrollEvent: boolean;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CharSizeService.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CharSizeService.ts
deleted file mode 100644
index 79696a28..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CharSizeService.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) 2016 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IOptionsService } from 'common/services/Services';
-import { IEvent, EventEmitter } from 'common/EventEmitter';
-import { ICharSizeService } from 'browser/services/Services';
-
-export class CharSizeService implements ICharSizeService {
- public serviceBrand: undefined;
-
- public width: number = 0;
- public height: number = 0;
- private _measureStrategy: IMeasureStrategy;
-
- public get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }
-
- private _onCharSizeChange = new EventEmitter();
- public get onCharSizeChange(): IEvent { return this._onCharSizeChange.event; }
-
- constructor(
- document: Document,
- parentElement: HTMLElement,
- @IOptionsService private readonly _optionsService: IOptionsService
- ) {
- this._measureStrategy = new DomMeasureStrategy(document, parentElement, this._optionsService);
- }
-
- public measure(): void {
- const result = this._measureStrategy.measure();
- if (result.width !== this.width || result.height !== this.height) {
- this.width = result.width;
- this.height = result.height;
- this._onCharSizeChange.fire();
- }
- }
-}
-
-interface IMeasureStrategy {
- measure(): IReadonlyMeasureResult;
-}
-
-interface IReadonlyMeasureResult {
- readonly width: number;
- readonly height: number;
-}
-
-interface IMeasureResult {
- width: number;
- height: number;
-}
-
-// TODO: For supporting browsers we should also provide a CanvasCharDimensionsProvider that uses ctx.measureText
-class DomMeasureStrategy implements IMeasureStrategy {
- private _result: IMeasureResult = { width: 0, height: 0 };
- private _measureElement: HTMLElement;
-
- constructor(
- private _document: Document,
- private _parentElement: HTMLElement,
- private _optionsService: IOptionsService
- ) {
- 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);
- }
-
- public measure(): IReadonlyMeasureResult {
- this._measureElement.style.fontFamily = this._optionsService.options.fontFamily;
- this._measureElement.style.fontSize = `${this._optionsService.options.fontSize}px`;
-
- // Note that this triggers a synchronous layout
- const geometry = this._measureElement.getBoundingClientRect();
-
- // If values are 0 then the element is likely currently display:none, in which case we should
- // retain the previous value.
- if (geometry.width !== 0 && geometry.height !== 0) {
- this._result.width = geometry.width;
- this._result.height = Math.ceil(geometry.height);
- }
-
- return this._result;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CharacterJoinerService.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CharacterJoinerService.ts
deleted file mode 100644
index ea65c29b..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CharacterJoinerService.ts
+++ /dev/null
@@ -1,330 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IBufferLine, ICellData, CharData } from 'common/Types';
-import { ICharacterJoiner } from 'browser/Types';
-import { AttributeData } from 'common/buffer/AttributeData';
-import { WHITESPACE_CELL_CHAR, Content } from 'common/buffer/Constants';
-import { CellData } from 'common/buffer/CellData';
-import { IBufferService } from 'common/services/Services';
-import { ICharacterJoinerService } from 'browser/services/Services';
-
-export class JoinedCellData extends AttributeData implements ICellData {
- private _width: number;
- // .content carries no meaning for joined CellData, simply nullify it
- // thus we have to overload all other .content accessors
- public content: number = 0;
- public fg: number;
- public bg: number;
- public combinedData: string = '';
-
- constructor(firstCell: ICellData, chars: string, width: number) {
- super();
- this.fg = firstCell.fg;
- this.bg = firstCell.bg;
- this.combinedData = chars;
- this._width = width;
- }
-
- public isCombined(): number {
- // always mark joined cell data as combined
- return Content.IS_COMBINED_MASK;
- }
-
- public getWidth(): number {
- return this._width;
- }
-
- public getChars(): string {
- return this.combinedData;
- }
-
- public getCode(): number {
- // code always gets the highest possible fake codepoint (read as -1)
- // this is needed as code is used by caches as identifier
- return 0x1FFFFF;
- }
-
- public setFromCharData(value: CharData): void {
- throw new Error('not implemented');
- }
-
- public getAsCharData(): CharData {
- return [this.fg, this.getChars(), this.getWidth(), this.getCode()];
- }
-}
-
-export class CharacterJoinerService implements ICharacterJoinerService {
- public serviceBrand: undefined;
-
- private _characterJoiners: ICharacterJoiner[] = [];
- private _nextCharacterJoinerId: number = 0;
- private _workCell: CellData = new CellData();
-
- constructor(
- @IBufferService private _bufferService: IBufferService
- ) { }
-
- public register(handler: (text: string) => [number, number][]): number {
- const joiner: ICharacterJoiner = {
- id: this._nextCharacterJoinerId++,
- handler
- };
-
- this._characterJoiners.push(joiner);
- return joiner.id;
- }
-
- public deregister(joinerId: number): boolean {
- for (let i = 0; i < this._characterJoiners.length; i++) {
- if (this._characterJoiners[i].id === joinerId) {
- this._characterJoiners.splice(i, 1);
- return true;
- }
- }
-
- return false;
- }
-
- public getJoinedCharacters(row: number): [number, number][] {
- if (this._characterJoiners.length === 0) {
- return [];
- }
-
- const line = this._bufferService.buffer.lines.get(row);
- if (!line || line.length === 0) {
- return [];
- }
-
- const ranges: [number, number][] = [];
- const lineStr = line.translateToString(true);
-
- // Because some cells can be represented by multiple javascript characters,
- // we track the cell and the string indexes separately. This allows us to
- // translate the string ranges we get from the joiners back into cell ranges
- // for use when rendering
- let rangeStartColumn = 0;
- let currentStringIndex = 0;
- let rangeStartStringIndex = 0;
- let rangeAttrFG = line.getFg(0);
- let rangeAttrBG = line.getBg(0);
-
- for (let x = 0; x < line.getTrimmedLength(); x++) {
- line.loadCell(x, this._workCell);
-
- if (this._workCell.getWidth() === 0) {
- // If this character is of width 0, skip it.
- continue;
- }
-
- // End of range
- if (this._workCell.fg !== rangeAttrFG || this._workCell.bg !== rangeAttrBG) {
- // If we ended up with a sequence of more than one character,
- // look for ranges to join.
- if (x - rangeStartColumn > 1) {
- const joinedRanges = this._getJoinedRanges(
- lineStr,
- rangeStartStringIndex,
- currentStringIndex,
- line,
- rangeStartColumn
- );
- for (let i = 0; i < joinedRanges.length; i++) {
- ranges.push(joinedRanges[i]);
- }
- }
-
- // Reset our markers for a new range.
- rangeStartColumn = x;
- rangeStartStringIndex = currentStringIndex;
- rangeAttrFG = this._workCell.fg;
- rangeAttrBG = this._workCell.bg;
- }
-
- currentStringIndex += this._workCell.getChars().length || WHITESPACE_CELL_CHAR.length;
- }
-
- // Process any trailing ranges.
- if (this._bufferService.cols - rangeStartColumn > 1) {
- const joinedRanges = this._getJoinedRanges(
- lineStr,
- rangeStartStringIndex,
- currentStringIndex,
- line,
- rangeStartColumn
- );
- for (let i = 0; i < joinedRanges.length; i++) {
- ranges.push(joinedRanges[i]);
- }
- }
-
- return ranges;
- }
-
- /**
- * Given a segment of a line of text, find all ranges of text that should be
- * joined in a single rendering unit. Ranges are internally converted to
- * column ranges, rather than string ranges.
- * @param line String representation of the full line of text
- * @param startIndex Start position of the range to search in the string (inclusive)
- * @param endIndex End position of the range to search in the string (exclusive)
- */
- private _getJoinedRanges(line: string, startIndex: number, endIndex: number, lineData: IBufferLine, startCol: number): [number, number][] {
- const text = line.substring(startIndex, endIndex);
- // At this point we already know that there is at least one joiner so
- // we can just pull its value and assign it directly rather than
- // merging it into an empty array, which incurs unnecessary writes.
- const joinedRanges: [number, number][] = this._characterJoiners[0].handler(text);
- for (let i = 1; i < this._characterJoiners.length; i++) {
- // We merge any overlapping ranges across the different joiners
- const joinerRanges = this._characterJoiners[i].handler(text);
- for (let j = 0; j < joinerRanges.length; j++) {
- CharacterJoinerService._mergeRanges(joinedRanges, joinerRanges[j]);
- }
- }
- this._stringRangesToCellRanges(joinedRanges, lineData, startCol);
- return joinedRanges;
- }
-
- /**
- * Modifies the provided ranges in-place to adjust for variations between
- * string length and cell width so that the range represents a cell range,
- * rather than the string range the joiner provides.
- * @param ranges String ranges containing start (inclusive) and end (exclusive) index
- * @param line Cell data for the relevant line in the terminal
- * @param startCol Offset within the line to start from
- */
- private _stringRangesToCellRanges(ranges: [number, number][], line: IBufferLine, startCol: number): void {
- let currentRangeIndex = 0;
- let currentRangeStarted = false;
- let currentStringIndex = 0;
- let currentRange = ranges[currentRangeIndex];
-
- // If we got through all of the ranges, stop searching
- if (!currentRange) {
- return;
- }
-
- for (let x = startCol; x < this._bufferService.cols; x++) {
- const width = line.getWidth(x);
- const length = line.getString(x).length || WHITESPACE_CELL_CHAR.length;
-
- // We skip zero-width characters when creating the string to join the text
- // so we do the same here
- if (width === 0) {
- continue;
- }
-
- // Adjust the start of the range
- if (!currentRangeStarted && currentRange[0] <= currentStringIndex) {
- currentRange[0] = x;
- currentRangeStarted = true;
- }
-
- // Adjust the end of the range
- if (currentRange[1] <= currentStringIndex) {
- currentRange[1] = x;
-
- // We're finished with this range, so we move to the next one
- currentRange = ranges[++currentRangeIndex];
-
- // If there are no more ranges left, stop searching
- if (!currentRange) {
- break;
- }
-
- // Ranges can be on adjacent characters. Because the end index of the
- // ranges are exclusive, this means that the index for the start of a
- // range can be the same as the end index of the previous range. To
- // account for the start of the next range, we check here just in case.
- if (currentRange[0] <= currentStringIndex) {
- currentRange[0] = x;
- currentRangeStarted = true;
- } else {
- currentRangeStarted = false;
- }
- }
-
- // Adjust the string index based on the character length to line up with
- // the column adjustment
- currentStringIndex += length;
- }
-
- // If there is still a range left at the end, it must extend all the way to
- // the end of the line.
- if (currentRange) {
- currentRange[1] = this._bufferService.cols;
- }
- }
-
- /**
- * Merges the range defined by the provided start and end into the list of
- * existing ranges. The merge is done in place on the existing range for
- * performance and is also returned.
- * @param ranges Existing range list
- * @param newRange Tuple of two numbers representing the new range to merge in.
- * @returns The ranges input with the new range merged in place
- */
- private static _mergeRanges(ranges: [number, number][], newRange: [number, number]): [number, number][] {
- let inRange = false;
- for (let i = 0; i < ranges.length; i++) {
- const range = ranges[i];
- if (!inRange) {
- if (newRange[1] <= range[0]) {
- // Case 1: New range is before the search range
- ranges.splice(i, 0, newRange);
- return ranges;
- }
-
- if (newRange[1] <= range[1]) {
- // Case 2: New range is either wholly contained within the
- // search range or overlaps with the front of it
- range[0] = Math.min(newRange[0], range[0]);
- return ranges;
- }
-
- if (newRange[0] < range[1]) {
- // Case 3: New range either wholly contains the search range
- // or overlaps with the end of it
- range[0] = Math.min(newRange[0], range[0]);
- inRange = true;
- }
-
- // Case 4: New range starts after the search range
- continue;
- } else {
- if (newRange[1] <= range[0]) {
- // Case 5: New range extends from previous range but doesn't
- // reach the current one
- ranges[i - 1][1] = newRange[1];
- return ranges;
- }
-
- if (newRange[1] <= range[1]) {
- // Case 6: New range extends from prvious range into the
- // current range
- ranges[i - 1][1] = Math.max(newRange[1], range[1]);
- ranges.splice(i, 1);
- return ranges;
- }
-
- // Case 7: New range extends from previous range past the
- // end of the current range
- ranges.splice(i, 1);
- i--;
- }
- }
-
- if (inRange) {
- // Case 8: New range extends past the last existing range
- ranges[ranges.length - 1][1] = newRange[1];
- } else {
- // Case 9: New range starts after the last existing range
- ranges.push(newRange);
- }
-
- return ranges;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CoreBrowserService.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CoreBrowserService.ts
deleted file mode 100644
index 4eabc895..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/CoreBrowserService.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ICoreBrowserService } from './Services';
-
-export class CoreBrowserService implements ICoreBrowserService {
- public serviceBrand: undefined;
-
- constructor(
- private _textarea: HTMLTextAreaElement
- ) {
- }
-
- public get isFocused(): boolean {
- const docOrShadowRoot = this._textarea.getRootNode ? this._textarea.getRootNode() as Document | ShadowRoot : document;
- return docOrShadowRoot.activeElement === this._textarea && document.hasFocus();
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/MouseService.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/MouseService.ts
deleted file mode 100644
index 348ba64e..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/MouseService.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ICharSizeService, IRenderService, IMouseService } from './Services';
-import { getCoords, getRawByteCoords } from 'browser/input/Mouse';
-
-export class MouseService implements IMouseService {
- public serviceBrand: undefined;
-
- constructor(
- @IRenderService private readonly _renderService: IRenderService,
- @ICharSizeService private readonly _charSizeService: ICharSizeService
- ) {
- }
-
- public getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, isSelection?: boolean): [number, number] | undefined {
- return getCoords(
- event,
- element,
- colCount,
- rowCount,
- this._charSizeService.hasValidSize,
- this._renderService.dimensions.actualCellWidth,
- this._renderService.dimensions.actualCellHeight,
- isSelection
- );
- }
-
- public getRawByteCoords(event: MouseEvent, element: HTMLElement, colCount: number, rowCount: number): { x: number, y: number } | undefined {
- const coords = this.getCoords(event, element, colCount, rowCount);
- return getRawByteCoords(coords);
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/RenderService.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/RenderService.ts
deleted file mode 100644
index 332e71da..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/RenderService.ts
+++ /dev/null
@@ -1,217 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IRenderer, IRenderDimensions } from 'browser/renderer/Types';
-import { RenderDebouncer } from 'browser/RenderDebouncer';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-import { Disposable } from 'common/Lifecycle';
-import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
-import { addDisposableDomListener } from 'browser/Lifecycle';
-import { IColorSet, IRenderDebouncer } from 'browser/Types';
-import { IOptionsService, IBufferService } from 'common/services/Services';
-import { ICharSizeService, IRenderService } from 'browser/services/Services';
-
-interface ISelectionState {
- start: [number, number] | undefined;
- end: [number, number] | undefined;
- columnSelectMode: boolean;
-}
-
-export class RenderService extends Disposable implements IRenderService {
- public serviceBrand: undefined;
-
- private _renderDebouncer: IRenderDebouncer;
- private _screenDprMonitor: ScreenDprMonitor;
-
- private _isPaused: boolean = false;
- private _needsFullRefresh: boolean = false;
- private _isNextRenderRedrawOnly: boolean = true;
- private _needsSelectionRefresh: boolean = false;
- private _canvasWidth: number = 0;
- private _canvasHeight: number = 0;
- private _selectionState: ISelectionState = {
- start: undefined,
- end: undefined,
- columnSelectMode: false
- };
-
- private _onDimensionsChange = new EventEmitter();
- public get onDimensionsChange(): IEvent { return this._onDimensionsChange.event; }
- private _onRender = new EventEmitter<{ start: number, end: number }>();
- public get onRenderedBufferChange(): IEvent<{ start: number, end: number }> { return this._onRender.event; }
- private _onRefreshRequest = new EventEmitter<{ start: number, end: number }>();
- public get onRefreshRequest(): IEvent<{ start: number, end: number }> { return this._onRefreshRequest.event; }
-
- public get dimensions(): IRenderDimensions { return this._renderer.dimensions; }
-
- constructor(
- private _renderer: IRenderer,
- private _rowCount: number,
- screenElement: HTMLElement,
- @IOptionsService optionsService: IOptionsService,
- @ICharSizeService private readonly _charSizeService: ICharSizeService,
- @IBufferService bufferService: IBufferService
- ) {
- super();
-
- this.register({ dispose: () => this._renderer.dispose() });
-
- this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end));
- this.register(this._renderDebouncer);
-
- this._screenDprMonitor = new ScreenDprMonitor();
- this._screenDprMonitor.setListener(() => this.onDevicePixelRatioChange());
- this.register(this._screenDprMonitor);
-
- this.register(bufferService.onResize(e => this._fullRefresh()));
- this.register(optionsService.onOptionChange(() => this._renderer.onOptionsChanged()));
- this.register(this._charSizeService.onCharSizeChange(() => this.onCharSizeChanged()));
-
- // No need to register this as renderer is explicitly disposed in RenderService.dispose
- this._renderer.onRequestRedraw(e => this.refreshRows(e.start, e.end, true));
-
- // dprchange should handle this case, we need this as well for browsers that don't support the
- // matchMedia query.
- this.register(addDisposableDomListener(window, 'resize', () => this.onDevicePixelRatioChange()));
-
- // Detect whether IntersectionObserver is detected and enable renderer pause
- // and resume based on terminal visibility if so
- if ('IntersectionObserver' in window) {
- const observer = new IntersectionObserver(e => this._onIntersectionChange(e[e.length - 1]), { threshold: 0 });
- observer.observe(screenElement);
- this.register({ dispose: () => observer.disconnect() });
- }
- }
-
- private _onIntersectionChange(entry: IntersectionObserverEntry): void {
- this._isPaused = entry.isIntersecting === undefined ? (entry.intersectionRatio === 0) : !entry.isIntersecting;
-
- // Terminal was hidden on open
- if (!this._isPaused && !this._charSizeService.hasValidSize) {
- this._charSizeService.measure();
- }
-
- if (!this._isPaused && this._needsFullRefresh) {
- this.refreshRows(0, this._rowCount - 1);
- this._needsFullRefresh = false;
- }
- }
-
- public refreshRows(start: number, end: number, isRedrawOnly: boolean = false): void {
- if (this._isPaused) {
- this._needsFullRefresh = true;
- return;
- }
- if (!isRedrawOnly) {
- this._isNextRenderRedrawOnly = false;
- }
- this._renderDebouncer.refresh(start, end, this._rowCount);
- }
-
- private _renderRows(start: number, end: number): void {
- this._renderer.renderRows(start, end);
-
- // Update selection if needed
- if (this._needsSelectionRefresh) {
- this._renderer.onSelectionChanged(this._selectionState.start, this._selectionState.end, this._selectionState.columnSelectMode);
- this._needsSelectionRefresh = false;
- }
-
- // Fire render event only if it was not a redraw
- if (!this._isNextRenderRedrawOnly) {
- this._onRender.fire({ start, end });
- }
- this._isNextRenderRedrawOnly = true;
- }
-
- public resize(cols: number, rows: number): void {
- this._rowCount = rows;
- this._fireOnCanvasResize();
- }
-
- public changeOptions(): void {
- this._renderer.onOptionsChanged();
- this.refreshRows(0, this._rowCount - 1);
- this._fireOnCanvasResize();
- }
-
- private _fireOnCanvasResize(): void {
- // Don't fire the event if the dimensions haven't changed
- if (this._renderer.dimensions.canvasWidth === this._canvasWidth && this._renderer.dimensions.canvasHeight === this._canvasHeight) {
- return;
- }
- this._onDimensionsChange.fire(this._renderer.dimensions);
- }
-
- public dispose(): void {
- super.dispose();
- }
-
- public setRenderer(renderer: IRenderer): void {
- // TODO: RenderService should be the only one to dispose the renderer
- this._renderer.dispose();
- this._renderer = renderer;
- this._renderer.onRequestRedraw(e => this.refreshRows(e.start, e.end, true));
-
- // Force a refresh
- this._needsSelectionRefresh = true;
- this._fullRefresh();
- }
-
- private _fullRefresh(): void {
- if (this._isPaused) {
- this._needsFullRefresh = true;
- } else {
- this.refreshRows(0, this._rowCount - 1);
- }
- }
-
- public setColors(colors: IColorSet): void {
- this._renderer.setColors(colors);
- this._fullRefresh();
- }
-
- public onDevicePixelRatioChange(): void {
- // Force char size measurement as DomMeasureStrategy(getBoundingClientRect) is not stable
- // when devicePixelRatio changes
- this._charSizeService.measure();
-
- this._renderer.onDevicePixelRatioChange();
- this.refreshRows(0, this._rowCount - 1);
- }
-
- public onResize(cols: number, rows: number): void {
- this._renderer.onResize(cols, rows);
- this._fullRefresh();
- }
-
- // TODO: Is this useful when we have onResize?
- public onCharSizeChanged(): void {
- this._renderer.onCharSizeChanged();
- }
-
- public onBlur(): void {
- this._renderer.onBlur();
- }
-
- public onFocus(): void {
- this._renderer.onFocus();
- }
-
- public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
- this._selectionState.start = start;
- this._selectionState.end = end;
- this._selectionState.columnSelectMode = columnSelectMode;
- this._renderer.onSelectionChanged(start, end, columnSelectMode);
- }
-
- public onCursorMove(): void {
- this._renderer.onCursorMove();
- }
-
- public clear(): void {
- this._renderer.clear();
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/SelectionService.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/SelectionService.ts
deleted file mode 100644
index c0547755..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/SelectionService.ts
+++ /dev/null
@@ -1,1009 +0,0 @@
-/**
- * Copyright (c) 2017 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
-import { IBuffer } from 'common/buffer/Types';
-import { IBufferLine, IDisposable } from 'common/Types';
-import * as Browser from 'common/Platform';
-import { SelectionModel } from 'browser/selection/SelectionModel';
-import { CellData } from 'common/buffer/CellData';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-import { IMouseService, ISelectionService, IRenderService } from 'browser/services/Services';
-import { ILinkifier2 } from 'browser/Types';
-import { IBufferService, IOptionsService, ICoreService } from 'common/services/Services';
-import { getCoordsRelativeToElement } from 'browser/input/Mouse';
-import { moveToCellSequence } from 'browser/input/MoveToCell';
-import { Disposable } from 'common/Lifecycle';
-import { getRangeLength } from 'common/buffer/BufferRange';
-
-/**
- * The number of pixels the mouse needs to be above or below the viewport in
- * order to scroll at the maximum speed.
- */
-const DRAG_SCROLL_MAX_THRESHOLD = 50;
-
-/**
- * The maximum scrolling speed
- */
-const DRAG_SCROLL_MAX_SPEED = 15;
-
-/**
- * The number of milliseconds between drag scroll updates.
- */
-const DRAG_SCROLL_INTERVAL = 50;
-
-/**
- * The maximum amount of time that can have elapsed for an alt click to move the
- * cursor.
- */
-const ALT_CLICK_MOVE_CURSOR_TIME = 500;
-
-const NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);
-const ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');
-
-/**
- * Represents a position of a word on a line.
- */
-interface IWordPosition {
- start: number;
- length: number;
-}
-
-/**
- * A selection mode, this drives how the selection behaves on mouse move.
- */
-export const enum SelectionMode {
- NORMAL,
- WORD,
- LINE,
- COLUMN
-}
-
-/**
- * A class that manages the selection of the terminal. With help from
- * SelectionModel, SelectionService handles with all logic associated with
- * dealing with the selection, including handling mouse interaction, wide
- * characters and fetching the actual text within the selection. Rendering is
- * not handled by the SelectionService but the onRedrawRequest event is fired
- * when the selection is ready to be redrawn (on an animation frame).
- */
-export class SelectionService extends Disposable implements ISelectionService {
- public serviceBrand: undefined;
-
- protected _model: SelectionModel;
-
- /**
- * The amount to scroll every drag scroll update (depends on how far the mouse
- * drag is above or below the terminal).
- */
- private _dragScrollAmount: number = 0;
-
- /**
- * The current selection mode.
- */
- protected _activeSelectionMode: SelectionMode;
-
- /**
- * A setInterval timer that is active while the mouse is down whose callback
- * scrolls the viewport when necessary.
- */
- private _dragScrollIntervalTimer: number | undefined;
-
- /**
- * The animation frame ID used for refreshing the selection.
- */
- private _refreshAnimationFrame: number | undefined;
-
- /**
- * Whether selection is enabled.
- */
- private _enabled = true;
-
- private _mouseMoveListener: EventListener;
- private _mouseUpListener: EventListener;
- private _trimListener: IDisposable;
- private _workCell: CellData = new CellData();
-
- private _mouseDownTimeStamp: number = 0;
- private _oldHasSelection: boolean = false;
- private _oldSelectionStart: [number, number] | undefined = undefined;
- private _oldSelectionEnd: [number, number] | undefined = undefined;
-
- private _onLinuxMouseSelection = this.register(new EventEmitter());
- public get onLinuxMouseSelection(): IEvent { return this._onLinuxMouseSelection.event; }
- private _onRedrawRequest = this.register(new EventEmitter());
- public get onRequestRedraw(): IEvent { return this._onRedrawRequest.event; }
- private _onSelectionChange = this.register(new EventEmitter());
- public get onSelectionChange(): IEvent { return this._onSelectionChange.event; }
- private _onRequestScrollLines = this.register(new EventEmitter());
- public get onRequestScrollLines(): IEvent { return this._onRequestScrollLines.event; }
-
- constructor(
- private readonly _element: HTMLElement,
- private readonly _screenElement: HTMLElement,
- private readonly _linkifier: ILinkifier2,
- @IBufferService private readonly _bufferService: IBufferService,
- @ICoreService private readonly _coreService: ICoreService,
- @IMouseService private readonly _mouseService: IMouseService,
- @IOptionsService private readonly _optionsService: IOptionsService,
- @IRenderService private readonly _renderService: IRenderService
- ) {
- super();
-
- // Init listeners
- this._mouseMoveListener = event => this._onMouseMove(event as MouseEvent);
- this._mouseUpListener = event => this._onMouseUp(event as MouseEvent);
- this._coreService.onUserInput(() => {
- if (this.hasSelection) {
- this.clearSelection();
- }
- });
- this._trimListener = this._bufferService.buffer.lines.onTrim(amount => this._onTrim(amount));
- this.register(this._bufferService.buffers.onBufferActivate(e => this._onBufferActivate(e)));
-
- this.enable();
-
- this._model = new SelectionModel(this._bufferService);
- this._activeSelectionMode = SelectionMode.NORMAL;
- }
-
- public dispose(): void {
- this._removeMouseDownListeners();
- }
-
- public reset(): void {
- this.clearSelection();
- }
-
- /**
- * Disables the selection manager. This is useful for when terminal mouse
- * are enabled.
- */
- public disable(): void {
- this.clearSelection();
- this._enabled = false;
- }
-
- /**
- * Enable the selection manager.
- */
- public enable(): void {
- this._enabled = true;
- }
-
- public get selectionStart(): [number, number] | undefined { return this._model.finalSelectionStart; }
- public get selectionEnd(): [number, number] | undefined { return this._model.finalSelectionEnd; }
-
- /**
- * Gets whether there is an active text selection.
- */
- public get hasSelection(): boolean {
- const start = this._model.finalSelectionStart;
- const end = this._model.finalSelectionEnd;
- if (!start || !end) {
- return false;
- }
- return start[0] !== end[0] || start[1] !== end[1];
- }
-
- /**
- * Gets the text currently selected.
- */
- public get selectionText(): string {
- const start = this._model.finalSelectionStart;
- const end = this._model.finalSelectionEnd;
- if (!start || !end) {
- return '';
- }
-
- const buffer = this._bufferService.buffer;
- const result: string[] = [];
-
- if (this._activeSelectionMode === SelectionMode.COLUMN) {
- // Ignore zero width selections
- if (start[0] === end[0]) {
- return '';
- }
-
- for (let i = start[1]; i <= end[1]; i++) {
- const lineText = buffer.translateBufferLineToString(i, true, start[0], end[0]);
- result.push(lineText);
- }
- } else {
- // Get first row
- const startRowEndCol = start[1] === end[1] ? end[0] : undefined;
- result.push(buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));
-
- // Get middle rows
- for (let i = start[1] + 1; i <= end[1] - 1; i++) {
- const bufferLine = buffer.lines.get(i);
- const lineText = buffer.translateBufferLineToString(i, true);
- if (bufferLine && bufferLine.isWrapped) {
- result[result.length - 1] += lineText;
- } else {
- result.push(lineText);
- }
- }
-
- // Get final row
- if (start[1] !== end[1]) {
- const bufferLine = buffer.lines.get(end[1]);
- const lineText = buffer.translateBufferLineToString(end[1], true, 0, end[0]);
- if (bufferLine && bufferLine!.isWrapped) {
- result[result.length - 1] += lineText;
- } else {
- result.push(lineText);
- }
- }
- }
-
- // Format string by replacing non-breaking space chars with regular spaces
- // and joining the array into a multi-line string.
- const formattedResult = result.map(line => {
- return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');
- }).join(Browser.isWindows ? '\r\n' : '\n');
-
- return formattedResult;
- }
-
- /**
- * Clears the current terminal selection.
- */
- public clearSelection(): void {
- this._model.clearSelection();
- this._removeMouseDownListeners();
- this.refresh();
- this._onSelectionChange.fire();
- }
-
- /**
- * Queues a refresh, redrawing the selection on the next opportunity.
- * @param isLinuxMouseSelection Whether the selection should be registered as a new
- * selection on Linux.
- */
- public refresh(isLinuxMouseSelection?: boolean): void {
- // Queue the refresh for the renderer
- if (!this._refreshAnimationFrame) {
- this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());
- }
-
- // If the platform is Linux and the refresh call comes from a mouse event,
- // we need to update the selection for middle click to paste selection.
- if (Browser.isLinux && isLinuxMouseSelection) {
- const selectionText = this.selectionText;
- if (selectionText.length) {
- this._onLinuxMouseSelection.fire(this.selectionText);
- }
- }
- }
-
- /**
- * Fires the refresh event, causing consumers to pick it up and redraw the
- * selection state.
- */
- private _refresh(): void {
- this._refreshAnimationFrame = undefined;
- this._onRedrawRequest.fire({
- start: this._model.finalSelectionStart,
- end: this._model.finalSelectionEnd,
- columnSelectMode: this._activeSelectionMode === SelectionMode.COLUMN
- });
- }
-
- /**
- * Checks if the current click was inside the current selection
- * @param event The mouse event
- */
- private _isClickInSelection(event: MouseEvent): boolean {
- const coords = this._getMouseBufferCoords(event);
- const start = this._model.finalSelectionStart;
- const end = this._model.finalSelectionEnd;
-
- if (!start || !end || !coords) {
- return false;
- }
-
- return this._areCoordsInSelection(coords, start, end);
- }
-
- protected _areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean {
- 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]);
- }
-
- /**
- * Selects word at the current mouse event coordinates.
- * @param event The mouse event.
- */
- private _selectWordAtCursor(event: MouseEvent, allowWhitespaceOnlySelection: boolean): boolean {
- // Check if there is a link under the cursor first and select that if so
- const range = this._linkifier.currentLink?.link?.range;
- if (range) {
- this._model.selectionStart = [range.start.x - 1, range.start.y - 1];
- this._model.selectionStartLength = getRangeLength(range, this._bufferService.cols);
- this._model.selectionEnd = undefined;
- return true;
- }
-
- const coords = this._getMouseBufferCoords(event);
- if (coords) {
- this._selectWordAt(coords, allowWhitespaceOnlySelection);
- this._model.selectionEnd = undefined;
- return true;
- }
- return false;
- }
-
- /**
- * Selects all text within the terminal.
- */
- public selectAll(): void {
- this._model.isSelectAllActive = true;
- this.refresh();
- this._onSelectionChange.fire();
- }
-
- public selectLines(start: number, end: number): void {
- this._model.clearSelection();
- start = Math.max(start, 0);
- end = Math.min(end, this._bufferService.buffer.lines.length - 1);
- this._model.selectionStart = [0, start];
- this._model.selectionEnd = [this._bufferService.cols, end];
- this.refresh();
- this._onSelectionChange.fire();
- }
-
- /**
- * Handle the buffer being trimmed, adjust the selection position.
- * @param amount The amount the buffer is being trimmed.
- */
- private _onTrim(amount: number): void {
- const needsRefresh = this._model.onTrim(amount);
- if (needsRefresh) {
- this.refresh();
- }
- }
-
- /**
- * Gets the 0-based [x, y] buffer coordinates of the current mouse event.
- * @param event The mouse event.
- */
- private _getMouseBufferCoords(event: MouseEvent): [number, number] | undefined {
- const coords = this._mouseService.getCoords(event, this._screenElement, this._bufferService.cols, this._bufferService.rows, true);
- if (!coords) {
- return undefined;
- }
-
- // Convert to 0-based
- coords[0]--;
- coords[1]--;
-
- // Convert viewport coords to buffer coords
- coords[1] += this._bufferService.buffer.ydisp;
- return coords;
- }
-
- /**
- * Gets the amount the viewport should be scrolled based on how far out of the
- * terminal the mouse is.
- * @param event The mouse event.
- */
- private _getMouseEventScrollAmount(event: MouseEvent): number {
- let offset = getCoordsRelativeToElement(event, this._screenElement)[1];
- const terminalHeight = this._renderService.dimensions.canvasHeight;
- 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));
- }
-
- /**
- * Returns whether the selection manager should force selection, regardless of
- * whether the terminal is in mouse events mode.
- * @param event The mouse event.
- */
- public shouldForceSelection(event: MouseEvent): boolean {
- if (Browser.isMac) {
- return event.altKey && this._optionsService.options.macOptionClickForcesSelection;
- }
-
- return event.shiftKey;
- }
-
- /**
- * Handles te mousedown event, setting up for a new selection.
- * @param event The mousedown event.
- */
- public onMouseDown(event: MouseEvent): void {
- this._mouseDownTimeStamp = event.timeStamp;
- // If we have selection, we want the context menu on right click even if the
- // terminal is in mouse mode.
- if (event.button === 2 && this.hasSelection) {
- return;
- }
-
- // Only action the primary button
- if (event.button !== 0) {
- return;
- }
-
- // Allow selection when using a specific modifier key, even when disabled
- if (!this._enabled) {
- if (!this.shouldForceSelection(event)) {
- return;
- }
-
- // Don't send the mouse down event to the current process, we want to select
- event.stopPropagation();
- }
-
- // Tell the browser not to start a regular selection
- event.preventDefault();
-
- // Reset drag scroll state
- 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);
- }
-
- /**
- * Adds listeners when mousedown is triggered.
- */
- private _addMouseDownListeners(): void {
- // Listen on the document so that dragging outside of viewport works
- if (this._screenElement.ownerDocument) {
- this._screenElement.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);
- this._screenElement.ownerDocument.addEventListener('mouseup', this._mouseUpListener);
- }
- this._dragScrollIntervalTimer = window.setInterval(() => this._dragScroll(), DRAG_SCROLL_INTERVAL);
- }
-
- /**
- * Removes the listeners that are registered when mousedown is triggered.
- */
- private _removeMouseDownListeners(): void {
- if (this._screenElement.ownerDocument) {
- this._screenElement.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);
- this._screenElement.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);
- }
- clearInterval(this._dragScrollIntervalTimer);
- this._dragScrollIntervalTimer = undefined;
- }
-
- /**
- * Performs an incremental click, setting the selection end position to the mouse
- * position.
- * @param event The mouse event.
- */
- private _onIncrementalClick(event: MouseEvent): void {
- if (this._model.selectionStart) {
- this._model.selectionEnd = this._getMouseBufferCoords(event);
- }
- }
-
- /**
- * Performs a single click, resetting relevant state and setting the selection
- * start position.
- * @param event The mouse event.
- */
- private _onSingleClick(event: MouseEvent): void {
- this._model.selectionStartLength = 0;
- this._model.isSelectAllActive = false;
- this._activeSelectionMode = this.shouldColumnSelect(event) ? SelectionMode.COLUMN : SelectionMode.NORMAL;
-
- // Initialize the new selection
- this._model.selectionStart = this._getMouseBufferCoords(event);
- if (!this._model.selectionStart) {
- return;
- }
- this._model.selectionEnd = undefined;
-
- // Ensure the line exists
- const line = this._bufferService.buffer.lines.get(this._model.selectionStart[1]);
- if (!line) {
- return;
- }
-
- // Return early if the click event is not in the buffer (eg. in scroll bar)
- if (line.length === this._model.selectionStart[0]) {
- return;
- }
-
- // If the mouse is over the second half of a wide character, adjust the
- // selection to cover the whole character
- if (line.hasWidth(this._model.selectionStart[0]) === 0) {
- this._model.selectionStart[0]++;
- }
- }
-
- /**
- * Performs a double click, selecting the current word.
- * @param event The mouse event.
- */
- private _onDoubleClick(event: MouseEvent): void {
- if (this._selectWordAtCursor(event, true)) {
- this._activeSelectionMode = SelectionMode.WORD;
- }
- }
-
- /**
- * Performs a triple click, selecting the current line and activating line
- * select mode.
- * @param event The mouse event.
- */
- private _onTripleClick(event: MouseEvent): void {
- const coords = this._getMouseBufferCoords(event);
- if (coords) {
- this._activeSelectionMode = SelectionMode.LINE;
- this._selectLineAt(coords[1]);
- }
- }
-
- /**
- * Returns whether the selection manager should operate in column select mode
- * @param event the mouse or keyboard event
- */
- public shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean {
- return event.altKey && !(Browser.isMac && this._optionsService.options.macOptionClickForcesSelection);
- }
-
- /**
- * Handles the mousemove event when the mouse button is down, recording the
- * end of the selection and refreshing the selection.
- * @param event The mousemove event.
- */
- private _onMouseMove(event: MouseEvent): void {
- // If the mousemove listener is active it means that a selection is
- // currently being made, we should stop propagation to prevent mouse events
- // to be sent to the pty.
- event.stopImmediatePropagation();
-
- // Do nothing if there is no selection start, this can happen if the first
- // click in the terminal is an incremental click
- if (!this._model.selectionStart) {
- return;
- }
-
- // Record the previous position so we know whether to redraw the selection
- // at the end.
- const previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;
-
- // Set the initial selection end based on the mouse coordinates
- this._model.selectionEnd = this._getMouseBufferCoords(event);
- if (!this._model.selectionEnd) {
- this.refresh(true);
- return;
- }
-
- // Select the entire line if line select mode is active.
- if (this._activeSelectionMode === SelectionMode.LINE) {
- if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {
- this._model.selectionEnd[0] = 0;
- } else {
- this._model.selectionEnd[0] = this._bufferService.cols;
- }
- } else if (this._activeSelectionMode === SelectionMode.WORD) {
- this._selectToWordAt(this._model.selectionEnd);
- }
-
- // Determine the amount of scrolling that will happen.
- this._dragScrollAmount = this._getMouseEventScrollAmount(event);
-
- // If the cursor was above or below the viewport, make sure it's at the
- // start or end of the viewport respectively. This should only happen when
- // NOT in column select mode.
- if (this._activeSelectionMode !== SelectionMode.COLUMN) {
- if (this._dragScrollAmount > 0) {
- this._model.selectionEnd[0] = this._bufferService.cols;
- } else if (this._dragScrollAmount < 0) {
- this._model.selectionEnd[0] = 0;
- }
- }
-
- // If the character is a wide character include the cell to the right in the
- // selection. Note that selections at the very end of the line will never
- // have a character.
- const buffer = this._bufferService.buffer;
- if (this._model.selectionEnd[1] < buffer.lines.length) {
- const line = buffer.lines.get(this._model.selectionEnd[1]);
- if (line && line.hasWidth(this._model.selectionEnd[0]) === 0) {
- this._model.selectionEnd[0]++;
- }
- }
-
- // Only draw here if the selection changes.
- if (!previousSelectionEnd ||
- previousSelectionEnd[0] !== this._model.selectionEnd[0] ||
- previousSelectionEnd[1] !== this._model.selectionEnd[1]) {
- this.refresh(true);
- }
- }
-
- /**
- * The callback that occurs every DRAG_SCROLL_INTERVAL ms that does the
- * scrolling of the viewport.
- */
- private _dragScroll(): void {
- if (!this._model.selectionEnd || !this._model.selectionStart) {
- return;
- }
- if (this._dragScrollAmount) {
- this._onRequestScrollLines.fire({ amount: this._dragScrollAmount, suppressScrollEvent: false });
- // Re-evaluate selection
- // If the cursor was above or below the viewport, make sure it's at the
- // start or end of the viewport respectively. This should only happen when
- // NOT in column select mode.
- const buffer = this._bufferService.buffer;
- if (this._dragScrollAmount > 0) {
- if (this._activeSelectionMode !== SelectionMode.COLUMN) {
- this._model.selectionEnd[0] = this._bufferService.cols;
- }
- this._model.selectionEnd[1] = Math.min(buffer.ydisp + this._bufferService.rows, buffer.lines.length - 1);
- } else {
- if (this._activeSelectionMode !== SelectionMode.COLUMN) {
- this._model.selectionEnd[0] = 0;
- }
- this._model.selectionEnd[1] = buffer.ydisp;
- }
- this.refresh();
- }
- }
-
- /**
- * Handles the mouseup event, removing the mousedown listeners.
- * @param event The mouseup event.
- */
- private _onMouseUp(event: MouseEvent): void {
- const timeElapsed = event.timeStamp - this._mouseDownTimeStamp;
-
- this._removeMouseDownListeners();
-
- if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.getOption('altClickMovesCursor')) {
- if (this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) {
- const coordinates = this._mouseService.getCoords(
- event,
- this._element,
- this._bufferService.cols,
- this._bufferService.rows,
- false
- );
- if (coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) {
- const sequence = moveToCellSequence(coordinates[0] - 1, coordinates[1] - 1, this._bufferService, this._coreService.decPrivateModes.applicationCursorKeys);
- this._coreService.triggerDataEvent(sequence, true);
- }
- }
- } else {
- this._fireEventIfSelectionChanged();
- }
- }
-
- private _fireEventIfSelectionChanged(): void {
- const start = this._model.finalSelectionStart;
- const end = this._model.finalSelectionEnd;
- const hasSelection = !!start && !!end && (start[0] !== end[0] || start[1] !== end[1]);
-
- if (!hasSelection) {
- if (this._oldHasSelection) {
- this._fireOnSelectionChange(start, end, hasSelection);
- }
- return;
- }
-
- // Sanity check, these should not be undefined as there is a selection
- if (!start || !end) {
- return;
- }
-
- if (!this._oldSelectionStart || !this._oldSelectionEnd || (
- start[0] !== this._oldSelectionStart[0] || start[1] !== this._oldSelectionStart[1] ||
- end[0] !== this._oldSelectionEnd[0] || end[1] !== this._oldSelectionEnd[1])) {
-
- this._fireOnSelectionChange(start, end, hasSelection);
- }
- }
-
- private _fireOnSelectionChange(start: [number, number] | undefined, end: [number, number] | undefined, hasSelection: boolean): void {
- this._oldSelectionStart = start;
- this._oldSelectionEnd = end;
- this._oldHasSelection = hasSelection;
- this._onSelectionChange.fire();
- }
-
- private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {
- this.clearSelection();
- // Only adjust the selection on trim, shiftElements is rarely used (only in
- // reverseIndex) and delete in a splice is only ever used when the same
- // number of elements was just added. Given this is could actually be
- // beneficial to leave the selection as is for these cases.
- this._trimListener.dispose();
- this._trimListener = e.activeBuffer.lines.onTrim(amount => this._onTrim(amount));
- }
-
- /**
- * Converts a viewport column to the character index on the buffer line, the
- * latter takes into account wide characters.
- * @param coords The coordinates to find the 2 index for.
- */
- private _convertViewportColToCharacterIndex(bufferLine: IBufferLine, coords: [number, number]): number {
- let charIndex = coords[0];
- for (let i = 0; coords[0] >= i; i++) {
- const length = bufferLine.loadCell(i, this._workCell).getChars().length;
- if (this._workCell.getWidth() === 0) {
- // Wide characters aren't included in the line string so decrement the
- // index so the index is back on the wide character.
- charIndex--;
- } else if (length > 1 && coords[0] !== i) {
- // Emojis take up multiple characters, so adjust accordingly. For these
- // we don't want ot include the character at the column as we're
- // returning the start index in the string, not the end index.
- charIndex += length - 1;
- }
- }
- return charIndex;
- }
-
- public setSelection(col: number, row: number, length: number): void {
- this._model.clearSelection();
- this._removeMouseDownListeners();
- this._model.selectionStart = [col, row];
- this._model.selectionStartLength = length;
- this.refresh();
- }
-
- public rightClickSelect(ev: MouseEvent): void {
- if (!this._isClickInSelection(ev)) {
- if (this._selectWordAtCursor(ev, false)) {
- this.refresh(true);
- }
- this._fireEventIfSelectionChanged();
- }
- }
-
- /**
- * Gets positional information for the word at the coordinated specified.
- * @param coords The coordinates to get the word at.
- */
- private _getWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean, followWrappedLinesAbove: boolean = true, followWrappedLinesBelow: boolean = true): IWordPosition | undefined {
- // Ensure coords are within viewport (eg. not within scroll bar)
- if (coords[0] >= this._bufferService.cols) {
- return undefined;
- }
-
- const buffer = this._bufferService.buffer;
- const bufferLine = buffer.lines.get(coords[1]);
- if (!bufferLine) {
- return undefined;
- }
-
- const line = buffer.translateBufferLineToString(coords[1], false);
-
- // Get actual index, taking into consideration wide characters
- let startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);
- let endIndex = startIndex;
-
- // Record offset to be used later
- const charOffset = coords[0] - startIndex;
- let leftWideCharCount = 0;
- let rightWideCharCount = 0;
- let leftLongCharOffset = 0;
- let rightLongCharOffset = 0;
-
- if (line.charAt(startIndex) === ' ') {
- // Expand until non-whitespace is hit
- while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {
- startIndex--;
- }
- while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {
- endIndex++;
- }
- } else {
- // Expand until whitespace is hit. This algorithm works by scanning left
- // and right from the starting position, keeping both the index format
- // (line) and the column format (bufferLine) in sync. When a wide
- // character is hit, it is recorded and the column index is adjusted.
- let startCol = coords[0];
- let endCol = coords[0];
-
- // Consider the initial position, skip it and increment the wide char
- // variable
- if (bufferLine.getWidth(startCol) === 0) {
- leftWideCharCount++;
- startCol--;
- }
- if (bufferLine.getWidth(endCol) === 2) {
- rightWideCharCount++;
- endCol++;
- }
-
- // Adjust the end index for characters whose length are > 1 (emojis)
- const length = bufferLine.getString(endCol).length;
- if (length > 1) {
- rightLongCharOffset += length - 1;
- endIndex += length - 1;
- }
-
- // Expand the string in both directions until a space is hit
- while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine.loadCell(startCol - 1, this._workCell))) {
- bufferLine.loadCell(startCol - 1, this._workCell);
- const length = this._workCell.getChars().length;
- if (this._workCell.getWidth() === 0) {
- // If the next character is a wide char, record it and skip the column
- leftWideCharCount++;
- startCol--;
- } else if (length > 1) {
- // If the next character's string is longer than 1 char (eg. emoji),
- // adjust the index
- leftLongCharOffset += length - 1;
- startIndex -= length - 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);
- const length = this._workCell.getChars().length;
- if (this._workCell.getWidth() === 2) {
- // If the next character is a wide char, record it and skip the column
- rightWideCharCount++;
- endCol++;
- } else if (length > 1) {
- // If the next character's string is longer than 1 char (eg. emoji),
- // adjust the index
- rightLongCharOffset += length - 1;
- endIndex += length - 1;
- }
- endIndex++;
- endCol++;
- }
- }
-
- // Incremenet the end index so it is at the start of the next character
- endIndex++;
-
- // Calculate the start _column_, converting the the string indexes back to
- // column coordinates.
- let start =
- startIndex // The index of the selection's start char in the line string
- + charOffset // The difference between the initial char's column and index
- - leftWideCharCount // The number of wide chars left of the initial char
- + leftLongCharOffset; // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)
-
- // Calculate the length in _columns_, converting the the string indexes back
- // to column coordinates.
- let length = Math.min(this._bufferService.cols, // Disallow lengths larger than the terminal cols
- endIndex // The index of the selection's end char in the line string
- - startIndex // The index of the selection's start char in the line string
- + leftWideCharCount // The number of wide chars left of the initial char
- + rightWideCharCount // The number of wide chars right of the initial char (inclusive)
- - leftLongCharOffset // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)
- - rightLongCharOffset); // The number of additional chars right of the initial char (inclusive) added by columns with strings longer than 1 (emojis)
-
- if (!allowWhitespaceOnlySelection && line.slice(startIndex, endIndex).trim() === '') {
- return undefined;
- }
-
- // Recurse upwards if the line is wrapped and the word wraps to the above line
- if (followWrappedLinesAbove) {
- if (start === 0 && bufferLine.getCodePoint(0) !== 32 /* ' ' */) {
- const previousBufferLine = buffer.lines.get(coords[1] - 1);
- if (previousBufferLine && bufferLine.isWrapped && previousBufferLine.getCodePoint(this._bufferService.cols - 1) !== 32 /* ' ' */) {
- const previousLineWordPosition = this._getWordAt([this._bufferService.cols - 1, coords[1] - 1], false, true, false);
- if (previousLineWordPosition) {
- const offset = this._bufferService.cols - previousLineWordPosition.start;
- start -= offset;
- length += offset;
- }
- }
- }
- }
-
- // Recurse downwards if the line is wrapped and the word wraps to the next line
- if (followWrappedLinesBelow) {
- if (start + length === this._bufferService.cols && bufferLine.getCodePoint(this._bufferService.cols - 1) !== 32 /* ' ' */) {
- const nextBufferLine = buffer.lines.get(coords[1] + 1);
- if (nextBufferLine && nextBufferLine.isWrapped && nextBufferLine.getCodePoint(0) !== 32 /* ' ' */) {
- const nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true);
- if (nextLineWordPosition) {
- length += nextLineWordPosition.length;
- }
- }
- }
- }
-
- return { start, length };
- }
-
- /**
- * Selects the word at the coordinates specified.
- * @param coords The coordinates to get the word at.
- * @param allowWhitespaceOnlySelection If whitespace should be selected
- */
- protected _selectWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean): void {
- const wordPosition = this._getWordAt(coords, allowWhitespaceOnlySelection);
- if (wordPosition) {
- // Adjust negative start value
- while (wordPosition.start < 0) {
- wordPosition.start += this._bufferService.cols;
- coords[1]--;
- }
- this._model.selectionStart = [wordPosition.start, coords[1]];
- this._model.selectionStartLength = wordPosition.length;
- }
- }
-
- /**
- * Sets the selection end to the word at the coordinated specified.
- * @param coords The coordinates to get the word at.
- */
- private _selectToWordAt(coords: [number, number]): void {
- const wordPosition = this._getWordAt(coords, true);
- if (wordPosition) {
- let endRow = coords[1];
-
- // Adjust negative start value
- while (wordPosition.start < 0) {
- wordPosition.start += this._bufferService.cols;
- endRow--;
- }
-
- // Adjust wrapped length value, this only needs to happen when values are reversed as in that
- // case we're interested in the start of the word, not the end
- if (!this._model.areSelectionValuesReversed()) {
- while (wordPosition.start + wordPosition.length > this._bufferService.cols) {
- wordPosition.length -= this._bufferService.cols;
- endRow++;
- }
- }
-
- this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : wordPosition.start + wordPosition.length, endRow];
- }
- }
-
- /**
- * Gets whether the character is considered a word separator by the select
- * word logic.
- * @param char The character to check.
- */
- private _isCharWordSeparator(cell: CellData): boolean {
- // Zero width characters are never separators as they are always to the
- // right of wide characters
- if (cell.getWidth() === 0) {
- return false;
- }
- return this._optionsService.options.wordSeparator.indexOf(cell.getChars()) >= 0;
- }
-
- /**
- * Selects the line specified.
- * @param line The line index.
- */
- protected _selectLineAt(line: number): void {
- const wrappedRange = this._bufferService.buffer.getWrappedRangeForLine(line);
- this._model.selectionStart = [0, wrappedRange.first];
- this._model.selectionEnd = [this._bufferService.cols, wrappedRange.last];
- this._model.selectionStartLength = 0;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/Services.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/Services.ts
deleted file mode 100644
index 8c8a7bd9..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/Services.ts
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IEvent } from 'common/EventEmitter';
-import { IRenderDimensions, IRenderer } from 'browser/renderer/Types';
-import { IColorSet } from 'browser/Types';
-import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
-import { createDecorator } from 'common/services/ServiceRegistry';
-import { IDisposable } from 'common/Types';
-
-export const ICharSizeService = createDecorator('CharSizeService');
-export interface ICharSizeService {
- serviceBrand: undefined;
-
- readonly width: number;
- readonly height: number;
- readonly hasValidSize: boolean;
-
- readonly onCharSizeChange: IEvent;
-
- measure(): void;
-}
-
-export const ICoreBrowserService = createDecorator('CoreBrowserService');
-export interface ICoreBrowserService {
- serviceBrand: undefined;
-
- readonly isFocused: boolean;
-}
-
-export const IMouseService = createDecorator('MouseService');
-export interface IMouseService {
- serviceBrand: undefined;
-
- getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, isSelection?: boolean): [number, number] | undefined;
- getRawByteCoords(event: MouseEvent, element: HTMLElement, colCount: number, rowCount: number): { x: number, y: number } | undefined;
-}
-
-export const IRenderService = createDecorator('RenderService');
-export interface IRenderService extends IDisposable {
- serviceBrand: undefined;
-
- onDimensionsChange: IEvent;
- /**
- * Fires when buffer changes are rendered. This does not fire when only cursor
- * or selections are rendered.
- */
- onRenderedBufferChange: IEvent<{ start: number, end: number }>;
- onRefreshRequest: IEvent<{ start: number, end: number }>;
-
- dimensions: IRenderDimensions;
-
- refreshRows(start: number, end: number): void;
- resize(cols: number, rows: number): void;
- changeOptions(): void;
- setRenderer(renderer: IRenderer): void;
- setColors(colors: IColorSet): void;
- onDevicePixelRatioChange(): void;
- onResize(cols: number, rows: number): void;
- // TODO: Is this useful when we have onResize?
- onCharSizeChanged(): void;
- onBlur(): void;
- onFocus(): void;
- onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
- onCursorMove(): void;
- clear(): void;
-}
-
-export const ISelectionService = createDecorator('SelectionService');
-export interface ISelectionService {
- serviceBrand: undefined;
-
- readonly selectionText: string;
- readonly hasSelection: boolean;
- readonly selectionStart: [number, number] | undefined;
- readonly selectionEnd: [number, number] | undefined;
-
- readonly onLinuxMouseSelection: IEvent;
- readonly onRequestRedraw: IEvent;
- readonly onRequestScrollLines: IEvent;
- readonly onSelectionChange: IEvent;
-
- disable(): void;
- enable(): void;
- reset(): void;
- setSelection(row: number, col: number, length: number): void;
- selectAll(): void;
- selectLines(start: number, end: number): void;
- clearSelection(): void;
- rightClickSelect(event: MouseEvent): void;
- shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean;
- shouldForceSelection(event: MouseEvent): boolean;
- refresh(isLinuxMouseSelection?: boolean): void;
- onMouseDown(event: MouseEvent): void;
-}
-
-export const ISoundService = createDecorator('SoundService');
-export interface ISoundService {
- serviceBrand: undefined;
-
- playBellSound(): void;
-}
-
-
-export const ICharacterJoinerService = createDecorator('CharacterJoinerService');
-export interface ICharacterJoinerService {
- serviceBrand: undefined;
-
- register(handler: (text: string) => [number, number][]): number;
- deregister(joinerId: number): boolean;
- getJoinedCharacters(row: number): [number, number][];
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/SoundService.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/SoundService.ts
deleted file mode 100644
index 3880b42d..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/services/SoundService.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2018 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IOptionsService } from 'common/services/Services';
-import { ISoundService } from 'browser/services/Services';
-
-export class SoundService implements ISoundService {
- public serviceBrand: undefined;
-
- private static _audioContext: AudioContext;
-
- public static get audioContext(): AudioContext | null {
- if (!SoundService._audioContext) {
- const audioContextCtor: typeof AudioContext = (window as any).AudioContext || (window as any).webkitAudioContext;
- if (!audioContextCtor) {
- console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');
- return null;
- }
- SoundService._audioContext = new audioContextCtor();
- }
- return SoundService._audioContext;
- }
-
- constructor(
- @IOptionsService private _optionsService: IOptionsService
- ) {
- }
-
- public playBellSound(): void {
- const ctx = SoundService.audioContext;
- if (!ctx) {
- return;
- }
- const bellAudioSource = ctx.createBufferSource();
- ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.options.bellSound)), (buffer) => {
- bellAudioSource.buffer = buffer;
- bellAudioSource.connect(ctx.destination);
- bellAudioSource.start(0);
- });
- }
-
- private _base64ToArrayBuffer(base64: string): ArrayBuffer {
- const binaryString = window.atob(base64);
- const len = binaryString.length;
- const bytes = new Uint8Array(len);
-
- for (let i = 0; i < len; i++) {
- bytes[i] = binaryString.charCodeAt(i);
- }
-
- return bytes.buffer;
- }
-
- private _removeMimeType(dataURI: string): string {
- // Split the input to get the mime-type and the data itself
- const splitUri = dataURI.split(',');
-
- // Return only the data
- return splitUri[1];
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/tsconfig.json b/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/tsconfig.json
deleted file mode 100644
index 212aeab8..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/browser/tsconfig.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "extends": "../tsconfig-library-base",
- "compilerOptions": {
- "lib": [
- "dom",
- "es2015",
- "es2016.Array.Include"
- ],
- "outDir": "../../out",
- "types": [
- "../../node_modules/@types/mocha"
- ],
- "baseUrl": "..",
- "paths": {
- "common/*": [ "./common/*" ]
- }
- },
- "include": [
- "./**/*",
- "../../typings/xterm.d.ts"
- ],
- "references": [
- { "path": "../common" }
- ]
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/CircularList.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/common/CircularList.ts
deleted file mode 100644
index 4d2c04ec..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/CircularList.ts
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- * Copyright (c) 2016 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { ICircularList } from 'common/Types';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-
-export interface IInsertEvent {
- index: number;
- amount: number;
-}
-
-export interface IDeleteEvent {
- index: number;
- amount: number;
-}
-
-/**
- * Represents a circular list; a list with a maximum size that wraps around when push is called,
- * overriding values at the start of the list.
- */
-export class CircularList implements ICircularList {
- protected _array: (T | undefined)[];
- private _startIndex: number;
- private _length: number;
-
- public onDeleteEmitter = new EventEmitter();
- public get onDelete(): IEvent { return this.onDeleteEmitter.event; }
- public onInsertEmitter = new EventEmitter();
- public get onInsert(): IEvent { return this.onInsertEmitter.event; }
- public onTrimEmitter = new EventEmitter();
- public get onTrim(): IEvent { return this.onTrimEmitter.event; }
-
- constructor(
- private _maxLength: number
- ) {
- this._array = new Array(this._maxLength);
- this._startIndex = 0;
- this._length = 0;
- }
-
- public get maxLength(): number {
- return this._maxLength;
- }
-
- public set maxLength(newMaxLength: number) {
- // There was no change in maxLength, return early.
- if (this._maxLength === newMaxLength) {
- return;
- }
-
- // Reconstruct array, starting at index 0. Only transfer values from the
- // indexes 0 to length.
- const newArray = new Array(newMaxLength);
- for (let 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;
- }
-
- public get length(): number {
- return this._length;
- }
-
- public set length(newLength: number) {
- if (newLength > this._length) {
- for (let i = this._length; i < newLength; i++) {
- this._array[i] = undefined;
- }
- }
- this._length = newLength;
- }
-
- /**
- * Gets the value at an index.
- *
- * Note that for performance reasons there is no bounds checking here, the index reference is
- * circular so this should always return a value and never throw.
- * @param index The index of the value to get.
- * @return The value corresponding to the index.
- */
- public get(index: number): T | undefined {
- return this._array[this._getCyclicIndex(index)];
- }
-
- /**
- * Sets the value at an index.
- *
- * Note that for performance reasons there is no bounds checking here, the index reference is
- * circular so this should always return a value and never throw.
- * @param index The index to set.
- * @param value The value to set.
- */
- public set(index: number, value: T | undefined): void {
- this._array[this._getCyclicIndex(index)] = value;
- }
-
- /**
- * Pushes a new value onto the list, wrapping around to the start of the array, overriding index 0
- * if the maximum length is reached.
- * @param value The value to push onto the list.
- */
- public push(value: T): void {
- 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++;
- }
- }
-
- /**
- * Advance ringbuffer index and return current element for recycling.
- * Note: The buffer must be full for this method to work.
- * @throws When the buffer is not full.
- */
- public recycle(): T {
- 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)]!;
- }
-
- /**
- * Ringbuffer is at max length.
- */
- public get isFull(): boolean {
- return this._length === this._maxLength;
- }
-
- /**
- * Removes and returns the last value on the list.
- * @return The popped value.
- */
- public pop(): T | undefined {
- return this._array[this._getCyclicIndex(this._length-- - 1)];
- }
-
- /**
- * Deletes and/or inserts items at a particular index (in that order). Unlike
- * Array.prototype.splice, this operation does not return the deleted items as a new array in
- * order to save creating a new array. Note that this operation may shift all values in the list
- * in the worst case.
- * @param start The index to delete and/or insert.
- * @param deleteCount The number of elements to delete.
- * @param items The items to insert.
- */
- public splice(start: number, deleteCount: number, ...items: T[]): void {
- // Delete items
- if (deleteCount) {
- for (let i = start; i < this._length - deleteCount; i++) {
- this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];
- }
- this._length -= deleteCount;
- this.onDeleteEmitter.fire({ index: start, amount: deleteCount });
- }
-
- // Add items
- for (let i = this._length - 1; i >= start; i--) {
- this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
- }
- for (let i = 0; i < items.length; i++) {
- this._array[this._getCyclicIndex(start + i)] = items[i];
- }
- if (items.length) {
- this.onInsertEmitter.fire({ index: start, amount: items.length });
- }
-
- // Adjust length as needed
- if (this._length + items.length > this._maxLength) {
- const countToTrim = (this._length + items.length) - this._maxLength;
- this._startIndex += countToTrim;
- this._length = this._maxLength;
- this.onTrimEmitter.fire(countToTrim);
- } else {
- this._length += items.length;
- }
- }
-
- /**
- * Trims a number of items from the start of the list.
- * @param count The number of items to remove.
- */
- public trimStart(count: number): void {
- if (count > this._length) {
- count = this._length;
- }
- this._startIndex += count;
- this._length -= count;
- this.onTrimEmitter.fire(count);
- }
-
- public shiftElements(start: number, count: number, offset: number): void {
- 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 (let i = count - 1; i >= 0; i--) {
- this.set(start + i + offset, this.get(start + i));
- }
- const 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 (let i = 0; i < count; i++) {
- this.set(start + i + offset, this.get(start + i));
- }
- }
- }
-
- /**
- * Gets the cyclic index for the specified regular index. The cyclic index can then be used on the
- * backing array to get the element associated with the regular index.
- * @param index The regular index.
- * @returns The cyclic index.
- */
- private _getCyclicIndex(index: number): number {
- return (this._startIndex + index) % this._maxLength;
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/Clone.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/common/Clone.ts
deleted file mode 100644
index 37821fe0..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/Clone.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (c) 2016 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-/*
- * A simple utility for cloning values
- */
-export function clone(val: T, depth: number = 5): T {
- if (typeof val !== 'object') {
- return val;
- }
-
- // If we're cloning an array, use an array as the base, otherwise use an object
- const clonedObject: any = Array.isArray(val) ? [] : {};
-
- for (const key in val) {
- // Recursively clone eack item unless we're at the maximum depth
- clonedObject[key] = depth <= 1 ? val[key] : (val[key] && clone(val[key], depth - 1));
- }
-
- return clonedObject as T;
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/CoreTerminal.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/common/CoreTerminal.ts
deleted file mode 100644
index 96a4b53d..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/CoreTerminal.ts
+++ /dev/null
@@ -1,291 +0,0 @@
-/**
- * Copyright (c) 2014-2020 The xterm.js authors. All rights reserved.
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
- * @license MIT
- *
- * 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.
- *
- * Terminal Emulation References:
- * http://vt100.net/
- * http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
- * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- * http://invisible-island.net/vttest/
- * http://www.inwap.com/pdp10/ansicode.txt
- * http://linux.die.net/man/4/console_codes
- * http://linux.die.net/man/7/urxvt
- */
-
-import { Disposable } from 'common/Lifecycle';
-import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, IDirtyRowService, LogLevelEnum } from 'common/services/Services';
-import { InstantiationService } from 'common/services/InstantiationService';
-import { LogService } from 'common/services/LogService';
-import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
-import { OptionsService } from 'common/services/OptionsService';
-import { ITerminalOptions, IDisposable, IBufferLine, IAttributeData, ICoreTerminal, IKeyboardEvent, IScrollEvent, ScrollSource } from 'common/Types';
-import { CoreService } from 'common/services/CoreService';
-import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
-import { CoreMouseService } from 'common/services/CoreMouseService';
-import { DirtyRowService } from 'common/services/DirtyRowService';
-import { UnicodeService } from 'common/services/UnicodeService';
-import { CharsetService } from 'common/services/CharsetService';
-import { updateWindowsModeWrappedState } from 'common/WindowsMode';
-import { IFunctionIdentifier, IParams } from 'common/parser/Types';
-import { IBufferSet } from 'common/buffer/Types';
-import { InputHandler } from 'common/InputHandler';
-import { WriteBuffer } from 'common/input/WriteBuffer';
-
-// Only trigger this warning a single time per session
-let hasWriteSyncWarnHappened = false;
-
-export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
- protected readonly _instantiationService: IInstantiationService;
- protected readonly _bufferService: IBufferService;
- protected readonly _logService: ILogService;
- protected readonly _charsetService: ICharsetService;
- protected readonly _dirtyRowService: IDirtyRowService;
-
- public readonly coreMouseService: ICoreMouseService;
- public readonly coreService: ICoreService;
- public readonly unicodeService: IUnicodeService;
- public readonly optionsService: IOptionsService;
-
- protected _inputHandler: InputHandler;
- private _writeBuffer: WriteBuffer;
- private _windowsMode: IDisposable | undefined;
-
- private _onBinary = new EventEmitter();
- public get onBinary(): IEvent { return this._onBinary.event; }
- private _onData = new EventEmitter();
- public get onData(): IEvent { return this._onData.event; }
- protected _onLineFeed = new EventEmitter();
- public get onLineFeed(): IEvent { return this._onLineFeed.event; }
- private _onResize = new EventEmitter<{ cols: number, rows: number }>();
- public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
- protected _onScroll = new EventEmitter();
- /**
- * Internally we track the source of the scroll but this is meaningless outside the library so
- * it's filtered out.
- */
- protected _onScrollApi?: EventEmitter;
- public get onScroll(): IEvent {
- if (!this._onScrollApi) {
- this._onScrollApi = new EventEmitter();
- this.register(this._onScroll.event(ev => {
- this._onScrollApi?.fire(ev.position);
- }));
- }
- return this._onScrollApi.event;
- }
-
- public get cols(): number { return this._bufferService.cols; }
- public get rows(): number { return this._bufferService.rows; }
- public get buffers(): IBufferSet { return this._bufferService.buffers; }
-
- constructor(
- options: ITerminalOptions
- ) {
- super();
-
- // Setup and initialize services
- this._instantiationService = new InstantiationService();
- this.optionsService = new OptionsService(options);
- this._instantiationService.setService(IOptionsService, this.optionsService);
- this._bufferService = this.register(this._instantiationService.createInstance(BufferService));
- this._instantiationService.setService(IBufferService, this._bufferService);
- this._logService = this._instantiationService.createInstance(LogService);
- this._instantiationService.setService(ILogService, this._logService);
- this.coreService = this.register(this._instantiationService.createInstance(CoreService, () => this.scrollToBottom()));
- this._instantiationService.setService(ICoreService, this.coreService);
- this.coreMouseService = this._instantiationService.createInstance(CoreMouseService);
- this._instantiationService.setService(ICoreMouseService, this.coreMouseService);
- this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService);
- this._instantiationService.setService(IDirtyRowService, this._dirtyRowService);
- this.unicodeService = this._instantiationService.createInstance(UnicodeService);
- this._instantiationService.setService(IUnicodeService, this.unicodeService);
- this._charsetService = this._instantiationService.createInstance(CharsetService);
- this._instantiationService.setService(ICharsetService, this._charsetService);
-
- // Register input handler and handle/forward events
- this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this.coreService, this._dirtyRowService, this._logService, this.optionsService, this.coreMouseService, this.unicodeService);
- this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed));
- this.register(this._inputHandler);
-
- // Setup listeners
- this.register(forwardEvent(this._bufferService.onResize, this._onResize));
- this.register(forwardEvent(this.coreService.onData, this._onData));
- this.register(forwardEvent(this.coreService.onBinary, this._onBinary));
- this.register(this.optionsService.onOptionChange(key => this._updateOptions(key)));
- this.register(this._bufferService.onScroll(event => {
- this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL });
- this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
- }));
- this.register(this._inputHandler.onScroll(event => {
- this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL });
- this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
- }));
-
- // Setup WriteBuffer
- this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult));
- }
-
- public dispose(): void {
- if (this._isDisposed) {
- return;
- }
- super.dispose();
- this._windowsMode?.dispose();
- this._windowsMode = undefined;
- }
-
- public write(data: string | Uint8Array, callback?: () => void): void {
- this._writeBuffer.write(data, callback);
- }
-
- /**
- * Write data to terminal synchonously.
- *
- * This method is unreliable with async parser handlers, thus should not
- * be used anymore. If you need blocking semantics on data input consider
- * `write` with a callback instead.
- *
- * @deprecated Unreliable, will be removed soon.
- */
- public writeSync(data: string | Uint8Array, maxSubsequentCalls?: number): void {
- if (this._logService.logLevel <= LogLevelEnum.WARN && !hasWriteSyncWarnHappened) {
- this._logService.warn('writeSync is unreliable and will be removed soon.');
- hasWriteSyncWarnHappened = true;
- }
- this._writeBuffer.writeSync(data, maxSubsequentCalls);
- }
-
- public resize(x: number, y: number): void {
- if (isNaN(x) || isNaN(y)) {
- return;
- }
-
- x = Math.max(x, MINIMUM_COLS);
- y = Math.max(y, MINIMUM_ROWS);
-
- this._bufferService.resize(x, y);
- }
-
- /**
- * Scroll the terminal down 1 row, creating a blank line.
- * @param isWrapped Whether the new line is wrapped from the previous line.
- */
- public scroll(eraseAttr: IAttributeData, isWrapped: boolean = false): void {
- this._bufferService.scroll(eraseAttr, isWrapped);
- }
-
- /**
- * Scroll the display of the terminal
- * @param disp The number of lines to scroll down (negative scroll up).
- * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used
- * to avoid unwanted events being handled by the viewport when the event was triggered from the
- * viewport originally.
- */
- public scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void {
- this._bufferService.scrollLines(disp, suppressScrollEvent, source);
- }
-
- /**
- * Scroll the display of the terminal by a number of pages.
- * @param pageCount The number of pages to scroll (negative scrolls up).
- */
- public scrollPages(pageCount: number): void {
- this._bufferService.scrollPages(pageCount);
- }
-
- /**
- * Scrolls the display of the terminal to the top.
- */
- public scrollToTop(): void {
- this._bufferService.scrollToTop();
- }
-
- /**
- * Scrolls the display of the terminal to the bottom.
- */
- public scrollToBottom(): void {
- this._bufferService.scrollToBottom();
- }
-
- public scrollToLine(line: number): void {
- this._bufferService.scrollToLine(line);
- }
-
- /** Add handler for ESC escape sequence. See xterm.d.ts for details. */
- public registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable {
- return this._inputHandler.registerEscHandler(id, callback);
- }
-
- /** Add handler for DCS escape sequence. See xterm.d.ts for details. */
- public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable {
- return this._inputHandler.registerDcsHandler(id, callback);
- }
-
- /** Add handler for CSI escape sequence. See xterm.d.ts for details. */
- public registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable {
- return this._inputHandler.registerCsiHandler(id, callback);
- }
-
- /** Add handler for OSC escape sequence. See xterm.d.ts for details. */
- public registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable {
- return this._inputHandler.registerOscHandler(ident, callback);
- }
-
- protected _setup(): void {
- if (this.optionsService.options.windowsMode) {
- this._enableWindowsMode();
- }
- }
-
- public reset(): void {
- this._inputHandler.reset();
- this._bufferService.reset();
- this._charsetService.reset();
- this.coreService.reset();
- this.coreMouseService.reset();
- }
-
- protected _updateOptions(key: string): void {
- // TODO: These listeners should be owned by individual components
- switch (key) {
- case 'scrollback':
- this.buffers.resize(this.cols, this.rows);
- break;
- case 'windowsMode':
- if (this.optionsService.options.windowsMode) {
- this._enableWindowsMode();
- } else {
- this._windowsMode?.dispose();
- this._windowsMode = undefined;
- }
- break;
- }
- }
-
- protected _enableWindowsMode(): void {
- if (!this._windowsMode) {
- const disposables: IDisposable[] = [];
- disposables.push(this.onLineFeed(updateWindowsModeWrappedState.bind(null, this._bufferService)));
- disposables.push(this.registerCsiHandler({ final: 'H' }, () => {
- updateWindowsModeWrappedState(this._bufferService);
- return false;
- }));
- this._windowsMode = {
- dispose: () => {
- for (const d of disposables) {
- d.dispose();
- }
- }
- };
- }
- }
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/EventEmitter.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/common/EventEmitter.ts
deleted file mode 100644
index 4684809f..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/EventEmitter.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2019 The xterm.js authors. All rights reserved.
- * @license MIT
- */
-
-import { IDisposable } from 'common/Types';
-
-interface IListener {
- (arg1: T, arg2: U): void;
-}
-
-export interface IEvent {
- (listener: (arg1: T, arg2: U) => any): IDisposable;
-}
-
-export interface IEventEmitter {
- event: IEvent;
- fire(arg1: T, arg2: U): void;
- dispose(): void;
-}
-
-export class EventEmitter implements IEventEmitter {
- private _listeners: IListener[] = [];
- private _event?: IEvent;
- private _disposed: boolean = false;
-
- public get event(): IEvent {
- if (!this._event) {
- this._event = (listener: (arg1: T, arg2: U) => any) => {
- this._listeners.push(listener);
- const disposable = {
- dispose: () => {
- if (!this._disposed) {
- for (let i = 0; i < this._listeners.length; i++) {
- if (this._listeners[i] === listener) {
- this._listeners.splice(i, 1);
- return;
- }
- }
- }
- }
- };
- return disposable;
- };
- }
- return this._event;
- }
-
- public fire(arg1: T, arg2: U): void {
- const queue: IListener[] = [];
- for (let i = 0; i < this._listeners.length; i++) {
- queue.push(this._listeners[i]);
- }
- for (let i = 0; i < queue.length; i++) {
- queue[i].call(undefined, arg1, arg2);
- }
- }
-
- public dispose(): void {
- if (this._listeners) {
- this._listeners.length = 0;
- }
- this._disposed = true;
- }
-}
-
-export function forwardEvent(from: IEvent, to: IEventEmitter): IDisposable {
- return from(e => to.fire(e));
-}
diff --git a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/InputHandler.ts b/meerschaum/api/resources/static/js/node_modules/xterm/src/common/InputHandler.ts
deleted file mode 100644
index f2f0d0ce..00000000
--- a/meerschaum/api/resources/static/js/node_modules/xterm/src/common/InputHandler.ts
+++ /dev/null
@@ -1,3091 +0,0 @@
-/**
- * Copyright (c) 2014 The xterm.js authors. All rights reserved.
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
- * @license MIT
- */
-
-import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IAnsiColorChangeEvent, IParseStack } from 'common/Types';
-import { C0, C1 } from 'common/data/EscapeSequences';
-import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets';
-import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser';
-import { Disposable } from 'common/Lifecycle';
-import { concat } from 'common/TypedArrayUtils';
-import { StringToUtf32, stringFromCodePoint, utf32ToString, Utf8ToUtf32 } from 'common/input/TextDecoder';
-import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
-import { EventEmitter, IEvent } from 'common/EventEmitter';
-import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IFunctionIdentifier } from 'common/parser/Types';
-import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content, UnderlineStyle } from 'common/buffer/Constants';
-import { CellData } from 'common/buffer/CellData';
-import { AttributeData } from 'common/buffer/AttributeData';
-import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, LogLevelEnum } from 'common/services/Services';
-import { OscHandler } from 'common/parser/OscParser';
-import { DcsHandler } from 'common/parser/DcsParser';
-import { IBuffer } from 'common/buffer/Types';
-
-/**
- * Map collect to glevel. Used in `selectCharset`.
- */
-const GLEVEL: {[key: string]: number} = { '(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2 };
-
-/**
- * VT commands done by the parser - FIXME: move this to the parser?
- */
-// @vt: #Y ESC CSI "Control Sequence Introducer" "ESC [" "Start of a CSI sequence."
-// @vt: #Y ESC OSC "Operating System Command" "ESC ]" "Start of an OSC sequence."
-// @vt: #Y ESC DCS "Device Control String" "ESC P" "Start of a DCS sequence."
-// @vt: #Y ESC ST "String Terminator" "ESC \" "Terminator used for string type sequences."
-// @vt: #Y ESC PM "Privacy Message" "ESC ^" "Start of a privacy message."
-// @vt: #Y ESC APC "Application Program Command" "ESC _" "Start of an APC sequence."
-// @vt: #Y C1 CSI "Control Sequence Introducer" "\x9B" "Start of a CSI sequence."
-// @vt: #Y C1 OSC "Operating System Command" "\x9D" "Start of an OSC sequence."
-// @vt: #Y C1 DCS "Device Control String" "\x90" "Start of a DCS sequence."
-// @vt: #Y C1 ST "String Terminator" "\x9C" "Terminator used for string type sequences."
-// @vt: #Y C1 PM "Privacy Message" "\x9E" "Start of a privacy message."
-// @vt: #Y C1 APC "Application Program Command" "\x9F" "Start of an APC sequence."
-// @vt: #Y C0 NUL "Null" "\0, \x00" "NUL is ignored."
-// @vt: #Y C0 ESC "Escape" "\e, \x1B" "Start of a sequence. Cancels any other sequence."
-
-/**
- * Document common VT features here that are currently unsupported
- */
-// @vt: #N DCS SIXEL "SIXEL Graphics" "DCS Ps ; Ps ; Ps ; q Pt ST" "Draw SIXEL image starting at cursor position."
-// @vt: #N OSC 1 "Set Icon Name" "OSC 1 ; Pt BEL" "Set icon name."
-
-/**
- * Max length of the UTF32 input buffer. Real memory consumption is 4 times higher.
- */
-const MAX_PARSEBUFFER_LENGTH = 131072;
-
-/**
- * Limit length of title and icon name stacks.
- */
-const STACK_LIMIT = 10;
-
-// map params to window option
-function paramToWindowOption(n: number, opts: IWindowOptions): boolean {
- if (n > 24) {
- return opts.setWinLines || false;
- }
- switch (n) {
- case 1: return !!opts.restoreWin;
- case 2: return !!opts.minimizeWin;
- case 3: return !!opts.setWinPosition;
- case 4: return !!opts.setWinSizePixels;
- case 5: return !!opts.raiseWin;
- case 6: return !!opts.lowerWin;
- case 7: return !!opts.refreshWin;
- case 8: return !!opts.setWinSizeChars;
- case 9: return !!opts.maximizeWin;
- case 10: return !!opts.fullscreenWin;
- case 11: return !!opts.getWinState;
- case 13: return !!opts.getWinPosition;
- case 14: return !!opts.getWinSizePixels;
- case 15: return !!opts.getScreenSizePixels;
- case 16: return !!opts.getCellSizePixels;
- case 18: return !!opts.getWinSizeChars;
- case 19: return !!opts.getScreenSizeChars;
- case 20: return !!opts.getIconTitle;
- case 21: return !!opts.getWinTitle;
- case 22: return !!opts.pushTitle;
- case 23: return !!opts.popTitle;
- case 24: return !!opts.setWinLines;
- }
- return false;
-}
-
-export enum WindowsOptionsReportType {
- GET_WIN_SIZE_PIXELS = 0,
- GET_CELL_SIZE_PIXELS = 1
-}
-
-// create a warning log if an async handler takes longer than the limit (in ms)
-const SLOW_ASYNC_LIMIT = 5000;
-
-/**
- * DCS subparser implementations
- */
-
-/**
- * DCS $ q Pt ST
- * DECRQSS (https://vt100.net/docs/vt510-rm/DECRQSS.html)
- * Request Status String (DECRQSS), VT420 and up.
- * Response: DECRPSS (https://vt100.net/docs/vt510-rm/DECRPSS.html)
- *
- * @vt: #P[See limited support below.] DCS DECRQSS "Request Selection or Setting" "DCS $ q Pt ST" "Request several terminal settings."
- * Response is in the form `ESC P 1 $ r Pt ST` for valid requests, where `Pt` contains the corresponding CSI string,
- * `ESC P 0 ST` for invalid requests.
- *
- * Supported requests and responses:
- *
- * | Type | Request | Response (`Pt`) |
- * | -------------------------------- | ----------------- | ----------------------------------------------------- |
- * | Graphic Rendition (SGR) | `DCS $ q m ST` | always reporting `0m` (currently broken) |
- * | Top and Bottom Margins (DECSTBM) | `DCS $ q r ST` | `Ps ; Ps r` |
- * | Cursor Style (DECSCUSR) | `DCS $ q SP q ST` | `Ps SP q` |
- * | Protection Attribute (DECSCA) | `DCS $ q " q ST` | always reporting `0 " q` (DECSCA is unsupported) |
- * | Conformance Level (DECSCL) | `DCS $ q " p ST` | always reporting `61 ; 1 " p` (DECSCL is unsupported) |
- *
- *
- * TODO:
- * - fix SGR report
- * - either implement DECSCA or remove the report
- * - either check which conformance is better suited or remove the report completely
- * --> we are currently a mixture of all up to VT400 but dont follow anyone strictly
- */
-class DECRQSS implements IDcsHandler {
- private _data: Uint32Array = new Uint32Array(0);
-
- constructor(
- private _bufferService: IBufferService,
- private _coreService: ICoreService,
- private _logService: ILogService,
- private _optionsService: IOptionsService
- ) { }
-
- public hook(params: IParams): void {
- this._data = new Uint32Array(0);
- }
-
- public put(data: Uint32Array, start: number, end: number): void {
- this._data = concat(this._data, data.subarray(start, end));
- }
-
- public unhook(success: boolean): boolean {
- if (!success) {
- this._data = new Uint32Array(0);
- return true;
- }
- const data = utf32ToString(this._data);
- this._data = new Uint32Array(0);
- switch (data) {
- // valid: DCS 1 $ r Pt ST (xterm)
- case '"q': // DECSCA
- this._coreService.triggerDataEvent(`${C0.ESC}P1$r0"q${C0.ESC}\\`);
- break;
- case '"p': // DECSCL
- this._coreService.triggerDataEvent(`${C0.ESC}P1$r61;1"p${C0.ESC}\\`);
- break;
- case 'r': // DECSTBM
- const pt = '' + (this._bufferService.buffer.scrollTop + 1) +
- ';' + (this._bufferService.buffer.scrollBottom + 1) + 'r';
- this._coreService.triggerDataEvent(`${C0.ESC}P1$r${pt}${C0.ESC}\\`);
- break;
- case 'm': // SGR
- // TODO: report real settings instead of 0m
- this._coreService.triggerDataEvent(`${C0.ESC}P1$r0m${C0.ESC}\\`);
- break;
- case ' q': // DECSCUSR
- const STYLES: {[key: string]: number} = { 'block': 2, 'underline': 4, 'bar': 6 };
- let style = STYLES[this._optionsService.options.cursorStyle];
- style -= this._optionsService.options.cursorBlink ? 1 : 0;
- this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\`);
- break;
- default:
- // invalid: DCS 0 $ r Pt ST (xterm)
- this._logService.debug('Unknown DCS $q %s', data);
- this._coreService.triggerDataEvent(`${C0.ESC}P0$r${C0.ESC}\\`);
- }
- return true;
- }
-}
-
-/**
- * DCS Ps; Ps| Pt ST
- * DECUDK (https://vt100.net/docs/vt510-rm/DECUDK.html)
- * not supported
- *
- * @vt: #N DCS DECUDK "User Defined Keys" "DCS Ps ; Ps | Pt ST" "Definitions for user-defined keys."
- */
-
-/**
- * DCS + q Pt ST (xterm)
- * Request Terminfo String
- * not implemented
- *
- * @vt: #N DCS XTGETTCAP "Request Terminfo String" "DCS + q Pt ST" "Request Terminfo String."
- */
-
-/**
- * DCS + p Pt ST (xterm)
- * Set Terminfo Data
- * not supported
- *
- * @vt: #N DCS XTSETTCAP "Set Terminfo Data" "DCS + p Pt ST" "Set Terminfo Data."
- */
-
-
-
-/**
- * The terminal's standard implementation of IInputHandler, this handles all
- * input from the Parser.
- *
- * Refer to http://invisible-island.net/xterm/ctlseqs/ctlseqs.html to understand
- * each function's header comment.
- */
-export class InputHandler extends Disposable implements IInputHandler {
- private _parseBuffer: Uint32Array = new Uint32Array(4096);
- private _stringDecoder: StringToUtf32 = new StringToUtf32();
- private _utf8Decoder: Utf8ToUtf32 = new Utf8ToUtf32();
- private _workCell: CellData = new CellData();
- private _windowTitle = '';
- private _iconName = '';
- protected _windowTitleStack: string[] = [];
- protected _iconNameStack: string[] = [];
-
- private _curAttrData: IAttributeData = DEFAULT_ATTR_DATA.clone();
- private _eraseAttrDataInternal: IAttributeData = DEFAULT_ATTR_DATA.clone();
-
- private _activeBuffer: IBuffer;
-
- private _onRequestBell = new EventEmitter();
- public get onRequestBell(): IEvent { return this._onRequestBell.event; }
- private _onRequestRefreshRows = new EventEmitter();
- public get onRequestRefreshRows(): IEvent { return this._onRequestRefreshRows.event; }
- private _onRequestReset = new EventEmitter();
- public get onRequestReset(): IEvent { return this._onRequestReset.event; }
- private _onRequestSyncScrollBar = new EventEmitter();
- public get onRequestSyncScrollBar(): IEvent { return this._onRequestSyncScrollBar.event; }
- private _onRequestWindowsOptionsReport = new EventEmitter();
- public get onRequestWindowsOptionsReport(): IEvent { return this._onRequestWindowsOptionsReport.event; }
-
- private _onA11yChar = new EventEmitter();
- public get onA11yChar(): IEvent { return this._onA11yChar.event; }
- private _onA11yTab = new EventEmitter();
- public get onA11yTab(): IEvent { return this._onA11yTab.event; }
- private _onCursorMove = new EventEmitter();
- public get onCursorMove(): IEvent { return this._onCursorMove.event; }
- private _onLineFeed = new EventEmitter();
- public get onLineFeed(): IEvent