From d7b49d6e2124921d43c43f9f4e0a3f02b0230476 Mon Sep 17 00:00:00 2001 From: frazze-jobb Date: Tue, 15 Oct 2024 08:54:25 +0200 Subject: [PATCH 1/3] erts: to_erl screen should not be cleared When you connect with to_erl, the screen should not be cleared. Instead the input line should be redrawn. Changing ^L to ^[l achieves this. --- erts/etc/unix/run_erl.c | 4 ++-- erts/etc/unix/to_erl.c | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c index 615764663058..d86acd72c21c 100644 --- a/erts/etc/unix/run_erl.c +++ b/erts/etc/unix/run_erl.c @@ -711,8 +711,8 @@ static void pass_on(pid_t childpid) #endif } } - - if (!got_some && wfd && buf[0] == '\014') { + if (!got_some && wfd && buf[0] == '\033' && + buf[1] == 'l') { char wbuf[30]; int wlen = sn_printf(wbuf,sizeof(wbuf),"[run_erl v%u-%u]\n", RUN_ERL_HI_VER, RUN_ERL_LO_VER); diff --git a/erts/etc/unix/to_erl.c b/erts/etc/unix/to_erl.c index 4de4ac4d64ae..e34c14102534 100644 --- a/erts/etc/unix/to_erl.c +++ b/erts/etc/unix/to_erl.c @@ -351,16 +351,12 @@ int main(int argc, char **argv) show_terminal_settings(&tty_smode); #endif /* - * "Write a ^L to the FIFO which causes the other end to redisplay - * the input line." - * This does not seem to work as was intended in old comment above. - * However, this control character is now (R12B-3) used by run_erl - * to trigger the version handshaking between to_erl and run_erl - * at the start of every new to_erl-session. + * Write ^[l to the FIFO. This trigger the version handshaking + * between to_erl and run_erl and a redraw in erl, at the start + * of every new to_erl-session. */ - - if (write(wfd, "\014", 1) < 0) { - fprintf(stderr, "Error in writing ^L to FIFO.\n"); + if (write(wfd, "\033l", 2) < 0) { + fprintf(stderr, "Error in writing ^[l to FIFO.\n"); } /* From b05b7b2bc7f7254e187505ed8851a6bf3bb47d5a Mon Sep 17 00:00:00 2001 From: frazze-jobb Date: Thu, 24 Oct 2024 10:30:14 +0200 Subject: [PATCH 2/3] erts: dumb terminal should ignore ^l --- lib/kernel/src/group.erl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/kernel/src/group.erl b/lib/kernel/src/group.erl index 17b4562ff6bd..73b7148fc5cb 100644 --- a/lib/kernel/src/group.erl +++ b/lib/kernel/src/group.erl @@ -1180,6 +1180,9 @@ edit_line_dumb([Erase|Cs],[], Rs) when Erase =:= $\177; Erase =:= $\^H -> edit_line_dumb(Cs,[], Rs); edit_line_dumb([Erase|Cs],[_|Chars], Rs) when Erase =:= $\177; Erase =:= $\^H -> edit_line_dumb(Cs,Chars, [{delete_chars, -1}|Rs]); +edit_line_dumb([$\e, $l |Cs],Chars, Rs) -> + %% this is a key sequence sent by to_erl to refresh the screen + edit_line_dumb(Cs,Chars, Rs); edit_line_dumb([CtrlChar|Cs],Chars, Rs) when CtrlChar < 32 -> edit_line_dumb(Cs,Chars,Rs); edit_line_dumb([Char|Cs],Chars, Rs) -> From 5a93549d3ba154277e00032eb43414ece1f5853f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Backstr=C3=B6m?= Date: Tue, 29 Oct 2024 10:14:43 +0100 Subject: [PATCH 3/3] kernel: Fix noshell-raw testcase for \el in to_erl handshake --- lib/kernel/test/interactive_shell_SUITE.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kernel/test/interactive_shell_SUITE.erl b/lib/kernel/test/interactive_shell_SUITE.erl index 7bb085043c1d..63467896cec1 100644 --- a/lib/kernel/test/interactive_shell_SUITE.erl +++ b/lib/kernel/test/interactive_shell_SUITE.erl @@ -2213,7 +2213,8 @@ noshell_raw(Config) -> %% Make sure we are in unicode encoding unicode = proplists:get_value(encoding, io:getopts()), - "\fhello\n" = io:get_line("1> "), + %% "\el" is an artifact from the attaching to_erl program + "\el" ++ "hello\n" = io:get_line("1> "), io:format(TCGl, "TC Line: ~p~n", [?LINE]), ok = shell:start_interactive({noshell, raw}),