Skip to content

Use io-console for Windows console support - #917

Merged
tompng merged 1 commit into
masterfrom
windows-console-support
Aug 10, 2026
Merged

Use io-console for Windows console support#917
tompng merged 1 commit into
masterfrom
windows-console-support

Conversation

@nobu

@nobu nobu commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • replace Reline's direct Windows Fiddle bindings with io-console APIs
  • use IO#console_input_events for interruptible input event processing
  • use io-console for TTY detection, console modes, cursor operations, screen updates, and key state checks
  • remove the Windows-only fiddle development dependency
  • add coverage for translating io-console key event hashes into Reline::KeyEventRecord

Motivation

Reline currently carries its own Win32 API bindings and input record parsing. Moving those responsibilities to io-console removes duplicated platform code, gives CRuby and JRuby the same Windows console path, and lets console input waits remain responsive to Ruby interrupts.

This PR depends on ruby/io-console#140. The Gemfile temporarily points at its development branch so this PR can test the integration before the required io-console version is released.

Validation

  • Add Windows console support io-console#140 passes its complete GitHub Actions matrix on Windows, macOS, Linux, JRuby, and TruffleRuby
  • the focused local Reline test could not start because the local Bundler cache had not checked out the Git-based io-console dependency; this PR's CI will install that dependency and exercise the integration

@nobu
nobu force-pushed the windows-console-support branch 14 times, most recently from a4489e0 to 88e24e5 Compare August 8, 2026 04:05
@nobu
nobu marked this pull request as ready for review August 8, 2026 06:02
@nobu
nobu force-pushed the windows-console-support branch from 88e24e5 to f7acb32 Compare August 8, 2026 08:41
Comment thread lib/reline/io/windows.rb
def move_cursor_column(val)
_, _, _, y, = get_console_screen_buffer_info
@SetConsoleCursorPosition.call(@hConsoleHandle, y * 65536 + val) if y
@console_output.goto_column(val)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reline::LineEditor assumes move_cursor_column and other methods not raise SystemCallError.
What do you think of adding rescue SystemCallError and make it no-op instead of raising error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in reline methods?
Or do you think that io-console should not raise SystemCallError?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO only in Reline methods is enough.
I think it's fine, or even expected in some case, to raise SystemCallError when there's no console handle available. I'm not sure though.

Comment thread Gemfile Outdated
Remove Fiddle bindings by using `io-console` for Windows input and
screen operations.
@nobu
nobu force-pushed the windows-console-support branch from f7acb32 to 4628d75 Compare August 10, 2026 13:48

@tompng tompng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tompng
tompng merged commit 96241f4 into master Aug 10, 2026
190 of 192 checks passed
@tompng
tompng deleted the windows-console-support branch August 10, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants