A terminal-based calculator with a text-editor experience
Features β’ Installation β’ Usage β’ Syntax β’ License
Crabculator is a terminal-based calculator application that provides a text-editor-like experience for writing and evaluating math expressions. Write multiple lines of calculations, define variables, and see results update live as you type.
- TUI β terminal-based user interface
- Real-time evaluation β Results update instantly as you type
- Variable support β Define variables (e.g.,
a = 5 + 3) - Math functions β Built-in functions like
sqrt,sin,cos,tan,log,ln,abs,floor,ceil - Constants β Access
piandedirectly in expressions - Inline error display β Red underlined tokens with clear error explanations
- Full editor navigation β Cursor movement and editing anywhere in the document
- Session persistence β Variables persist across sessions
Requires Rust 2024 edition.
git clone https://github.com/marconae/crabculator.git
cd crabculator
cargo install --path .The binary will be available at target/release/crabculator.
Launch the application:
crabculator| Key | Action |
|---|---|
Arrow keys |
Move cursor |
Home / End |
Jump to line start/end |
Ctrl+H |
Toggle help overlay |
Ctrl+R |
Clear buffer |
Ctrl+C / Ctrl+Q |
Exit |
5 + 3 β 8
10 - 4 β 6
6 * 7 β 42
15 / 3 β 5
17 % 5 β 2
(5 + 3) * 2 β 16
a = 5 + 3 β 8
b = a * 2 β 16
total = a + b β 24
Variables persist across sessions and are stored in ~/.crabculator/state.json.
| Category | Function | Description |
|---|---|---|
| Basic | sqrt(x) |
Square root |
cbrt(x) |
Cube root | |
abs(x) |
Absolute value | |
pow(base, exp) |
Power | |
| Trig | sin(x), cos(x), tan(x) |
Trigonometric (radians) |
asin(x), acos(x), atan(x) |
Inverse trigonometric | |
atan2(y, x) |
Two-argument arctangent | |
| Hyperbolic | sinh(x), cosh(x), tanh(x) |
Hyperbolic functions |
asinh(x), acosh(x), atanh(x) |
Inverse hyperbolic | |
| Log/Exp | ln(x) |
Natural logarithm |
log(x), log10(x) |
Base-10 logarithm | |
log2(x) |
Base-2 logarithm | |
exp(x) |
Exponential (e^x) | |
exp2(x) |
Power of 2 (2^x) | |
| Rounding | floor(x), ceil(x) |
Round down/up |
round(x) |
Round to nearest | |
| Utility | min(a, b), max(a, b) |
Minimum/maximum |
hypot(a, b) |
Hypotenuse (sqrt(aΒ² + bΒ²)) |
| Constant | Value |
|---|---|
pi |
3.14159... |
e |
2.71828... |
radius = 5
area = pi * radius^2 β 78.5398...
circumference = 2 * pi * radius β 31.4159...
a = 3
b = 4
hypotenuse = sqrt(a^2 + b^2) β 5
Free and open-source under MIT.
Build with π¦ Rust and made with β€οΈ by marconae β blogging on deliberate.codes.