Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep slave program in sync with terminal #146

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions demo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ app.ws('/bash', function(ws, req) {
});
term.on('data', function(data) {
try {
// XOFF - stop pty pipe
// XON will be triggered by emulator before processing data chunk
term.write('\x13');
ws.send(data);
} catch (ex) {
// The WebSocket is not open, ignore
Expand Down
12 changes: 12 additions & 0 deletions src/xterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@
this.prefix = '';
this.postfix = '';

// user input states
this.user_xoff = false; // user pressed XOFF

/**
* An array of all lines in the entire buffer, including the prompt. The lines are array of
* characters which are 2-length arrays where [0] is an attribute and [1] is the character.
Expand Down Expand Up @@ -1458,6 +1461,11 @@
* @public
*/
Terminal.prototype.write = function(data) {
// XON - about to process data, thus we can get more
// dont lift XOFF if user pressed it
if (!this.user_xoff)
this.send('\x11');

var l = data.length, i = 0, j, cs, ch;

this.refreshStart = this.y;
Expand Down Expand Up @@ -2655,6 +2663,10 @@
}
break;
}
if (result.key === '\x13')
this.user_xoff = true;
else if (result.key === '\x11')
this.user_xoff = false;
return result;
};

Expand Down