Skip to content
/ mcui Public

mcui (MAIPA's Console User Interface) is a C++ library designed to simplify the creation of console-based menus and input fields. It provides a structured way to build interactive terminal interfaces with minimal effort.

License

Notifications You must be signed in to change notification settings

MAIPA01/mcui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mcui - MAIPA's Console User Interface

About

mcui (MAIPA's Console User Interface) is a C++ library designed to simplify the creation of console-based menus and input fields. It provides a structured way to build interactive terminal interfaces with minimal effort.

Features

  • Menu System: Easily create hierarchical console menus with selectable options.
  • User Input Handling: Prompt users for input with a message.
  • Custom Views: Define your own menu display style.
  • Header-Only: Simple integration without the need for compilation.
  • Cross-Platform: Works on Windows, macOS, and Linux.
  • C++20 Compatible: Utilizes modern C++ features.

Requirements

  • C++ Standard: Requires C++20 or later.
  • Dependencies: Uses mstd (Maipa’s Standard Library).

Installation

No additional setup is required apart from including mcui headers and ensuring mstd is available.

Usage Examples

Creating a Simple Menu

#include <mcui/mcui.hpp>
#include <iostream>

using namespace std;
using namespace mcui;

void menu2OptionFunc() {
    cout << "Menu 2 Option" << endl;
}

MenuExitState menuOptionFunc() {
    return MenuExitState::Exit;
}

int main() {
    MenuBuilder::makeStandardMenu("Menu", true, false, true,
        MenuBuilder::makeStandardMenu("Menu2", true, true, false,
            MenuBuilder::makeOption("Menu2 Option 1", &menu2OptionFunc)
        ),
        MenuBuilder::makeOption("Exit", &menuOptionFunc)
    )->run();
}

Creating a Simple Input Field

#include <mcui/mcui.hpp>
#include <iostream>

using namespace std;
using namespace mcui;

int main() {
    std::string name = InputBuilder::makeInput("Name: "s)->run();
    cout << "Hello " << name << endl;
}

Customizing Menu Appearance

You can define your own menu rendering style by implementing a custom View structure:

struct ViewSample {
    static void printView(const std::string& menu_name,
        const mstd::ordered_map<std::string, MenuElementSPtr>& elements);
};

License

This project is licensed under the BSD 3-Clause License with Attribution Requirement. See the LICENSE file for more details.

About

mcui (MAIPA's Console User Interface) is a C++ library designed to simplify the creation of console-based menus and input fields. It provides a structured way to build interactive terminal interfaces with minimal effort.

Topics

Resources

License

Stars

Watchers

Forks