-
Notifications
You must be signed in to change notification settings - Fork 53
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
cpp-terminal road map #114
Comments
Do you think is good? @certik I thought this is a good idea to keep on track on things. You can do some things as well if something interests you. |
I think this works! (I would call the header files We plan to sync with the latest https://gitlab.com/lfortran/lfortran/-/issues/292 and maintain the multi-line REPL capability on all platforms. So we will ensure things keep working. I have other ideas that I would like to do and use |
The thing with the files: The change is not important for the library. I'm just seeing that most "modern" c++ libraries use .hpp instead of .h to match the source files .cpp. I think it would look more modern, also it would be always clear that this is a c++ library not a C one. To the other changes: Feel free to add things or ask me to add some. I don't think that we need everything for a full featured text editor, but you could add that as optional feature for the window class. |
Also great that you want to sync cpp-terminal. It make the merge of new features easier next time. |
I have looked at what you are planing to do. I think that would be an awesome project. I would add some C++ goodies too like clang-format, clang-tidy, cpptest etc. Snek - a small snake clone with some extra gamemodes: Also this project is not intended to be well coded. I'm working on this with a friend who is really new to programming and don't want to make it too complicated Snek ultimate - the same but by myself with some more features in mind, like multiplayer and a particle system to make nice looking visual effects: https://github.com/MCWertGaming/snek-utimate This is not really started yet, because i have done other things. but this will be the next thing i want to do. Also I started a chess library with currently all required movement checking. Not yet done and also not yet playable as I don't created a front end yet. I'm planing on doing one for the terminal and one as actual GUI version https://github.com/MCWertGaming/chess/tree/main/chess I have also some other ideas for terminal games, but these are the ones i want to get working on in the future. |
I have created multiple files now and moved all functions. My goal would be to also move most functions out of the #ifdef _WIN32
explicit BaseTerminal(bool enable_keyboard = false,
bool /*disable_ctrl_c*/ = true)
: keyboard_enabled{enable_keyboard} {
// Uncomment this to silently disable raw mode for non-tty
// if (keyboard_enabled) keyboard_enabled = is_stdin_a_tty();
out_console = is_stdout_a_tty();
if (out_console) {
hout = GetStdHandle(STD_OUTPUT_HANDLE);
out_code_page = GetConsoleOutputCP();
SetConsoleOutputCP(65001);
if (hout == INVALID_HANDLE_VALUE) {
throw std::runtime_error(
"GetStdHandle(STD_OUTPUT_HANDLE) failed");
}
if (!GetConsoleMode(hout, &dwOriginalOutMode)) {
throw std::runtime_error("GetConsoleMode() failed");
}
DWORD flags = dwOriginalOutMode;
flags |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
flags |= DISABLE_NEWLINE_AUTO_RETURN;
if (!SetConsoleMode(hout, flags)) {
throw std::runtime_error("SetConsoleMode() failed");
}
}
if (keyboard_enabled) {
hin = GetStdHandle(STD_INPUT_HANDLE);
in_code_page = GetConsoleCP();
SetConsoleCP(65001);
if (hin == INVALID_HANDLE_VALUE) {
throw std::runtime_error(
"GetStdHandle(STD_INPUT_HANDLE) failed");
}
if (!GetConsoleMode(hin, &dwOriginalInMode)) {
throw std::runtime_error("GetConsoleMode() failed");
}
DWORD flags = dwOriginalInMode;
flags |= ENABLE_VIRTUAL_TERMINAL_INPUT;
flags &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
if (!SetConsoleMode(hin, flags)) {
throw std::runtime_error("SetConsoleMode() failed");
}
}
#else
explicit BaseTerminal(bool enable_keyboard = false,
bool disable_ctrl_c = true)
: keyboard_enabled{enable_keyboard} {
// Uncomment this to silently disable raw mode for non-tty
// if (keyboard_enabled) keyboard_enabled = is_stdin_a_tty();
if (keyboard_enabled) {
if (tcgetattr(STDIN_FILENO, &orig_termios) == -1) {
throw std::runtime_error("tcgetattr() failed");
}
// Put terminal in raw mode
struct termios raw = orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
// This disables output post-processing, requiring explicit \r\n. We
// keep it enabled, so that in C++, one can still just use std::endl
// for EOL instead of "\r\n".
// raw.c_oflag &= ~(OPOST);
raw.c_cflag |= (CS8);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN);
if (disable_ctrl_c) {
raw.c_lflag &= ~(ISIG);
}
raw.c_cc[VMIN] = 0;
raw.c_cc[VTIME] = 0;
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1) {
throw std::runtime_error("tcsetattr() failed");
}
}
#endif
} This in detail. If it does both preparing the terminal and preparing the input, we should probably consider to either split it into two classes /just make functions out of it. Or we have to include the input into the |
Yes, it prepares the input as well as output, depending on the platform. I am fine with hpp too, as well as rearranging things. You can suggest what you think should be done and we can discuss. |
Sure, i'm going to create a WIP pull-request as soon as the biggest things are done! But I have yet another question. What does this do? Removing it changes nothing for me on linux and it's excluded for windows: #undef B0
#undef B50
#undef B75
#undef B110
#undef B134
#undef B150
#undef B200
#undef B300
#undef B600
#undef B1200
#undef B1800
#undef B2400
#undef B4800
#undef B9600
#undef B19200
#undef B28800
#undef B38400
#undef B57600
#undef B115200 |
Once we move to cpp, we will remove this from the header files, so there won't be an issue anymore. |
Okay, great. Thank you! |
Moved the roadmap to https://github.com/jupyter-xeus/cpp-terminal/projects/1 |
I have thought of some things, I would like to to do with cpp-terminal to make it better for it's purpose - providing a way to write cross-platform terminal applications. I thought of doing those steps in the particular order:
cpp-terminal/base.hpp
which provides the raw functions to handle console input (basically the color functions and such)cpp-terminal/window.hpp
which provides a manages "window", basically the window classcpp-terminal/input.hpp
which provides the input functionscpp-terminal/prompt.hpp
which provides the prompt and things like (Split the prompt into its own header file #72)cpp-terminal/tools.hpp
wich provides all function which are just meant for being used inside of the library-> add github actions for automatically applying clang-format (like with
/bot apply-clang-format
as issue comment)colors.cpp
from the examples for stand-alone test #151-> fixes The color chart in ./colors seems incorrect on macOS #108
-> fixes menu_window_24bit does not seem to work on macOS #107
-> maybe even use those functions inside of the Window class to prevent duplicate code
render()
algorithm (Implement more efficientrender
algorithm #71)unicode
to be automatically #153get_term_size_slow()
(removed the get_term_size_slow() function #115)I will make this Issue pinned on the repository and update it when needed to keep track on the things we want to do. Also for other peoples and possible contributors. Help is always appreciated!
The text was updated successfully, but these errors were encountered: