Public Access
Terminal: measure characters with Unicode 11 widths, so an emoji takes the two columns the remote counts
This commit is contained in:
1 parent
ad1a129159
commit
6806e542f9
9 files changed
+136
-6
No files matched your search
@@ -203,12 +203,22 @@ function FakeTerminal(options) {
|
||||
this.focuses = 0;
|
||||
this.disposed = false;
|
||||
this.pane = null;
|
||||
this.addons = [];
|
||||
|
||||
// The proposed unicode API, at xterm's own default, so a test can see which table the page picked.
|
||||
this.unicode = { activeVersion: '6' };
|
||||
|
||||
terminals.push(this);
|
||||
}
|
||||
|
||||
FakeTerminal.prototype.loadAddon = function () {};
|
||||
FakeTerminal.prototype.open = function (pane) { this.pane = pane; };
|
||||
FakeTerminal.prototype.loadAddon = function (addon) { this.addons.push(addon); };
|
||||
FakeTerminal.prototype.open = function (pane) {
|
||||
this.pane = pane;
|
||||
|
||||
// Taken at open() because that is when the first frame is laid out: a table chosen afterwards would leave
|
||||
// whatever was drawn first measured with the old one.
|
||||
this.unicodeAtOpen = this.unicode.activeVersion;
|
||||
};
|
||||
FakeTerminal.prototype.attachCustomKeyEventHandler = function (handler) { this.keys = handler; };
|
||||
FakeTerminal.prototype.onData = function (handler) { this.data = handler; };
|
||||
FakeTerminal.prototype.onResize = function (handler) { this.resized = handler; };
|
||||
@@ -242,6 +252,12 @@ var FitAddon = {
|
||||
},
|
||||
};
|
||||
|
||||
var Unicode11Addon = {
|
||||
Unicode11Addon: function () {
|
||||
this.kind = 'unicode11';
|
||||
},
|
||||
};
|
||||
|
||||
var WebglAddon = {
|
||||
WebglAddon: function () {
|
||||
this.onContextLoss = function () {};
|
||||
@@ -489,6 +505,16 @@ function typed(sessionId) {
|
||||
return terminalFor(sessionId).inputs.join('|');
|
||||
}
|
||||
|
||||
/** Which character-width table the pane was opened with. */
|
||||
function unicodeAtOpen(sessionId) {
|
||||
return terminalFor(sessionId).unicodeAtOpen;
|
||||
}
|
||||
|
||||
/** Whether that pane loaded the Unicode 11 addon. */
|
||||
function hasUnicode11(sessionId) {
|
||||
return terminalFor(sessionId).addons.some(function (addon) { return addon.kind === 'unicode11'; });
|
||||
}
|
||||
|
||||
/** How many times that pane has been asked for the caret. */
|
||||
function focuses(sessionId) {
|
||||
return terminalFor(sessionId).focuses;
|
||||
|
||||
Reference in new issue
Block a user