A library that creates a terminal-like window with feature-packed drawing of text and easy input handling. MIRROR.

Overview

BearLibTerminal provides a pseudoterminal window with a grid of character cells and a simple yet powerful API for flexible textual output and uncomplicated input processing.

Features

  • Unicode support: you can use UTF-8 or UTF-16/32 wide strings easily.
  • Support for bitmap and vector (TrueType) fonts and tilesets.
  • Extended output facilities: tile composition, alignment, offsets.
  • High performance (uses OpenGL).
  • Keyboard and mouse support.
  • Bindings for several programming languages: С/С++, C#, Go, Lua, Pascal, Python, Ruby.
  • Windows, Linux and OS X support.

Documentation

Using

Some notes about using it with various languages or compilers:

C/C++

Visual C++ projects should be linked against BearLibTerminal.lib import library (specify it in the additional linker dependencies).

MinGW projects should link against .dll directly (the .lib is just an import library for Visual C++, do not copy it):

g++ -I/path/to/header -L/path/to/dll main.cpp -lBearLibTerminal -o app.exe

Python

Python packages are available. You can install everything you need to use the library with

pip install bearlibterminal

Depending on the OS and Python installation, you might also want to

  • Replace pip with pip3 or python3 -m pip to select a correct version of Python.
  • Add --user flag to install package locally (i. e. user-wide).

Package contains both wrapper and an appropriate binary for the platform, so you do not need to copy anything else anywhere. Just import the library in the source:

from bearlibterminal import terminal

terminal.open()
terminal.printf(2, 1, "Hello, world!")
terminal.refresh()
while terminal.read() != terminal.TK_CLOSE:
    pass
terminal.close()

Lua

Wrapper for Lua is built-in. You need to use a regular (dynamic) Lua runtime and place BearLibTerminal binary in a suitable location (e. g. in the same directory as script). For Linux you'll also need to rename the .so to just 'BearLibTerminal.so' (dropping the 'lib' prefix). After that it would be possible to import the library the usual way:

local terminal = require "BearLibTerminal" 

Building

BearLibTerminal is a language-agnostic dynamic-link library (.dll/.so/.dylib), therefore you generally do not have to build it yourself and may simply use the prebuilt binaries.

To build BearLibTerminal you will need CMake and a recent GCC/MinGW compiler. For Linux any GCC version 4.6.3 and above will do. For Windows there are several MinGW builds with various quirks, using TDM-GCC or mingw-builds (a flavour of mingw-w64) is recommended. MinGW compiler MUST use Posix thread model.

License

The library is licensed mainly under the MIT license with a few parts under other permissive licenses.

You might also like...
Native cross-platform full feature terminal-based sequence editor for git interactive rebase.
Native cross-platform full feature terminal-based sequence editor for git interactive rebase.

Native cross-platform full feature terminal-based sequence editor for git interactive rebase.

Terminal based, feature rich, interactive SQL tool

datafusion-tui (dft) DataFusion-tui provides a feature rich terminal application, built with tui-rs, for using DataFusion (and eventually Ballista). I

 A command-line utility that creates project structure.
A command-line utility that creates project structure.

petridish A command-line utility that creates project structure. If you have heard of the cookiecutter project, petridish is a rust implementation of

A simple lexer which creates over 75 various tokens based on the rust programming language.

Documentation. This complete Lexer/Lexical Scanner produces tokens for a string or a file path entry. The output is a Vector for the user to handle ac

`boxy` - declarative box-drawing characters

boxy - declarative box-drawing characters Box-drawing characters are used extensively in text user interfaces software for drawing lines, boxes, and o

A tiny library and application for animating text in the terminal.
A tiny library and application for animating text in the terminal.

🐌 snailshell A tiny library and application for animating text in the terminal. 🪄 It's so easy to add some flair to your text RPGs or console progra

Rust CLI utility library. Error handling, status reporting, and exit codes.
Rust CLI utility library. Error handling, status reporting, and exit codes.

narrate This library provides CLI application error and status reporting utilities. The coloured output formatting aims to be similar to Cargo. Error

Schemars is a high-performance Python serialization library, leveraging Rust and PyO3 for efficient handling of complex objects

Schemars Introduction Schemars is a Python package, written in Rust and leveraging PyO3, designed for efficient and flexible serialization of Python c

A small Rust library that let's you get position and size of the active window on Windows and MacOS

active-win-pos-rs A small Rust library that let's you get position and size of the active window on Windows and MacOS Build % git clone https://github

Comments
  • edit to fix compiling with new mingw

    edit to fix compiling with new mingw

    you need to edit log.cpp and add

    #define _POSIX_THREAD_SAFE_FUNCTIONS <--
    #include "Log.hpp"
    

    to make it compile I am using mingw from MSYS2

    opened by hero2002 4
  • Terminal is significantly scaled down on MacOS

    Terminal is significantly scaled down on MacOS

    The code

    #include <stdio.h>
    #include "BearLibTerminal.h"
    
    int main()
    {
        terminal_open();
    
        terminal_print(1, 1, "Hello, world!");
        terminal_refresh();
    
        while (terminal_read() != TK_CLOSE);
    
        terminal_close();
    }
    

    As taken from here will compile and run just fine, but the text is significantly scaled to 25% of the display

    image

    This happens with all BearLibTerminal terminals, for example, the SampleOmni program looks like this Screen Shot 2020-09-23 at 6 52 00 PM

    And the mouse program looks like this (Mouse is in top right corner of screen) Screen Shot 2020-09-23 at 6 53 06 PM

    opened by l4tte 2
  • Python read function always returns 224

    Python read function always returns 224

    contents of 224.py:

    from bearlibterminal import terminal as term
    key = term.read()
    print('key:')
    print(key)
    

    Output:

    me@pop-os:~/bearlibterminal$ python 224.py
    key:
    224 
    
    opened by pabrams 1
Releases(v0.12.1)
  • v0.12.1(Mar 28, 2015)

    This mirrors the release you can download from http://foo.wyrd.name/en:bearlibterminal , and there may be more recent versions available there. 32 and 64-bit libraries are included, as are bindings to different languages (C, C#, Python, Ruby, and Pascal) in the Terminal/Include directory. The zip is for Windows, the tar.bz2 is for Linux, and there's no Mac build yet (it's intended to be included in some future release).

    Source code(tar.gz)
    Source code(zip)
    bearlibterminal_0121.tar.bz2(1.80 MB)
    bearlibterminal_0121.zip(2.05 MB)
Owner
Tommy Ettinger
There was a time when I made games, or tried as much. Now I make game-related libraries, by the truckload. Commit Streak for Life.
Tommy Ettinger
An feature packed Google Tasks CLI written purely in Rust

rChore A feature packed unofficial Google Tasks CLI to boost your producitvity, written purely in Rust. ?? What is rChore? rChore is an unofficial Goo

Hemanth Krishna 41 Dec 24, 2022
SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project.

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project. With just a few primary configurations, such as project name, you can get started quickly.

Gabriel Michaliszen 4 May 9, 2023
a rust crate for drawing fancy pie charts in the terminal

piechart piechart is a rust crate for drawing fancy pie charts in the terminal. Example usage: use piechart::{Chart, Color, Data}; fn main() { le

Jakob Hellermann 35 Dec 30, 2022
Rustato: A powerful, thread-safe global state management library for Rust applications, offering type-safe, reactive state handling with an easy-to-use macro-based API.

Rustato State Manager A generical thread-safe global state manager for Rust Introduction • Features • Installation • Usage • Advanced Usage • Api Refe

BiteCraft 8 Sep 16, 2024
Pure Rust multi-line text handling

COSMIC Text Pure Rust multi-line text handling. COSMIC Text provides advanced text shaping, layout, and rendering wrapped up into a simple abstraction

Pop!_OS 1k Apr 26, 2023
🖥 A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3

?? A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3

Christian Visintin 574 Jan 5, 2023
Fuzzy Index for Python, written in Rust. Works like error-tolerant dict, keyed by a human input.

FuzzDex FuzzDex is a fast Python library, written in Rust. It implements an in-memory fuzzy index that works like an error-tolerant dictionary keyed b

Tomasz bla Fortuna 8 Dec 15, 2022
Tracing layer that automatically creates and manages progress bars for active spans.

tracing-indicatif A tracing layer that automatically creates and manages indicatif progress bars for active spans. Progress bars are a great way to ma

Emerson Ford 95 Feb 22, 2023
A Rust library for drawing grid-based user interfaces using ASCII characters.

grux A library for drawing grid-based user interfaces using ASCII characters. // Provides a uniform interface for drawing to a 2D grid. use grux::Grid

Matan Lurey 4 Jan 10, 2023
Rusty fast cross-platform 2D drawing library

Bly Rusty fast cross-platform 2D graphics library Concept Easy to use Bly is easy to use and yet can be called from various windowing libraries using

null 4 Feb 27, 2023