more work on desktoplib

This commit is contained in:
2026-09-07 14:36:45 -06:00
parent 5d47f08354
commit bdade6bc27
3 changed files with 197 additions and 4 deletions
+82 -3
View File
@@ -1,6 +1,85 @@
# desktoplib
A library that helps when building desktop apps by adding support for Terminals, Serial interfaces, and other general desktop-only things.
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
Designed as a standalone library, so its scope is intentionally limited.
ckittylib: Not required.
A lightweight, cross-platform C++20 library for building desktop applications that need uniform access to terminal UIs, OS processes, and serial (USB) interfaces.
Designed as a standalone static library with an intentionally limited scope. No heavy dependencies — just standard C++20 and platform-specific OS calls.
## Features
- **Terminal UI** — ANSI escape-sequenced output with RGB/HSL colors, cursor positioning, alternative buffers, and input handling
- **UI Widgets** — Built-in `Box`, `InnerScroll`, `MenuMap`, and `Content` for composing terminal layouts
- **Process Management** — Planned uniform process spawn/stream abstraction (stub in place)
- **Serial Communication** — Planned cross-platform USB/serial port interface
- **OS Abstraction Layer** — Shared terminal/input/OS calls behind `common.hpp`, with POSIX and Windows implementations
## Requirements
- C++20 compatible compiler (`g++` recommended)
- Make (GNU Make)
- POSIX or Windows environment
## Building
```bash
# Build the static library
make -f makelib.mak
# Build and run the test executable
make
./out/out.exe
```
Produces `out/libdesktoplib.a` for linking into your own projects.
## Quick Start
```cpp
#include <desktoplib/terminal/Terminal.hpp>
int main() {
using namespace ckitty::terminal;
Terminal term;
term.altbuff(true)
.cursor(false)
.cls()
.fill(color::B_BLACK);
term << pos{ 1, 1 } << backg::BLUE << color::WHITE << style::BOLD;
term.center(40, " Hello, desktoplib ");
term << style::RESET;
term.flush();
term.wait(); // Block until a key is pressed
term.altbuff(false).cursor(true).cls();
return 0;
}
```
## Architecture
```
src/desktoplib/
├── os/ # Platform abstraction (POSIX / Windows)
├── terminal/ # Terminal engine, ANSI codes, input
│ └── ui/ # Widgets: Box, InnerScroll, MenuMap, Content
└── proc/ # Process management (stub)
```
All modules live in the `ckitty` namespace. The terminal layer uses ANSI escape sequences wrapped in typed structs (`color`, `backg`, `style`, `pos`, `move`) and supports method chaining on `Terminal`.
## Roadmap
| Module | Status | Target |
|--------|--------|--------|
| Terminal UI | Stable | — |
| OS Abstraction | Stable (POSIX + Windows) | — |
| Process | Stub | Spawn, stdin/stdout/stderr streams, exit code |
| Serial / USB | Not started | Cross-platform port enumeration + read/write |
## License
MIT — see [LICENSE](LICENSE).