add clear screen support with CTRL-L
#229
Changes:
- add to
*keyboard.hsupport 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
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.
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?
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.
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
Terminalis 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
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.