Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add clear screen support with CTRL-L #242

Merged
merged 2 commits into from
May 21, 2024

Conversation

lu-maca
Copy link
Contributor

@lu-maca lu-maca commented May 6, 2024

#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

@daniele77
Copy link
Owner

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.

@lu-maca
Copy link
Contributor Author

lu-maca commented May 12, 2024

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?

@daniele77
Copy link
Owner

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.

@lu-maca
Copy link
Contributor Author

lu-maca commented May 16, 2024

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

@daniele77
Copy link
Owner

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 daniele77 merged commit b99fbea into daniele77:master May 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants