Skip to content

parv141206/kontra

Repository files navigation



Kontra

A modern C++ Terminal UI library
because `std::cout` just doesn't cut it anymore.


🚀 What is Kontra?

Kontra is a C++ library for building sleek terminal UIs - no GUI bloat, no weird DSLs. Just clean code, styled boxes, smooth input, and full control - all in your terminal.


🚀 Installation & Usage

Getting Kontra TUI into your project is designed to be simple and modern using CMake. Here are the two recommended ways to get started.

Method 1: The Modern Way with CPM.cmake (Recommended ✨)

This is the fastest and easiest way to integrate Kontra. It automatically fetches the library from GitHub when you configure your project.

Prerequisites:

  • A C++17 compatible compiler.
  • CMake (version 3.16 or higher).

Steps:

  1. Download CPM.cmake Download the latest CPM.cmake script from its GitHub repository and place it in a cmake folder within your project.

    YourCoolApp/
    ├── main.cpp
    ├── CMakeLists.txt
    └── cmake/
        └── CPM.cmake
    
  2. Add Kontra to your CMakeLists.txt Add the following block to your project's CMakeLists.txt. It will include CPM, download Kontra, and link it to your application.

    # YourCoolApp/CMakeLists.txt
    
    cmake_minimum_required(VERSION 3.16)
    project(YourCoolApp LANGUAGES CXX)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    # Tell CMake where to find the CPM.cmake script
    list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
    include(CPM)
    
    # ----------------------------------------------------
    # ✨ Add Kontra TUI to your project!
    # ----------------------------------------------------
    # This command tells CPM to fetch the Kontra library directly from GitHub.
    # We recommend pinning to a specific version/release tag for stability.
    CPMAddPackage(
        NAME Kontra
        GITHUB_REPOSITORY parv141206/kontra
        GIT_TAG master
    )
    
    # Create your application executable
    add_executable(YourCoolApp main.cpp)
    
    # Link against the 'kontra' library. CPM makes this target available automatically!
    target_link_libraries(YourCoolApp PRIVATE kontra)
  3. Configure and Build That's it! Now, when you run CMake to configure your project, it will automatically download and set up Kontra.

    # Create a build directory
    cmake -S . -B build
    
    # Build your project
    cmake --build build

Method 2: The Classic Way with git submodule 📦

This method is great if you want to work offline or have a local copy of the library source code locked to your project's git history.

Prerequisites:

  • git installed on your system.
  • A C++17 compatible compiler.
  • CMake (version 3.16 or higher).

Steps:

  1. Add Kontra as a Git Submodule From the root directory of your project, run the following command. This will clone the Kontra repository into a subfolder named external/kontra.

    git submodule add https://github.com/parv141206/kontra.git external/kontra
    git submodule update --init --recursive

    Your project structure will now look like this:

    YourCoolApp/
    ├── main.cpp
    ├── CMakeLists.txt
    └── external/
        └── kontra/
            └── (Kontra TUI source code...)
    
  2. Add the Subdirectory in CMakeLists.txt Modify your project's CMakeLists.txt to include the downloaded library as part of your build.

    # YourCoolApp/CMakeLists.txt
    
    cmake_minimum_required(VERSION 3.16)
    project(YourCoolApp LANGUAGES CXX)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    # ----------------------------------------------------
    # 📦 Add the Kontra TUI subdirectory
    # ----------------------------------------------------
    # This command tells CMake to find and process the CMakeLists.txt
    # inside the submodule folder. This creates the 'kontra' library target.
    add_subdirectory(external/kontra)
    
    # Create your application executable
    add_executable(YourCoolApp main.cpp)
    
    # Link against the 'kontra' library target, which is now available.
    target_link_libraries(YourCoolApp PRIVATE kontra)
  3. Configure and Build The process is the same. Because the files are already local, no download will occur.

    # Create a build directory
    cmake -S . -B build
    
    # Build your project
    cmake --build build

Happy building! 💖 I am excited to see what you create with Kontra TUI :)

About

Kontra is a C++ library for building sleek terminal UIs - no GUI bloat, no weird DSLs. Just clean code, styled boxes, smooth input, and full control - all in your terminal.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors