Skip to content

Instantly share code, notes, and snippets.

View SerializeAddon.ts
import { Terminal, ITerminalAddon, IBufferCell } from 'xterm';
export class SerializeAddon implements ITerminalAddon {
private _terminal: Terminal|undefined = undefined;
public dispose(): void {}
public activate(terminal: Terminal): void {
this._terminal = terminal;
}
private _extractAttributes(oldCell: IBufferCell, newCell: IBufferCell): string {
View SerializeAddon.ts
import { Terminal, ITerminalAddon } from 'xterm';
export const enum Attributes {
/**
* bit 1..8 blue in RGB, color in P256 and P16
*/
BLUE_MASK = 0xFF,
BLUE_SHIFT = 0,
PCOLOR_MASK = 0xFF,
PCOLOR_SHIFT = 0,
View parser_benchmark.js
var Module = require('module');
var originalRequire = Module.prototype.require;
// monkey patch require paths
Module.prototype.require = function() {
const path = arguments[0];
if (path.slice(0, 6) === 'common') {
return require('xterm/out/' + path);
}
if (path.slice(0, 4) === 'core') {
View test_colors256.sh
#!/bin/bash
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
set -eu # Fail on errors or undeclared variables
printable_colours=256
View input.ts
import { perfContext, before, ThroughputRuntimeCase } from '..';
//import * as xterm from 'xterm';
import { Terminal as TerminalType } from 'xterm/src/Terminal';
const Terminal: typeof TerminalType = require('xterm/lib/Terminal').Terminal;
const pty = require('xterm/node_modules/node-pty');
class TestTerminal extends Terminal {
writeSync(data: string) {
this.writeBuffer.push(data);
View terminal_translateToString.perf.js
const Terminal = require('xterm/lib/Terminal').Terminal;
const pty = require('xterm/node_modules/node-pty');
const perfContext = require('../lib/index').perfContext;
const before = require('../lib/index').before;
const RuntimeCase = require('../lib/index').RuntimeCase;
class TestTerminal extends Terminal {
writeSync(data) {
this.writeBuffer.push(data);
this._innerWrite();
View perftest.js
const fs = require('fs');
const Terminal = require('./lib/Terminal').Terminal;
class TestTerminal extends Terminal {
writeSync(data) {
this.writeBuffer.push(data);
this._innerWrite();
}
}
View idea.ts
type CharDataNew = [
number, // flags 1 - current flags
number, // flags 2 - store missing RGB values
number // content - UTF32 char or pointer to combined string (at the end of the memory)
]
type SomeType = null; // to be implmented
/**
* memory layout:
View test.js
var os = require('os');
var pty = require('./lib/index');
var shell = os.platform() === 'win32'
? 'powershell.exe'
: 'bash';
process.on('exit', function(c) {
console.log('exit ' + c)
});
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>