Coder Social home page Coder Social logo

cxxcurses's Introduction

cxxcurses

Example

Header-only C++ wrapper aiming to provide more friendly interface to the most used (at least by me) functions of ncurses instead of not so fun to use C interface.

#include <cxxcurses/cxxcurses.hpp>

#include <ostream>
#include <string>

class custom_type
{
public:
    friend auto operator<<( std::ostream& os, const custom_type& type )
        -> std::ostream&
    {
        return os << "str: " << type.str_ << " pi: " << type.pi_;
    }

private:
    const std::string str_ { "user defined" };
    const double pi_ { 3.14 };
};

auto main() -> int
{
    namespace cc = cxxcurses;
    const auto& main_win = cc::terminal::main_win;
    cc::terminal init;

    const auto hello_string { std::string { "Hello, world" } };

    main_win << cc::format( 4 )( "C++ curses centered example" );
    main_win << cc::format( 5, 6 )(
        "Here comes {rR} {gB} {bB}!!!", "multi", "colored", hello_string );
    main_win << cc::format( 6, 6 )( "Supports {R} types!", custom_type {} );

    auto some_window { cc::widget::window { { 10, 5, 5, 30 },
                                            cc::terminal::main_win } };

    some_window << cc::format( 2, 2 )( "Hello from sub-window!" );
    some_window.get_char();

    return 0;
}

Building with cxxcurses

You need to have ncurses installed on your system (in case of Windows pdcurses) and link it to your project as usual.

cxxcurses's People

Contributors

christhrasher avatar hjaremko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.