Greg's calculator - a terminal UI calculator inspired by galculator (GTK), implemented in Go with Bubble Tea. Features decimal math, base display cycling (DEC/HEX/BIN/OCT) with CERR on non-integers, tactile keypad, wide integrated display.
Go to file
Grok 700e70a355
All checks were successful
CI / Test (push) Successful in 17s
Release / Create Release (push) Successful in 1m33s
CI / Lint (push) Successful in 22s
CI / Build (push) Successful in 20s
fix: resolve golangci-lint v2.1.6 staticcheck failures
- SA9003 (empty branch): rewrote TestFormatLargeAndScientific to actually
  call FormatForDisplay and perform a minimal non-empty assertion instead of
  an if-with-no-body.
- SA1019 (deprecated keyStyle.Copy()): replaced all .Copy() with direct
  assignment or method chaining on the base keyStyle. lipgloss styles are
  immutable and their builder methods already return new instances.
- Removed now-unused "strings" import from calc_test.go.
- All changes pass go test -short, go build, go vet, and gofmt.

This makes the Lint job (which runs golangci-lint-action + staticcheck) green.
The v0.3.0 tag was already pushed from the prior commit; this is master
hygiene so future CI + any follow-up tags are clean.
2026-06-06 17:09:43 +01:00
.gitea/workflows ci: add ci-build.sh, install scripts, and lint job 2026-06-06 15:30:50 +01:00
docs ui: dynamic A-F buttons in keypad that only appear in HEX mode 2026-06-06 15:59:22 +01:00
internal fix: resolve golangci-lint v2.1.6 staticcheck failures 2026-06-06 17:09:43 +01:00
scripts fix: update install scripts to use correct gralculator repo name in GITEA_BASE URLs 2026-06-06 15:35:04 +01:00
.gitignore chore: initialize git repository and create docs/ with ARCHITECTURE.md and UI_DESIGN.md 2026-06-06 14:28:30 +01:00
ci-build.sh ci: add ci-build.sh, install scripts, and lint job 2026-06-06 15:30:50 +01:00
go.mod feat(tui): focused rendering spike for galculator-inspired two-row display + single BASE (phase 3) 2026-06-06 14:30:08 +01:00
go.sum feat(tui): focused rendering spike for galculator-inspired two-row display + single BASE (phase 3) 2026-06-06 14:30:08 +01:00
main.go feat(tui): focused rendering spike for galculator-inspired two-row display + single BASE (phase 3) 2026-06-06 14:30:08 +01:00
Makefile feat(calc,ui): complete tight-mode HEX entry with cross-base chaining and result formatting 2026-06-06 17:04:11 +01:00
README.md docs: add comprehensive README.md 2026-06-06 15:38:07 +01:00
spec.md chore: initialize git repository and create docs/ with ARCHITECTURE.md and UI_DESIGN.md 2026-06-06 14:28:30 +01:00

Gralculator

Gralculator — Greg's Calculator. A terminal UI calculator.

Portmanteau of "Greg" + "calculator". A fast, keyboard-centric TUI inspired by the visual layout of galculator (the GTK programmer's calculator), with a wide integrated display row and tactile keypad.

All calculations are performed in decimal. Display bases (DEC / HEX / BIN / OCT) are purely for formatting the current value. A single Tab (BASE) key cycles the display format. Non-integer values trigger a brief "CERR" (conversion error) flash instead of silently truncating.

Features (v0.1 MVP)

  • Wide display row: [BASE] indicator on the left + large, right-aligned number area (LCD-style with green-on-dark styling and subtle borders).
  • Base cycling via Tab (or the visual BASE key if present in your build).
  • Core operations: + - * / and MOD (modulo).
  • Clear controls: Backspace for Clear Entry (C), Delete for All Clear (AC).
  • Decimal point, sign change (+/-), and standard digit entry.
  • Tactile visual keypad: individually bordered buttons with color-coded groups (numbers, operators, clears, MOD, BASE), height for "key" feel, and press-flash feedback (bright 63 background).
  • Minimal non-wrapping hint row at the bottom.
  • Content-sized, centered card layout (no stretching) using lipgloss patterns refined in the gostations project.
  • Pure, testable calculation engine (internal/calc) separate from the Bubble Tea UI.
  • Cross-platform static binary.

Requirements

  • Linux or macOS (Windows via installers or WSL)
  • For running the binary: a modern terminal (kitty, WezTerm, Ghostty, etc. recommended for Unicode and color)
  • For building from source: Go 1.24.2+

Install (for normal users)

The easiest way is the one-liner installer attached to each release:

Linux / macOS

curl -L https://repos.gmgauthier.com/gmgauthier/gralculator/releases/download/v0.1.0/gralculator-install.sh \
  | VERSION=0.1.0 bash

Windows (PowerShell) / macOS / Linux with PowerShell

irm https://repos.gmgauthier.com/gmgauthier/gralculator/releases/download/v0.1.0/gralculator-install.ps1 | iex

The installer:

  • Detects your OS and architecture.
  • Downloads the matching gralculator-OS-ARCH-vX.Y.Z.tar.gz (verifies checksum when possible).
  • Installs the binary to ~/.local/bin/gralculator (.exe on Windows).
  • Prints PATH advice if needed and runs gralculator -v.

After installation, just run gralculator.

Usage

Run with no arguments to launch the TUI.

Display

A single wide row inside a bordered LCD-style panel:

  • Left: current base indicator (e.g. [DEC], [HEX], [BIN], or [OCT])
  • Right: the current value, right-aligned and filling the available width

Keypad

Tactile visual buttons below the display (numbers, operators, MOD, C, AC, +/-, etc.). The BASE action is keyboard-driven via Tab (the visual button was removed in favor of a clean grid + hint).

Key Bindings

  • Tab — cycle display base (DEC → HEX → BIN → OCT → DEC). Flashes "CERR" on the number area if the current value is non-integer.
  • m / M — MOD (modulo)
  • Backspace — Clear Entry (C)
  • Delete — All Clear (AC)
  • 0-9 — digits
  • . — decimal point
  • + - * / — operators
  • = or Enter — equals / commit pending operation
  • +/- — change sign
  • q, Ctrl+C, Esc — quit

The hint row at the bottom always shows the essentials.

Building from Source

git clone https://repos.gmgauthier.com/gmgauthier/gralculator.git
cd gralculator
make build          # produces build/gralculator
make install        # installs to ~/.local/bin/gralculator
make test           # or make test-short

The Makefile supports cross-compilation (make cross), ldflags for version injection, and matches the conventions used by gostations and grokkit.

Development

  • spec.md — living high-level specification and design decisions (MVP scope, CERR policy, single BASE cycle, etc.).
  • docs/ARCHITECTURE.md — package structure, key decisions, and future-proofing notes.
  • docs/UI_DESIGN.md — detailed notes on the display row, keypad styling, and rendering approach.
  • Workflows in .gitea/workflows/ (CI on push/PR + release on v* tags) are modeled after gostations and grokkit.
  • Pure engine in internal/calc/ (easy to test independently of the UI).
  • UI in internal/ui/ uses Bubble Tea + lipgloss (reuses patterns from gostations: centered cards, button cells, 140 ms color-63 flashes, minimal hints).

The project is part of a personal collection of console apps (see the REXX ~/.local/bin/apps launcher). It is designed to be keyboard-primary and pleasant to use in a modern terminal.

License

See the UNLICENSE file (or equivalent in the root) for this personal project.


Built as an exercise in Bubble Tea TUI design, with heavy reuse of patterns from the gostations radio player. Feedback and iteration welcome!