{"id":18021278,"url":"https://github.com/ho-cooh/console","last_synced_at":"2025-08-08T02:47:28.267Z","repository":{"id":112727076,"uuid":"264355646","full_name":"HO-COOH/Console","owner":"HO-COOH","description":"Simple Windows Console wrapper with easy-to-use APIs and drawing functionality","archived":false,"fork":false,"pushed_at":"2020-10-07T15:35:31.000Z","size":49791,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T02:45:36.338Z","etag":null,"topics":["console","console-application","console-visualization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HO-COOH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-16T04:04:15.000Z","updated_at":"2023-03-12T15:13:13.000Z","dependencies_parsed_at":"2023-09-13T03:00:46.131Z","dependency_job_id":null,"html_url":"https://github.com/HO-COOH/Console","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HO-COOH%2FConsole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HO-COOH%2FConsole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HO-COOH%2FConsole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HO-COOH%2FConsole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HO-COOH","download_url":"https://codeload.github.com/HO-COOH/Console/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217958,"owners_count":20903176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","console-application","console-visualization"],"created_at":"2024-10-30T06:09:19.424Z","updated_at":"2025-04-04T17:23:36.829Z","avatar_url":"https://github.com/HO-COOH.png","language":"C++","readme":"# Console\n\n Simple **Windows \u0026 Ncurses** Console wrapper with easy-to-use APIs and drawing functionality. The project is focused on sweet syntax, without ugly types and pointers nonsense.\n\n**!Still very early in development!**\n\n## Description\n\nThe original implementation was used in [Simple TCP chatroom Client](https://github.com/HO-COOH/CS7850/tree/master/Project/V2). And as I was developing that project, I found out that just wrapping up the native Win32 console APIs is far from enough. Therefore I make it as a new project. \n\n## How to use\n\nCompile time polymorphism is given higher priority. But I tried to make it easy to use.\n\n**``console`` is a global object that is guaranteed to initialized first before you use, so no need to construct it anymore if you only use one console window**\n\nIn the future, runtime polymorphism will be considered.\n\nAn example of using ``Console`` class.\n\n```cpp\nvoid TestConsole()\n{\n\n    /*Setting text color using familiar syntax */\n    console \u003c\u003c Color::RED \u003c\u003c \"This is a red text on black background\\n\";\n    /*Or use traditional member function*/\n    console.set(Color::MAGENTA).writeln(\"This is magenta text\");\n\n    /*Setting background color using the same syntax */\n    console \u003c\u003c BackgroundColor::WHITE \u003c\u003c \"This is a magenta text on white background\\n\";\n    console.set(BackgroundColor::DEFAULT, false).set(Color::WHITE);\n\n    /*Moving cursor using relative or absolute position */\n    console.moveCursor(4, Direction::RIGHT);\n    console \u003c\u003c \"Indent text\\n\";\n    console.moveCursorTo({ 20,10 });\n    console \u003c\u003c \"Text start at [20,10]\\n\";\n    console.moveCursorTo(MIDDLE{});\n\n    /*Erase one line or clear the whole window */\n    console \u003c\u003c \"Press enter to delete this line: \";\n    std::cin.get();\n    console.eraseLine();\n    std::cin.get();\n    console.clear();\n}\n```\n\n```cpp\n#include \"Console.h\"        //For simple Windows console wrapper\n#include \"ConsoleEngine.h\"  //For Console drawing engine\nint main()\n{\n    ConsoleEngine eng{console}; //create a console engine, bind with the just-created window\n\n    auto canvas=eng.add\u003cRectangleArea\u003e();   //create a rectangleArea, returns a handle to the area\n\n    canvas.setBorder('U', 'D', 'L', 'R');   //set the border line characters in the order of: up, down, left, right\n\n    /*Divide a area into 2 (with an optional [position] parameter), returning a pair of handles*/\n    //if [position] is set to 0, then automatically divide in the middle\n    auto [chatArea, userArea]=canvas.divide(RectangleArea::Divisor::Vertical, 30);\n\n    /*Use of TextBox class */\n    auto chatView=chatArea.add\u003cTextBox\u003e();\n    chatView.setText(\"Hello World\");\n}\n```\n\n## Modules\n\n### Console\n\nWindows ConsoleAPI \u0026 ncurses wrapper. ``./include/Console.h``\n\n### ConsoleEngine\n\nTake ownership of the console and draw stuff. ``./include/ConsoleEngine.h``\n\n### GUI Elements\n\nAll GUI elements are inherited from ``RectangleArea``.\n\n- TextBox\n- ScrollArea\n- ProgressBar\n\nGUI library is written with code reusability in mind. They work great not only with ``ConsoleEngine``, but also with your ordinary ``std::cout`` or ``std::wcout``, meaning that you can reuse them without engaging with ``ConsoleEngine`` in your own project, freeing you from re-implementing basic GUI elements in the Console.\n\n```cpp\n#include \"Shape.h\"\nProgressBar bar{20, 1};\nbar.setPercentage(30);\nstd::cout \u003c\u003c bar \u003c\u003c '\\n';\n```\n\n### VideoEngine\n\n```cpp\n#include \u003cConsoleEngine.h\u003e\n#include \u003cVideoEngine.h\u003e\nvoid VideoTest()\n{\n    ConsoleEngine engine{console};\n    /*Play a single video*/\n    {\n        auto video = engine.add\u003cVideo\u003e();\n        video.load(\"SomeFile.mp4\");\n        video.play(30);//play at 30 fps\n    }\n    /*Or use multithreading to play multiple videos at once*/\n    {\n        auto [videoFrameLeft, videoFrameRight]=engine.divide(RectangleArea::Vertical);\n        auto videoLeft = videoFrameLeft.add\u003cVideo\u003e(engine);\n        auto videoRight = videoDrameRight.add\u003cVideo\u003e(engine);\n        videoLeft.load(\"SomeFile.mp4\");\n        videoRight.load(\"AnotherFile.mp4\");\n        VideoEngine{ {videoLeft, videoRight} };//play 2 videos\n    }\n}\n```\n\n- A single-video-single-window demo\n  + GrayScale Video Demo [China](https://www.bilibili.com/video/BV1aK411p7hJ) [Non China](https://www.youtube.com/watch?v=0b1pUuar8Fc\u0026t=151s)\n  + Colored Video Demo [China](https://www.bilibili.com/video/BV165411Y7w6) [Non China](https://www.youtube.com/watch?v=9k3mMGZGRz4)\n- A multi-video-single-window demo\n  \n  ### PictureEngine\n\n## Plan To-Do\n\n- One console (std handle) √\n- Colors √\n- Able to create multiple console windows~~(so change originally ``static`` functions to ``non-static``)~~\n- Drawing functionality\n  + borders √\n  + Text region\n  + Scroll View (automatic scrolling text region)\n  + Progress bar\n  + Forms\n- Keyboard events √×(partially)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fho-cooh%2Fconsole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fho-cooh%2Fconsole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fho-cooh%2Fconsole/lists"}