Skip to content

Commit

Permalink
ssh: support dumb terminals in ssh client
Browse files Browse the repository at this point in the history
  • Loading branch information
frazze-jobb committed Sep 8, 2023
1 parent 5ac156d commit 88e1d35
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/ssh/src/ssh_cli.erl
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,28 @@ to_group(Data, Group) ->
%%% displaying device...
%%% We are *not* really unicode aware yet, we just filter away characters
%%% beyond the latin1 range. We however handle the unicode binaries...
io_request(Request, Buf, Tty = #ssh_pty{term = "dumb"}, Group) ->
%% When we have a dumb terminal, we should only support outputing text, no navigation
%% or redraws necessary.
case Request of
{put_chars, Cs} ->
put_chars(bin_to_list(Cs), Buf, Tty);
{put_chars, unicode, Cs} ->
put_chars(unicode:characters_to_list(Cs,unicode), Buf, Tty);
{put_chars_sync, unicode, Cs, Reply} ->
Group ! {reply, Reply, ok},
put_chars(unicode:characters_to_list(Cs,unicode), Buf, Tty);
{insert_chars, Cs} ->
put_chars(bin_to_list(Cs), Buf, Tty);
{insert_chars, unicode, Cs} ->
put_chars(unicode:characters_to_list(Cs,unicode), Buf, Tty);
{requests,Rs} ->
io_requests(Rs, Buf, Tty, [], Group);
beep ->
{[7], Buf};
_Ignore ->
{[], Buf}
end;
io_request({window_change, OldTty}, Buf, Tty, _Group) ->
window_change(Tty, OldTty, Buf);
io_request({put_chars, Cs}, Buf, Tty, _Group) ->
Expand Down Expand Up @@ -509,7 +531,7 @@ get_tty_command(left, N, _TerminalType) ->
-define(TABWIDTH, 8).

%% convert input characters to buffer and to writeout
%% Note that the buf is reversed but the buftail is not
%% Note that Bef is reversed but Aft is not
%% (this is handy; the head is always next to the cursor)
conv_buf([], {LB, {Bef, Aft}, LA, Col}, AccWrite, _Tty) ->
{{LB, {Bef, Aft}, LA}, lists:reverse(AccWrite), Col};
Expand Down
3 changes: 3 additions & 0 deletions lib/stdlib/src/edlin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ start(Pbs) ->

%% Only two modes used: 'none' and 'search'. Other modes can be
%% handled inline through specific character handling.
start(Pbs, {_,{_,_},[]}=Cont) ->
%% Skip redraw if the cursor is at the end.
{more_chars,{line,Pbs,Cont,none},[{insert_chars,unicode,multi_line_prompt(Pbs)}]};
start(Pbs, {_,{_,_},_}=Cont) ->
{more_chars,{line,Pbs,Cont,none},redraw(Pbs, Cont, [])};

Expand Down

0 comments on commit 88e1d35

Please sign in to comment.