terminal-kit
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -23,2 +23,4 @@ | ||
* Methods: | ||
* [.destroy()](#ref.Element.destroy) | ||
* [.destroyNoRedraw()](#ref.Element.destroyNoRedraw) | ||
* [.updateZ() / .updateZIndex()](#ref.Element.updateZ) | ||
@@ -92,2 +94,19 @@ * [.topZ()](#ref.Element.topZ) | ||
<a name="ref.Element.destroy"></a> | ||
### .destroy() | ||
It destroys the *element* immediately, and triggers all draw/redraw necessary to remove it from the screen now. | ||
<a name="ref.Element.destroyNoRedraw"></a> | ||
### .destroyNoRedraw() | ||
It destroys the *element* immediately, but nothing is redrawn, so the *element* is still visible until the next redraw. | ||
It is usually done when there is a lot of *elements* to remove at once, to avoid redrawing the screen for each one, which would dramatically slow down the app. | ||
Instead of `.destroy()`, it's best to use `.destroyNoRedraw()` each *element*, and then to call `document.draw()` once done. | ||
<a name="ref.Element.updateZ"></a> | ||
@@ -94,0 +113,0 @@ ### .updateZ( z ) / .updateZIndex( z ) |
@@ -157,5 +157,19 @@ /* | ||
BaseMenu.prototype.focusFirstPageItem = function( focusType ) { | ||
this.focusChild = this.children[ this.page ? 1 : 0 ] ; | ||
var focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
if ( ! focusAware ) { this.document.focusNext() ; } | ||
} ; | ||
BaseMenu.prototype.focusLastPageItem = function( focusType ) { | ||
this.focusChild = this.children[ this.page === this.maxPage ? this.children.length - 1 : this.children.length - 2 ] ; | ||
var focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
if ( ! focusAware ) { this.document.focusNext() ; } | ||
} ; | ||
BaseMenu.prototype.previousPage = function( focusType ) { | ||
var focusAware ; | ||
if ( this.maxPage && this.page > 0 ) { | ||
@@ -165,5 +179,6 @@ this.page -- ; | ||
this.focusChild = this.children[ this.children.length - 2 ] ; | ||
focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
let focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
if ( ! focusAware ) { this.document.focusPrevious() ; } | ||
this.updateDraw() ; | ||
this.emit( 'previousPage' , this.page , this ) ; | ||
} | ||
@@ -175,4 +190,2 @@ } ; | ||
BaseMenu.prototype.nextPage = function( focusType ) { | ||
var focusAware ; | ||
if ( this.maxPage && this.page < this.maxPage ) { | ||
@@ -182,5 +195,6 @@ this.page ++ ; | ||
this.focusChild = this.children[ 1 ] ; | ||
focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
let focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
if ( ! focusAware ) { this.document.focusNext() ; } | ||
this.updateDraw() ; | ||
this.emit( 'nextPage' , this.page , this ) ; | ||
} | ||
@@ -192,9 +206,7 @@ } ; | ||
BaseMenu.prototype.toPage = function( page , focusType ) { | ||
var focusAware ; | ||
if ( this.maxPage && page !== this.page ) { | ||
this.page = page ; | ||
this.initPage() ; | ||
this.focusChild = this.children[ 1 ] ; | ||
focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
this.focusChild = this.children[ this.page ? 1 : 0 ] ; | ||
let focusAware = this.document.giveFocusTo_( this.focusChild , focusType ) ; | ||
if ( ! focusAware ) { this.document.focusNext() ; } | ||
@@ -483,2 +495,5 @@ this.updateDraw() ; | ||
} | ||
else { | ||
this.focusFirstPageItem( 'backCycle' ) ; | ||
} | ||
} ; | ||
@@ -490,2 +505,5 @@ | ||
} | ||
else { | ||
this.focusLastPageItem( 'cycle' ) ; | ||
} | ||
} ; | ||
@@ -497,2 +515,5 @@ | ||
} | ||
else { | ||
this.focusFirstPageItem( 'backCycle' ) ; | ||
} | ||
} ; | ||
@@ -504,4 +525,15 @@ | ||
} | ||
else { | ||
this.focusLastPageItem( 'cycle' ) ; | ||
} | ||
} ; | ||
userActions.firstPageItem = function() { | ||
this.focusFirstPageItem( 'backCycle' ) ; | ||
} ; | ||
userActions.lastPageItem = function() { | ||
this.focusLastPageItem( 'cycle' ) ; | ||
} ; | ||
userActions.parentMenu = function() { | ||
@@ -508,0 +540,0 @@ if ( this.isSubmenu ) { |
@@ -320,2 +320,3 @@ /* | ||
this.buttons.length = 0 ; | ||
this.hotkeyToButtonIndex.clear() ; | ||
@@ -411,2 +412,11 @@ this.pageItemsDef[ page ].forEach( ( def , index ) => { | ||
if ( def.hotkey ) { | ||
if ( Array.isArray( def.hotkey ) ) { | ||
def.hotkey.forEach( hotkey => this.hotkeyToButtonIndex.set( hotkey , index ) ) ; | ||
} | ||
else { | ||
this.hotkeyToButtonIndex.set( def.hotkey , index ) ; | ||
} | ||
} | ||
if ( isToggle ) { | ||
@@ -413,0 +423,0 @@ this.buttons[ index ].on( 'toggle' , this.onButtonToggle ) ; |
@@ -173,4 +173,7 @@ /* | ||
// User API | ||
Element.prototype.destroyNoRedraw = function() { return this.destroy( undefined , true ) ; } ; | ||
Element.inherit = function( Class , FromClass = Element ) { | ||
@@ -177,0 +180,0 @@ Class.prototype = Object.create( FromClass.prototype ) ; |
@@ -372,3 +372,3 @@ /* | ||
sortedChannels = [ ... rgb ].sort() ; | ||
sortedChannels = [ ... rgb ].sort( ( a , b ) => a - b ) ; | ||
@@ -375,0 +375,0 @@ //console.log( "Clipped!" , rgb , chromaColor.rgb() ) ; |
{ | ||
"name": "terminal-kit", | ||
"version": "3.0.1", | ||
"version": "3.0.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!", | ||
@@ -19,4 +19,4 @@ "main": "lib/termkit.js", | ||
"seventh": "^0.9.2", | ||
"string-kit": "^0.17.10", | ||
"tree-kit": "^0.8.1" | ||
"string-kit": "^0.18.1", | ||
"tree-kit": "^0.8.7" | ||
}, | ||
@@ -23,0 +23,0 @@ "scripts": { |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
4670066
76487
+ Addedstring-kit@0.18.3(transitive)
- Removedstring-kit@0.17.10(transitive)
Updatedstring-kit@^0.18.1
Updatedtree-kit@^0.8.7