Commit Graph

18052 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto d8045dc5bc mruby-bin-mirb: re-indent current line on Enter
Before inserting a newline, re-indent the current line to match
the expected indent level. This fixes cases where the user typed
with incorrect indentation.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:25 +09:00
Yukihiro "Matz" Matsumoto ac306ae3e5 mruby-bin-mirb: preserve cursor position during TAB auto-indent
When TAB triggers auto-indentation, preserve the cursor's relative
position within the line instead of moving it to the indent boundary.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:25 +09:00
Yukihiro "Matz" Matsumoto f585cc2eff mruby-bin-mirb: align dedent to proper indent level
Instead of just removing 2 spaces, perform_dedent() now calculates
the expected indent level from previous lines and aligns to that.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:24 +09:00
Yukihiro "Matz" Matsumoto e901b6d1a3 mruby-bin-mirb: auto-dedent for else, elsif, when, rescue, ensure
Extend auto-dedent to trigger when typing dedent keywords, not just
end and }. Now dedent occurs when completing: else, elsif, when,
rescue, ensure.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:24 +09:00
Yukihiro "Matz" Matsumoto 1c07ac4892 mruby-bin-mirb: fix indentation when splitting line at dedent keyword
When splitting a line with Enter, check if the new line starts with
a dedenting keyword (end, else, elsif, when, rescue, ensure, }) and
reduce indentation by one level.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:24 +09:00
Yukihiro "Matz" Matsumoto fa74186b51 mruby-bin-mirb: add TAB auto-indentation
TAB now performs auto-indentation instead of completion when:
- cursor is at start of line
- cursor is at end of line
- character before cursor is whitespace

Auto-indent calculates expected indent level from previous lines
and adjusts current line. Dedenting keywords (end, else, elsif,
when, rescue, ensure, }) reduce indent by one level.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:24 +09:00
Yukihiro "Matz" Matsumoto cda57fcf03 mruby-bin-mirb: make Ctrl+K delete empty lines
when pressing Ctrl+K on an empty line, delete the entire line instead
of doing nothing. this makes it easier to clean up empty lines while
editing multi-line input.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:24 +09:00
Yukihiro "Matz" Matsumoto 53e78b8353 mruby-bin-mirb: only evaluate on Enter at end of last line
pressing Enter in the middle of multi-line input now always inserts
a new line instead of evaluating, even if the code is syntactically
complete. evaluation only occurs when cursor is at the end of the
last line.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:24 +09:00
Yukihiro "Matz" Matsumoto d3fcb176bf mruby-bin-mirb: restore tab completion for custom editor
- restore mirb_completion.c/h from before readline removal
- add editor adapter for tab completion (mirb_setup_editor_completion,
  mirb_get_completions, mirb_free_completions)
- add TAB key handling in mirb_editor.c
- fix string literal completion: properly detect when cursor is outside
  a string by scanning forward, allow string/array/hash literals as
  safe receivers for method completion

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:24 +09:00
Yukihiro "Matz" Matsumoto d47dedd17d mruby-bin-mirb: improve Enter key behavior and auto-indentation
- fix Enter in middle of line with trailing blank continuation line:
  now properly splits the line and removes redundant blank line
- fix auto-indentation when inserting in middle of existing code:
  calculate indent from lines up to cursor, not entire buffer
- add mirb_buffer_delete_line() for removing lines from buffer

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:23 +09:00
Yukihiro "Matz" Matsumoto 23c49ad026 mruby-bin-mirb: show incrementing line numbers in multi-line prompts
Previously, all continuation lines showed the same line number (e.g.,
"1*" for every line). Now each line shows its actual line number:

  1> class Foo
  2*   def bar
  3*   end
  4* end

Add mirb_editor_set_prompt_format() which accepts printf-style format
strings (e.g., "%d> ", "%d* ") and calculates the correct prompt length
for each line to ensure proper cursor positioning.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:23 +09:00
Yukihiro "Matz" Matsumoto 5f85c1beae mruby-bin-mirb: add command history with Up/Down navigation
Add in-memory command history for mirb sessions:
- Up arrow on first line: navigate to older history entries
- Down arrow on last line: navigate to newer history entries
- Current input is preserved when browsing and restored when
  navigating past the newest entry
- History uses a circular buffer (100 entries max)
- Duplicate consecutive entries are not added

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-18 16:27:22 +09:00
Yukihiro "Matz" Matsumoto f44e7409ba Merge pull request #6685 from mruby/dependabot/github_actions/super-linter/super-linter-8.3.1 2025-12-17 10:47:59 +09:00
dependabot[bot] 68a488def0 build(deps): bump super-linter/super-linter from 8.3.0 to 8.3.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 8.3.0 to 8.3.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v8.3.0...v8.3.1)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-version: 8.3.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-16 14:01:16 +00:00
Yukihiro "Matz" Matsumoto b04ec275f1 Merge pull request #6684 from mruby/dependabot/github_actions/actions/upload-artifact-6 2025-12-15 23:04:49 +09:00
dependabot[bot] 9ecaf0699c build(deps): bump actions/upload-artifact from 5 to 6
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-15 14:01:58 +00:00
Yukihiro "Matz" Matsumoto e1b595a61b Merge pull request #6682 from mruby/dependabot/github_actions/actions/cache-5 2025-12-14 23:06:47 +09:00
dependabot[bot] d755e2bc1b build(deps): bump actions/cache from 4 to 5
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-12 14:01:27 +00:00
Yukihiro "Matz" Matsumoto 2813f794a2 mruby-io: rename mruby/ext/io.h to mruby/io.h
Simplify the header path to be consistent with mruby/time.h.
The ext/ subdirectory was unnecessary.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:11 +09:00
Yukihiro "Matz" Matsumoto c521d8348e gem.rb: separate inter-gem headers from external API headers; close #6671
Headers in mrbgems are now categorized into three types:
- src/*.h: gem internal only
- include/*.h: inter-gem use (visible to dependent gems)
- include/export/*.h: external API (exported via mruby-config --cflags)

This prevents internal headers like *_hal.h from being exposed to
external users while maintaining inter-gem header accessibility.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:11 +09:00
Yukihiro "Matz" Matsumoto 527018cf07 mruby-bin-mirb: replace readline with custom multi-line editor
Remove readline/linenoise dependency and implement custom multi-line
editor with:
- Terminal raw mode handling (POSIX termios)
- Multi-line buffer with cursor navigation
- Auto-indentation for Ruby blocks
- Auto-dedentation when typing 'end' or '}'
- Natural terminal scrolling behavior
- Emacs-style keybindings (Ctrl+A/E/K/U/W/Y, Alt+B/F/D)

This eliminates GPL licensing concerns from readline while providing
better multi-line editing than the previous single-line implementation.

The MRUBY_MIRB_READLINE environment variable is no longer supported
as readline integration has been completely removed; ref #6626

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:10 +09:00
Yukihiro "Matz" Matsumoto b36e0b4090 mruby-bin-mirb: add colored output for prompts and errors
Add ANSI color support to mirb for better visual distinction:
- green prompts (both ready '>' and continuation '*')
- red error messages (syntax errors, runtime errors, warnings)
- bold result indicator ('=>')

Colors are automatically disabled when:
- output is not a TTY
- TERM is unset or "dumb"
- NO_COLOR environment variable is set

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:10 +09:00
Yukihiro "Matz" Matsumoto d52f3189d8 mruby-bin-mirb: add auto-indent for continuation lines
- automatically indent continuation lines based on block depth
- detect block-opening keywords (def, class, if, do, etc.) and braces
- use ANSI escape sequences to fix indentation for:
  - block-closing keywords (end, })
  - mid-block keywords (else, elsif, rescue, ensure, when)
- only active for interactive TTY input with ANSI support
- requires GNU readline (not available with linenoise)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:10 +09:00
Yukihiro "Matz" Matsumoto 9ad72e3a96 mrbgems: add README documentation for mruby-bin-* gems
- mruby-bin-config
- mruby-bin-debugger
- mruby-bin-mrbc
- mruby-bin-mruby
- mruby-bin-strip

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:10 +09:00
Yukihiro "Matz" Matsumoto f55bb0857a mruby-bin-mirb: add README with tab completion documentation
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:10 +09:00
Yukihiro "Matz" Matsumoto 97d4d8f45b mruby-set: standardize block parameter spacing
changed block spacing from { | to {| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:10 +09:00
Yukihiro "Matz" Matsumoto 4bef968452 mruby-method: standardize block parameter spacing
changed block spacing from { | to {| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:10 +09:00
Yukihiro "Matz" Matsumoto 8b0a4519b1 mruby-enum-ext: fix remaining block parameter spacing
changed block spacing from method{ to method { for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto b7563c327b mruby-benchmark: standardize block parameter spacing
changed block spacing from { | to {| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto 3cc4a77f49 mruby-socket: standardize block parameter spacing
changed block spacing from { | to {| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto e6fa93929d mruby-io: standardize block parameter spacing
changed block spacing from { | to {| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto 7cc41d5bc0 mruby-hash-ext: standardize block parameter spacing
changed block spacing from method{ to method { for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto 93cdb62985 mruby-struct: standardize block parameter spacing
changed block spacing from method{ to method { for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto 0d4695a91c mruby-enum-lazy: standardize block parameter spacing
changed block spacing from method{ to method { for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto 89237e9cf9 mruby-enum-ext: standardize block parameter spacing
changed block spacing from method{ to method { for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:08 +09:00
Yukihiro "Matz" Matsumoto bc24a32f2d enum.rb: standardize block parameter spacing
changed block spacing from method{ to method { for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:08 +09:00
Yukihiro "Matz" Matsumoto 722d4f77dd mruby-array-ext: standardize block parameter spacing
changed block spacing from { |param| to {|param| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:08 +09:00
Yukihiro "Matz" Matsumoto 35bab8dfed hash.rb: standardize block parameter spacing
changed block spacing from {|param| to {|param| (space before brace)
for consistency with the most common pattern in the codebase.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:08 +09:00
Yukihiro "Matz" Matsumoto 4dedb120c8 mruby-enum-ext: add parentheses to respond_to? call
added parentheses to respond_to? call where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:08 +09:00
Yukihiro "Matz" Matsumoto 676ab238a2 mruby-complex: add parentheses to Math method calls
added parentheses to Math.hypot and Math.atan2 calls where the return
value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:08 +09:00
Yukihiro "Matz" Matsumoto 6b2d0b3e0f numeric.rb: add parentheses to block.call
added parentheses to block.call where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto 1b85ad2bfe hash.rb: add parentheses to block.call
added parentheses to block.call where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto 0d7903694c mruby-enumerator: add parentheses to block.call
added parentheses to block.call calls where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto 171ad3fb4f mruby-array-ext: add parentheses to block.call
added parentheses to block.call where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto 75d7b8ed7c mruby-string-ext: add parentheses to to_enum call
added parentheses to to_enum call where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto 29644b0365 mruby-set: add parentheses to to_enum calls
added parentheses to all to_enum calls where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto 1fbace12a4 mruby-object-ext: add parentheses to to_enum call
added parentheses to to_enum call where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto 5f20013219 mruby-io: add parentheses to to_enum call
added parentheses to to_enum call where the return value is used,
explicitly specifying :each for readability.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:06 +09:00
Yukihiro "Matz" Matsumoto 6e67d64068 mruby-hash-ext: add parentheses to to_enum calls
added parentheses to all to_enum calls where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:06 +09:00
Yukihiro "Matz" Matsumoto 284dde6a3f mruby-enumerator: add parentheses to to_enum calls
added parentheses to all to_enum calls where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:06 +09:00