hterm: add a pref for default terminal encoding
This allows for easy experimentation with terminal encoding and is a
step to setting the default encoding to utf8. For now, the default is
unchanged (iso-2022/ecma-35) which means character map (graphics maps)
are available. In the future, if all goes well, we'll default to utf8
and see if anyone notices, and if they do, they'll be able to back out
in the meantime.
BUG=chromium:747625
Change-Id: Ia63542c9a97b18ec09abeb954dc2de75d682d92f
Reviewed-on: https://chromium-review.googlesource.com/591919
Reviewed-by: Brandon Gilmore <varz@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/hterm/js/hterm_preference_manager.js b/hterm/js/hterm_preference_manager.js
index dd6cd06..82a8f52 100644
--- a/hterm/js/hterm_preference_manager.js
+++ b/hterm/js/hterm_preference_manager.js
@@ -441,6 +441,20 @@
[hterm.PreferenceManager.categories.Encoding, 'utf-8', ['utf-8', 'raw'],
'Set the encoding for data sent to host.'],
+ 'terminal-encoding':
+ [hterm.PreferenceManager.categories.Encoding, 'iso-2022',
+ ['iso-2022', 'utf-8', 'utf-8-locked'],
+ 'The default terminal encoding (DOCS).\n' +
+ '\n' +
+ 'ISO-2022 enables character map translations (like graphics maps).\n' +
+ 'UTF-8 disables support for those.\n' +
+ '\n' +
+ 'The locked variant means the encoding cannot be changed at runtime ' +
+ 'via terminal escape sequences.\n' +
+ '\n' +
+ 'You should stick with UTF-8 unless you notice broken rendering with ' +
+ 'legacy applications.'],
+
'shift-insert-paste':
[hterm.PreferenceManager.categories.Keyboard, true, 'bool',
'Shift + Insert pastes if true, sent to host if false.'],
diff --git a/hterm/js/hterm_terminal.js b/hterm/js/hterm_terminal.js
index 31f56ef..b802580 100644
--- a/hterm/js/hterm_terminal.js
+++ b/hterm/js/hterm_terminal.js
@@ -537,6 +537,26 @@
terminal.keyboard.shiftInsertPaste = v;
},
+ 'terminal-encoding': function(v) {
+ switch (v) {
+ default:
+ console.warn('Invalid value for "terminal-encoding": ' + v);
+ // Fall through.
+ case 'iso-2022':
+ terminal.vt.codingSystemUtf8 = false;
+ terminal.vt.codingSystemLocked = false;
+ break;
+ case 'utf-8-locked':
+ terminal.vt.codingSystemUtf8 = true;
+ terminal.vt.codingSystemLocked = true;
+ break;
+ case 'utf-8':
+ terminal.vt.codingSystemUtf8 = true;
+ terminal.vt.codingSystemLocked = false;
+ break;
+ }
+ },
+
'user-css': function(v) {
terminal.scrollPort_.setUserCssUrl(v);
},