Skip to content

Commit

Permalink
support startup_message with narrow window size
Browse files Browse the repository at this point in the history
In narrow console window, start up message shows like below:
```
+-----+
|Multi|
|line |
|REPL.|
|promp|
|t>   |
|     |
```
When start_tarminal() with ```startup_message: 'Multiline REPL.'```,
vterm.rb recieves startup message as stream, so window size is not matter.
windows.rb can't recieve startup message as stream, only can retreive_screen().

retreive_screen recieves like:
```["Multi", "line", "REPL.", "promp", "t>", "", ...]```

This patch splits startup_message into every width characters to allow for correct comparisons.

If there are wide widths or complex characters, they will fail to divide accurately.
So it is not perfect. Nevertheless, the situation can be mitigated.
  • Loading branch information
YO4 committed Oct 10, 2024
1 parent 30e8bc9 commit f0ee26b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/yamatanooroti/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def start_terminal(height, width, command, wait: nil, timeout: nil, startup_mess

case startup_message
when String
wait_startup_message { |message| message.start_with?(startup_message) }
wait_startup_message { |message| message.start_with?(startup_message.chars.each_slice(width).map { |l| l.join.rstrip }.join("\n")) }
when Regexp
wait_startup_message { |message| startup_message.match?(message) }
end
Expand Down

0 comments on commit f0ee26b

Please sign in to comment.