Skip to content

Commit 33c3443

Browse files
committed
kernel: Handle new edlin result in JCL mode
closes #8388
1 parent e26c520 commit 33c3443

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

lib/kernel/src/user_drv.erl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
%% Clears the state, not touching the characters
8888
new_prompt.
8989

90-
-export_type([message/0]).
90+
-export_type([message/0, request/0]).
9191
-export([start/0, start/1, start_shell/0, start_shell/1, whereis_group/0]).
9292

9393
%% gen_statem state callbacks
@@ -644,8 +644,18 @@ switch_loop(info,{ReadHandle,{data,Cs}}, {Cont, #state{ read = ReadHandle } = St
644644
{blink,NewCont,Rs} ->
645645
{keep_state,
646646
{NewCont, State#state{ tty = io_requests(Rs, State#state.tty)}},
647-
1000}
647+
1000};
648+
{_What, _Cs, _NewCont, _Rs} ->
649+
keep_state_and_data;
650+
{_What, _Bef, _Cs, _NewCont, _Rs} ->
651+
keep_state_and_data
648652
end;
653+
switch_loop(info, {Requester, get_unicode_state}, {_Cont, #state{ tty = TTYState }}) ->
654+
Requester ! {self(), get_unicode_state, prim_tty:unicode(TTYState) },
655+
keep_state_and_data;
656+
switch_loop(info, {Requester, get_terminal_state}, _State) ->
657+
Requester ! {self(), get_terminal_state, prim_tty:isatty(stdout) },
658+
keep_state_and_data;
649659
switch_loop(timeout, _, {_Cont, State}) ->
650660
{keep_state_and_data,
651661
{next_event, info, {State#state.read,{data,[]}}}};

lib/kernel/test/interactive_shell_SUITE.erl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ setup_tty(Config) ->
16161616
"strace" ->
16171617
STraceLog = filename:join(proplists:get_value(priv_dir,Config),
16181618
Name++".strace"),
1619-
ct:pal("Link to strace: file://~ts", [STraceLog]),
1619+
ct:log("Link to strace: file://~ts", [STraceLog]),
16201620
[os:find_executable("strace"),"-f",
16211621
"-o",STraceLog,
16221622
"-e","trace=all",
@@ -2018,7 +2018,7 @@ shell_history_eaccess(Config) ->
20182018
{expect, "echo\r\n"}
20192019
], [], [], mk_history_param(Path)),
20202020

2021-
ct:pal("~p",[Logs1]),
2021+
ct:log("~p",[Logs1]),
20222022
rtnode:check_logs("erlang.log.1", "Error handling file", Logs1),
20232023

20242024
%% shell_docs recursively creates the folder to store the
@@ -2278,6 +2278,14 @@ job_control_local(Config) when is_list(Config) ->
22782278
{putline, "h"},
22792279
{expect, "this message"},
22802280
{expect, "--> $"},
2281+
{putdata, "\t"}, %% Test that we don't crash
2282+
{sleep, 100},
2283+
{putline, ""},
2284+
{expect, "^\r\n\r\n --> $"},
2285+
{putdata, "\^r"}, %% Test that we don't crash
2286+
{sleep, 100},
2287+
{putline, ""},
2288+
{expect, "^\r\n\r\n --> $"},
22812289
{putline, "c 1"},
22822290
{expect, "\r\n"},
22832291
{putline, "35."},

lib/kernel/test/rtnode.erl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ send_commands(Node, CPid, [{expect, Encoding, Expect}|T], N) when is_list(Expect
140140
ok ->
141141
send_commands(Node, CPid, T, N + 1);
142142
{expect_timeout, Got} ->
143-
ct:pal("expect timed out waiting for ~p\ngot: ~p\n", [Expect,Got]),
143+
ct:log("expect timed out waiting for ~p\ngot: ~p\n", [Expect,Got]),
144144
{error, timeout};
145145
Other ->
146146
Other
@@ -289,7 +289,7 @@ start_runerl_node(RunErl,Erl,Tempdir,Nodename,Args) ->
289289

290290
start_runerl_command(RunErl, Tempdir, Cmd) ->
291291
FullCmd = "\""++RunErl++"\" "++Tempdir++"/ "++Tempdir++" \""++Cmd++"\"",
292-
ct:pal("~ts",[FullCmd]),
292+
ct:log("~ts",[FullCmd]),
293293
os:cmd(FullCmd).
294294

295295
start_peer_runerl_node(RunErl,Erl,Tempdir,[],Args) ->
@@ -533,9 +533,9 @@ dump_logs(Logs) ->
533533
maps:foreach(
534534
fun(File, Data) ->
535535
try re:replace(Data,"\e","\\\\e",[unicode,global]) of
536-
D -> ct:pal("~ts: ~ts",[File, D])
536+
D -> ct:log("~ts: ~ts",[File, D])
537537
catch error:badarg ->
538-
ct:pal("~ts: ~s",[File, re:replace(Data,"\e","\\\\e",[global])])
538+
ct:log("~ts: ~s",[File, re:replace(Data,"\e","\\\\e",[global])])
539539
end
540540
end, Logs).
541541

@@ -546,6 +546,7 @@ read_logs(Tempdir) ->
546546
LogFiles = [F || F <- LogFiles0,
547547
case F of
548548
"erlang.log" ++ _ -> true;
549+
% "peer" ++ _ -> true;
549550
_ -> false
550551
end],
551552

lib/stdlib/src/edlin.erl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,24 @@ start(Pbs, EditState) ->
8888
keymap() ->
8989
get(key_map).
9090

91+
-type continuation() :: {line, _, _, _} | {_, _, _}.
92+
-spec edit_line(unicode:chardata() | eof, continuation()) ->
93+
{done, continuation(), Rest :: unicode:chardata(), [user_drv:request()]} |
94+
{open_editor | format_expression | history_up | history_down | search,
95+
Cs :: unicode:chardata(), continuation(), [user_drv:request()]} |
96+
{help | expand | expand_full,
97+
Before :: unicode:chardata(),
98+
Cs :: unicode:chardata(), continuation(),
99+
[user_drv:request()]} |
100+
{search_found | search_quit | search_cancel,
101+
Cs :: unicode:chardata(), [user_drv:request()]} |
102+
{blink | more_chars, continuation(), [user_drv:request()]}.
91103
edit_line(Cs, {line,P,L,{blink,N_Rs}}) ->
92104
edit(Cs, P, L, {normal, none}, N_Rs);
93105
edit_line(Cs, {line,P,L,M}) ->
94106
edit(Cs, P, L, M, []).
95107

108+
%% Called when in search mode
96109
edit_line1(Cs, {line,P,L,{blink,N_Rs}}) ->
97110
edit(Cs, P, L, {normal, none}, N_Rs);
98111
edit_line1(Cs, {line,P,{B,{[],[]},A},{normal,none}}) ->

0 commit comments

Comments
 (0)