mirror of
https://github.com/nuintun/command-manager.git
synced 2025-12-15 15:20:06 +08:00
update files
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
module.exports = function (Terminal){
|
||||
// CSI s
|
||||
// Save cursor (ANSI.SYS).
|
||||
Terminal.prototype.saveCursor = function (params){
|
||||
Terminal.prototype.saveCursor = function (){
|
||||
this.savedX = this.x;
|
||||
this.savedY = this.y;
|
||||
};
|
||||
|
||||
// CSI u
|
||||
// Restore cursor (ANSI.SYS).
|
||||
Terminal.prototype.restoreCursor = function (params){
|
||||
Terminal.prototype.restoreCursor = function (){
|
||||
this.x = this.savedX || 0;
|
||||
this.y = this.savedY || 0;
|
||||
};
|
||||
@@ -23,8 +23,11 @@ module.exports = function (Terminal){
|
||||
// Cursor Up Ps Times (default = 1) (CUU).
|
||||
Terminal.prototype.cursorUp = function (params){
|
||||
var param = params[0];
|
||||
|
||||
if (param < 1) param = 1;
|
||||
|
||||
this.y -= param;
|
||||
|
||||
if (this.y < 0) this.y = 0;
|
||||
};
|
||||
|
||||
@@ -32,8 +35,11 @@ module.exports = function (Terminal){
|
||||
// Cursor Down Ps Times (default = 1) (CUD).
|
||||
Terminal.prototype.cursorDown = function (params){
|
||||
var param = params[0];
|
||||
|
||||
if (param < 1) param = 1;
|
||||
|
||||
this.y += param;
|
||||
|
||||
if (this.y >= this.rows) {
|
||||
this.y = this.rows - 1;
|
||||
}
|
||||
@@ -43,8 +49,11 @@ module.exports = function (Terminal){
|
||||
// Cursor Forward Ps Times (default = 1) (CUF).
|
||||
Terminal.prototype.cursorForward = function (params){
|
||||
var param = params[0];
|
||||
|
||||
if (param < 1) param = 1;
|
||||
|
||||
this.x += param;
|
||||
|
||||
if (this.x >= this.cols) {
|
||||
this.x = this.cols - 1;
|
||||
}
|
||||
@@ -54,8 +63,11 @@ module.exports = function (Terminal){
|
||||
// Cursor Backward Ps Times (default = 1) (CUB).
|
||||
Terminal.prototype.cursorBackward = function (params){
|
||||
var param = params[0];
|
||||
|
||||
if (param < 1) param = 1;
|
||||
|
||||
this.x -= param;
|
||||
|
||||
if (this.x < 0) this.x = 0;
|
||||
};
|
||||
|
||||
@@ -93,11 +105,15 @@ module.exports = function (Terminal){
|
||||
// same as CSI Ps B ?
|
||||
Terminal.prototype.cursorNextLine = function (params){
|
||||
var param = params[0];
|
||||
|
||||
if (param < 1) param = 1;
|
||||
|
||||
this.y += param;
|
||||
|
||||
if (this.y >= this.rows) {
|
||||
this.y = this.rows - 1;
|
||||
}
|
||||
|
||||
this.x = 0;
|
||||
};
|
||||
|
||||
@@ -106,9 +122,13 @@ module.exports = function (Terminal){
|
||||
// reuse CSI Ps A ?
|
||||
Terminal.prototype.cursorPrecedingLine = function (params){
|
||||
var param = params[0];
|
||||
|
||||
if (param < 1) param = 1;
|
||||
|
||||
this.y -= param;
|
||||
|
||||
if (this.y < 0) this.y = 0;
|
||||
|
||||
this.x = 0;
|
||||
};
|
||||
|
||||
@@ -116,7 +136,9 @@ module.exports = function (Terminal){
|
||||
// Cursor Character Absolute [column] (default = [row,1]) (CHA).
|
||||
Terminal.prototype.cursorCharAbsolute = function (params){
|
||||
var param = params[0];
|
||||
|
||||
if (param < 1) param = 1;
|
||||
|
||||
this.x = param - 1;
|
||||
};
|
||||
|
||||
@@ -124,6 +146,7 @@ module.exports = function (Terminal){
|
||||
// Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
|
||||
Terminal.prototype.cursorForwardTab = function (params){
|
||||
var param = params[0] || 1;
|
||||
|
||||
while (param--) {
|
||||
this.x = this.nextStop();
|
||||
}
|
||||
@@ -132,9 +155,9 @@ module.exports = function (Terminal){
|
||||
// CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
|
||||
Terminal.prototype.cursorBackwardTab = function (params){
|
||||
var param = params[0] || 1;
|
||||
|
||||
while (param--) {
|
||||
this.x = this.prevStop();
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user