Skip to content
Proyek

Tentang

An immediate-mode TUI library for Odin. Pure Odin, no C, batteries included.

Alat pengembangan

Cara angka ini diukur

118 bintang4 Fork +1 dalam 24 jam

Pertumbuhan bintang terukur

dalam 24 jam
+1
dalam 7 hari
+4
dalam 15 hari
+6
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

hnoss logo

hnoss

An immediate-mode TUI library for Odin. Pure Odin, no C, batteries included.
Documentation · Guide · Widgets · Examples

CI

hnoss demo: plasma, a rotating torus, live graphs, a list, a table and a command line in one terminal

examples/demo: plasma, a shaded 3D torus on a braille canvas, live graphs and scripted input, at 60 fps in ~2 ms a frame. Try it: ./build.sh run demo

hnoss monitor

examples/monitor: a live system monitor reading /proc on Linux and sysctl on FreeBSD, in the Odlar Yurdu theme.

Gallery

showcase
Widgets
tabs, lists, table, graphs, forms, modals, text area
plasma
Truecolor at 60 fps
double-buffered diff, one write per frame
text
Text & markup
wrapping by grapheme, [b red]markup[/]
layout
Layout
cuts, split, grid, center
list
Stateful widgets
keyboard, mouse, focus
events
Input
keys, modifiers, mouse, paste, focus

Install

hnoss is a plain Odin package; there is no package manager, so add the repository to your project:

git submodule add https://github.com/Huseynteymurzade28/hnoss libs/hnoss   # inside a git repo (git init first)
# or, without git in your project:
git clone https://github.com/Huseynteymurzade28/hnoss libs/hnoss

Then import it by path, relative to the file that imports it (import hnoss "libs/hnoss"), or register a collection once and import it from anywhere in your project:

odin run . -collection:libs=libs      # import hnoss "libs:hnoss"

Quick start

package main

import hnoss "libs/hnoss"

main :: proc() {
    term, _ := hnoss.init(hnoss.DEFAULT_OPTIONS + {.Mouse_Capture})
    defer hnoss.deinit(&term)           // the terminal is always restored, even on panic or Ctrl+C

    cities := []string{"Bakı", "Gəncə", "Şəki", "Lənkəran"}
    list: hnoss.List_State
    events: []hnoss.Event
    for {
        f := hnoss.begin_frame(&term)
        ui := hnoss.ui(f, events)
        inner := hnoss.box(ui, hnoss.inset(f.area, 1), "🇦🇿 [b]Cities[/]")
        hnoss.focus(ui, &list)
        hnoss.list(ui, inner, cities, &list)          // ↑↓, click, wheel

        for ev in hnoss.unhandled(ui) {
            if hnoss.is_char(ev, 'q') { return }
        }
        hnoss.end_frame(&term)                        // diff, one write
        free_all(context.temp_allocator)
        events = hnoss.poll_events(&term, -1)
    }
}

Why hnoss

  • Pure Odin. Only core: and base:; raw syscalls on Linux, core:sys/posix on macOS and FreeBSD. No ncurses, no C.
  • Immediate mode. Calling a widget draws it, handles its input and returns what happened.
  • Fast. Only changed cells are written; a full 200×60 truecolor frame diffs in ~2 ms.
  • Correct text. Unicode 16 widths and grapheme clusters: 世界, é, 👩‍💻, 🇦🇿.
  • Safe. Raw mode, alt screen and cursor are restored on exit, panic and signals.

Build

./build.sh                 # check + tests + all examples into bin/
./build.sh run demo        # or: showcase, monitor, file_manager, plasma, text, layout, keymap, tween, event_inspector, w_<widget>

Runs on Linux, macOS (Intel and Apple Silicon) and FreeBSD; CI builds and tests all three. Windows is #5. examples/monitor uses /proc on Linux and sysctl/ps on FreeBSD.

License

MIT

Jelajahi proyek terkait

Memuat…