dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Using Blessed with Vorpal causes two characters input instead of one #278

Open jeffhuys opened 7 years ago

jeffhuys commented 7 years ago

Using Blessed in conjunction with Vorpal like this:

const blessed = require('blessed')
const vorpal  = require('vorpal')()

const program = blessed.program() // Commenting this out means normal behaviour

vorpal
  .command('test')
  .action(function (args, cb) {
    this.log('Good luck getting to this command!')
    cb()
  })

vorpal
  .delimiter('> ')
  .show()

Causes output like this:

➔ node minimal.js
> tteesstt

  Invalid Command. Showing Help:

  Commands:

    help [command...]  Provides help for a given command.
    exit               Exits application.
    test

>
>

As you can probably tell, every keystroke is sent / read twice, even the "return" key.
My guess is that Blessed attaches their own listener, and emits the event as well? Just a guess, though.

Maybe someone with knowledge of Blessed can help me out?

dthree commented 7 years ago

Vorpal doesn't play well with any other library that attempts to control the terminal. Both libraries add listeners, and then do their own thing.

jeffhuys commented 7 years ago

@dthree I see. Is there any other way to make this work (like only calling blessed.program() when I want to hand the terminal over to blessed)? Or is what I want a lost cause?

milesj commented 7 years ago

Is there a reason you're trying to use both together?

jeffhuys commented 7 years ago

@milesj yes, I want to create a REPL where I create dashboards. So, first I use Vorpal to allow for commands to be parsed. When a user types "create dashboard" or "show dashboard dash1", it hands the terminal over to Blessed, where it can do its thing (show a dynamic dashboard), and when q is pressed, it hands the terminal back to Vorpal, where other commands can be supplied.

amir-arad commented 6 years ago

i would like that very very much as well