comparison src/term.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 0dd8d1291439
children 31ac050a29a7
comparison
equal deleted inserted replaced
19404:7be3663e2f2b 19405:08f4dc2ba716
6388 *ansi_idx = 0; 6388 *ansi_idx = 0;
6389 } 6389 }
6390 } 6390 }
6391 #endif 6391 #endif
6392 6392
6393 /*
6394 * Replace K_BS by <BS> and K_DEL by <DEL>
6395 */
6396 void
6397 term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len)
6398 {
6399 int i;
6400 int c;
6401
6402 for (i = ta_len; i < ta_len + len; ++i)
6403 {
6404 if (ta_buf[i] == CSI && len - i > 2)
6405 {
6406 c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]);
6407 if (c == K_DEL || c == K_KDEL || c == K_BS)
6408 {
6409 mch_memmove(ta_buf + i + 1, ta_buf + i + 3,
6410 (size_t)(len - i - 2));
6411 if (c == K_DEL || c == K_KDEL)
6412 ta_buf[i] = DEL;
6413 else
6414 ta_buf[i] = Ctrl_H;
6415 len -= 2;
6416 }
6417 }
6418 else if (ta_buf[i] == '\r')
6419 ta_buf[i] = '\n';
6420 if (has_mbyte)
6421 i += (*mb_ptr2len_len)(ta_buf + i, ta_len + len - i) - 1;
6422 }
6423 }