Comparing version 3.10.0-beta2 to 3.10.0-beta3
@@ -196,4 +196,4 @@ "use strict"; | ||
this._executeHandlers = null; | ||
this._escHandlers = null; | ||
this._csiHandlers = null; | ||
this._escHandlers = null; | ||
this._oscHandlers = null; | ||
@@ -220,4 +220,20 @@ this._dcsHandlers = null; | ||
}; | ||
EscapeSequenceParser.prototype.addCsiHandler = function (flag, callback) { | ||
var index = flag.charCodeAt(0); | ||
if (this._csiHandlers[index] === undefined) { | ||
this._csiHandlers[index] = []; | ||
} | ||
var handlerList = this._csiHandlers[index]; | ||
handlerList.push(callback); | ||
return { | ||
dispose: function () { | ||
var handlerIndex = handlerList.indexOf(callback); | ||
if (handlerIndex !== -1) { | ||
handlerList.splice(handlerIndex, 1); | ||
} | ||
} | ||
}; | ||
}; | ||
EscapeSequenceParser.prototype.setCsiHandler = function (flag, callback) { | ||
this._csiHandlers[flag.charCodeAt(0)] = callback; | ||
this._csiHandlers[flag.charCodeAt(0)] = [callback]; | ||
}; | ||
@@ -241,4 +257,19 @@ EscapeSequenceParser.prototype.clearCsiHandler = function (flag) { | ||
}; | ||
EscapeSequenceParser.prototype.addOscHandler = function (ident, callback) { | ||
if (this._oscHandlers[ident] === undefined) { | ||
this._oscHandlers[ident] = []; | ||
} | ||
var handlerList = this._oscHandlers[ident]; | ||
handlerList.push(callback); | ||
return { | ||
dispose: function () { | ||
var handlerIndex = handlerList.indexOf(callback); | ||
if (handlerIndex !== -1) { | ||
handlerList.splice(handlerIndex, 1); | ||
} | ||
} | ||
}; | ||
}; | ||
EscapeSequenceParser.prototype.setOscHandler = function (ident, callback) { | ||
this._oscHandlers[ident] = callback; | ||
this._oscHandlers[ident] = [callback]; | ||
}; | ||
@@ -370,7 +401,12 @@ EscapeSequenceParser.prototype.clearOscHandler = function (ident) { | ||
case 7: | ||
callback = this._csiHandlers[code]; | ||
if (callback) | ||
callback(params, collect); | ||
else | ||
var handlers = this._csiHandlers[code]; | ||
var j = handlers ? handlers.length - 1 : -1; | ||
for (; j >= 0; j--) { | ||
if (handlers[j](params, collect)) { | ||
break; | ||
} | ||
} | ||
if (j < 0) { | ||
this._csiHandlerFb(collect, params, code); | ||
} | ||
break; | ||
@@ -434,8 +470,8 @@ case 8: | ||
case 5: | ||
for (var j = i + 1;; j++) { | ||
if (j >= l | ||
|| (code = data.charCodeAt(j)) < 0x20 | ||
for (var j_1 = i + 1;; j_1++) { | ||
if (j_1 >= l | ||
|| (code = data.charCodeAt(j_1)) < 0x20 | ||
|| (code > 0x7f && code <= 0x9f)) { | ||
osc += data.substring(i, j); | ||
i = j - 1; | ||
osc += data.substring(i, j_1); | ||
i = j_1 - 1; | ||
break; | ||
@@ -454,7 +490,12 @@ } | ||
var content = osc.substring(idx + 1); | ||
callback = this._oscHandlers[identifier]; | ||
if (callback) | ||
callback(content); | ||
else | ||
var handlers_1 = this._oscHandlers[identifier]; | ||
var j_2 = handlers_1 ? handlers_1.length - 1 : -1; | ||
for (; j_2 >= 0; j_2--) { | ||
if (handlers_1[j_2](content)) { | ||
break; | ||
} | ||
} | ||
if (j_2 < 0) { | ||
this._oscHandlerFb(identifier, content); | ||
} | ||
} | ||
@@ -461,0 +502,0 @@ } |
@@ -297,2 +297,8 @@ "use strict"; | ||
}; | ||
InputHandler.prototype.addCsiHandler = function (flag, callback) { | ||
return this._parser.addCsiHandler(flag, callback); | ||
}; | ||
InputHandler.prototype.addOscHandler = function (ident, callback) { | ||
return this._parser.addOscHandler(ident, callback); | ||
}; | ||
InputHandler.prototype.bell = function () { | ||
@@ -299,0 +305,0 @@ this._terminal.bell(); |
@@ -64,2 +64,8 @@ "use strict"; | ||
}; | ||
Terminal.prototype.addCsiHandler = function (flag, callback) { | ||
return this._core.addCsiHandler(flag, callback); | ||
}; | ||
Terminal.prototype.addOscHandler = function (ident, callback) { | ||
return this._core.addOscHandler(ident, callback); | ||
}; | ||
Terminal.prototype.registerLinkMatcher = function (regex, handler, options) { | ||
@@ -66,0 +72,0 @@ return this._core.registerLinkMatcher(regex, handler, options); |
@@ -15,3 +15,3 @@ "use strict"; | ||
ctx.font = getFont(config.fontWeight, config); | ||
ctx.textBaseline = 'top'; | ||
ctx.textBaseline = 'middle'; | ||
for (var i = 0; i < 256; i++) { | ||
@@ -22,3 +22,3 @@ ctx.save(); | ||
ctx.clip(); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, 0); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight / 2); | ||
ctx.restore(); | ||
@@ -33,3 +33,3 @@ } | ||
ctx.clip(); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight * 1.5); | ||
ctx.restore(); | ||
@@ -47,3 +47,3 @@ } | ||
ctx.fillStyle = config.colors.ansi[colorIndex].css; | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2); | ||
ctx.restore(); | ||
@@ -61,3 +61,3 @@ } | ||
ctx.fillStyle = config.colors.ansi[colorIndex].css; | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2); | ||
ctx.restore(); | ||
@@ -64,0 +64,0 @@ } |
@@ -151,3 +151,3 @@ "use strict"; | ||
fontStyle + " " + fontWeight + " " + this._config.fontSize * this._config.devicePixelRatio + "px " + this._config.fontFamily; | ||
this._tmpCtx.textBaseline = 'top'; | ||
this._tmpCtx.textBaseline = 'middle'; | ||
this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css; | ||
@@ -157,3 +157,3 @@ if (glyph.dim) { | ||
} | ||
this._tmpCtx.fillText(glyph.chars, 0, 0); | ||
this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight / 2); | ||
this._tmpCtx.restore(); | ||
@@ -160,0 +160,0 @@ var imageData = this._tmpCtx.getImageData(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight); |
@@ -125,5 +125,5 @@ "use strict"; | ||
this._ctx.font = this._getFont(terminal, false, false); | ||
this._ctx.textBaseline = 'top'; | ||
this._ctx.textBaseline = 'middle'; | ||
this._clipRow(terminal, y); | ||
this._ctx.fillText(charData[Buffer_1.CHAR_DATA_CHAR_INDEX], x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop); | ||
this._ctx.fillText(charData[Buffer_1.CHAR_DATA_CHAR_INDEX], x * this._scaledCellWidth + this._scaledCharLeft, (y + 0.5) * this._scaledCellHeight + this._scaledCharTop); | ||
}; | ||
@@ -148,3 +148,3 @@ BaseRenderLayer.prototype.drawChars = function (terminal, chars, code, width, x, y, fg, bg, bold, dim, italic) { | ||
this._ctx.font = this._getFont(terminal, bold, italic); | ||
this._ctx.textBaseline = 'top'; | ||
this._ctx.textBaseline = 'middle'; | ||
if (fg === Types_1.INVERTED_DEFAULT_COLOR) { | ||
@@ -163,3 +163,3 @@ this._ctx.fillStyle = this._colors.background.css; | ||
} | ||
this._ctx.fillText(chars, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop); | ||
this._ctx.fillText(chars, x * this._scaledCellWidth + this._scaledCharLeft, (y + 0.5) * this._scaledCellHeight + this._scaledCharTop); | ||
this._ctx.restore(); | ||
@@ -166,0 +166,0 @@ }; |
@@ -291,5 +291,7 @@ "use strict"; | ||
var span = row.children[x]; | ||
span.style.textDecoration = enabled ? 'underline' : 'none'; | ||
x = (x + 1) % cols; | ||
if (x === 0) { | ||
if (span) { | ||
span.style.textDecoration = enabled ? 'underline' : 'none'; | ||
} | ||
if (++x >= cols) { | ||
x = 0; | ||
y++; | ||
@@ -296,0 +298,0 @@ } |
@@ -924,2 +924,8 @@ "use strict"; | ||
}; | ||
Terminal.prototype.addCsiHandler = function (flag, callback) { | ||
return this._inputHandler.addCsiHandler(flag, callback); | ||
}; | ||
Terminal.prototype.addOscHandler = function (ident, callback) { | ||
return this._inputHandler.addOscHandler(ident, callback); | ||
}; | ||
Terminal.prototype.registerLinkMatcher = function (regex, handler, options) { | ||
@@ -926,0 +932,0 @@ var matcherId = this.linkifier.registerLinkMatcher(regex, handler, options); |
{ | ||
"name": "xterm", | ||
"description": "Full xterm terminal, in your browser", | ||
"version": "3.10.0-beta2", | ||
"version": "3.10.0-beta3", | ||
"main": "lib/public/Terminal.js", | ||
@@ -6,0 +6,0 @@ "types": "typings/xterm.d.ts", |
@@ -7,4 +7,12 @@ /** | ||
import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from './Types'; | ||
import { IDisposable } from 'xterm'; | ||
import { Disposable } from './common/Lifecycle'; | ||
interface IHandlerCollection<T> { | ||
[key: string]: T[]; | ||
} | ||
type CsiHandler = (params: number[], collect: string) => boolean | void; | ||
type OscHandler = (data: string) => boolean | void; | ||
/** | ||
@@ -226,5 +234,5 @@ * Returns an array filled with numbers between the low and high parameters (right exclusive). | ||
protected _executeHandlers: any; | ||
protected _csiHandlers: any; | ||
protected _csiHandlers: IHandlerCollection<CsiHandler>; | ||
protected _escHandlers: any; | ||
protected _oscHandlers: any; | ||
protected _oscHandlers: IHandlerCollection<OscHandler>; | ||
protected _dcsHandlers: any; | ||
@@ -283,4 +291,4 @@ protected _activeDcsHandler: IDcsHandler | null; | ||
this._executeHandlers = null; | ||
this._escHandlers = null; | ||
this._csiHandlers = null; | ||
this._escHandlers = null; | ||
this._oscHandlers = null; | ||
@@ -309,4 +317,20 @@ this._dcsHandlers = null; | ||
addCsiHandler(flag: string, callback: CsiHandler): IDisposable { | ||
const index = flag.charCodeAt(0); | ||
if (this._csiHandlers[index] === undefined) { | ||
this._csiHandlers[index] = []; | ||
} | ||
const handlerList = this._csiHandlers[index]; | ||
handlerList.push(callback); | ||
return { | ||
dispose: () => { | ||
const handlerIndex = handlerList.indexOf(callback); | ||
if (handlerIndex !== -1) { | ||
handlerList.splice(handlerIndex, 1); | ||
} | ||
} | ||
}; | ||
} | ||
setCsiHandler(flag: string, callback: (params: number[], collect: string) => void): void { | ||
this._csiHandlers[flag.charCodeAt(0)] = callback; | ||
this._csiHandlers[flag.charCodeAt(0)] = [callback]; | ||
} | ||
@@ -330,4 +354,19 @@ clearCsiHandler(flag: string): void { | ||
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { | ||
if (this._oscHandlers[ident] === undefined) { | ||
this._oscHandlers[ident] = []; | ||
} | ||
const handlerList = this._oscHandlers[ident]; | ||
handlerList.push(callback); | ||
return { | ||
dispose: () => { | ||
const handlerIndex = handlerList.indexOf(callback); | ||
if (handlerIndex !== -1) { | ||
handlerList.splice(handlerIndex, 1); | ||
} | ||
} | ||
}; | ||
} | ||
setOscHandler(ident: number, callback: (data: string) => void): void { | ||
this._oscHandlers[ident] = callback; | ||
this._oscHandlers[ident] = [callback]; | ||
} | ||
@@ -469,5 +508,13 @@ clearOscHandler(ident: number): void { | ||
case ParserAction.CSI_DISPATCH: | ||
callback = this._csiHandlers[code]; | ||
if (callback) callback(params, collect); | ||
else this._csiHandlerFb(collect, params, code); | ||
// Trigger CSI Handler | ||
const handlers = this._csiHandlers[code]; | ||
let j = handlers ? handlers.length - 1 : -1; | ||
for (; j >= 0; j--) { | ||
if (handlers[j](params, collect)) { | ||
break; | ||
} | ||
} | ||
if (j < 0) { | ||
this._csiHandlerFb(collect, params, code); | ||
} | ||
break; | ||
@@ -547,5 +594,13 @@ case ParserAction.PARAM: | ||
const content = osc.substring(idx + 1); | ||
callback = this._oscHandlers[identifier]; | ||
if (callback) callback(content); | ||
else this._oscHandlerFb(identifier, content); | ||
// Trigger OSC Handler | ||
const handlers = this._oscHandlers[identifier]; | ||
let j = handlers ? handlers.length - 1 : -1; | ||
for (; j >= 0; j--) { | ||
if (handlers[j](content)) { | ||
break; | ||
} | ||
} | ||
if (j < 0) { | ||
this._oscHandlerFb(identifier, content); | ||
} | ||
} | ||
@@ -552,0 +607,0 @@ } |
@@ -62,2 +62,8 @@ /** | ||
} | ||
public addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable { | ||
return this._core.addCsiHandler(flag, callback); | ||
} | ||
public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { | ||
return this._core.addOscHandler(ident, callback); | ||
} | ||
public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number { | ||
@@ -64,0 +70,0 @@ return this._core.registerLinkMatcher(regex, handler, options); |
@@ -32,3 +32,3 @@ /** | ||
ctx.font = getFont(config.fontWeight, config); | ||
ctx.textBaseline = 'top'; | ||
ctx.textBaseline = 'middle'; | ||
@@ -41,3 +41,3 @@ // Default color | ||
ctx.clip(); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, 0); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight / 2); | ||
ctx.restore(); | ||
@@ -53,3 +53,3 @@ } | ||
ctx.clip(); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight * 1.5); | ||
ctx.restore(); | ||
@@ -70,3 +70,3 @@ } | ||
ctx.fillStyle = config.colors.ansi[colorIndex].css; | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2); | ||
ctx.restore(); | ||
@@ -87,3 +87,3 @@ } | ||
ctx.fillStyle = config.colors.ansi[colorIndex].css; | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y); | ||
ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2); | ||
ctx.restore(); | ||
@@ -90,0 +90,0 @@ } |
@@ -253,3 +253,3 @@ /** | ||
`${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`; | ||
this._tmpCtx.textBaseline = 'top'; | ||
this._tmpCtx.textBaseline = 'middle'; | ||
@@ -263,3 +263,3 @@ this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css; | ||
// Draw the character | ||
this._tmpCtx.fillText(glyph.chars, 0, 0); | ||
this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight / 2); | ||
this._tmpCtx.restore(); | ||
@@ -266,0 +266,0 @@ |
@@ -239,3 +239,3 @@ /** | ||
this._ctx.font = this._getFont(terminal, false, false); | ||
this._ctx.textBaseline = 'top'; | ||
this._ctx.textBaseline = 'middle'; | ||
this._clipRow(terminal, y); | ||
@@ -245,3 +245,3 @@ this._ctx.fillText( | ||
x * this._scaledCellWidth + this._scaledCharLeft, | ||
y * this._scaledCellHeight + this._scaledCharTop); | ||
(y + 0.5) * this._scaledCellHeight + this._scaledCharTop); | ||
} | ||
@@ -300,3 +300,3 @@ | ||
this._ctx.font = this._getFont(terminal, bold, italic); | ||
this._ctx.textBaseline = 'top'; | ||
this._ctx.textBaseline = 'middle'; | ||
@@ -322,3 +322,3 @@ if (fg === INVERTED_DEFAULT_COLOR) { | ||
x * this._scaledCellWidth + this._scaledCharLeft, | ||
y * this._scaledCellHeight + this._scaledCharTop); | ||
(y + 0.5) * this._scaledCellHeight + this._scaledCharTop); | ||
this._ctx.restore(); | ||
@@ -325,0 +325,0 @@ } |
@@ -367,5 +367,7 @@ /** | ||
const span = <HTMLElement>row.children[x]; | ||
span.style.textDecoration = enabled ? 'underline' : 'none'; | ||
x = (x + 1) % cols; | ||
if (x === 0) { | ||
if (span) { | ||
span.style.textDecoration = enabled ? 'underline' : 'none'; | ||
} | ||
if (++x >= cols) { | ||
x = 0; | ||
y++; | ||
@@ -372,0 +374,0 @@ } |
@@ -1416,2 +1416,11 @@ /** | ||
/** Add handler for CSI escape sequence. See xterm.d.ts for details. */ | ||
public addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable { | ||
return this._inputHandler.addCsiHandler(flag, callback); | ||
} | ||
/** Add handler for OSC escape sequence. See xterm.d.ts for details. */ | ||
public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { | ||
return this._inputHandler.addOscHandler(ident, callback); | ||
} | ||
/** | ||
@@ -1418,0 +1427,0 @@ * Registers a link matcher, allowing custom link patterns to be matched and |
@@ -495,2 +495,4 @@ /** | ||
setCsiHandlerFallback(callback: (collect: string, params: number[], flag: number) => void): void; | ||
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable; | ||
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; | ||
@@ -497,0 +499,0 @@ setEscHandler(collectAndFlag: string, callback: () => void): void; |
@@ -485,2 +485,25 @@ /** | ||
/** | ||
* (EXPERIMENTAL) Adds a handler for CSI escape sequences. | ||
* @param flag The flag should be one-character string, which specifies the | ||
* final character (e.g "m" for SGR) of the CSI sequence. | ||
* @param callback The function to handle the escape sequence. The callback | ||
* is called with the numerical params, as well as the special characters | ||
* (e.g. "$" for DECSCPP). 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. | ||
*/ | ||
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable; | ||
/** | ||
* (EXPERIMENTAL) Adds a handler for OSC escape sequences. | ||
* @param ident The number (first parameter) of the sequence. | ||
* @param callback The function to handle the escape sequence. 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. | ||
*/ | ||
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; | ||
/** | ||
* (EXPERIMENTAL) Registers a link matcher, allowing custom link patterns to | ||
@@ -487,0 +510,0 @@ * be matched and handled. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1365964
25399