From f0ee26b8fd832b786e4fd7a7c8c145fb4ae73687 Mon Sep 17 00:00:00 2001 From: YO4 Date: Thu, 10 Oct 2024 21:09:51 +0900 Subject: [PATCH] support startup_message with narrow window size 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. --- lib/yamatanooroti/windows.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yamatanooroti/windows.rb b/lib/yamatanooroti/windows.rb index b75f149..93c0da1 100644 --- a/lib/yamatanooroti/windows.rb +++ b/lib/yamatanooroti/windows.rb @@ -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