Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

console-gui-tools

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-gui-tools - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

30

index.js

@@ -264,2 +264,4 @@ import { EventEmitter } from "events"

this.visible = visible
this.marginTop = 4
this.startIndex = 0
if (this.CM.widgetsCollection[this.id]) {

@@ -274,9 +276,23 @@ this.CM.unRegisterWidget(this)

adaptOptions() {
return this.options.slice(this.startIndex, this.startIndex + this.CM.Terminal.rows - this.marginTop - 4)
}
keyListner(str, key) {
switch (key.name) {
case 'down':
this.setSelected(this.options[(this.options.indexOf(this.selected) + 1) % this.options.length])
this.setSelected(this.options[(this.options.indexOf(this.selected) + 1) % this.options.length], false)
if (this.CM.Terminal.rows - this.marginTop - 4 < this.options.length) {
if (this.selected === this.options[this.adaptOptions().length + this.startIndex]) {
this.startIndex++
}
} else {
this.startIndex = 0
}
break
case 'up':
this.setSelected(this.options[(this.options.indexOf(this.selected) - 1 + this.options.length) % this.options.length])
this.setSelected(this.options[(this.options.indexOf(this.selected) - 1 + this.options.length) % this.options.length], false)
if (this.startIndex > 0 && this.selected === this.adaptOptions()[0]) {
this.startIndex--
}
break

@@ -317,3 +333,3 @@ case 'return':

setSelected(selected) {
setSelected(selected, refresh = true) {
this.selected = selected

@@ -359,2 +375,6 @@ this.CM.refresh()

draw() {
// Change start index if selected is not in the adaptOptions return array
if (this.adaptOptions().indexOf(this.selected) === -1) {
this.startIndex = this.options.indexOf(this.selected) - this.adaptOptions().length + 1 > 0 ? this.options.indexOf(this.selected) - this.adaptOptions().length + 1 : 0
}
const offset = 2

@@ -380,3 +400,3 @@ const maxOptionsLength = this.options.map((o) => o.toString()).reduce((max, option) => Math.max(max, option.length), 0)

let content = ""
this.options.forEach((option, index) => {
this.adaptOptions().forEach((option, index) => {
content += `│${option === this.selected ? "<" : " "} ${option}${option === this.selected ? " >" : " "}${" ".repeat(windowWidth - option.toString().length - 4)}│\n`

@@ -387,3 +407,3 @@ })

windowDesign.split('\n').forEach((line, index) => {
this.CM.Terminal.cursorTo(Math.round((this.CM.Terminal.columns / 2) - (windowWidth / 2)), 4 + index)
this.CM.Terminal.cursorTo(Math.round((this.CM.Terminal.columns / 2) - (windowWidth / 2)), this.marginTop + index)
this.CM.Terminal.write(line)

@@ -390,0 +410,0 @@ })

2

package.json
{
"name": "console-gui-tools",
"version": "1.1.1",
"version": "1.1.2",
"description": "A simple library to draw option menu or other popup inputs and layout on Node.js console.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc