* Separate out DEL vs backspace when possible for ANSI-BBS terminals. *nix terminals don't send us what we need, but deal with it.
* Handle delete in MultiLineTextEditView. More to come soon!
This commit is contained in:
parent
47551b1803
commit
e37409e9b5
|
@ -306,7 +306,21 @@ function Client(input, output) {
|
|||
key.name = 'line feed';
|
||||
} else if('\t' === s) {
|
||||
key.name = 'tab';
|
||||
} else if ('\b' === s || '\x7f' === s || '\x1b\x7f' === s || '\x1b\b' === s) {
|
||||
} else if('\x7f' === s) {
|
||||
//
|
||||
// Backspace vs delete is a crazy thing, especially in *nix.
|
||||
// - ANSI-BBS uses 0x7f for DEL
|
||||
// - xterm et. al clients send 0x7f for backspace... ugg.
|
||||
//
|
||||
// See http://www.hypexr.org/linux_ruboff.php
|
||||
// And a great discussion @ https://lists.debian.org/debian-i18n/1998/04/msg00015.html
|
||||
//
|
||||
if(self.term.isNixTerm()) {
|
||||
key.name = 'backspace';
|
||||
} else {
|
||||
key.name = 'delete';
|
||||
}
|
||||
} else if ('\b' === s || '\x1b\x7f' === s || '\x1b\b' === s) {
|
||||
// backspace, CTRL-H
|
||||
key.name = 'backspace';
|
||||
key.meta = ('\x1b' === s.charAt(0));
|
||||
|
|
|
@ -67,7 +67,7 @@ const SPECIAL_KEY_MAP_DEFAULT = {
|
|||
'line feed' : [ 'return' ],
|
||||
exit : [ 'esc' ],
|
||||
backspace : [ 'backspace' ],
|
||||
delete : [ 'del' ],
|
||||
delete : [ 'delete' ],
|
||||
tab : [ 'tab' ],
|
||||
up : [ 'up arrow' ],
|
||||
down : [ 'down arrow' ],
|
||||
|
@ -354,21 +354,14 @@ function MultiLineEditTextView(options) {
|
|||
};
|
||||
|
||||
this.removeCharactersFromText = function(index, col, operation, count) {
|
||||
if('right' === operation) {
|
||||
if('delete' === operation) {
|
||||
self.textLines[index].text =
|
||||
self.textLines[index].text.slice(col, count) +
|
||||
self.textLines[index].text.slice(0, col) +
|
||||
self.textLines[index].text.slice(col + count);
|
||||
|
||||
self.cursorPos.col -= count;
|
||||
|
||||
self.updateTextWordWrap(index);
|
||||
self.redrawRows(self.cursorPos.row, self.dimens.height);
|
||||
|
||||
if(0 === self.textLines[index].text) {
|
||||
|
||||
} else {
|
||||
self.redrawRows(self.cursorPos.row, self.dimens.height);
|
||||
}
|
||||
self.moveClientCursorToCursorPos();
|
||||
} else if ('backspace' === operation) {
|
||||
// :TODO: method for splicing text
|
||||
self.textLines[index].text =
|
||||
|
@ -868,11 +861,25 @@ function MultiLineEditTextView(options) {
|
|||
};
|
||||
|
||||
this.keyPressDelete = function() {
|
||||
self.removeCharactersFromText(
|
||||
self.getTextLinesIndex(),
|
||||
self.cursorPos.col,
|
||||
'right',
|
||||
1);
|
||||
const lineIndex = self.getTextLinesIndex();
|
||||
|
||||
if(0 === self.cursorPos.col && 0 === self.textLines[lineIndex].text.length && self.textLines.length > 0) {
|
||||
//
|
||||
// Start of line and nothing left. Just delete the line
|
||||
//
|
||||
self.removeCharactersFromText(
|
||||
lineIndex,
|
||||
0,
|
||||
'delete line'
|
||||
);
|
||||
} else {
|
||||
self.removeCharactersFromText(
|
||||
lineIndex,
|
||||
self.cursorPos.col,
|
||||
'delete',
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
self.emitEditPosition();
|
||||
};
|
||||
|
@ -1143,7 +1150,7 @@ const HANDLED_SPECIAL_KEYS = [
|
|||
'line feed',
|
||||
'insert',
|
||||
'tab',
|
||||
'backspace', 'del',
|
||||
'backspace', 'delete',
|
||||
'delete line',
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue