Compare commits

..

2 Commits

2 changed files with 21 additions and 21 deletions
+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`
+18 -17
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
@@ -68,10 +66,10 @@ State exposed on instances:
```js README.md
const calc = new RpnCalculator({
maxSize: 2048,
base: 10,
angleMode: 'deg',
enabledCommands: ['add', 'sub', 'mul', 'div']
maxSize: 2048,
base: 10,
angleMode: 'deg',
enabledCommands: ['add', 'sub', 'mul', 'div']
});
```
@@ -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(...)`:
@@ -194,10 +195,10 @@ console.log(calc.pop()); // 5
```html README.md
<script src="./src/rpn-calculator.js"></script>
<script>
const calc = new RpnCalculator({ angleMode: 'deg' });
calc.push(9);
calc.command('sqrt');
console.log(calc.pop());
const calc = new RpnCalculator({ angleMode: 'deg' });
calc.push(9);
calc.command('sqrt');
console.log(calc.pop());
</script>
```
@@ -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