Files
RedBear-OS/local/recipes/tui/tlc
vasilito 0ec7bd46bb Phase 3: GPU 3D drivers + Phase 1-2 stability fixes — full rollup
ROLLUP of all Phase 1-3 work on branch 0.3.0, targeting a production-ready
console + full graphical desktop under Intel and Virgl/VirtIO-GPU.

=== Phase 1 — Stability ===
 - fbcond: Enter key handler (scancode 0x1C→\n), display map buffering,
   control-char filter in all 7 keymaps, write_event assert
 - build-redbear.sh: auto-rebuild-prefix when fork timestamps are newer
   than prefix/x86_64-unknown-redox/sysroot (was warning-only). Added
   configurable REDBEAR_SKIP_PREFIX_REBUILD guard.
 - build-redbear.sh: set explicit keymap '-K us' in console activation
 - config/redbear-device-services.toml: remove spurious init.d service
   files for redbear-acmd/ecmd/usbaudiod. These USB device daemons are
   spawned dynamically by pcid-spawner, not as boot-time init services.
   Starting them without args panicked the boot flow.
 - relibc: grantpt/unlockpt/ptsname (then deduplicated against stdlib)
 - userutils: cherry-pick upstream getty commit 2834434 (standard C
   ptsname/grantpt/unlockpt)
 - base fork: Russian (ЙЦУКЕН) keymap + inputd control-char filter
   (K_ESC/K_BKSP/K_ENTER → \0, commit 73e44d81 in submodule/base)

=== Phase 2 — Login & Console ===
 - login.rs: restored to 0.2.5-known-good liner-based prompt
 - redbear-upower: removed tokio full/signal features → protection fault fix
 - redbear-power: excluded temporarily (being fixed in other session)
 - tlc version: updated to 0.3.0

=== Phase 3 — GPU/3D Drivers (commit 0898332f7a) ===
Intel i915: FULLY implemented — real ring buffer + MMIO command
submission via GEM DMA → GGTT → i915 render ring, with hardware
head-pointer polling (2M iterations, 50µs backoff). Zero stubs.

VirtIO GPU/Virgl (VirtioTransport): 11 VIRTGPU ioctls (GETPARAM,
GET_CAPS, RESOURCE_CREATE, RESOURCE_INFO, CONTEXT_INIT, EXECBUFFER,
WAIT, TRANSFER_TO_HOST, TRANSFER_FROM_HOST, MAP, CREATE_BLOB) ported
from Linux 7.1 virtgpu_ioctl.c and virtgpu_vq.c.
 - driver.rs: 8 virgl_* trait methods (default Unsupported)
 - scheme.rs: 11 ioctl constants + 8 wire structures + dispatch
 - virtio/transport.rs: PCI capability discovery, feature negotiation,
   control+cursor virtqueue setup, vring descriptor building
 - virtio/mod.rs: real implementations for all 8 virgl_* methods
 - intel/mod.rs: explicit virgl Unsupported stubs

Other changes from active sessions: Cargo.toml version bumps, linux-kpi
headers, libpciaccess recipe, mesa/recipe.toml, kf6 patches, expat,
driver-manager, redbear-sessiond, redbear-compositor, cub, tlc, and
many other local recipes.
2026-07-09 20:29:28 +03:00
..

Twilight Commander (tlc) — Red Bear OS

TLC is Red Bear's internal TUI file manager, originally derived from Midnight Commander (MC) 4.8.33, but now architecturally and implementation-wise pure Rust, no FFI, no C compilation.

Status

TLC's source tree is TLC's own. It was derived from MC 4.8.33 once and fully rewritten in Rust — every Rust module, every Rust function, every Rust test is original Red Bear code. The C source of MC 4.8.33 lives in the canonical MC recipe at local/recipes/tui/mc/source/ and serves as read-only cross-reference for algorithm correctness.

TLC and MC are two separate, completely independent programs.

Name

Originally tc (Twilight Commander). Renamed to tlc on 2026-06-13 to avoid collision with iproute2's /usr/bin/tc traffic-control binary and the third-party tc crate on crates.io. "TLC" is intentionally a double reading: Twilight List-and-Copy (the function) and Tender Loving Care (the ethos).

Architecture

local/recipes/tui/tlc/
├── PLAN.md                ← canonical plan, phase status, quality assessment
├── recipe.toml            ← cookbook recipe (custom template, cargo build)
└── source/                ← PURE RUST — 113 .rs files, 46k+ lines
    ├── Cargo.toml         ← [package] name = "tlc"
    ├── config/default.toml
    ├── locales/*.yml      ← rust-i18n catalogues
    └── src/               ← app, config, editor, filemanager, fs, key,
                              keymap, locale, log, ops, paths, skin,
                              terminal, text, vfs, viewer, widget

The recipe builds three binaries — tlc (file manager), tlcedit (standalone editor), and tlcview (standalone viewer) — and stages them at /usr/bin/ in the Red Bear OS image. tlc is registered in both redbear-mini.toml and redbear-full.toml configs as tlc = {}.

Why pure Rust, no FFI

  • termion provides everything MC's tty layer did
  • ratatui provides everything MC's widget layer did
  • FFI adds unsafe, which project policy forbids
  • Pure Rust code is auditable and deterministic

Build

Linux (host build, zero setup)

TLC is pure portable Rust — it builds and runs natively on Linux with no Redox-specific code or dependencies.

cd local/recipes/tui/tlc/source
cargo build --release          # tlc (5.0 MB), tlcedit (1.2 MB), tlcview (661 KB)
./target/release/tlc --version # tlc 0.2.5
./target/release/tlc           # launch file manager TUI
./target/release/tlcedit file.txt   # launch standalone editor
./target/release/tlcview file.txt   # launch standalone viewer
./target/release/tlc help      # list keybindings

Redox (cross build for ISO)

cd local/recipes/tui/tlc/source
cargo build --release --target x86_64-unknown-redox

# Full ISO with TLC installed
./local/scripts/build-redbear.sh redbear-mini   # includes /usr/bin/tlc
./local/scripts/build-redbear.sh redbear-full   # includes /usr/bin/tlc

# Single recipe via cookbook
./target/release/repo cook local/recipes/tui/tlc

Test

cd local/recipes/tui/tlc/source
cargo test --lib
# → 1213 passed; 0 failed (verified 2026-07-05)

Linux Portability

TLC is designed as a pure-Rust portable application. It uses:

  • std::fs abstractions for all filesystem operations
  • cfg(unix) gates for platform-specific behavior (stat, permissions)
  • ratatui + termion for terminal rendering (works on any Unix tty)
  • No target_os = "redox" or target_os = "linux" gates anywhere

The redox Cargo feature and redox-scheme dependency were removed (declared but never consumed — no source file used #[cfg(feature = "redox")]). TLC is the same binary on Linux and Redox.

Shared TUI palette

TLC's src/terminal/color.rs consumes the shared Red Bear TUI palette from local/recipes/tui/redbear-tui-theme/ (a Red Bear-internal library crate). The 23-field Theme struct in terminal/color.rs is preserved (it deserializes user TOML skins), but the DEFAULT_THEME and LIGHT_THEME constants are now built from the shared REDBEAR_DARK / REDBEAR_LIGHT presets via a const as_color(rgb) adapter.

All rendering code (widgets, dialogs, editor, viewer, file panels) sources colors exclusively from the Theme palette — no hardcoded Color::White/Color::Blue/etc. remain in any render path. Every render() method accepts a theme: &Theme parameter. User TOML skins with any of the 23 palette slots are fully functional via Skin::to_theme().

The brand red is #B52430 — the same red as the Red Bear OS icon, the loading background, the cub RedBearTheme::accent (when cub migrates), and every other TUI app that adopts the shared palette.

See local/recipes/tui/redbear-tui-theme/README.md for the full palette, contrast table, and migration guide.

Built-in skins

TLC ships with 8 built-in skins accessible via Alt-S at runtime:

Skin Description
default-dark Red Bear Dark (brand palette, default)
default-light Red Bear Light
mc-classic Midnight Commander Classic (blue/cyan)
mc-dark MC Dark — gray panels, bright accents
mc-dark-gray MC Dark Gray — near-black, desaturated
high-contrast Black/white, WCAG-maximum
solarized-dark Solarized Dark palette
nord Nord palette

User TOML skins in ~/.config/tlc/skin/*.toml are also listed in the dialog. Selection persists to ~/.config/tlc/config.toml.

Phase status

Phase Status
0 ops dialogs
1 dual-panel shell
2 F3 viewer
3 F4 editor
4 keymap + dispatcher
5 editor polish
6 filemanager + viewer extras
7 VFS (local + remote backends) SFTP full read-write, FTP, scheme:// (Redox), tar/cpio/zip/extfs
8 archives + skin + i18n browse+extract+compress (Alt-Shift-C), 8 skins, i18n
13 skins + runtime selection 8 built-in skins, Alt-S dialog, config persistence
14a critical features menu bar (F9), select/unselect group, quick cd, Ctrl-O sub-shell, Alt-Enter cmdline
14b bug fixes viewer keys, editor cursor sync, overwrite dialog, Ctrl-O sub-shell
15a panel essentials marking (Ctrl-T), invert (*), sort cycle (Alt-T), history (Alt-H/Y/U), save setup (Alt-Shift-S), listing modes (Alt-L), mini-status, tab completion, cmdline auto-activate, editor block ops + selection highlight
15b shell + exec fixes foreground command execution (no popup), Ctrl+O drop/recreate Tui (clean terminal restore)
15c editor + percent + user menu bracket match (Alt-B), word completion (Alt-Tab), percent escapes (17 tokens), F2 user menu (INI parser + condition + extension filters)
15d bug fixes + standalone binaries ESC no-op on main screen (MC parity), editor arrow keys structural fix (Option B — cursor sync in every move_*/select_*), command execution (no pause, returns immediately), tlcedit + tlcview standalone binaries built and staged alongside tlc
15e syntax highlighter + render wiring Highlighter struct, syntax_for_path(), is_text_file() in editor/syntax.rs; wired into Editor::render() with viewport scroll state replay and selection overlay (split_spans_for_selection)
15f Jobs/Panelize/VFS dialogs Background jobs dialog (C-x j), external panelize (C-x !), VFS list (C-x a) — all safe Rust, Arc<Mutex<JobRegistry>>, zero unsafe
15g Ctrl-X chord + Compare Dirs + SymlinkRelative + dialogs Ctrl-X prefix dispatch (9 follow-ups), Compare Dirs (C-x d size-only), SymlinkRelative (C-x s), SymlinkEdit (C-x v), ScreenList/EditHistory/FilteredView wired, editor format paragraph (Alt-P), viewer growing buffer (tail -f)
15h File highlighting Type-based coloring in panel entries (9 categories: executable, archive, audio, video, image, source, documentation, database), extension tables + permission-bit detection
15i VFS archive panel integration Browse .tar/.tar.gz/.tar.bz2/.tar.xz/.zip/.cpio archives in-place; Enter opens archive, '..' at root exits to local filesystem; VFS scheme dispatch via for_path()
15j PanelInfo (C-x i) + PanelQuickView (C-x q) Inactive panel toggles to Info mode (filesystem summary + cursor file metadata) or QuickView mode (first 30 lines of cursor file, binary detection); toggle-only (excluded from Alt-L listing cycle)
15k Clippy cleanup All 20 clippy lints fixed across 9 files; only 1 pre-existing warning remains (mc_ext.rs Include(String) never read)
15l Split ratio + QuitQuiet + menubar + Compare files SplitMore/Less (Alt-Shift-Right/Left, 5% steps, 10-90%), QuitQuiet (Shift-F10 actually quits), F9 menubar expanded with all 20+ commands, Compare files (Ctrl-d, LCS diff viewer)
31 SortDialog + truncation + editor toggles SortDialog wired to Alt-Shift-T (field/reverse/case), filename truncation indicator (~), editor auto-indent toggle (Alt-A), editor show whitespace toggle (Alt-E)
33 Editor F9 menubar + PLAN refresh All editor F9 commands wired (New/Open/Save/SaveAs/Quit/Find/Replace/Bookmarks), Options menu with 5 toggles, Ctrl-X h chord, §14.1-§14.6 tables refreshed (~93% MC parity)

See PLAN.md for the comprehensive quality assessment and remaining tasks.