mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
options. events. readme.
This commit is contained in:
@@ -21,7 +21,8 @@ window.addEventListener('load', function() {
|
||||
socket.on('connect', function() {
|
||||
var term = new Terminal({
|
||||
cols: 80,
|
||||
rows: 24
|
||||
rows: 24,
|
||||
screenKeys: true
|
||||
});
|
||||
|
||||
term.on('data', function(data) {
|
||||
@@ -47,6 +48,28 @@ window.addEventListener('load', function() {
|
||||
}, false);
|
||||
```
|
||||
|
||||
## Tmux-like
|
||||
|
||||
While term.js has always supported copy/paste using the mouse, it now also
|
||||
supports several keyboard based solutions for copy/paste.
|
||||
|
||||
term.js includes a tmux-like selection mode (enabled with the `screenKeys`
|
||||
option) which makes copy and paste very simple. `Ctrl-A` enters `prefix` mode,
|
||||
from here you can type `Ctrl-V` to paste. Press `[` in prefix mode to enter
|
||||
selection mode. To select text press `v` (or `space`) to enter visual mode, use
|
||||
`hjkl` to navigate and create a selection, and press `Ctrl-C` to copy.
|
||||
|
||||
`Ctrl-C` (in visual mode) and `Ctrl-V` (in prefix mode) should work in any OS
|
||||
for copy and paste. `y` (in visual mode) will work for copying only on X11
|
||||
systems. It will copy to the primary selection.
|
||||
|
||||
Note: `Ctrl-C` will also work in prefix mode for the regular OS/browser
|
||||
selection. If you want to select text with your mouse and copy it to the
|
||||
clipboard, simply select the text and type `Ctrl-A + Ctrl-C`, and
|
||||
`Ctrl-A + Ctrl-V` to paste it.
|
||||
|
||||
For mac users: consider `Ctrl` to be `Command/Apple` above.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||
|
||||
+2
-1
@@ -37,7 +37,8 @@
|
||||
var term = new Terminal({
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
useStyle: true
|
||||
useStyle: true,
|
||||
screenKeys: true
|
||||
});
|
||||
|
||||
term.on('data', function(data) {
|
||||
|
||||
+19
-34
@@ -216,6 +216,8 @@ function Terminal(options) {
|
||||
this.entry = '';
|
||||
this.entryPrefix = '';
|
||||
this._real;
|
||||
this._selected;
|
||||
this._textarea;
|
||||
|
||||
// charset
|
||||
this.charset = null;
|
||||
@@ -390,7 +392,7 @@ Terminal.defaults = {
|
||||
visualBell: false,
|
||||
popOnBell: false,
|
||||
scrollback: 1000,
|
||||
// screenKeys: false,
|
||||
screenKeys: false,
|
||||
// programFeatures: false,
|
||||
// escapeKey: null,
|
||||
debug: false,
|
||||
@@ -467,7 +469,6 @@ Terminal.prototype.initGlobal = function() {
|
||||
|
||||
Terminal.bindKeys(document);
|
||||
|
||||
//if (this.screenKeys)
|
||||
Terminal.bindCopy(document);
|
||||
|
||||
if (this.isIpad) {
|
||||
@@ -2536,10 +2537,11 @@ Terminal.prototype.keyDown = function(ev) {
|
||||
return;
|
||||
}
|
||||
// Ctrl-A
|
||||
//if (this.screenKeys)
|
||||
if (!this.prefixMode && !this.selectMode && ev.keyCode === 65) {
|
||||
this.enterPrefix();
|
||||
return cancel(ev);
|
||||
if (this.screenKeys) {
|
||||
if (!this.prefixMode && !this.selectMode && ev.keyCode === 65) {
|
||||
this.enterPrefix();
|
||||
return cancel(ev);
|
||||
}
|
||||
}
|
||||
// Ctrl-V
|
||||
if (this.prefixMode && ev.keyCode === 86) {
|
||||
@@ -2584,8 +2586,6 @@ Terminal.prototype.keyDown = function(ev) {
|
||||
break;
|
||||
}
|
||||
|
||||
// this.emit('keydown', ev);
|
||||
|
||||
if (!key) return true;
|
||||
|
||||
if (this.prefixMode) {
|
||||
@@ -4905,13 +4905,15 @@ Terminal.prototype.keyPrefix = function(ev, key) {
|
||||
} else if (key === 'c') {
|
||||
this.emit('request create');
|
||||
} else if (key >= '0' && key <= '9') {
|
||||
this.emit('request tab', +key);
|
||||
key = +key - 1;
|
||||
if (!~key) key = 9;
|
||||
this.emit('request term', key);
|
||||
} else if (key === 'n') {
|
||||
this.emit('request tab next');
|
||||
this.emit('request term next');
|
||||
} else if (key === 'P') {
|
||||
this.emit('request tab previous');
|
||||
this.emit('request term previous');
|
||||
} else if (key === ':') {
|
||||
// this.enterCommand();
|
||||
this.emit('request command mode');
|
||||
} else if (key === '[') {
|
||||
this.enterSelect();
|
||||
}
|
||||
@@ -5030,7 +5032,7 @@ Terminal.prototype.keySelect = function(ev, key) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'v') {
|
||||
if (key === 'v' || key === ' ') {
|
||||
if (!this.visualMode) {
|
||||
this.enterVisual();
|
||||
} else {
|
||||
@@ -5388,21 +5390,6 @@ Terminal.prototype.keySelect = function(ev, key) {
|
||||
return false;
|
||||
};
|
||||
|
||||
Terminal.prototype.keyVisual = function(ev, key) {
|
||||
var ox = this.x
|
||||
, oy = this.y
|
||||
, oyd = this.ydisp
|
||||
, ret;
|
||||
|
||||
ret = this.keySelect(ev, key);
|
||||
|
||||
if (ret !== false && this.visualMode) {
|
||||
this.selectText(this.x, ox, this.ydisp + this.y, oy + oyd);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Terminal.prototype.keySearch = function(ev, key) {
|
||||
if (key === '\x1b') {
|
||||
this.leaveSearch();
|
||||
@@ -5457,7 +5444,7 @@ Terminal.prototype.keySearch = function(ev, key) {
|
||||
y++;
|
||||
if (y > this.ybase + this.rows - 1) {
|
||||
if (wrapped) break;
|
||||
// set_message("Search wrapped. Continuing at TOP.");
|
||||
// this.setMessage('Search wrapped. Continuing at TOP.');
|
||||
wrapped = true;
|
||||
y = 0;
|
||||
}
|
||||
@@ -5465,7 +5452,7 @@ Terminal.prototype.keySearch = function(ev, key) {
|
||||
y--;
|
||||
if (y < 0) {
|
||||
if (wrapped) break;
|
||||
// set_message("Search wrapped. Continuing at BOTTOM.");
|
||||
// this.setMessage('Search wrapped. Continuing at BOTTOM.');
|
||||
wrapped = true;
|
||||
y = this.ybase + this.rows - 1;
|
||||
}
|
||||
@@ -5488,17 +5475,15 @@ Terminal.prototype.keySearch = function(ev, key) {
|
||||
this.x = x, this.y = y;
|
||||
this.scrollDisp(-this.ydisp + yb);
|
||||
|
||||
// if (!wrapped) UPDATE_SCROLL;
|
||||
|
||||
if (this.visualMode) {
|
||||
this.selectText(ox, this.x, oy + oyd, this.ydisp + this.y);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
// set_message("No matches found.");
|
||||
}
|
||||
|
||||
// this.setMessage("No matches found.");
|
||||
this.refresh(0, this.rows - 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user