* Minor updates to MultiLineEditTextView
This commit is contained in:
parent
e62d146075
commit
e46105984c
|
@ -215,7 +215,6 @@ function MultiLineEditTextView(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getTextBufferPosition = function(row, col) {
|
this.getTextBufferPosition = function(row, col) {
|
||||||
var line = self.renderBuffer[row];
|
|
||||||
var replaceTabsRe = self.getReplaceTabsRegExp();
|
var replaceTabsRe = self.getReplaceTabsRegExp();
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
for(var r = 0; r < row; ++r) {
|
for(var r = 0; r < row; ++r) {
|
||||||
|
@ -232,9 +231,14 @@ function MultiLineEditTextView(options) {
|
||||||
return pos;
|
return pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getLineTextLength = function(row) {
|
||||||
|
return self.renderBuffer[row].replace(self.getReplaceTabsRegExp(), '\t').replace(/\n/g, '').length;
|
||||||
|
//return self.renderBuffer[row].replace(/\n/g, '').length;
|
||||||
|
};
|
||||||
|
|
||||||
this.getEndOfLinePosition = function(row) {
|
this.getEndOfLinePosition = function(row) {
|
||||||
row = row || self.cursorPos.row;
|
row = row || self.cursorPos.row;
|
||||||
return self.position.col + self.renderBuffer[row].length;
|
return self.position.col + self.getLineTextLength(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getAbsolutePosition = function(row, col) {
|
this.getAbsolutePosition = function(row, col) {
|
||||||
|
@ -284,10 +288,16 @@ function MultiLineEditTextView(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.cursorRight = function() {
|
this.cursorRight = function() {
|
||||||
var max = Math.min(self.dimens.width, self.renderBuffer[self.cursorPos.row].length);
|
var max = Math.min(self.dimens.width, self.getLineTextLength(self.cursorPos.row) - 1);
|
||||||
if(self.cursorPos.col < max) {
|
if(self.cursorPos.col < max) {
|
||||||
self.cursorPos.col++;
|
self.cursorPos.col++;
|
||||||
self.client.term.write(ansi.right());
|
self.client.term.write(ansi.right());
|
||||||
|
|
||||||
|
// make tab adjustment if necessary
|
||||||
|
if('\t' === self.getCharAtCursorPosition()) {
|
||||||
|
self.cursorPos.col++;
|
||||||
|
self.client.term.write(ansi.right(self.tabWidth - 1));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if(self.cursorPos.row > 0) {
|
if(self.cursorPos.row > 0) {
|
||||||
self.cursorPos.row--;
|
self.cursorPos.row--;
|
||||||
|
@ -379,7 +389,10 @@ MultiLineEditTextView.prototype.onSpecialKeyPress = function(keyName) {
|
||||||
this.cursorRight();
|
this.cursorRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(JSON.stringify(this.getAbsolutePosition()) + ': ' + this.getCharAtCursorPosition())
|
console.log(
|
||||||
|
'row=' + this.cursorPos.row + ' / col=' + this.cursorPos.col +
|
||||||
|
' / abs=' + JSON.stringify(this.getAbsolutePosition()) +
|
||||||
|
': ' + this.getCharAtCursorPosition() + '( ' + this.getCharAtCursorPosition().charCodeAt(0) + ')')
|
||||||
|
|
||||||
MultiLineEditTextView.super_.prototype.onSpecialKeyPress.call(this, keyName);
|
MultiLineEditTextView.super_.prototype.onSpecialKeyPress.call(this, keyName);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue