diff --git a/.memory/project.md b/.memory/project.md index 7b1ebe3..c06bd9d 100644 --- a/.memory/project.md +++ b/.memory/project.md @@ -2,6 +2,7 @@ - Core engine: `src/rpn-calculator.js` - 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 +- Note: keep scrolling behavior in mind for the calc-02 demo when changing the stack/UI layout - 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` and `e`; arithmetic includes `root`; constants can be added or removed dynamically through the core API diff --git a/samples/calc-02/index.js b/samples/calc-02/index.js index 517fed7..c4335ea 100644 --- a/samples/calc-02/index.js +++ b/samples/calc-02/index.js @@ -120,9 +120,7 @@ function clearStatus() { } function normalizeStack() { - while (calc.stack.length > 4) { - calc.stack.shift(); - } + // Demo display only shows the top 4 stack values; the calculator stack remains unlimited. } function getStackLine(indexFromTop) { @@ -159,7 +157,6 @@ function updateCopyButtons() { } function render() { - normalizeStack(); const isPortrait = window.matchMedia('(orientation: portrait)').matches || window.innerWidth <= 860; calculatorEl?.classList.toggle('portrait', isPortrait); calculatorEl?.classList.toggle('landscape', !isPortrait); @@ -520,16 +517,18 @@ leftButton.addEventListener('click', () => { } }); downButton.addEventListener('click', () => { - if (!calc.isEditing && calc.isValidIndex(0)) { - const value = calc.stack[0]; - calc.remove(0); - calc.isEditing = true; - calc.inputValue = calc.formatNumber(value); - render(); - focusInput(); - } +if (!calc.isEditing && calc.isValidIndex(0)) { + const value = calc.stack[0]; + calc.remove(0); + calc.isEditing = true; + calc.inputValue = calc.formatNumber(value); + editCursor = calc.inputValue.length; + render(); + focusInput(); +} }); + rightButton.addEventListener('click', () => { if (calc.isEditing) { editCursor = Math.min(calc.inputValue.length, editCursor + 1);