Mercurial > vim
comparison src/term.c @ 13365:c6bafddbfa33 v8.0.1556
patch 8.0.1556: may not parse the t_RS response correctly
commit https://github.com/vim/vim/commit/590ec878a52b3b3d4453475f1eb4899f2b37969f
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 2 20:58:42 2018 +0100
patch 8.0.1556: may not parse the t_RS response correctly
Problem: May not parse the t_RS response correctly, resulting in wrong
characters in the input stream.
Solution: When the t_RS response is partly received wait for more
characters.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 02 Mar 2018 21:00:07 +0100 |
parents | de19318319a6 |
children | 0f9dd1b43244 |
comparison
equal
deleted
inserted
replaced
13364:53c7faf39d64 | 13365:c6bafddbfa33 |
---|---|
4864 * {lead} can be <Esc>P or DCS | 4864 * {lead} can be <Esc>P or DCS |
4865 * {flag} can be '0' or '1' | 4865 * {flag} can be '0' or '1' |
4866 * {tail} can be Esc>\ or STERM | 4866 * {tail} can be Esc>\ or STERM |
4867 * | 4867 * |
4868 * Check for cursor shape response from xterm: | 4868 * Check for cursor shape response from xterm: |
4869 * {lead}1$r<number> q{tail} | 4869 * {lead}1$r<digit> q{tail} |
4870 * | 4870 * |
4871 * {lead} can be <Esc>P or DCS | 4871 * {lead} can be <Esc>P or DCS |
4872 * {tail} can be Esc>\ or STERM | 4872 * {tail} can be Esc>\ or STERM |
4873 * | 4873 * |
4874 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". | 4874 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
4895 key_name[1] = (int)KE_IGNORE; | 4895 key_name[1] = (int)KE_IGNORE; |
4896 slen = i + 1 + (tp[i] == ESC); | 4896 slen = i + 1 + (tp[i] == ESC); |
4897 break; | 4897 break; |
4898 } | 4898 } |
4899 } | 4899 } |
4900 else if ((len >= j + 6 && isdigit(argp[3])) | 4900 else |
4901 && argp[4] == ' ' | |
4902 && argp[5] == 'q') | |
4903 { | 4901 { |
4904 /* cursor shape response */ | 4902 /* Probably the cursor shape response. Make sure that "i" |
4905 i = j + 6; | 4903 * is equal to "len" when there are not sufficient |
4906 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') | 4904 * characters. */ |
4907 || tp[i] == STERM) | 4905 for (i = j + 3; i < len; ++i) |
4908 { | 4906 { |
4909 int number = argp[3] - '0'; | 4907 if (i - j == 3 && !isdigit(tp[i])) |
4910 | 4908 break; |
4911 /* 0, 1 = block blink, 2 = block | 4909 if (i - j == 4 && tp[i] != ' ') |
4912 * 3 = underline blink, 4 = underline | 4910 break; |
4913 * 5 = vertical bar blink, 6 = vertical bar */ | 4911 if (i - j == 5 && tp[i] != 'q') |
4914 number = number == 0 ? 1 : number; | 4912 break; |
4915 initial_cursor_shape = (number + 1) / 2; | 4913 if (i - j == 6 && tp[i] != ESC && tp[i] != STERM) |
4916 /* The blink flag is actually inverted, compared to | 4914 break; |
4917 * the value set with T_SH. */ | 4915 if ((i - j == 6 && tp[i] == STERM) |
4918 initial_cursor_shape_blink = | 4916 || (i - j == 7 && tp[i] == '\\')) |
4917 { | |
4918 int number = argp[3] - '0'; | |
4919 | |
4920 /* 0, 1 = block blink, 2 = block | |
4921 * 3 = underline blink, 4 = underline | |
4922 * 5 = vertical bar blink, 6 = vertical bar */ | |
4923 number = number == 0 ? 1 : number; | |
4924 initial_cursor_shape = (number + 1) / 2; | |
4925 /* The blink flag is actually inverted, compared to | |
4926 * the value set with T_SH. */ | |
4927 initial_cursor_shape_blink = | |
4919 (number & 1) ? FALSE : TRUE; | 4928 (number & 1) ? FALSE : TRUE; |
4920 rcs_status = STATUS_GOT; | 4929 rcs_status = STATUS_GOT; |
4921 LOG_TR("Received cursor shape response"); | 4930 LOG_TR("Received cursor shape response"); |
4922 | 4931 |
4923 key_name[0] = (int)KS_EXTRA; | 4932 key_name[0] = (int)KS_EXTRA; |
4924 key_name[1] = (int)KE_IGNORE; | 4933 key_name[1] = (int)KE_IGNORE; |
4925 slen = i + 1 + (tp[i] == ESC); | 4934 slen = i + 1; |
4926 # ifdef FEAT_EVAL | 4935 # ifdef FEAT_EVAL |
4927 set_vim_var_string(VV_TERMSTYLERESP, tp, slen); | 4936 set_vim_var_string(VV_TERMSTYLERESP, tp, slen); |
4928 # endif | 4937 # endif |
4938 break; | |
4939 } | |
4929 } | 4940 } |
4930 } | 4941 } |
4931 | 4942 |
4932 if (i == len) | 4943 if (i == len) |
4933 { | 4944 { |