Commit Graph

3 Commits

Author SHA1 Message Date
Grok
0812bc162f sketch: tight-scope HEX entry via keyboard (A-F only while base=HEX)
- Engine:
  * EnterDigit now accepts A-F (uppercased) only for BaseHEX; decimal path now validates 0-9.
  * EnterDecimalPoint ignored for non-DEC.
  * currentNumericValue parses entry using current base (ParseInt base 16 for HEX, extended to BIN/OCT for robustness).
  * FormatForDisplay prefers returning the raw (upper) entry string when active *and* base indicator matches (so typing 1A in HEX shows '1A', not 26).
  * CycleBase now commits any active entry (parsed with old base) before switching. This makes mid-entry Tab safe and preserves CERR semantics.
- UI: added A-F/a-f key handling in Update (only when CurrentBase()==HEX). Sets pressedKey (harmless since no visual A-F buttons in tight scope).
- Tests: added 4 focused tests for hex digit acceptance, decimal ignore, mode gating, and mid-entry base switch + subsequent arithmetic.
- All existing behavior (DEC, CERR, etc.) preserved.
- Build + tests green.

This is the minimal 'keyboard only while indicator says HEX' scope requested. No visual A-F keypad buttons, no fractional hex, no changes to BIN/OCT entry.
2026-06-06 15:55:02 +01:00
Grok
a3ed82c6d9 feat(engine): implement core calculation engine (phase 2)
- float64 decimal math + classic entry buffer (in-progress digits visible)
- CycleBase() with IsInteger() (epsilon) + ErrConversionNotPossible (CERR)
- FormatForDisplay() for DEC/HEX/BIN/OCT (integer formatting for non-DEC)
- Basic ops: + - * / and MOD (math.Mod)
- Equals, SetOperator, EnterDigit/DecimalPoint, ClearEntry, AllClear, ChangeSign, Backspace
- Comprehensive tests covering the critical CERR path (23/6, 1/3 + BASE) plus arithmetic and MOD

This completes the pure engine. The engine is now usable by the upcoming TUI spike. Paper trail updated.
2026-06-06 14:29:36 +01:00
Grok
2a26148c8a chore(skeleton): minimal Go project layout + build system
- go.mod (1.24.2 + initial bubbletea/lipgloss)
- Makefile (build, install to ~/.local/bin/gralculator, test, clean; ldflags version injection)
- internal/version (ldflags-compatible String())
- main.go stub (version flag + placeholder)
- internal/calc/ (Engine skeleton with Base, CycleBase, IsInteger, ErrConversionNotPossible, FormatForDisplay stub + basic tests for CERR path)
- internal/ui/ (App model stub with Tab handling placeholder + lipgloss import for future rendering)

This establishes the three-phase foundation. Next: flesh out engine (phase 2), then TUI spike (phase 3). Paper trail continues.
2026-06-06 14:28:59 +01:00