comparison src/os_win32.c @ 19405:08f4dc2ba716 v8.2.0260

patch 8.2.0260: several lines of code are duplicated Commit: https://github.com/vim/vim/commit/f4140488c72cad4dbf5449dba099cfa7de7bbb22 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 15 23:06:45 2020 +0100 patch 8.2.0260: several lines of code are duplicated Problem: Several lines of code are duplicated. Solution: Move duplicated code to a function. (Yegappan Lakshmanan, closes #5330)
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Feb 2020 23:15:04 +0100
parents 7894f20668b1
children 5eb0ead1415f
comparison
equal deleted inserted replaced
19404:7be3663e2f2b 19405:08f4dc2ba716
4171 // buffer used to receive keys 4171 // buffer used to receive keys
4172 char_u ta_buf[BUFLEN + 1]; // TypeAHead 4172 char_u ta_buf[BUFLEN + 1]; // TypeAHead
4173 int ta_len = 0; // valid bytes in ta_buf[] 4173 int ta_len = 0; // valid bytes in ta_buf[]
4174 4174
4175 DWORD i; 4175 DWORD i;
4176 int c;
4177 int noread_cnt = 0; 4176 int noread_cnt = 0;
4178 garray_T ga; 4177 garray_T ga;
4179 int delay = 1; 4178 int delay = 1;
4180 DWORD buffer_off = 0; // valid bytes in buffer[] 4179 DWORD buffer_off = 0; // valid bytes in buffer[]
4181 char *p = NULL; 4180 char *p = NULL;
4310 CloseHandle(g_hChildStd_IN_Wr); 4309 CloseHandle(g_hChildStd_IN_Wr);
4311 g_hChildStd_IN_Wr = NULL; 4310 g_hChildStd_IN_Wr = NULL;
4312 } 4311 }
4313 } 4312 }
4314 4313
4315 // replace K_BS by <BS> and K_DEL by <DEL> 4314 term_replace_bs_del_keycode(ta_buf, ta_len, len);
4316 for (i = ta_len; i < ta_len + len; ++i)
4317 {
4318 if (ta_buf[i] == CSI && len - i > 2)
4319 {
4320 c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]);
4321 if (c == K_DEL || c == K_KDEL || c == K_BS)
4322 {
4323 mch_memmove(ta_buf + i + 1, ta_buf + i + 3,
4324 (size_t)(len - i - 2));
4325 if (c == K_DEL || c == K_KDEL)
4326 ta_buf[i] = DEL;
4327 else
4328 ta_buf[i] = Ctrl_H;
4329 len -= 2;
4330 }
4331 }
4332 else if (ta_buf[i] == '\r')
4333 ta_buf[i] = '\n';
4334 if (has_mbyte)
4335 i += (*mb_ptr2len_len)(ta_buf + i,
4336 ta_len + len - i) - 1;
4337 }
4338 4315
4339 /* 4316 /*
4340 * For pipes: echo the typed characters. For a pty this 4317 * For pipes: echo the typed characters. For a pty this
4341 * does not seem to work. 4318 * does not seem to work.
4342 */ 4319 */