diff options
-rw-r--r-- | src/console/ptyc_console_reader.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/console/ptyc_console_reader.c b/src/console/ptyc_console_reader.c index 75547b5..44287ec 100644 --- a/src/console/ptyc_console_reader.c +++ b/src/console/ptyc_console_reader.c @@ -14,6 +14,48 @@ typedef nt_unicode_conversion_params_utf16_to_utf8 uc_conv_params; +static size_t ptyc_repeat(unsigned char * ch, size_t n, uint16_t count) +{ + unsigned char * dst; + int i; + + if (!--count) + return n; + + if (n == 1) { + for (i=count, dst=&ch[n]; i; i--) { + dst[0] = ch[0]; + dst = &dst[n]; + } + + } else if (n == 2) { + for (i=count, dst=&ch[n]; i; i--) { + dst[0] = ch[0]; + dst[1] = ch[1]; + dst = &dst[n]; + } + + } else if (n == 3) { + for (i=count, dst=&ch[n]; i; i--) { + dst[0] = ch[0]; + dst[1] = ch[1]; + dst[2] = ch[2]; + dst = &dst[n]; + } + + } else if (n == 4) { + for (i=count, dst=&ch[n]; i; i--) { + dst[0] = ch[0]; + dst[1] = ch[1]; + dst[2] = ch[2]; + dst[3] = ch[3]; + dst = &dst[n]; + } + } + + return n*count; +} + static size_t ptyc_translate_keyboard_event( nt_input_record * rec, unsigned char * ch, @@ -57,7 +99,10 @@ static size_t ptyc_translate_keyboard_event( ntapi->uc_convert_unicode_stream_utf16_to_utf8( ¶ms); - return params.bytes_written; + return ptyc_repeat( + ch, + params.bytes_written, + rec->key_event.repeat_count); } static size_t ptyc_translate_mouse_event( |