Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
/ hterm Public archive

Commit

Permalink
hterm 1.1, Grab bag of fixes.
Browse files Browse the repository at this point in the history
* Fix base64 encoding of the bell audio.
* Reset the vt object when terminal is reset.
* Break out of a parseUntilStringTerminator_ if an embedded ESC is
  found (other than the one that may appear as part of a 7-bit ST),
  or if the sequence has been going on for too long (measured by the
  wall clock).

BUG=chromium:191050, Map Chrome OS top-row keys to function keys.
BUG=chromum-os:30792, beeps accumulate - leads to non stop beeping
BUG=chromum-os:35288, scroll-on-output doesn't appear to work
BUG=chromum-os:39645, Application keypad doesn't work properly

TEST=hterm_test.html 66/66 tests passed.

Change-Id: I65bf070e596d4fd5134d3c6d9e43b63f7b2def0e
Reviewed-on: https://gerrit.chromium.org/gerrit/45485
Reviewed-by: Dmitry Polukhin <[email protected]>
Commit-Queue: Robert Ginda <[email protected]>
Reviewed-by: Robert Ginda <[email protected]>
Tested-by: Robert Ginda <[email protected]>
  • Loading branch information
rginda authored and ChromeBot committed Mar 18, 2013
1 parent e2d6890 commit ad50607
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 61 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
17 changes: 0 additions & 17 deletions bin/echo_changelog.sh

This file was deleted.

5 changes: 5 additions & 0 deletions concat/hterm_deps.concat
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ libdot/js/lib_storage_local.js
libdot/js/lib_storage_memory.js
libdot/js/lib_test_manager.js
libdot/js/lib_utf8.js

@resource libdot/changelog/version text/plain $ \
echo_changelog version "$(search_file libdot/doc/changelog.txt)"
@resource libdot/changelog/version text/plain $ \
echo_changelog date "$(search_file libdot/doc/changelog.txt)"
7 changes: 4 additions & 3 deletions concat/hterm_resources.concat
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

# This file lists the resources needed by hterm.

@resource hterm/audio/bell audio/ogg;base64 < hterm/audio/bell.ogg
@resource hterm/changelog/version text/plain $ ../bin/echo_changelog.sh version
@resource hterm/changelog/date text/plain $ ../bin/echo_changelog.sh date
@resource hterm/audio/bell audio/ogg;base64 $ base64 -w0 ../audio/bell.ogg
@resource hterm/concat/date text/plain $ date -uR
@resource hterm/changelog/version text/plain $ echo_changelog version
@resource hterm/changelog/date text/plain $ echo_changelog date
@resource hterm/git/HEAD text/plain $ git rev-parse HEAD
@resource hterm/git/shortstat text/plain $ git diff --shortstat | sed -e 's/ //'
12 changes: 12 additions & 0 deletions doc/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
1.1, 2013-03-13, Grab bag of fixes.

* Fix base64 encoding of the bell audio.
* Break out of a parseUntilStringTerminator_ if an embedded ESC is
found (other than the one that may appear as part of a 7-bit ST),
or if the sequence has been going on for too long (measured by the
wall clock).
* BUG=chromium:191050, Map Chrome OS top-row keys to function keys.
* BUG=chromum-os:30792, beeps accumulate - leads to non stop beeping
* BUG=chromum-os:35288, scroll-on-output doesn't appear to work
* BUG=chromum-os:39645, Application keypad doesn't work properly

1.0, 2013-03-06, Initial split from Secure Shell codebase.

* Move nassh related files out into ../nassh/.
Expand Down
70 changes: 41 additions & 29 deletions js/hterm_keyboard_keymap.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,20 @@ hterm.Keyboard.KeyMap.prototype.reset = function() {
[8, '[BKSP]', bs('\x7f', '\b'), bs('\b', '\x7f'), DEFAULT, DEFAULT],

// Third row.
[9, '[TAB]', '\t', STRIP, PASS, DEFAULT],
[81, 'qQ', DEFAULT, ctl('Q'), DEFAULT, DEFAULT],
[87, 'wW', DEFAULT, ctl('W'), DEFAULT, DEFAULT],
[69, 'eE', DEFAULT, ctl('E'), DEFAULT, DEFAULT],
[82, 'rR', DEFAULT, ctl('R'), DEFAULT, DEFAULT],
[84, 'tT', DEFAULT, ctl('T'), DEFAULT, DEFAULT],
[89, 'yY', DEFAULT, ctl('Y'), DEFAULT, DEFAULT],
[85, 'uU', DEFAULT, ctl('U'), DEFAULT, DEFAULT],
[73, 'iI', DEFAULT, ctl('I'), DEFAULT, DEFAULT],
[79, 'oO', DEFAULT, ctl('O'), DEFAULT, DEFAULT],
[80, 'pP', DEFAULT, ctl('P'), DEFAULT, DEFAULT],
[219, '[{', DEFAULT, ctl('['), DEFAULT, DEFAULT],
[221, ']}', DEFAULT, ctl(']'), DEFAULT, DEFAULT],
[220, '\\|', DEFAULT, ctl('\\'), DEFAULT, DEFAULT],
[9, '[TAB]', sh('\t', CSI + 'Z'), STRIP, PASS, DEFAULT],
[81, 'qQ', DEFAULT, ctl('Q'), DEFAULT, DEFAULT],
[87, 'wW', DEFAULT, ctl('W'), DEFAULT, DEFAULT],
[69, 'eE', DEFAULT, ctl('E'), DEFAULT, DEFAULT],
[82, 'rR', DEFAULT, ctl('R'), DEFAULT, DEFAULT],
[84, 'tT', DEFAULT, ctl('T'), DEFAULT, DEFAULT],
[89, 'yY', DEFAULT, ctl('Y'), DEFAULT, DEFAULT],
[85, 'uU', DEFAULT, ctl('U'), DEFAULT, DEFAULT],
[73, 'iI', DEFAULT, ctl('I'), DEFAULT, DEFAULT],
[79, 'oO', DEFAULT, ctl('O'), DEFAULT, DEFAULT],
[80, 'pP', DEFAULT, ctl('P'), DEFAULT, DEFAULT],
[219, '[{', DEFAULT, ctl('['), DEFAULT, DEFAULT],
[221, ']}', DEFAULT, ctl(']'), DEFAULT, DEFAULT],
[220, '\\|', DEFAULT, ctl('\\'), DEFAULT, DEFAULT],

// Fourth row. (We let Ctrl-Shift-J pass for Chrome DevTools.)
[20, '[CAPS]', PASS, PASS, PASS, DEFAULT],
Expand Down Expand Up @@ -300,21 +300,33 @@ hterm.Keyboard.KeyMap.prototype.reset = function() {
// and 'block of six' for some keys, and null key codes for the rest.

// Keypad with numlock on generates unique key codes...
[96, '[KP0]', ak(DEFAULT, CSI + '2~'), DEFAULT, DEFAULT, DEFAULT],
[97, '[KP1]', ak(DEFAULT, SS3 + 'F'), DEFAULT, DEFAULT, DEFAULT],
[98, '[KP2]', ak(DEFAULT, CSI + 'B'), DEFAULT, DEFAULT, DEFAULT],
[99, '[KP3]', ak(DEFAULT, CSI + '6~'), DEFAULT, DEFAULT, DEFAULT],
[100, '[KP4]', ak(DEFAULT, CSI + 'D'), DEFAULT, DEFAULT, DEFAULT],
[101, '[KP5]', ak(DEFAULT, CSI + 'E'), DEFAULT, DEFAULT, DEFAULT],
[102, '[KP6]', ak(DEFAULT, CSI + 'C'), DEFAULT, DEFAULT, DEFAULT],
[103, '[KP7]', ak(DEFAULT, SS3 + 'H'), DEFAULT, DEFAULT, DEFAULT],
[104, '[KP8]', ak(DEFAULT, CSI + 'A'), DEFAULT, DEFAULT, DEFAULT],
[105, '[KP9]', ak(DEFAULT, CSI + '5~'), DEFAULT, DEFAULT, DEFAULT],
[107, '[KP+]', ak(DEFAULT, SS3 + 'k'), DEFAULT, DEFAULT, DEFAULT],
[109, '[KP-]', ak(DEFAULT, SS3 + 'm'), DEFAULT, DEFAULT, DEFAULT],
[106, '[KP*]', ak(DEFAULT, SS3 + 'j'), DEFAULT, DEFAULT, DEFAULT],
[111, '[KP/]', ak(DEFAULT, SS3 + 'o'), DEFAULT, DEFAULT, DEFAULT],
[110, '[KP.]', ak(DEFAULT, CSI + '3~'), DEFAULT, DEFAULT, DEFAULT]
[96, '[KP0]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[97, '[KP1]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[98, '[KP2]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[99, '[KP3]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[100, '[KP4]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[101, '[KP5]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[102, '[KP6]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[103, '[KP7]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[104, '[KP8]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[105, '[KP9]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[107, '[KP+]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[109, '[KP-]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[106, '[KP*]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[111, '[KP/]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],
[110, '[KP.]', DEFAULT, DEFAULT, DEFAULT, DEFAULT],

// Chrome OS keyboard top row.
[166, '[BACK]', mod(SS3 + 'P', CSI + 'P'), DEFAULT, CSI + "23~", DEFAULT],
[167, '[FWD]', mod(SS3 + 'Q', CSI + 'Q'), DEFAULT, CSI + "24~", DEFAULT],
[168, '[RELOAD]', mod(SS3 + 'R', CSI + 'R'), DEFAULT, CSI + "25~", DEFAULT],
[183, '[FSCR]', mod(SS3 + 'S', CSI + 'S'), DEFAULT, CSI + "26~", DEFAULT],
[182, '[WINS]', CSI + '15~', DEFAULT, CSI + "28~", DEFAULT],
[216, '[BRIT-]', CSI + '17~', DEFAULT, CSI + "29~", DEFAULT],
[217, '[BRIT+]', CSI + '18~', DEFAULT, CSI + "31~", DEFAULT],
[173, '[MUTE]', CSI + '19~', DEFAULT, CSI + "32~", DEFAULT],
[174, '[VOL-]', CSI + '20~', DEFAULT, CSI + "33~", DEFAULT],
[175, '[VOL+]', CSI + '21~', DEFAULT, CSI + "34~", DEFAULT]
);
};

Expand Down
3 changes: 3 additions & 0 deletions js/hterm_scrollport.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ hterm.ScrollPort.prototype.redraw_ = function() {

this.previousRowNodeCache_ = this.currentRowNodeCache_;
this.currentRowNodeCache_ = null;

this.isScrolledEnd = (
this.getTopRowIndex() + this.visibleRowCount >= this.lastRowCount_);
};

/**
Expand Down
20 changes: 17 additions & 3 deletions js/hterm_terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@ hterm.Terminal.prototype.reset = function() {

this.setCursorBlink(!!this.prefs_.get('cursor-blink'));

this.vt.reset();

this.softReset();
};

Expand Down Expand Up @@ -1872,18 +1874,30 @@ hterm.Terminal.prototype.setReverseVideo = function(state) {

/**
* Ring the terminal bell.
*
* This will not play the bell audio more than once per second.
*/
hterm.Terminal.prototype.ringBell = function() {
if (this.bellAudio_.getAttribute('src'))
this.bellAudio_.play();

this.cursorNode_.style.backgroundColor =
this.scrollPort_.getForegroundColor();

var self = this;
setTimeout(function() {
self.cursorNode_.style.backgroundColor = self.prefs_.get('cursor-color');
}, 200);

if (this.bellAudio_.getAttribute('src')) {
if (this.bellSquelchTimeout_ || term_.bellAudio_.currentTime != 0)
return;

this.bellAudio_.play();

this.bellSequelchTimeout_ = setTimeout(function() {
delete this.bellSquelchTimeout_;
}.bind(this), 1000);
} else {
delete this.bellSquelchTimeout_;
}
};

/**
Expand Down
33 changes: 24 additions & 9 deletions js/hterm_vt.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ hterm.VT = function(terminal) {
// True if we should fake-out mouse "cell motion" reporting (DECSET 1002)
this.mouseCellMotionTrick_ = false;

// The amount of time we're willing to wait for the end of an OSC sequence.
this.oscTimeLimit_ = 20000;

// Construct a regular expression to match the known one-byte control chars.
// This is used in parseUnknown_ to quickly scan a string for the next
// control character.
Expand Down Expand Up @@ -616,24 +619,36 @@ hterm.VT.prototype.parseUntilStringTerminator_ = function(parseState) {
var nextTerminator = buf.search(/(\x1b\\|\x07)/);
var args = parseState.args;

if (!args.length)
if (!args.length) {
args[0] = '';
args[1] = new Date();
}

if (nextTerminator == -1) {
// No terminator here, have to wait for the next string.

args[0] += buf;

if (args[0].length <= this.maxStringSequence) {
// If we're at or under the limit for a runaway sequence, consume
// what we've seen and wait for more.
parseState.advance(buf.length);
return true;
var abortReason;

if (args[0].length > this.maxStringSequence)
abortReason = 'too long: ' + args[0].length;

if (args[0].indexOf('\x1b') != -1)
abortReason = 'embedded escape: ' + args[0].indexOf('\x1b');

if (new Date() - args[1] > this.oscTimeLimit_)
abortReason = 'timeout expired: ' + new Date() - args[1];

if (abortReason) {
console.log('parseUntilStringTerminator_: aborting: ' + abortReason,
args[0]);
parseState.reset(args[0]);
return false;
}

// Otherwise, re-parse using the default parser.
parseState.reset(args[0]);
return false;
parseState.advance(buf.length);
return true;
}

if (args[0].length + nextTerminator > this.maxStringSequence) {
Expand Down
80 changes: 80 additions & 0 deletions test_data/utf-8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
From the Anglo-Saxon Rune Poem:
ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ
ᛋᚳᛖᚪᛚ᛫ᚦᛖᚪᚻ᛫ᛗᚪᚾᚾᚪ᛫ᚷᛖᚻᚹᛦᛚᚳ᛫ᛗᛁᚳᛚᚢᚾ᛫ᚻᛦᛏ᛫ᛞᚫᛚᚪᚾ
ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ᛬

From Laȝamon's Brut (Middle English, West Midlands):
An preost wes on leoden, Laȝamon was ihoten
He wes Leovenaðes sone -- liðe him be Drihten.
He wonede at Ernleȝe at æðelen are chirechen,
Uppen Sevarne staþe, sel þar him þuhte,
Onfest Radestone, þer he bock radde.

From the Tagelied of Wolfram von Eschenbach (Middle High German):
Sîne klâwen durh die wolken sint geslagen,
er stîget ûf mit grôzer kraft,
ich sih in grâwen tägelîch als er wil tagen,
den tac, der im geselleschaft
erwenden wil, dem werden man,
den ich mit sorgen în verliez.
ich bringe in hinnen, ob ich kan.
sîn vil manegiu tugent michz leisten hiez.

Some lines of Odysseus Elytis (Greek):
Monotonic:
Τη γλώσσα μου έδωσαν ελληνική<
το σπίτι φτωχικό στις αμμουδιές του Ομήρου.
Μονάχη έγνοια η γλώσσα μου στις αμμουδιές του Ομήρου.

από το Άξιον Εστί
του Οδυσσέα Ελύτη

Polytonic:
Τὴ γλῶσσα μοῦ ἔδωσαν ἑλληνικὴ
τὸ σπίτι φτωχικὸ στὶς ἀμμουδιὲς τοῦ Ὁμήρου.
Μονάχη ἔγνοια ἡ γλῶσσα μου στὶς ἀμμουδιὲς τοῦ Ὁμήρου.

ἀπὸ τὸ Ἄξιον ἐστί
τοῦ Ὀδυσσέα Ἐλύτη

The first stanza of Pushkin's Bronze Horseman (Russian):
На берегу пустынных волн
Стоял он, дум великих полн,
И вдаль глядел. Пред ним широко
Река неслася; бедный чёлн
По ней стремился одиноко.
По мшистым, топким берегам
Чернели избы здесь и там,
Приют убогого чухонца;
И лес, неведомый лучам
В тумане спрятанного солнца,
Кругом шумел.

Šota Rustaveli's Veṗxis Ṭq̇aosani, ̣︡Th, The Knight in the Tiger's Skin
(Georgian):
ვეპხის ტყაოსანი
შოთა რუსთაველი

ღმერთსი შემვედრე, ნუთუ კვლა დამხსნას სოფლისა შრომასა,
ცეცხლს, წყალსა და მიწასა, ჰაერთა თანა მრომასა;
მომცნეს ფრთენი და აღვფრინდე, მივჰხვდე მას ჩემსა ნდომასა,
დღისით და ღამით ვჰხედვიდე მზისა ელვათა კრთომაასა.

Tamil poetry of Subramaniya Bharathiyar: சுப்ரமணிய பாரதியார் (1882-1921):
யாமறிந்த மொழிகளிலே தமிழ்மொழி போல் இனிதாவது எங்கும் காணோம்,
பாமரராய் விலங்குகளாய், உலகனைத்தும் இகழ்ச்சிசொலப் பான்மை கெட்டு,
நாமமது தமிழரெனக் கொண்டு இங்கு வாழ்ந்திடுதல் நன்றோ? சொல்லீர்!
தேமதுரத் தமிழோசை உலகமெலாம் பரவும்வகை செய்தல் வேண்டும்.

Kannada poetry by Kuvempu - ಬಾ ಇಲ್ಲಿ ಸಂಭವಿಸು
ಬಾ ಇಲ್ಲಿ ಸಂಭವಿಸು ಇಂದೆನ್ನ ಹೃದಯದಲಿ
ನಿತ್ಯವೂ ಅವತರಿಪ ಸತ್ಯಾವತಾರ

ಮಣ್ಣಾಗಿ ಮರವಾಗಿ ಮಿಗವಾಗಿ ಕಗವಾಗೀ...

ಮಣ್ಣಾಗಿ ಮರವಾಗಿ ಮಿಗವಾಗಿ ಕಗವಾಗಿ

ಭವ ಭವದಿ ಭತಿಸಿಹೇ ಭವತಿ ದೂರ

ನಿತ್ಯವೂ ಅವತರಿಪ ಸತ್ಯಾವತಾರ || ಬಾ ಇಲ್ಲಿ ||

0 comments on commit ad50607

Please sign in to comment.