mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge branch 'master' into fix-edge-selection-color
This commit is contained in:
@@ -160,6 +160,7 @@ Xterm.js is used in several world-class applications to provide great terminal e
|
||||
- [**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, ...
|
||||
|
||||
[And much more...](https://github.com/xtermjs/xterm.js/network/dependents)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xterm-addon-webgl",
|
||||
"version": "0.5.0",
|
||||
"version": "0.5.1",
|
||||
"author": {
|
||||
"name": "The xterm.js authors",
|
||||
"url": "https://xtermjs.org/"
|
||||
|
||||
@@ -128,6 +128,9 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
const cursorY = terminal.buffer.baseY + terminal.buffer.cursorY;
|
||||
const viewportRelativeCursorY = cursorY - terminal.buffer.viewportY;
|
||||
|
||||
// in case cursor.x == cols adjust visual cursor to cols - 1
|
||||
const cursorX = Math.min(terminal.buffer.cursorX, terminal.cols - 1);
|
||||
|
||||
// Don't draw the cursor if it's off-screen
|
||||
if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) {
|
||||
this._clearCursor();
|
||||
@@ -135,7 +138,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
}
|
||||
|
||||
// TODO: Need fast buffer API for loading cell
|
||||
(terminal as any)._core.buffer.lines.get(cursorY).loadCell(terminal.buffer.cursorX, this._cell);
|
||||
(terminal as any)._core.buffer.lines.get(cursorY).loadCell(cursorX, this._cell);
|
||||
if (this._cell.content === undefined) {
|
||||
return;
|
||||
}
|
||||
@@ -146,12 +149,12 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
this._ctx.fillStyle = this._colors.cursor.css;
|
||||
const cursorStyle = terminal.getOption('cursorStyle');
|
||||
if (cursorStyle && cursorStyle !== 'block') {
|
||||
this._cursorRenderers[cursorStyle](terminal, terminal.buffer.cursorX, viewportRelativeCursorY, this._cell);
|
||||
this._cursorRenderers[cursorStyle](terminal, cursorX, viewportRelativeCursorY, this._cell);
|
||||
} else {
|
||||
this._renderBlurCursor(terminal, terminal.buffer.cursorX, viewportRelativeCursorY, this._cell);
|
||||
this._renderBlurCursor(terminal, cursorX, viewportRelativeCursorY, this._cell);
|
||||
}
|
||||
this._ctx.restore();
|
||||
this._state.x = terminal.buffer.cursorX;
|
||||
this._state.x = cursorX;
|
||||
this._state.y = viewportRelativeCursorY;
|
||||
this._state.isFocused = false;
|
||||
this._state.style = cursorStyle;
|
||||
@@ -167,7 +170,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
|
||||
if (this._state) {
|
||||
// The cursor is already in the correct spot, don't redraw
|
||||
if (this._state.x === terminal.buffer.cursorX &&
|
||||
if (this._state.x === cursorX &&
|
||||
this._state.y === viewportRelativeCursorY &&
|
||||
this._state.isFocused === isTerminalFocused(terminal) &&
|
||||
this._state.style === terminal.getOption('cursorStyle') &&
|
||||
@@ -178,10 +181,10 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
}
|
||||
|
||||
this._ctx.save();
|
||||
this._cursorRenderers[terminal.getOption('cursorStyle') || 'block'](terminal, terminal.buffer.cursorX, viewportRelativeCursorY, this._cell);
|
||||
this._cursorRenderers[terminal.getOption('cursorStyle') || 'block'](terminal, cursorX, viewportRelativeCursorY, this._cell);
|
||||
this._ctx.restore();
|
||||
|
||||
this._state.x = terminal.buffer.cursorX;
|
||||
this._state.x = cursorX;
|
||||
this._state.y = viewportRelativeCursorY;
|
||||
this._state.isFocused = false;
|
||||
this._state.style = terminal.getOption('cursorStyle');
|
||||
|
||||
@@ -32,9 +32,15 @@ const TYPES = [
|
||||
'SOS'
|
||||
];
|
||||
|
||||
const MARKDOWN_TMPL = `
|
||||
const MARKDOWN_TMPL = `---
|
||||
title: Supported Terminal Sequences
|
||||
category: API
|
||||
---
|
||||
|
||||
{::options parse_block_html="true" /}
|
||||
|
||||
# Supported Terminal Sequences
|
||||
|
||||
xterm.js version: {{version}}
|
||||
|
||||
## Table of Contents
|
||||
|
||||
+5
-1
@@ -2,6 +2,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>xterm.js demo</title>
|
||||
<!--
|
||||
WARNING: This demo is a barebones implementation designed for development and evaluation
|
||||
purposes only. It is definitely NOT production ready and does not aim to be so. Exposing the
|
||||
demo to the public as is would introduce security risks for the host.
|
||||
-->
|
||||
<link rel="shortcut icon" type="image/png" href="/logo.png">
|
||||
<link rel="stylesheet" href="/xterm.css" />
|
||||
<link rel="stylesheet" href="/style.css" />
|
||||
@@ -44,7 +49,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<p><strong>Attention:</strong> The demo is a barebones implementation and is designed for the development and evaluation of xterm.js only. Exposing the demo to the public as is would introduce security risks for the host.</p>
|
||||
<button id="dispose" title="This is used to testing memory leaks">Dispose terminal</button>
|
||||
<script src="dist/client-bundle.js" defer ></script>
|
||||
</body>
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/**
|
||||
* WARNING: This demo is a barebones implementation designed for development and evaluation
|
||||
* purposes only. It is definitely NOT production ready and does not aim to be so. Exposing the
|
||||
* demo to the public as is would introduce security risks for the host.
|
||||
**/
|
||||
|
||||
var express = require('express');
|
||||
var expressWs = require('express-ws');
|
||||
var os = require('os');
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2020 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { addDisposableDomListener } from './Lifecycle';
|
||||
import jsdom = require('jsdom');
|
||||
|
||||
describe('addDisposableDomListener', () => {
|
||||
const dom = new jsdom.JSDOM();
|
||||
const document = dom.window.document;
|
||||
|
||||
function createEvent(type: string): Event {
|
||||
const event = document.createEvent('Event');
|
||||
event.initEvent(type);
|
||||
return event;
|
||||
}
|
||||
|
||||
it('dispose', () => {
|
||||
let calledTimes = 0;
|
||||
const div = document.createElement('div');
|
||||
const disposable = addDisposableDomListener(div, 'test', () => { calledTimes++; });
|
||||
|
||||
assert.equal(calledTimes, 0);
|
||||
|
||||
div.dispatchEvent(createEvent('test'));
|
||||
assert.equal(calledTimes, 1);
|
||||
|
||||
disposable.dispose();
|
||||
|
||||
div.dispatchEvent(createEvent('test'));
|
||||
assert.equal(calledTimes, 1);
|
||||
|
||||
disposable.dispose(); // double disposing
|
||||
|
||||
div.dispatchEvent(createEvent('test'));
|
||||
assert.equal(calledTimes, 1);
|
||||
});
|
||||
});
|
||||
@@ -20,7 +20,7 @@ export function addDisposableDomListener(
|
||||
let disposed = false;
|
||||
return {
|
||||
dispose: () => {
|
||||
if (!disposed) {
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
disposed = true;
|
||||
|
||||
@@ -140,7 +140,9 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
return;
|
||||
}
|
||||
|
||||
this._bufferService.buffer.lines.get(cursorY)!.loadCell(this._bufferService.buffer.x, this._cell);
|
||||
// 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;
|
||||
}
|
||||
@@ -151,12 +153,12 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
this._ctx.fillStyle = this._colors.cursor.css;
|
||||
const cursorStyle = this._optionsService.options.cursorStyle;
|
||||
if (cursorStyle && cursorStyle !== 'block') {
|
||||
this._cursorRenderers[cursorStyle](this._bufferService.buffer.x, viewportRelativeCursorY, this._cell);
|
||||
this._cursorRenderers[cursorStyle](cursorX, viewportRelativeCursorY, this._cell);
|
||||
} else {
|
||||
this._renderBlurCursor(this._bufferService.buffer.x, viewportRelativeCursorY, this._cell);
|
||||
this._renderBlurCursor(cursorX, viewportRelativeCursorY, this._cell);
|
||||
}
|
||||
this._ctx.restore();
|
||||
this._state.x = this._bufferService.buffer.x;
|
||||
this._state.x = cursorX;
|
||||
this._state.y = viewportRelativeCursorY;
|
||||
this._state.isFocused = false;
|
||||
this._state.style = cursorStyle;
|
||||
@@ -172,7 +174,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
|
||||
if (this._state) {
|
||||
// The cursor is already in the correct spot, don't redraw
|
||||
if (this._state.x === this._bufferService.buffer.x &&
|
||||
if (this._state.x === cursorX &&
|
||||
this._state.y === viewportRelativeCursorY &&
|
||||
this._state.isFocused === this._coreBrowserService.isFocused &&
|
||||
this._state.style === this._optionsService.options.cursorStyle &&
|
||||
@@ -183,10 +185,10 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
}
|
||||
|
||||
this._ctx.save();
|
||||
this._cursorRenderers[this._optionsService.options.cursorStyle || 'block'](this._bufferService.buffer.x, viewportRelativeCursorY, this._cell);
|
||||
this._cursorRenderers[this._optionsService.options.cursorStyle || 'block'](cursorX, viewportRelativeCursorY, this._cell);
|
||||
this._ctx.restore();
|
||||
|
||||
this._state.x = this._bufferService.buffer.x;
|
||||
this._state.x = cursorX;
|
||||
this._state.y = viewportRelativeCursorY;
|
||||
this._state.isFocused = false;
|
||||
this._state.style = this._optionsService.options.cursorStyle;
|
||||
|
||||
@@ -352,7 +352,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
||||
|
||||
public renderRows(start: number, end: number): void {
|
||||
const cursorAbsoluteY = this._bufferService.buffer.ybase + this._bufferService.buffer.y;
|
||||
const cursorX = this._bufferService.buffer.x;
|
||||
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++) {
|
||||
|
||||
Vendored
+1
-1
@@ -1177,7 +1177,7 @@ declare module 'xterm' {
|
||||
|
||||
/**
|
||||
* The x position of the cursor. This ranges between `0` (left side) and
|
||||
* `Terminal.cols - 1` (right side).
|
||||
* `Terminal.cols` (after last cell of the row).
|
||||
*/
|
||||
readonly cursorX: number;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user