Skip to content

Hello World Program

Anthony edited this page Sep 11, 2018 · 6 revisions
#include <cppurses/cppurses.hpp>

using namespace cppurses;

int main() {
    // Creating this object initializes CPPurses so it can print to the screen.
    System sys;

    // Create a text string with Attributes, known as a Glyph_string.
    Glyph_string greeting{"Hello, World!", Attribute::Underline};

    // Create Textbox Widget with `greeting` as the initial text.
    Textbox tb{greeting};

    // Set the background and foreground colors of the Textbox.
    set_background(tb, Color::Dark_blue);
    set_foreground(tb, Color::Light_blue);

    // Enable a border to be drawn around the Textbox.
    enable_border(tb);

    // Set the Textbox as the main, or head Widget.
    sys.set_head(&tb);

    // Starts the event loop to display the TUI and process user input.
    return sys.run();
}
Clone this wiki locally