cli icon indicating copy to clipboard operation
cli copied to clipboard

add clear screen support with CTRL-L

Open lu-maca opened this issue 1 year ago • 3 comments

#229

Changes:

  • add to *keyboard.h support for CTRL-L;
  • a CTRL-L in Terminal::Keypressed() clears the screen by flushing the escape string on the ostream;
  • after a CTRL-L, restore the session by calling session.Prompt()

TODO: add escape string for windows

lu-maca avatar May 06 '24 23:05 lu-maca

Thank you for your contribution, Luca. I just need you to get rid of the std::string_view since this is a C++14 library, and std::string_view is in the C++17 standard. Sorry, but we need to keep compatibility with C++14. Thanks.

daniele77 avatar May 09 '24 21:05 daniele77

Hi @daniele77, no problem for me. I'm having some troubles with including the change for windows. I'm not sure if there is a way to clear the terminal without invoking some system call. Would it be ok?

lu-maca avatar May 12 '24 16:05 lu-maca

After a quick check, I made Windows ctrl-L work using a Windows API. Unfortunately, the library currently does not distinguish between Windows and Linux "terminal" (class Terminal is unique, as you can see), so I must put in place some design refractory to the class structure. Besides, ctrl-L doesn't work on the telnet terminal either. I hope this can be fixed, I'll look at it in the next few days.

daniele77 avatar May 13 '24 17:05 daniele77

After a quick check, I made Windows ctrl-L work using a Windows API. Unfortunately, the library currently does not distinguish between Windows and Linux "terminal" (class Terminal is unique, as you can see), so I must put in place some design refractory to the class structure. Besides, ctrl-L doesn't work on the telnet terminal either. I hope this can be fixed, I'll look at it in the next few days.

This was my doubt: I was not sure if using Windows API would broke something on other sides. Linux can have this problem too: escape sequences for clearing the terminal are not - as far as I know - standardized for different terminals

lu-maca avatar May 16 '24 14:05 lu-maca

I've already implemented (not yet pushed on the server, though) all the machinery needed to make ctrl-L work on Linux, Windows, and telnet. However, I've used the escape sequence for Linux (and telnet), and I don't know if it will work on different terminals. I'm going to push the feature in the next few days, after the usual tests and documentation update.

daniele77 avatar May 16 '24 14:05 daniele77