terminal-kit
Advanced tools
Comparing version 2.9.1 to 2.9.2
@@ -99,6 +99,8 @@ /* | ||
CTRL_X: 'deleteSelection' , | ||
SHIFT_LEFT: 'extendSelectionBackward' , | ||
SHIFT_RIGHT: 'extendSelectionForward' , | ||
SHIFT_UP: 'extendSelectionUp' , | ||
SHIFT_DOWN: 'extendSelectionDown' , | ||
SHIFT_LEFT: 'expandSelectionBackward' , | ||
SHIFT_RIGHT: 'expandSelectionForward' , | ||
SHIFT_UP: 'expandSelectionUp' , | ||
SHIFT_DOWN: 'expandSelectionDown' , | ||
CTRL_SHIFT_LEFT: 'expandSelectionStartOfWord' , | ||
CTRL_SHIFT_RIGHT: 'expandSelectionEndOfWord' , | ||
CTRL_K: 'meta' , | ||
@@ -162,3 +164,6 @@ // We copy vi/vim here, that use 'y' for copy (yank) and 'p' for paste (put) | ||
this.textBuffer.insert( str , this.textAttr ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -187,3 +192,6 @@ } | ||
var count = this.textBuffer.insert( key , this.textAttr ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -215,3 +223,6 @@ this.emit( 'change' , { | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -232,3 +243,6 @@ this.emit( 'change' , { | ||
this.textBuffer.insert( '\t' , this.textAttr ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -249,3 +263,6 @@ this.emit( 'change' , { | ||
var deleted = this.textBuffer.delete( 1 , true ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -269,3 +286,6 @@ | ||
var deleted = this.textBuffer.backDelete( 1 , true ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -288,3 +308,6 @@ | ||
var deleted = this.textBuffer.deleteLine( true ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -308,3 +331,6 @@ | ||
var deleted = this.textBuffer.deleteSelection( true ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
// No .hilightSelection() here, cause we just deleted it | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -397,3 +423,3 @@ | ||
userActions.extendSelectionBackward = function() { | ||
userActions.expandSelectionBackward = function() { | ||
var selection = this.textBuffer.selectionRegion , | ||
@@ -404,3 +430,3 @@ cx = this.textBuffer.cx , | ||
if ( selection && selection.xmin === cx && selection.ymin === cy ) { | ||
// Can extend | ||
// Can expand | ||
this.textBuffer.moveBackward() ; | ||
@@ -425,3 +451,3 @@ this.textBuffer.startOfSelection() ; | ||
userActions.extendSelectionUp = function() { | ||
userActions.expandSelectionStartOfWord = function() { | ||
var selection = this.textBuffer.selectionRegion , | ||
@@ -432,3 +458,29 @@ cx = this.textBuffer.cx , | ||
if ( selection && selection.xmin === cx && selection.ymin === cy ) { | ||
// Can extend | ||
// Can expand | ||
this.textBuffer.moveToStartOfWord() ; | ||
this.textBuffer.startOfSelection() ; | ||
} | ||
else if ( selection && selection.xmax === cx - 1 && selection.ymax === cy ) { | ||
// Can contract | ||
this.textBuffer.moveToStartOfWord() ; | ||
this.textBuffer.endOfSelection() ; | ||
} | ||
else { | ||
// Start a new selection | ||
this.textBuffer.endOfSelection() ; | ||
this.textBuffer.moveToStartOfWord() ; | ||
this.textBuffer.startOfSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
this.emit( 'cursorMove' ) ; | ||
} ; | ||
userActions.expandSelectionUp = function() { | ||
var selection = this.textBuffer.selectionRegion , | ||
cx = this.textBuffer.cx , | ||
cy = this.textBuffer.cy ; | ||
if ( selection && selection.xmin === cx && selection.ymin === cy ) { | ||
// Can expand | ||
this.textBuffer.moveUp() ; | ||
@@ -455,3 +507,3 @@ this.textBuffer.startOfSelection() ; | ||
userActions.extendSelectionForward = function() { | ||
userActions.expandSelectionForward = function() { | ||
var selection = this.textBuffer.selectionRegion , | ||
@@ -462,3 +514,3 @@ cx = this.textBuffer.cx , | ||
if ( selection && selection.xmax === cx - 1 && selection.ymax === cy ) { | ||
// Can extend | ||
// Can expand | ||
this.textBuffer.moveForward() ; | ||
@@ -483,3 +535,3 @@ this.textBuffer.endOfSelection() ; | ||
userActions.extendSelectionDown = function() { | ||
userActions.expandSelectionEndOfWord = function() { | ||
var selection = this.textBuffer.selectionRegion , | ||
@@ -490,3 +542,29 @@ cx = this.textBuffer.cx , | ||
if ( selection && selection.xmax === cx - 1 && selection.ymax === cy ) { | ||
// Can extend | ||
// Can expand | ||
this.textBuffer.moveToEndOfWord() ; | ||
this.textBuffer.endOfSelection() ; | ||
} | ||
else if ( selection && selection.xmin === cx && selection.ymin === cy ) { | ||
// Can contract | ||
this.textBuffer.moveToEndOfWord() ; | ||
this.textBuffer.startOfSelection() ; | ||
} | ||
else { | ||
// Start a new selection | ||
this.textBuffer.startOfSelection() ; | ||
this.textBuffer.moveToEndOfWord() ; | ||
this.textBuffer.endOfSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
this.emit( 'cursorMove' ) ; | ||
} ; | ||
userActions.expandSelectionDown = function() { | ||
var selection = this.textBuffer.selectionRegion , | ||
cx = this.textBuffer.cx , | ||
cy = this.textBuffer.cy ; | ||
if ( selection && selection.xmax === cx - 1 && selection.ymax === cy ) { | ||
// Can expand | ||
this.textBuffer.moveDown() ; | ||
@@ -531,3 +609,6 @@ this.textBuffer.endOfSelection() ; | ||
let count = this.textBuffer.insert( str , this.textAttr ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -554,3 +635,6 @@ this.emit( 'change' , { | ||
let count = this.textBuffer.insert( str , this.textAttr ) ; | ||
this.textBuffer.runStateMachine() ; | ||
if ( this.stateMachine ) { | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
this.autoScrollAndDraw() ; | ||
@@ -557,0 +641,0 @@ this.emit( 'change' , { |
@@ -496,2 +496,3 @@ /* | ||
this.textBuffer.runStateMachine() ; | ||
this.textBuffer.hilightSelection() ; | ||
} | ||
@@ -498,0 +499,0 @@ |
@@ -645,2 +645,6 @@ /* | ||
ALT_LEFT: '\x1b[1;3D' , | ||
ALT_SHIFT_UP: '\x1b[1;4A' , | ||
ALT_SHIFT_DOWN: '\x1b[1;4B' , | ||
ALT_SHIFT_RIGHT: '\x1b[1;4C' , | ||
ALT_SHIFT_LEFT: '\x1b[1;4D' , | ||
CTRL_UP: '\x1b[1;5A' , | ||
@@ -650,2 +654,6 @@ CTRL_DOWN: '\x1b[1;5B' , | ||
CTRL_LEFT: '\x1b[1;5D' , | ||
CTRL_SHIFT_UP: '\x1b[1;6A' , | ||
CTRL_SHIFT_DOWN: '\x1b[1;6B' , | ||
CTRL_SHIFT_RIGHT: '\x1b[1;6C' , | ||
CTRL_SHIFT_LEFT: '\x1b[1;6D' , | ||
@@ -652,0 +660,0 @@ //BACKSPACE: '\x7f' , |
@@ -679,2 +679,19 @@ /* | ||
TextBuffer.prototype.isInSelection = function( x = this.cx , y = this.cy ) { | ||
if ( ! this.selectionRegion ) { return false ; } | ||
return this.isInRegion( this.selectionRegion , x , y ) ; | ||
} ; | ||
TextBuffer.prototype.isInRegion = function( region , x = this.cx , y = this.cy ) { | ||
return ( | ||
y >= region.ymin && y <= region.ymax | ||
&& ( y !== region.ymin || x >= region.xmin ) | ||
&& ( y !== region.ymax || x <= region.xmax ) | ||
) ; | ||
} ; | ||
TextBuffer.prototype.setSelectionRegion = function( region ) { | ||
@@ -750,3 +767,3 @@ if ( this.selectionRegion ) { | ||
// Internal | ||
// Internal or maybe useful for userland? | ||
TextBuffer.prototype.hilightSelection = function( turnOn = true ) { | ||
@@ -819,3 +836,6 @@ var x , y , xmin , xmax , ymax , | ||
TextBuffer.prototype.deleteSelection = function( getDeleted = false ) { | ||
return this.deleteRegion( this.selectionRegion , getDeleted ) ; | ||
if ( ! this.selectionRegion ) { return ; } | ||
var deleted = this.deleteRegion( this.selectionRegion , getDeleted ) ; | ||
this.selectionRegion = null ; // unselect now | ||
return deleted ; | ||
} ; | ||
@@ -822,0 +842,0 @@ |
{ | ||
"name": "terminal-kit", | ||
"version": "2.9.1", | ||
"version": "2.9.2", | ||
"description": "256 colors, keys and mouse, input field, progress bars, screen buffer (including 32-bit composition and image loading), text buffer, and many more... Whether you just need colors and styles, build a simple interactive command line tool or a complexe terminal app: this is the absolute terminal lib for Node.js!", | ||
@@ -5,0 +5,0 @@ "main": "lib/termkit.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4767862
81701