Feature/editbox widget - #5
Merged
Merged
Conversation
New features: - DrawEditBox(): renders text input field with optional cursor bar - EditBoxProcessKey(): handles one raw scan code (insert/delete/arrows/Return/Esc) - EditBoxPollKey(): convenience wrapper that reads and consumes current_key - DrawGadget() now dispatches GADGET_TYPE_EDITBOX (type 2) via new EDITBOX struct - editbox_sc_unshifted: 128-entry scan-code → ASCII table (unshifted US layout) lib/gui.i: - EDITBOX struct (28 bytes, offsets 0-19 match GADGET for transparent dispatch) - GADGET_TYPE_EDITBOX = 2 - XREF/HAS extern declarations for new functions lib/keyboardcodes.i: - Completed all scan-code constants with verified Amiga HRM values (KEY_RETURN, KEY_BACKSP, KEY_TAB, all letters, all digits, punctuation, modifier keys, function keys) examples/editbox_demo.has: - Full interactive demo: type text, arrow cursor, backspace, Return (confirm), Escape (clear), mouse Exit button
There was a problem hiding this comment.
Pull request overview
Key findings (need follow-up):
lib/gui.snow unconditionally referencescurrent_key, which introduces a hard link-time dependency onlib/keyboard.sfor any consumer oflib/gui.s(even msgbox/button-only programs).scripts/build_example.shdependency closure needs to pull inlib/keyboard.swhenlib/gui.sis selected; otherwise GUI examples that don’texternkeyboard symbols will fail to link.
Purpose:
Adds a new GUI EditBox widget to the Amiga-side GUI library (rendering + scan-code-driven text editing), plus helper build scripts and documentation so examples can be built more easily.
Changes:
- Added EditBox rendering + input processing routines to
lib/gui.s, plus newEDITBOX_*struct layout and gadget dispatch support inlib/gui.i. - Introduced
scripts/build_example.shto build.hasexamples with auto-selected library objects. - Expanded keyboard scan-code equates and added an end-to-end
examples/editbox_demo.has, with docs + changelog updates.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/build.sh | Generalized single-file build helper to accept .has or .s inputs and auto-detect toolchain paths. |
| scripts/build_example.sh | New example build script that compiles HAS, assembles selected libs, and links into an Amiga executable. |
| lib/keyboardcodes.i | Replaced placeholder key equates with HRM-based scan-code constants used by examples/libs. |
| lib/gui.s | Added EditBox widget rendering, key processing, polling helper, and scan-code→ASCII table; updated gadget dispatch. |
| lib/gui.i | Added GADGET_TYPE_EDITBOX, EDITBOX_* struct offsets, and XREFs for new EditBox routines. |
| examples/editbox_demo.has | New demo showcasing EditBox typing/editing, submit/cancel behaviors, and mouse-driven exit. |
| docs/GUI_LIBRARY.md | Documented EditBox APIs/struct layout and build integration updates. |
| docs/CHANGELOG.md | Logged the new EditBox widget feature and related API additions. |
Comment on lines
60
to
+63
| XREF GetMouseDX | ||
| XREF GetMouseDY | ||
| XREF GetMouseLBtn | ||
| XREF current_key |
Comment on lines
+1465
to
+1469
| editbox_sc_unshifted: | ||
| ; $00-$07 ` 1 2 3 4 5 6 7 | ||
| dc.b $60,$31,$32,$33,$34,$35,$36,$37 | ||
| ; $08-$0F 8 9 0 - = \(intl) [unused] 0(KP0) | ||
| dc.b $38,$39,$30,$2D,$3D,$5C,$00,$30 |
Comment on lines
+159
to
+163
| gui.s) | ||
| for dep in "$LIB_DIR/graphics.s" "$LIB_DIR/input.s"; do | ||
| if [[ -z "${WANT_LIB[$dep]:-}" ]]; then add_dep "$dep"; changed=1; fi | ||
| done | ||
| ;; |
Comment on lines
87
to
+91
| echo "Assembling $OUT_S -> $OUT_O" | ||
| vasm68000_mot -Fhunkexe -o "$OUT_O" "$OUT_S" | ||
| "$VASM" -Fhunkexe -o "$OUT_O" "$OUT_S" | ||
|
|
||
| echo "Linking $OUT_O -> $OUT_EXE" | ||
| vlink -bamigahunk "$OUT_O" -o "$OUT_EXE" | ||
| "$VLINK" -bamigahunk "$OUT_O" -o "$OUT_EXE" |
Comment on lines
17
to
21
| - [DrawButton](#drawbutton) ← 3D gadget style | ||
| - [DrawEditBox](#draweditbox) | ||
| - [EditBoxProcessKey](#editboxprocesskey) | ||
| - [EditBoxPollKey](#editboxpollkey) | ||
| - [DrawWrappedText](#drawwrappedtext) |
| @@ -346,7 +456,10 @@ Pass `&cursor` (the address of the height word) to `CreateSprite`. | |||
| Link `lib/gui.s`, `lib/sprite.s` (if using cursor), `lib/input.s`, `lib/graphics.s`, `lib/font8x8.s`, `lib/helpers.s`, and `lib/takeover.s` together: | |||
Comment on lines
+24
to
+28
| // python3 -m hasc.cli examples/editbox_demo.has -o build/editbox_demo.s | ||
| // vasmm68k_mot -Fhunkexe -I lib/ -o build/editbox_demo.o \ | ||
| // build/editbox_demo.s lib/gui.s lib/graphics.s lib/font8x8.s \ | ||
| // lib/helpers.s lib/input.s lib/keyboard.s lib/takeover.s | ||
| // vlink -bamigahunk build/editbox_demo.o -o build/editbox_demo.exe |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.