hterm: Add character map overrides preference.
character-map-overrides is specified as an object. It is a sparse
array, where each property is the character set code and the value is
an object that is a sparse array itself. In that sparse array, each
property is the received character and the value is the displayed
character.
For example, specifying the following:
{"0":{"+":"\u2192",",":"\u2190","-":"\u2191",".":"\u2193",
"0":"\u2588","h":"\u2591","i":"\u256c","~":"\u2022"}}
This would modify character set "0" and add codes for "+", ",", "-",
"." (arrows pointing right, left, up, and down, respectively), and "0"
(solid square block). It would also change the codes for "h" to a
light shade (board of squares), "i" to box drawings double vertical
and horizontal (lantern symbol), and "~" to a bullet.
This is useful for things like adding codes for the alternate
character set in ncurses. The terminfo man page
(http://manpages.ubuntu.com/manpages/trusty/man5/terminfo.5.html)
shows the glyphs supported by ncurses (search for "Line Graphics" on
the page).
Change-Id: I3a50fec7988eaba90d4846afa546ec11e32bf0ea
Reviewed-on: https://chromium-review.googlesource.com/259550
Reviewed-by: Rob Ginda <rginda@chromium.org>
Tested-by: Rob Ginda <rginda@chromium.org>
diff --git a/hterm/js/hterm_terminal.js b/hterm/js/hterm_terminal.js
index 59caee9..4cdd4ae 100644
--- a/hterm/js/hterm_terminal.js
+++ b/hterm/js/hterm_terminal.js
@@ -277,6 +277,22 @@
terminal.keyboard.backspaceSendsBackspace = v;
},
+ 'character-map-overrides': function(v) {
+ if (!(v == null || v instanceof Object)) {
+ console.warn('Preference character-map-modifications is not an ' +
+ 'object: ' + v);
+ return;
+ }
+
+ for (var code in v) {
+ var glmap = hterm.VT.CharacterMap.maps[code].glmap;
+ for (var received in v[code]) {
+ glmap[received] = v[code][received];
+ }
+ hterm.VT.CharacterMap.maps[code].reset(glmap);
+ }
+ },
+
'cursor-blink': function(v) {
terminal.setCursorBlink(!!v);
},