Add remaining naming conventions into tslint
This commit is contained in:
@@ -179,7 +179,7 @@ export class AccessibilityManager implements IDisposable {
|
|||||||
this._refreshRowsDimensions();
|
this._refreshRowsDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public _createAccessibilityTreeNode(): HTMLElement {
|
private _createAccessibilityTreeNode(): HTMLElement {
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('div');
|
||||||
element.setAttribute('role', 'listitem');
|
element.setAttribute('role', 'listitem');
|
||||||
element.tabIndex = -1;
|
element.tabIndex = -1;
|
||||||
|
|||||||
+2
-2
@@ -323,9 +323,9 @@ export class Buffer implements IBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Marker extends EventEmitter implements IMarker {
|
export class Marker extends EventEmitter implements IMarker {
|
||||||
private static NEXT_ID = 1;
|
private static _nextId = 1;
|
||||||
|
|
||||||
private _id: number = Marker.NEXT_ID++;
|
private _id: number = Marker._nextId++;
|
||||||
public isDisposed: boolean = false;
|
public isDisposed: boolean = false;
|
||||||
public disposables: IDisposable[] = [];
|
public disposables: IDisposable[] = [];
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -121,7 +121,7 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu
|
|||||||
}
|
}
|
||||||
const control = opts.control | 0;
|
const control = opts.control | 0;
|
||||||
let table: number[] | Uint32Array = null;
|
let table: number[] | Uint32Array = null;
|
||||||
function init_table(): number[] | Uint32Array {
|
function initTable(): number[] | Uint32Array {
|
||||||
// lookup table for BMP
|
// lookup table for BMP
|
||||||
const CODEPOINTS = 65536; // BMP holds 65536 codepoints
|
const CODEPOINTS = 65536; // BMP holds 65536 codepoints
|
||||||
const BITWIDTH = 2; // a codepoint can have a width of 0, 1 or 2
|
const BITWIDTH = 2; // a codepoint can have a width of 0, 1 or 2
|
||||||
@@ -161,7 +161,7 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu
|
|||||||
if (num < 127) {
|
if (num < 127) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
let t = table || init_table();
|
let t = table || initTable();
|
||||||
if (num < 65536) {
|
if (num < 65536) {
|
||||||
return t[num >> 4] >> ((num & 15) << 1) & 3;
|
return t[num >> 4] >> ((num & 15) << 1) & 3;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -622,7 +622,7 @@ export class InputHandler implements IInputHandler {
|
|||||||
* [columns] (default = [row,col+1]) (HPR)
|
* [columns] (default = [row,col+1]) (HPR)
|
||||||
* reuse CSI Ps C ?
|
* reuse CSI Ps C ?
|
||||||
*/
|
*/
|
||||||
public HPositionRelative(params: number[]): void {
|
public hPositionRelative(params: number[]): void {
|
||||||
let param = params[0];
|
let param = params[0];
|
||||||
if (param < 1) {
|
if (param < 1) {
|
||||||
param = 1;
|
param = 1;
|
||||||
@@ -736,7 +736,7 @@ export class InputHandler implements IInputHandler {
|
|||||||
* [rows] (default = [row+1,column])
|
* [rows] (default = [row+1,column])
|
||||||
* reuse CSI Ps B ?
|
* reuse CSI Ps B ?
|
||||||
*/
|
*/
|
||||||
public VPositionRelative(params: number[]): void {
|
public vPositionRelative(params: number[]): void {
|
||||||
let param = params[0];
|
let param = params[0];
|
||||||
if (param < 1) {
|
if (param < 1) {
|
||||||
param = 1;
|
param = 1;
|
||||||
@@ -756,7 +756,7 @@ export class InputHandler implements IInputHandler {
|
|||||||
* Horizontal and Vertical Position [row;column] (default =
|
* Horizontal and Vertical Position [row;column] (default =
|
||||||
* [1,1]) (HVP).
|
* [1,1]) (HVP).
|
||||||
*/
|
*/
|
||||||
public HVPosition(params: number[]): void {
|
public hVPosition(params: number[]): void {
|
||||||
if (params[0] < 1) params[0] = 1;
|
if (params[0] < 1) params[0] = 1;
|
||||||
if (params[1] < 1) params[1] = 1;
|
if (params[1] < 1) params[1] = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import { MockBuffer, MockTerminal } from './utils/TestUtils.test';
|
|||||||
import { CircularList } from './utils/CircularList';
|
import { CircularList } from './utils/CircularList';
|
||||||
|
|
||||||
class TestLinkifier extends Linkifier {
|
class TestLinkifier extends Linkifier {
|
||||||
constructor(_terminal: ITerminal) {
|
constructor(terminal: ITerminal) {
|
||||||
super(_terminal);
|
super(terminal);
|
||||||
Linkifier.TIME_BEFORE_LINKIFY = 0;
|
(<any>Linkifier).TIME_BEFORE_LINKIFY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get linkMatchers(): ILinkMatcher[] { return this._linkMatchers; }
|
public get linkMatchers(): ILinkMatcher[] { return this._linkMatchers; }
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ export class Linkifier extends EventEmitter implements ILinkifier {
|
|||||||
* the costly operation of searching every row multiple times, potentially a
|
* the costly operation of searching every row multiple times, potentially a
|
||||||
* huge amount of times.
|
* huge amount of times.
|
||||||
*/
|
*/
|
||||||
protected static TIME_BEFORE_LINKIFY = 200;
|
protected static readonly TIME_BEFORE_LINKIFY = 200;
|
||||||
|
|
||||||
protected _linkMatchers: ILinkMatcher[] = [];
|
protected _linkMatchers: ILinkMatcher[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -74,23 +74,23 @@ function terminalToString(term: Terminal): string {
|
|||||||
|
|
||||||
// Skip tests on Windows since pty.open isn't supported
|
// Skip tests on Windows since pty.open isn't supported
|
||||||
if (os.platform() !== 'win32') {
|
if (os.platform() !== 'win32') {
|
||||||
let CONSOLE_LOG = console.log;
|
const consoleLog = console.log;
|
||||||
|
|
||||||
// expect files need terminal at 80x25!
|
// expect files need terminal at 80x25!
|
||||||
let COLS = 80;
|
const cols = 80;
|
||||||
let ROWS = 25;
|
const rows = 25;
|
||||||
|
|
||||||
/** some helpers for pty interaction */
|
/** some helpers for pty interaction */
|
||||||
// we need a pty in between to get the termios decorations
|
// we need a pty in between to get the termios decorations
|
||||||
// for the basic test cases a raw pty device is enough
|
// for the basic test cases a raw pty device is enough
|
||||||
primitivePty = pty.native.open(COLS, ROWS);
|
primitivePty = pty.native.open(cols, rows);
|
||||||
|
|
||||||
/** tests */
|
/** tests */
|
||||||
describe('xterm output comparison', () => {
|
describe('xterm output comparison', () => {
|
||||||
let xterm;
|
let xterm;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
xterm = new Terminal({ cols: COLS, rows: ROWS });
|
xterm = new Terminal({ cols: cols, rows: rows });
|
||||||
xterm.refresh = () => {};
|
xterm.refresh = () => {};
|
||||||
xterm.viewport = {
|
xterm.viewport = {
|
||||||
syncScrollArea: () => {}
|
syncScrollArea: () => {}
|
||||||
@@ -128,7 +128,7 @@ if (os.platform() !== 'win32') {
|
|||||||
xterm._innerWrite();
|
xterm._innerWrite();
|
||||||
|
|
||||||
let fromEmulator = terminalToString(xterm);
|
let fromEmulator = terminalToString(xterm);
|
||||||
console.log = CONSOLE_LOG;
|
console.log = consoleLog;
|
||||||
let expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
|
let expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
|
||||||
// Some of the tests have whitespace on the right of lines, we trim all the linex
|
// Some of the tests have whitespace on the right of lines, we trim all the linex
|
||||||
// from xterm.js so ignore this for now at least.
|
// from xterm.js so ignore this for now at least.
|
||||||
|
|||||||
+36
-41
@@ -2210,7 +2210,42 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
|
|
||||||
// TODO: Remove when true color is implemented
|
// TODO: Remove when true color is implemented
|
||||||
public matchColor(r1: number, g1: number, b1: number): number {
|
public matchColor(r1: number, g1: number, b1: number): number {
|
||||||
return matchColor_(r1, g1, b1);
|
const hash = (r1 << 16) | (g1 << 8) | b1;
|
||||||
|
|
||||||
|
if (matchColorCache[hash] != null) {
|
||||||
|
return matchColorCache[hash];
|
||||||
|
}
|
||||||
|
|
||||||
|
let ldiff = Infinity;
|
||||||
|
let li = -1;
|
||||||
|
let i = 0;
|
||||||
|
let c: number;
|
||||||
|
let r2: number;
|
||||||
|
let g2: number;
|
||||||
|
let b2: number;
|
||||||
|
let diff: number;
|
||||||
|
|
||||||
|
for (; i < DEFAULT_ANSI_COLORS.length; i++) {
|
||||||
|
c = DEFAULT_ANSI_COLORS[i].rgba;
|
||||||
|
r2 = c >>> 24;
|
||||||
|
g2 = c >>> 16 & 0xFF;
|
||||||
|
b2 = c >>> 8 & 0xFF;
|
||||||
|
// assume that alpha is 0xFF
|
||||||
|
|
||||||
|
diff = matchColorDistance(r1, g1, b1, r2, g2, b2);
|
||||||
|
|
||||||
|
if (diff === 0) {
|
||||||
|
li = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diff < ldiff) {
|
||||||
|
ldiff = diff;
|
||||||
|
li = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchColorCache[hash] = li;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _visualBell(): boolean {
|
private _visualBell(): boolean {
|
||||||
@@ -2266,43 +2301,3 @@ function matchColorDistance(r1: number, g1: number, b1: number, r2: number, g2:
|
|||||||
+ Math.pow(59 * (g1 - g2), 2)
|
+ Math.pow(59 * (g1 - g2), 2)
|
||||||
+ Math.pow(11 * (b1 - b2), 2);
|
+ Math.pow(11 * (b1 - b2), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function matchColor_(r1: number, g1: number, b1: number): number {
|
|
||||||
const hash = (r1 << 16) | (g1 << 8) | b1;
|
|
||||||
|
|
||||||
if (matchColorCache[hash] != null) {
|
|
||||||
return matchColorCache[hash];
|
|
||||||
}
|
|
||||||
|
|
||||||
let ldiff = Infinity;
|
|
||||||
let li = -1;
|
|
||||||
let i = 0;
|
|
||||||
let c: number;
|
|
||||||
let r2: number;
|
|
||||||
let g2: number;
|
|
||||||
let b2: number;
|
|
||||||
let diff: number;
|
|
||||||
|
|
||||||
for (; i < DEFAULT_ANSI_COLORS.length; i++) {
|
|
||||||
c = DEFAULT_ANSI_COLORS[i].rgba;
|
|
||||||
r2 = c >>> 24;
|
|
||||||
g2 = c >>> 16 & 0xFF;
|
|
||||||
b2 = c >>> 8 & 0xFF;
|
|
||||||
// assume that alpha is 0xFF
|
|
||||||
|
|
||||||
diff = matchColorDistance(r1, g1, b1, r2, g2, b2);
|
|
||||||
|
|
||||||
if (diff === 0) {
|
|
||||||
li = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diff < ldiff) {
|
|
||||||
ldiff = diff;
|
|
||||||
li = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return matchColorCache[hash] = li;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ function zmodemAttach(ws: WebSocket, opts: IZmodemOptions = {}): void {
|
|||||||
|
|
||||||
let zsentry;
|
let zsentry;
|
||||||
|
|
||||||
function _shouldWrite(): boolean {
|
function shouldWrite(): boolean {
|
||||||
return !!zsentry.get_confirmed_session() || !opts.noTerminalWriteOutsideSession;
|
return !!zsentry.get_confirmed_session() || !opts.noTerminalWriteOutsideSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
zsentry = new zmodem.Sentry({
|
zsentry = new zmodem.Sentry({
|
||||||
to_terminal: (octets: ArrayLike<number>) => {
|
to_terminal: (octets: ArrayLike<number>) => {
|
||||||
if (_shouldWrite()) {
|
if (shouldWrite()) {
|
||||||
term.write(
|
term.write(
|
||||||
String.fromCharCode.apply(String, octets)
|
String.fromCharCode.apply(String, octets)
|
||||||
);
|
);
|
||||||
@@ -72,7 +72,7 @@ function zmodemAttach(ws: WebSocket, opts: IZmodemOptions = {}): void {
|
|||||||
// may be specific to xterm.js’s demo, ultimately we
|
// may be specific to xterm.js’s demo, ultimately we
|
||||||
// should reject anything that isn’t binary.
|
// should reject anything that isn’t binary.
|
||||||
if (typeof evt.data === 'string') {
|
if (typeof evt.data === 'string') {
|
||||||
if (_shouldWrite()) {
|
if (shouldWrite()) {
|
||||||
term.write(evt.data);
|
term.write(evt.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -93,7 +93,16 @@
|
|||||||
|
|
||||||
"naming-convention": [
|
"naming-convention": [
|
||||||
true,
|
true,
|
||||||
{"type": "property", "modifiers": ["public", "static", "const"], "format": "UPPER_CASE"}
|
{"type": "default", "format": "camelCase", "leadingUnderscore": "forbid"},
|
||||||
|
{"type": "type", "format": "PascalCase"},
|
||||||
|
{"type": "class", "format": "PascalCase"},
|
||||||
|
{"type": "property", "modifiers": ["const"], "format": "UPPER_CASE"},
|
||||||
|
{"type": "member", "modifiers": ["protected"], "format": "camelCase", "leadingUnderscore": "allow"},
|
||||||
|
// TODO: Change allow to require when there aren't many PRs out
|
||||||
|
// {"type": "member", "modifiers": ["protected"], "format": "camelCase", "leadingUnderscore": "require"},
|
||||||
|
{"type": "member", "modifiers": ["private"], "format": "camelCase", "leadingUnderscore": "require"},
|
||||||
|
{"type": "variable", "modifiers": ["const"], "format": ["camelCase", "UPPER_CASE"]},
|
||||||
|
{"type": "interface", "prefix": "I"}
|
||||||
],
|
],
|
||||||
"no-else-after-return": {
|
"no-else-after-return": {
|
||||||
"options": "allow-else-if"
|
"options": "allow-else-if"
|
||||||
|
|||||||
Reference in New Issue
Block a user