kandi background
Explore Kits

TermOx | C17 Terminal User Interface Library | Command Line Interface library

 by   a-n-t-h-o-n-y C++ Version: Current License: MIT

 by   a-n-t-h-o-n-y C++ Version: Current License: MIT

Download this library from

kandi X-RAY | TermOx Summary

TermOx is a C++ library typically used in Utilities, Command Line Interface applications. TermOx has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.
TermOx is a Terminal User Interface(TUI) Framework written in C++17. Built on top of Escape, it defines a set of Widgets, Layouts, and Events that make it quick to craft unique user interfaces in the terminal.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • TermOx has a low active ecosystem.
  • It has 371 star(s) with 32 fork(s). There are 18 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 3 open issues and 33 have been closed. On average issues are closed in 70 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of TermOx is current.
TermOx Support
Best in #Command Line Interface
Average in #Command Line Interface
TermOx Support
Best in #Command Line Interface
Average in #Command Line Interface

quality kandi Quality

  • TermOx has no bugs reported.
TermOx Quality
Best in #Command Line Interface
Average in #Command Line Interface
TermOx Quality
Best in #Command Line Interface
Average in #Command Line Interface

securitySecurity

  • TermOx has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
TermOx Security
Best in #Command Line Interface
Average in #Command Line Interface
TermOx Security
Best in #Command Line Interface
Average in #Command Line Interface

license License

  • TermOx is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
TermOx License
Best in #Command Line Interface
Average in #Command Line Interface
TermOx License
Best in #Command Line Interface
Average in #Command Line Interface

buildReuse

  • TermOx releases are not available. You will need to build from source code and install.
  • Installation instructions, examples and code snippets are available.
TermOx Reuse
Best in #Command Line Interface
Average in #Command Line Interface
TermOx Reuse
Best in #Command Line Interface
Average in #Command Line Interface
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

TermOx Key Features

C++17 Terminal User Interface(TUI) Library.

TermOx Examples and Code Snippets

See all related Code Snippets

Build Instructions

copy iconCopydownload iconDownload
git clone https://github.com/a-n-t-h-o-n-y/TermOx.git
mkdir TermOx/build && cd TermOx/build
git submodule update --init --recursive   # Pull in dependencies
cmake .. -DCMAKE_BUILD_TYPE=Release       # Generate Makefiles
make                                      # Build library
make demos                                # Build demos(optional)
make termox.unit.tests                    # Build Unit Tests(optional)
make termox.ui.tests                      # Build UI Tests(optional)
make install                              # Install to system directories(optional)

Using the Library

copy iconCopydownload iconDownload
# CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
add_executable(my_app
               ...
               my_app.main.cpp
)

# If TermOx is cloned into a directory named external/
add_subdirectory(external/TermOx)
target_link_libraries(my_app TermOx)

Custom Widget

copy iconCopydownload iconDownload
#include <map>
#include <string>

#include <termox/termox.hpp>

using namespace ox;

class Pinbox : public Widget {
   public:
    // Emitted when a new pin is inserted.
    sl::Signal<void(Point)> pin_inserted;

    // Emitted when an existing pin is removed.
    sl::Signal<void(Point)> pin_removed;

   public:
    Pinbox()
    {
        using namespace ox::pipe;
        *this | on_mouse_press([&](auto const& m) { this->handle_mouse(m); })
              | on_mouse_move ([&](auto const& m) { this->handle_mouse(m); })
              | on_paint([&](Painter& p) {
                  for (auto [xy, color] : points_)
                      p.put(U'•' | fg(color), xy);
              });
    }

   public:
    // Set the Color for newly inserted pins.
    void set_foreground(Color c) { foreground_ = c; }

    // Remove all pins from the screen.
    void clear_screen() { points_.clear(); this->update(); }

   private:
    std::map<Point, Color> points_;
    Color foreground_ = Color::Light_blue;

   private:
    // Inserts pin at Point p, if p is empty; emits pin_inserted Signal.
    void insert_pin(Point p)
    {
        auto const [_, inserted] = points_.insert({p, foreground_});
        if (inserted) {
            pin_inserted.emit(p);
            this->update();  // Post a Paint Event
        }
    }

    // Removes pin at Point p, if it exists; emits pin_removed Signal.
    void remove_pin(Point p)
    {
        auto const count = points_.erase(p);
        if (count != 0) {
            pin_removed.emit(p);
            this->update();  // Post a Paint Event
        }
    }

    void handle_mouse(Mouse const& m)
    {
        switch (m.button) {
            case Mouse::Button::Left: this->insert_pin(m.at); break;
            case Mouse::Button::Right: this->remove_pin(m.at); break;
            default: break;
        }
    }
};

Building with Types

copy iconCopydownload iconDownload
using namespace ox;

class Side_pane : public VTuple<HLabel,
                                Color_select,
                                HLabel,
                                Text_view,
                                HLine,
                                HPair<HLabel, Int_view>,
                                HLine,
                                Confirm_button,
                                Widget> {
   public:
    HLabel& color_label        = this->get<0>();
    Color_select& color_select = this->get<1>();
    HLabel& status_label       = this->get<2>();
    Text_view& status_box      = this->get<3>();
    HLabel& count_label        = this->get<5>().first;
    Int_view& count_box        = this->get<5>().second;
    Confirm_button& clear_btn  = this->get<7>();
    Widget& empty_space        = this->get<8>();

   public:
    Side_pane()
    {
        using namespace ox::pipe;

        *this | fixed_width(16);

        color_label  | align_center() | text("- Color -" | Trait::Bold);
        color_select | fixed_height(2);
        status_label | text("Status" | Trait::Bold);
        status_box   | fixed_height(1) | bg(Color::Dark_blue);
        this->get<5>() | fixed_height(1);
        count_label | text("Pin Count" | Trait::Bold) | fixed_width(10);
        count_box   | value(0);
        clear_btn.main_btn | text("Clear") | bg(Color::Dark_blue);
    }
};

struct Pinbox_app : HPair<Pinbox, Passive<Bordered<Side_pane>>> {
    Pinbox& pinbox       = this->first;
    Side_pane& side_pane = this->second | pipe::take_west() | pipe::wrapped();

    Pinbox_app()
    {
        using namespace ox::pipe;
        using std::to_string;
        auto& status_box = side_pane.status_box;
        auto& count_box  = side_pane.count_box;

        side_pane.color_select.color_selected.connect([&](Color c) {
            pinbox.set_foreground(c);
            status_box | text(color_to_string(c) + " Set");
        });

        side_pane.clear_btn.pressed.connect([&] {
            pinbox.clear_screen();
            count_box  | value(0);
            status_box | text("Screen Cleared");
        });

        pinbox.pin_inserted.connect([&](Point at) {
            count_box  | value(count_box.value() + 1);
            status_box | text("Added x" + to_string(at.x) + " y" + to_string(at.y));
        });

        pinbox.pin_removed.connect([&](Point at) {
            count_box  | value(count_box.value() - 1);
            status_box | text("Removed x" + to_string(at.x) + " y" + to_string(at.y));
        });
    }
};

int main() { return System{Mouse_mode::Drag}.run<Pinbox_app>(); }

Building with Values

copy iconCopydownload iconDownload
auto pinbox_app()
{
    using namespace ox;
    using namespace ox::pipe;
    auto pa =
        hpair(
            std::make_unique<Pinbox>(),
            bordered(vtuple(
                hlabel("- Color -" | Trait::Bold) | align_center(),
                color_select() | fixed_height(2),
                hlabel("Status" | Trait::Bold),
                text_display() | fixed_height(1) | bg(Color::Dark_blue),
                hline(),
                hpair(
                    hlabel("Pin Count" | Trait::Bold) | fixed_width(10),
                    int_view(0)
                ) | fixed_height(1),
                hline(),
                confirm_button("Clear"),
                widget()
            ) | fixed_width(17)) | take_west()
        );

    auto& pinbox       = pa->first;
    auto& color_select = pa->second.wrapped.get<1>();
    auto& status_box   = pa->second.wrapped.get<3>();
    auto& count_box    = pa->second.wrapped.get<5>().second;
    auto& clear_btn    = pa->second.wrapped.get<7>();

    clear_btn.main_btn | bg(Color::Dark_blue);

    color_select.color_selected.connect([&](Color c) {
        pinbox.set_foreground(c);
        status_box | text(color_to_string(c) + " Set");
    });

    clear_btn.pressed.connect([&] {
        pinbox.clear_screen();
        count_box | value(0);
        status_box | text("Screen Cleared");
    });

    using std::to_string;
    pinbox.pin_inserted.connect([&](Point at) {
        count_box | value(count_box.value() + 1);
        status_box | text("Added x" + to_string(at.x) + " y" + to_string(at.y));
    });

    pinbox.pin_removed.connect([&](Point at) {
        count_box | value(count_box.value() - 1);
        status_box |
            text("Removed x" + to_string(at.x) + " y" + to_string(at.y));
    });

    return pa;
}

int main() { return System{Mouse_mode::Drag}.run(*pinbox_app()); }

How to read space-separated data into a numpy array?

copy iconCopydownload iconDownload
import numpy as np
A = np.loadtxt(arquivox, delimiter=' ')

See all related Code Snippets

Community Discussions

Trending Discussions on TermOx
  • How to read space-separated data into a numpy array?
Trending Discussions on TermOx

QUESTION

How to read space-separated data into a numpy array?

Asked 2020-Oct-14 at 13:05

I have a text file with numbers separated by spaces, such as:

-2 -3 4 -1 -2 1.5 -3

I tried to create an numpy array with the file elements using the following code:

root = tk.Tk()
root.withdraw()
A = np.array([])
arquivox = filedialog.askopenfilename()
# reading datafile
with open(arquivox, "r") as f:
    for termox in f:
        # specifying the separator
        termox = termox.split(' ')
        # converting the elements to float and generating the array
        A = np.append(A, float(termox[0]))
print(A)

However, I am only saving the first element of the file (-2). What am I doing wrong?

ANSWER

Answered 2020-Oct-14 at 13:01

Since you are reading into a numpy.array anyway, I'd suggest using numpy.loadtxt

import numpy as np
A = np.loadtxt(arquivox, delimiter=' ')

Source https://stackoverflow.com/questions/64353814

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install TermOx

TermOx depends on the Signals Light and Escape libraries, these are both included as git submodules. Try out the ./demos/demos app to get a feel for what TermOx is capable of.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with TermOx
Consider Popular Command Line Interface Libraries
Try Top Libraries by a-n-t-h-o-n-y
Compare Command Line Interface Libraries with Highest Support
Compare Command Line Interface Libraries with Highest Quality
Compare Command Line Interface Libraries with Highest Security
Compare Command Line Interface Libraries with Permissive License
Compare Command Line Interface Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.