Commit Graph

18044 Commits

Author SHA1 Message Date
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
Yukihiro "Matz" Matsumoto 2e71944f2b mruby-enum-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 531d5a76e5 mruby-enum-chain: 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 fce4eba9b2 mruby-array-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 ec1f9860b1 mrblib: add parentheses to method calls with used return values
added parentheses to all `to_enum` and `super` calls where the return
value is used (returned, assigned, or passed to another method). this
makes the code style consistent with the guideline that method calls
should use parentheses when their return values are consumed.

changes:
- return to_enum :symbol -> return to_enum(:symbol)
- return to_enum :symbol, arg -> return to_enum(:symbol, arg)
- super message, name -> super(message, name)

affected files: 10error.rb, array.rb, enum.rb, hash.rb, kernel.rb,
numeric.rb, range.rb

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:06 +09:00
Yukihiro "Matz" Matsumoto 4cf75fb035 mruby-bin-mirb: restrict evaluation to simple receivers
fixed a bug where tab completion on complex expressions like "d.new(1).a"
would corrupt local variables, causing them to become nil.

the root cause was that evaluating complex receiver expressions during tab
completion ran mrb_vm_run() without proper stack management (stack_keep)
and environment adjustment that mirb's main REPL loop performs. this
corrupted the local variable storage.

the fix restricts tab completion to only evaluate simple receiver
expressions (variable/constant names without operators or method calls).
complex expressions are skipped for completion. this means:
- works: d.<tab> completes methods of variable d
- works: String.<tab> completes methods of constant String
- skipped: d.new(1).<tab> provides no completion

this is a reasonable trade-off that prevents the corruption bug while
still supporting the most common completion scenarios.

also updated mirb_eval_receiver() to use the compiler context for proper
local variable resolution, with argument order matching mrb_parse_string.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:05 +09:00
Yukihiro "Matz" Matsumoto 2f152823f3 mruby-bin-mirb: add tab completion support
implements context-aware tab completion for mirb supporting all readline
variants (GNU readline, libedit, linenoise) with graceful degradation
when no readline library is available.

completion features:
- method names on objects (e.g., "hello".re<Tab> completes to reverse, replace)
- local variables from compiler context
- global variables via Ruby introspection
- constants and class names
- Ruby keywords

architecture:
- core completion engine is library-agnostic
- thin adapters for readline/libedit and linenoise
- context detection based on cursor position analysis
- safe receiver evaluation with exception handling
- proper word break characters so "String.new" works correctly

implementation adds:
- mirb_completion.h: interface definitions and data structures
- mirb_completion.c: complete implementation (~670 lines)
- mirb.c: integration with setup/cleanup calls

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:05 +09:00
Yukihiro "Matz" Matsumoto 0aafb83374 mruby-bin-mirb: add MRUBY_MIRB_READLINE to control readline library selection
addresses #6626 where users building portable binaries need explicit control
over readline detection instead of auto-detection.

MRUBY_MIRB_READLINE values:
  auto (default) - auto-detect: try readline, then edit, then linenoise
  readline, gnu  - force GNU readline only
  edit, libedit  - force libedit only
  linenoise      - force linenoise only
  none, off, false, disabled - use plain input mode (no readline)

close #6626

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:05 +09:00
Yukihiro "Matz" Matsumoto 9aa6f28eab mirb: show method context for errors from previous code
runtime errors now distinguish between:
- errors in current input: show relative line number
- errors from previously defined methods: show method context

examples:
1> a.foo
line 1: undefined method 'a' for Object (NoMethodError)

1> def foo
2*   bar
3* end
1> foo
(mirb):in foo: undefined method 'bar' for Object (NoMethodError)

this provides better context since method name is more useful
than line number for errors in previously defined code

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