omove. misc.

This commit is contained in:
Christopher Jeffrey 2013-07-12 01:04:57 -05:00
parent ead26b4a66
commit 3ef2048289
2 changed files with 53 additions and 40 deletions

View File

@ -725,6 +725,36 @@ Program.prototype.move = function(x, y) {
return this.cursorPos(y, x); return this.cursorPos(y, x);
}; };
// TODO: Fix cud and cuu calls.
Program.prototype.omove = function(x, y) {
if (!this.zero) {
x = (x || 1) - 1;
y = (y || 1) - 1;
} else {
x = x || 0;
y = y || 0;
}
if (y === this.y && x === this.x) {
return;
}
if (y === this.y) {
if (x > this.x) {
this.cuf(x - this.x);
} else if (x < this.x) {
this.cub(this.x - x);
}
} else if (x === this.x) {
if (y > this.y) {
this.cud(y - this.y);
} else if (y < this.y) {
this.cuu(this.y - y);
}
} else {
if (!this.zero) x++, y++;
this.cup(y, x);
}
};
Program.prototype.rsetx = function(x) { Program.prototype.rsetx = function(x) {
// return this.HPositionRelative(x); // return this.HPositionRelative(x);
if (!x) return; if (!x) return;
@ -777,7 +807,9 @@ Program.prototype.vtab = function() {
return this.write('\x0b'); return this.write('\x0b');
}; };
Program.prototype.ff =
Program.prototype.form = function() { Program.prototype.form = function() {
if (this.tput) return this.put.ff();
return this.write('\x0c'); return this.write('\x0c');
}; };
@ -798,10 +830,12 @@ Program.prototype.tab = function() {
}; };
Program.prototype.shiftOut = function() { Program.prototype.shiftOut = function() {
// if (this.tput) return this.put.S2();
return this.write('\x0e'); return this.write('\x0e');
}; };
Program.prototype.shiftIn = function() { Program.prototype.shiftIn = function() {
// if (this.tput) return this.put.S3();
return this.write('\x0f'); return this.write('\x0f');
}; };
@ -1013,6 +1047,8 @@ Program.prototype.rmacs = function() {
Program.prototype.setG = function(val) { Program.prototype.setG = function(val) {
// tput: TODO // tput: TODO
// if (this.tput) return this.put('s' + val); // if (this.tput) return this.put('s' + val);
// if (this.tput) return this.put.S2();
// if (this.tput) return this.put.S3();
switch (val) { switch (val) {
case 1: case 1:
val = '~'; // GR val = '~'; // GR
@ -2238,7 +2274,7 @@ Program.prototype.cht =
Program.prototype.cursorForwardTab = function(param) { Program.prototype.cursorForwardTab = function(param) {
this.x += 8; this.x += 8;
this._ncoords(); this._ncoords();
// Does not exit (?): // Does not exist (?):
// if (this.tput) return this.put.cht(param); // if (this.tput) return this.put.cht(param);
if (this.tput) return this.put.tab(param); // or this.put.ht if (this.tput) return this.put.tab(param); // or this.put.ht
return this.write('\x1b[' + (param || 1) + 'I'); return this.write('\x1b[' + (param || 1) + 'I');
@ -2249,7 +2285,7 @@ Program.prototype.su =
Program.prototype.scrollUp = function(param) { Program.prototype.scrollUp = function(param) {
this.y -= param || 1; this.y -= param || 1;
this._ncoords(); this._ncoords();
// Does not exit: // Does not exist:
// if (this.tput) return this.put.su(param); // if (this.tput) return this.put.su(param);
if (this.tput) return this.put.rin(param); if (this.tput) return this.put.rin(param);
return this.write('\x1b[' + (param || 1) + 'I'); return this.write('\x1b[' + (param || 1) + 'I');
@ -2260,7 +2296,7 @@ Program.prototype.sd =
Program.prototype.scrollDown = function(param) { Program.prototype.scrollDown = function(param) {
this.y += param || 1; this.y += param || 1;
this._ncoords(); this._ncoords();
// Does not exit: // Does not exist:
// if (this.tput) return this.put.sd(param); // if (this.tput) return this.put.sd(param);
if (this.tput) return this.put.indn(param); if (this.tput) return this.put.indn(param);
return this.write('\x1b[' + (param || 1) + 'T'); return this.write('\x1b[' + (param || 1) + 'T');

View File

@ -2064,7 +2064,7 @@ function List(options) {
}); });
} }
function resize() { this.on('resize', function() {
var visible = self.height - (self.border ? 2 : 0); var visible = self.height - (self.border ? 2 : 0);
if (visible >= self.selected + 1) { if (visible >= self.selected + 1) {
//if (self.selected < visible - 1) { //if (self.selected < visible - 1) {
@ -2075,11 +2075,7 @@ function List(options) {
self.childBase = self.selected - visible + 1; self.childBase = self.selected - visible + 1;
self.childOffset = visible - 1; self.childOffset = visible - 1;
} }
} });
// this.onScreenEvent('resize', resize);
this.on('resize', resize);
} }
List.prototype.__proto__ = ScrollableBox.prototype; List.prototype.__proto__ = ScrollableBox.prototype;
@ -2169,6 +2165,7 @@ List.prototype.select = function(index) {
if (this.selected === index && this._listInitialized) return; if (this.selected === index && this._listInitialized) return;
this._listInitialized = true; this._listInitialized = true;
// TODO: Handle this a less stupid way.
['bg', 'fg', 'bold', 'underline', ['bg', 'fg', 'bold', 'underline',
'blink', 'inverse', 'invisible'].forEach(function(name) { 'blink', 'inverse', 'invisible'].forEach(function(name) {
if (this.items[this.selected]) { if (this.items[this.selected]) {
@ -2506,9 +2503,6 @@ function Textarea(options) {
this.value = options.value || ''; this.value = options.value || '';
this.cx = -1;
this.cy = -1;
this.__updateCursor = this.updateCursor.bind(this); this.__updateCursor = this.updateCursor.bind(this);
this.on('resize', this.__updateCursor); this.on('resize', this.__updateCursor);
this.on('move', this.__updateCursor); this.on('move', this.__updateCursor);
@ -2523,10 +2517,6 @@ Textarea.prototype.updateCursor = function() {
return; return;
} }
// To test blessed-maintained coords:
// this.cx = this.screen.program.x;
// this.cy = this.screen.program.y;
var last = this._clines[this._clines.length-1] var last = this._clines[this._clines.length-1]
, program = this.screen.program , program = this.screen.program
, line , line
@ -2547,35 +2537,25 @@ Textarea.prototype.updateCursor = function() {
cy = this.top + (this.border ? 1 : 0) + line; cy = this.top + (this.border ? 1 : 0) + line;
cx = this.left + (this.border ? 1 : 0) + last.length; cx = this.left + (this.border ? 1 : 0) + last.length;
if (cy === this.cy && cx === this.cx) { if (cy === program.y && cx === program.x) {
return; return;
} }
if (cy === this.cy) { if (cy === program.y) {
if (cx > this.cx) { if (cx > program.x) {
program.cuf(cx - this.cx); program.cuf(cx - program.x);
} else if (cx < this.cx) { } else if (cx < program.x) {
program.cub(this.cx - cx); program.cub(program.x - cx);
} }
} else if (cx === this.cx) { } else if (cx === program.x) {
if (cy > this.cy) { if (cy > program.y) {
// if (cy - this.cy === 1) { program.cud(cy - program.y);
// program.ind(); } else if (cy < program.y) {
// } else { program.cuu(program.y - cy);
program.cud(cy - this.cy);
} else if (cy < this.cy) {
// Technically works:
// if (this.cy - cy === 1) {
// program.ri();
// } else {
program.cuu(this.cy - cy);
} }
} else { } else {
program.cup(cy, cx); program.cup(cy, cx);
} }
this.cx = cx;
this.cy = cy;
}; };
Textarea.prototype.input = Textarea.prototype.input =
@ -2591,9 +2571,6 @@ Textarea.prototype.setInput = function(callback) {
this.screen.grabKeys = true; this.screen.grabKeys = true;
this.cx = -1;
this.cy = -1;
this.updateCursor(); this.updateCursor();
this.screen.program.showCursor(); this.screen.program.showCursor();
this.screen.program.sgr('normal'); this.screen.program.sgr('normal');