Giter Site home page Giter Site logo

Comments (12)

certik avatar certik commented on May 24, 2024 1

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.

certik avatar certik commented on May 24, 2024 1

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.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

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.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

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.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

Also great that you want to sync cpp-terminal. It make the merge of new features easier next time.

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

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.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

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.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

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.

certik avatar certik commented on May 24, 2024

This was introduced in #36. You can read the discussion and the issue (#35) it closed over there.

from cpp-terminal.

certik avatar certik commented on May 24, 2024

Once we move to cpp, we will remove this from the header files, so there won't be an issue anymore.

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

Okay, great. Thank you!

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

Moved the roadmap to https://github.com/jupyter-xeus/cpp-terminal/projects/1

from cpp-terminal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.