CellBlocksTUI

A spreadsheet in your terminal. The most complex Go TUI project.

Go 100% Oct 2025
cellblockstui - Sheet1
     |    A     |    B     |    C     |
-----+----------+----------+----------+
  1  | Revenue  | Expenses | Profit   |
  2  |   50000  |   32000  | =A2-B2   |
  3  |   65000  |   41000  |   24000  |
  4  |   72000  |   38000  |   34000  |
-----+----------+----------+----------+
 C2: =A2-B2 | Result: 18000
>

Project Overview

CellBlocksTUI brings spreadsheet functionality to the terminal. Navigate cells with arrow keys or vim bindings, enter values, write formulas, and see results update in real time -- all within a Bubble Tea TUI.

This was the most technically challenging Go TUI project. Implementing a formula parser, cell dependency graph, and spreadsheet navigation in a terminal UI pushed the boundaries of what Bubble Tea can handle. The state management alone -- tracking cell values, formulas, dependencies, and display formatting -- required careful architecture.

{}

Tech Stack

Go
100% Go. The formula parser and evaluator are pure Go with no external math libraries.
Bubble Tea
Elm architecture handling complex cell selection, editing modes, and formula evaluation.
Lipgloss
Table rendering with column alignment, cell highlighting, and formula bar styling.
Bubbles
Text input for cell editing, viewport for scrolling large sheets.
#

Architecture

  CellBlocksTUI State Architecture
  ==================================

  Sheet Model
    |-- cells map[CellRef]*Cell
    |-- selection (row, col)
    |-- editMode bool
    |-- viewport (scroll offset)
    |
    +-- Formula Engine
    |     |-- tokenizer (=A1+B2*C3)
    |     |-- parser (AST)
    |     |-- evaluator (resolve refs)
    |     +-- dependency graph
    |
    +-- Renderer
          |-- column width calc
          |-- cell formatting
          |-- selection highlight
          +-- formula bar display
*

Key Features

Cell Editing
Enter edit mode, type values or formulas, confirm with Enter. Text, numbers, and formula cells.
Formula Engine
Supports arithmetic operators, cell references (A1, B2), and basic functions like SUM and AVERAGE.
Dependency Graph
Cells track which other cells they depend on. Changing a value triggers cascading recalculations.
Spreadsheet Navigation
Arrow keys, Tab, Enter, Home/End, and vim bindings to move between cells. Cell reference display in formula bar.
Column Formatting
Auto-width columns, right-aligned numbers, left-aligned text. Clean tabular display with box-drawing borders.
Data Manipulation
Copy/paste cells, insert/delete rows and columns, and clear ranges. Basic spreadsheet operations.
~

Stats

100%
Go
16.8
MB Size
Oct 16
Created 2025
#1
Most Complex TUI
!

Lessons Learned

Complex state management in TUIs is a different beast than web state management. There are no React hooks or Redux stores -- just a Go struct and messages. Building a formula parser from scratch taught the fundamentals of tokenization and AST evaluation. And the dependency graph for cell recalculation was a practical lesson in topological sorting. The most complex project is often the best teacher.