Skip to content

antialberteinstein/eins_tui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

GUI Library for C++

Overview

This is a simple GUI library for C++ designed for console applications on Windows OS. It provides basic functionalities to create menus, handle user input, and display text with colors in the console.

Features

  • Clear the console screen
  • Wait for user input
  • Change the state of the GUI
  • Display menus and settings
  • Handle user input for menu navigation
  • Display text with colors
  • Full-screen mode support

Installation

  1. Clone the repository:
    git clone https://github.com/antialberteinstein/gui-library.git
  2. Include the gui.h and gui.cpp files in your project, make sure that gui.cpp is compiled with code source.
  3. NOTE: You may be able to change gui.cpp and gui.h for your purpose, we are welcome about those.

Usage

Initialization

Before using the GUI library, initialize it by calling:

init_gui();

Creating a Menu

  1. Define the actions for your menu items:

    void action1() {
        cout << "Action 1 selected" << endl;
    }
    
    void action2() {
        cout << "Action 2 selected" << endl;
    }
  2. Create a Settings object and a Menu object:

    Settings settings;
    Menu menu(settings);
  3. Add items to the menu:

    menu.add_item("Option 1", action1);
    menu.add_item("Option 2", action2);
  4. Show the menu and handle user input:

    bool running = true;
    while (running) {
        menu.show();
        menu.update();
        attach_running(running);
    }

Displaying Text with Colors

Use the set_color and reset_color functions to display text with colors:

set_color(RED);
cout << "This is red text" << endl;
reset_color();

Full-Screen Mode

Enter full-screen mode by calling:

enter_full_screen();

Example

Here is a complete example of a simple program using the GUI library:

#include "gui.h"

void action1() {
    cout << "Action 1 selected" << endl;
}

void action2() {
    cout << "Action 2 selected" << endl;
}

int main() {
    init_gui();

    Settings settings;
    Menu menu(settings);

    menu.add_item("Option 1", action1);
    menu.add_item("Option 2", action2);

    bool running = true;
    while (running) {
        menu.show();
        menu.update();
        attach_running(running);
    }

    return 0;
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Developed by antialberteinstein Thank you <3.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages