Compare commits

..

6 Commits

5 changed files with 42 additions and 42 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# State
- Core engine: `src/rpn-calculator.js`
- Reference demo: `samples/calc-02/` (portrait-first HP48GX layout, compact mode/constants popups)
- Reference demo: `samples/calc-02/` (portrait-first HP48GX layout, compact mode/constants popups; Const button comes before Mode in the display row)
- Important UI behavior: mode button shows the current angle mode; keyboard focus stays on the hidden input on desktop; clipboard paste is supported
- Public API: `push`, `pop`, `clear`, `swap`, `remove`, `edit`, `isValidIndex`, `input`, `command`, `getOperationsByCategory`, `getConstants`, `listConstants`, `setConstant`, `removeConstant`, `hasConstant`
- Config: `maxSize`, `base`, `angleMode`, `enabledCommands`
+3 -4
View File
@@ -1,9 +1,8 @@
# State
- Core engine: `src/rpn-calculator.js`
- Active demo: `samples/calc-02/` portrait-only HP48GX layout; display-adjacent button row stays in 4 columns and now shares the same base button styling as the function keys
- Mode button shows the current angle mode only; selecting a mode uses a popup menu
- Default demo: `samples/dev/` classic browser demo; `samples/calc-02/` remains the portrait-first HP48GX-inspired reference
- Public API: `push`, `pop`, `clear`, `swap`, `remove`, `edit`, `isValidIndex`, `input`, `command`, `getOperationsByCategory`, `getConstants`, `listConstants`, `setConstant`, `removeConstant`, `hasConstant`
- Config: `maxSize`, `base`, `angleMode`, `enabledCommands`
- Commands: arithmetic, stack, trigonometry, constants `pi`, `e`, `phi`, `g`, and `c`; arithmetic now includes `root` for y-th roots; constants can now be added or removed dynamically through the core API
- Demo actions: keyboard focus is kept on the hidden input on desktop so typing keeps working; the keypad layout places Enter in the bottom-left, ± in the former Enter position, and Esc before Clear for safety; paste parses clipboard text as a number before pushing it to the stack; Ctrl+V is supported via the hidden input paste event; backspace is ignored when the stack is empty; operation errors are shown as an overlay bar on top of the calculator with a shorter timeout and darker red; the display button row uses a 4-column grid with a spacer cell to preserve alignment
- Commands: arithmetic, stack, trigonometry, constants `pi`, `e`, `phi`, `g`, and `c`; arithmetic includes `root` with `y√x`, `yroot`, and `nroot` aliases; constants can be added or removed dynamically through the core API
- Demo behavior: `samples/dev/` keeps hidden input focus on desktop and supports clipboard paste; `samples/calc-02/` uses compact mode/constants popups, a 4-column display-adjacent row, stack selection/move mode, and paste through the hidden input
- Exports: browser `window.RpnCalculator`, CommonJS `module.exports`
+10 -9
View File
@@ -1,15 +1,16 @@
# RPN Virtual Calculator
A browser-friendly RPN calculator built around a small, generic JavaScript API.
A browser-friendly RPN calculator built around a small JavaScript API.
## Overview
This project provides:
- a reusable JavaScript RPN engine in `src/rpn-calculator.js`
- browser demos in `samples/dev/` and `samples/calc-02/`
- a command system centralized in a single operation dictionary
- a small public API focused on stack operations and generic command dispatch
- a classic browser demo in `samples/dev/`
- a portrait-first HP48GX-inspired demo in `samples/calc-02/`
- a centralized command system with aliases
- a compact public API focused on stack operations, editing, and command dispatch
The main class is `RpnCalculator`.
@@ -19,9 +20,6 @@ The main class is `RpnCalculator`.
- `samples/dev/index.html`: browser demo entry point
- `samples/dev/index.css`: demo styles
- `samples/dev/index.js`: demo UI and keyboard logic
- `samples/calc-01/index.html`: active browser demo entry point
- `samples/calc-01/index.css`: demo styles
- `samples/calc-01/index.js`: demo UI and keyboard logic
- `samples/calc-02/index.html`: portrait-first HP48GX-style demo entry point
- `samples/calc-02/index.css`: portrait-first demo styles
- `samples/calc-02/index.js`: portrait-first HP48GX-style demo UI and keyboard logic
@@ -88,6 +86,9 @@ Available constants:
- `pi`
- `e`
- `phi`
- `g`
- `c`
- plus any user-defined constants added through the engine API
They can be used through `command(...)`:
@@ -239,7 +240,7 @@ console.log(calc.pop()); // 0.5
## Demo
The active demo lives in `samples/dev/`.
The default demo lives in `samples/dev/`.
Main UI features:
@@ -249,7 +250,7 @@ Main UI features:
- angle mode selector for `deg`, `rad`, and `grad`
- status pills for `inputValue` and `isEditing`
- grouped panels for `Stack`, `Arithmetic`, `Trigonometry`, and `Constants`
- error display area
- keyboard-friendly hidden input on desktop
## Calc 02 demo
+3 -3
View File
@@ -25,11 +25,11 @@
<div class="display-buttons-panel">
<div class="display-buttons-grid">
<button id="modeButton" class="display-button">Mode</button>
<button id="constButton" class="display-button">π</button>
<button id="upButton" class="display-button"><span class="display-button-symbol arrow-symbol"></span></button>
<div class="display-button-spacer"></div>
<button id="pasteButton" class="display-button"><span class="display-button-symbol paste-symbol"></span></button>
<button id="upButton" class="display-button"><span class="display-button-symbol arrow-symbol"></span></button>
<button id="modeButton" class="display-button">Mode</button>
<div class="display-button-spacer"></div>
<button id="leftButton" class="display-button display-button-offset"><span class="display-button-symbol arrow-symbol"></span></button>
<button id="downButton" class="display-button"><span class="display-button-symbol arrow-symbol"></span></button>
<button id="rightButton" class="display-button"><span class="display-button-symbol arrow-symbol"></span></button>
+7 -7
View File
@@ -15,7 +15,7 @@
```
┌──────── Display Buttons ────────┐
| Mode | Paste | Up | Const |
| Const | Paste | Up | Mode |
| | Left | Down | Right |
└─────────────────────────────────┘
```
@@ -23,30 +23,30 @@
## Keypad
```
┌──────────── Keypad ─────────────┐
┌──────────── Keypad ─────────────┐
| +/- | Clear | Esc | backspace |
| 7 | 8 | 9 | / |
| 4 | 5 | 6 | * |
| 1 | 2 | 3 | - |
| 0 | . | Enter | + |
└───────────────────────────────────
└─────────────────────────────────┘
```
## Functions
```
┌──────────── Functions ────────────
┌──────────── Functions ──────────┐
| x^2 | y^x | 1/x | % |
| √x | y√x | 10^x | |
| log | ln | | |
└───────────────────────────────────
└─────────────────────────────────┘
```
## Trigo
```
┌──────────── Trigo ──────────────┐
┌──────────── Trigo ──────────────┐
| sin | cos | tan | |
| asin | acos | atan | |
└───────────────────────────────────
└─────────────────────────────────┘
```