McParen / croatoan

This repository has been migrated to Codeberg.
Other
147 stars 13 forks source link

Question build a cli interface using croatoan #17

Closed vin-d closed 4 years ago

vin-d commented 4 years ago

Hi, I'd like to build a small CLI using croatoan with sbcl and would need a bit of help to know how to achieve that. my running environment is Debian and bash terminal

Goal : have a CLI program started from bash which react similarly like other interpreters (take python as example).

I launch my sbcl program with cl-launch which work fine, but then my standard input is in cooked mode . Because of this I use croatoan doing

(croatoan:with-screen (scr :input-buffering nil :process-control-chars t
...)

so I can get each char typed one by one (cbreak mode)to catch up and down arrows (for command history) and tab for autocompletion.

I have a few undesirable effect when I am in the with-screen macro :

So how should I use croatoan to use my terminal window without a new screen even if I want to be in cbreak mode. how can I get the value of the arrow keys so I can propose command line history like most shells do.

Thanks.

McParen commented 4 years ago

Hello vin-d,

Although it is possible to keep the previous screen with ncurses using the newterm() init function instead of initscr(), ncurses is intentionally designed to take over the whole screen, and not to just provide bindings to command line apps.

What you are looking for is not ncurses/croatoan, but packages like linedit and cl-readline, which do not provide full-screen access, but just a command line.

Having said that, in your other questions, (format t "xyz") prints to the standard output, which is the repl in your terminal and not the ncurses screen. You either have to bind standard-output to the initialized scr, or use scr as the output stream in format: (format scr "xyz").

In order to be able to use the arrow keys, you have to similarly read the char from scr, not from the terminal standard input.

vin-d commented 4 years ago

Thank you for the response, indeed linedit and cl-readline look more appropriate for the CLI I want to build.