soopentui

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 0 Imported by: 0

README

soopentui

Solod (So) 向けの OpenTUI 第三者バインディングです。
ネイティブ core(libopentui.a)を静的リンクして使う前提の薄い C ABI ラップです。

go get github.com/zztkm/soopentui@latest

go get で届くのは So ソース・C ヘッダ・ビルド用ツールです。リンク用の libopentui.a は同梱しません(OS/arch 依存のため)。別途ビルドしてください。

前提

ツール 用途
Go 1.22+ モジュール取得 / cmd/* の実行
Zig 0.15.2 OpenTUI ネイティブ core とアプリのリンク
Git OpenTUI の clone とパッチ適用
Solod (so) So のトランスパイル
Xcode Command Line Tools(macOS) SDK / システム framework
go install solod.dev/cmd/so@main
go get solod.dev@main   # 標準ライブラリも tip 推奨(@latest は古いことがある)

利用の流れ

1. モジュールを取得
go get github.com/zztkm/soopentui@v0.1.0

アプリ側:

import "github.com/zztkm/soopentui"
2. 静的ライブラリをビルド
go run github.com/zztkm/soopentui/cmd/opentui-static@v0.1.0

カレントディレクトリに _build/opentui/.../libopentui.a ができます(モジュールキャッシュは読み取り専用のため)。

3. トランスパイルとリンク

so translate 後、zig cc で生成 C と libopentui.a をリンクします。C ABI ヘッダはモジュールの include/ にあります:

SOOPENTUI_DIR="$(go list -m -f '{{.Dir}}' github.com/zztkm/soopentui)"
# zig cc ... -I"$SOOPENTUI_DIR/include" ... path/to/libopentui.a

手元のクローンではサンプル一式をビルドできます:

go run ./cmd/hello-tui
./examples/hello-tui/hello-tui
フラグ 意味
-o path 出力バイナリ
-run ビルド後に実行
-skip-lib libopentui.a が無いときに自動ビルドしない

ローカル開発

このリポジトリを直接いじるときは、例アプリで一時的に replace を足します:

replace github.com/zztkm/soopentui => ../..

公開済みバージョンだけを使う場合は replace を外し、require でタグを指定します。

構成

パス 役割
soopentui.go So バインディング(モジュールルート)
include/opentui.h MVP 用 C ABI 宣言
cmd/opentui-static/ OpenTUI clone → patch → libopentui.a
cmd/hello-tui/ サンプルの translate → link
patches/ 静的リンク用パッチ
examples/hello-tui/ 最小 TUI サンプル

既知の注意(macOS + Zig 0.15.2)

新しい Xcode / macOS SDK では Zig 0.15.2 の build runner が失敗することがあります。
cmd/opentui-staticDEVELOPER_DIR=/dev/null を自動設定します。

OPENTUI_KEEP_DEVELOPER_DIR=1 go run ./cmd/opentui-static

so buildLDFLAGS-o の後に付くため、framework リンクでは使えません。hello-tui は translate + 明示リンクです。

起動時に端末 capability 問い合わせの応答がシェルに漏れることがあります(stdin を読んでいないため)。表示自体は問題ありません。

ライセンス

MIT(LICENSE)。OpenTUI 本体はその上流のライセンスに従います。

Documentation

Overview

Package soopentui is a third-party Solod (So) binding for the OpenTUI native C ABI.

Index

Constants

View Source
const DestinationMemory uint8 = 1

DestinationMemory keeps frames in memory (no terminal I/O).

View Source
const DestinationStdout uint8 = 0

DestinationStdout writes rendered frames to the terminal.

View Source
const RemoteAuto uint8 = 0

RemoteAuto lets OpenTUI detect local vs remote terminal behavior.

View Source
const RemoteLocal uint8 = 1

RemoteLocal forces local terminal mode.

View Source
const RemoteRemote uint8 = 2

RemoteRemote forces remote terminal mode.

Variables

This section is empty.

Functions

func Clear

func Clear(buffer Handle, bg RGBA)

Clear fills the buffer with bg.

func Destroy

func Destroy(renderer Handle)

Destroy releases a renderer.

func DrawText

func DrawText(buffer Handle, text string, x, y uint32, fg RGBA)

DrawText draws text at (x, y) with the given foreground color.

func Render

func Render(renderer Handle, force bool) uint8

Render presents the next buffer to the terminal.

func RestoreTerminal

func RestoreTerminal(renderer Handle)

RestoreTerminal restores the terminal after SetupTerminal.

func SetRGB

func SetRGB(out *RGBA, r, g, b uint8)

SetRGB writes an opaque RGB color into out.

func SetupTerminal

func SetupTerminal(renderer Handle, alternateScreen bool)

SetupTerminal enters the OpenTUI terminal modes (optionally alternate screen).

Types

type Handle

type Handle = uint32

Handle is an OpenTUI native object handle.

const InvalidHandle Handle = 0

func CreateRenderer

func CreateRenderer(width, height uint32) Handle

CreateRenderer creates a renderer for the given terminal size.

func NextBuffer

func NextBuffer(renderer Handle) Handle

NextBuffer returns the buffer to draw into for the next frame.

type RGBA

type RGBA [4]uint16

RGBA is OpenTUI's packed color (4x uint16, low byte = channel).

Directories

Path Synopsis
cmd
hello-tui command
Command hello-tui builds examples/hello-tui with a statically linked OpenTUI.
Command hello-tui builds examples/hello-tui with a statically linked OpenTUI.
opentui-static command
Command opentui-static clones OpenTUI under _build/, patches it for static linkage, and builds libopentui.a.
Command opentui-static clones OpenTUI under _build/, patches it for static linkage, and builds libopentui.a.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL