libdot: add a lib.f.getOs helper
We do ad-hoc OS detection in a few places. Merge this into a central
location to avoid all that nonsense.
Change-Id: I286d54ba1f5754a2bba794fb6648da0686c06510
Reviewed-on: https://chromium-review.googlesource.com/822774
Reviewed-by: Brandon Gilmore <varz@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/hterm/js/hterm_terminal.js b/hterm/js/hterm_terminal.js
index 6001bfa..7180967 100644
--- a/hterm/js/hterm_terminal.js
+++ b/hterm/js/hterm_terminal.js
@@ -458,11 +458,9 @@
'pass-alt-number': function(v) {
if (v == null) {
- var osx = window.navigator.userAgent.match(/Mac OS X/);
-
// Let Alt-1..9 pass to the browser (to control tab switching) on
// non-OS X systems, or if hterm is not opened in an app window.
- v = (!osx && hterm.windowType != 'popup');
+ v = (hterm.os != 'mac' && hterm.windowType != 'popup');
}
terminal.passAltNumber = v;
@@ -470,11 +468,9 @@
'pass-ctrl-number': function(v) {
if (v == null) {
- var osx = window.navigator.userAgent.match(/Mac OS X/);
-
// Let Ctrl-1..9 pass to the browser (to control tab switching) on
// non-OS X systems, or if hterm is not opened in an app window.
- v = (!osx && hterm.windowType != 'popup');
+ v = (hterm.os != 'mac' && hterm.windowType != 'popup');
}
terminal.passCtrlNumber = v;
@@ -482,11 +478,9 @@
'pass-meta-number': function(v) {
if (v == null) {
- var osx = window.navigator.userAgent.match(/Mac OS X/);
-
// Let Meta-1..9 pass to the browser (to control tab switching) on
// OS X systems, or if hterm is not opened in an app window.
- v = (osx && hterm.windowType != 'popup');
+ v = (hterm.os == 'mac' && hterm.windowType != 'popup');
}
terminal.passMetaNumber = v;
@@ -809,8 +803,7 @@
return;
}
- var ary = navigator.userAgent.match(/\(X11;\s+(\S+)/);
- if (!ary || ary[1] == 'CrOS') {
+ if (hterm.os != 'linux') {
this.mousePasteButton = 1; // Middle mouse button.
} else {
this.mousePasteButton = 2; // Right mouse button.