Comments (12)
I think this works! (I would call the header files *.h
, but that's minor.)
We plan to sync with the latest cpp-terminal
in LFortran:
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 cpp-terminal
for:
https://gitlab.com/lfortran/lfortran/-/issues/293
from cpp-terminal.
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.
from cpp-terminal.
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.
from cpp-terminal.
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.
from cpp-terminal.
Also great that you want to sync cpp-terminal. It make the merge of new features easier next time.
from cpp-terminal.
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.
Also we can make it with true color support when we have done the automatic conversion of true color to 8bit / 4bit colors. We wouldn't have to care about different terminal support anymore then. I have some projects too:
Snek - a small snake clone with some extra gamemodes:
https://github.com/BlackVyperStudios/snek
(branch menu, master is the old ncurses variant)
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.
from cpp-terminal.
I have created multiple files now and moved all functions. My goal would be to also move most functions out of the BaseTerminal()
and Terminal()
classes into the base.h
so users will have functions like get_term_size()
without requiring the input.h
file. Also I would suggest to do something with the Terminal and BaseTerminal classes. What is the constructor of the BaseTerminal class doing? @certik
#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 base.h
or something like that. I basically want that the header files make sense in terms of what's in there.
from cpp-terminal.
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
from cpp-terminal.
This was introduced in #36. You can read the discussion and the issue (#35) it closed over there.
from cpp-terminal.
Once we move to cpp, we will remove this from the header files, so there won't be an issue anymore.
from cpp-terminal.
Okay, great. Thank you!
from cpp-terminal.
Moved the roadmap to https://github.com/jupyter-xeus/cpp-terminal/projects/1
from cpp-terminal.
Related Issues (20)
- Color are wrong with unicode characters on Windows HOT 2
- Flickering HOT 20
- Windows terminal can be turned into `legacy mode` and so crash our ANSII support detection
- example 'kilo' does not support special characters HOT 7
- exception leaking destructor is dangerous HOT 10
- build as shared library, error adding symbols: DSO missing from command line HOT 12
- Compiling the examples with GCC results in errors HOT 7
- Create a list of projects that are using this library HOT 3
- Bug: cpp-terminal crashes if two utf8 are inserted simultaneously HOT 42
- Multiline prompt stopped working on macOS
- Ctrl + I and Tab HOT 6
- Bug: Text Wrap Incompatibility HOT 6
- Bring back the list of other similar libraries HOT 4
- Pressing Ctrl, Alt, Shift creates a copy paste event on windows? HOT 3
- Addition of Metakey and Key results in warning of deprecation HOT 1
- Bug in key + metakey arithmetic HOT 7
- Exception thrown at this line when typeing to fast HOT 7
- mouse sending random characters to the terminal after examples/minimal ends HOT 8
- `std::cin` doesn't read pipe redirection HOT 8
- Issue with file headers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpp-terminal.