mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 14:04:59 +02:00
Fix sshd server to not send back space erase when no character in the line
sshd server keeps count of characters typed on a line and will not send backspace erase to the client if no character is there to erase on the line even if the users is typing backspaces. This avoids erase of shell prompt characters for visual user friendliness.
This commit is contained in:
parent
9ec4bf235c
commit
bf2766ba2d
19
channels.c
19
channels.c
@ -2410,6 +2410,9 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
|
||||
const u_char *data;
|
||||
u_int data_len, win_len;
|
||||
Channel *c;
|
||||
#ifdef WIN32_FIXME
|
||||
static charinline = 0; // counts characters in a line for sshd in tty mode
|
||||
#endif
|
||||
|
||||
/* Get the channel number and verify it. */
|
||||
id = packet_get_int();
|
||||
@ -2476,9 +2479,19 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
|
||||
else {
|
||||
buffer_append(&c->output, data, data_len); // it is the sshd server, so pass it on
|
||||
if ( c->isatty ) { // we echo the data if it is sshd server and pty interactive mode
|
||||
buffer_append(&c->input, data, data_len);
|
||||
if ( (data_len ==1) && (data[0] == '\b') )
|
||||
buffer_append(&c->input, " \b", 2); // for backspace, we need to send space and another backspace for visual erase
|
||||
if ( (data_len ==1) && (data[0] == '\b') ) {
|
||||
if (charinline >0) {
|
||||
buffer_append(&c->input, "\b \b", 3); // for backspace, we need to send space and another backspace for visual erase
|
||||
charinline--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
buffer_append(&c->input, data, data_len);
|
||||
charinline += data_len; // one more char on the line
|
||||
}
|
||||
|
||||
if ( (data[data_len-1] == '\r') || (data[data_len-1] == '\n') )
|
||||
charinline = 0; // a line has ended, begin char in line count again
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user