Mercurial > vim
comparison src/terminal.c @ 15211:de63593896b3 v8.1.0615
patch 8.1.0615: get_tv function names are not consistent
commit https://github.com/vim/vim/commit/d155d7a8519987361169459b8d464ae1caef5e9c
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Dec 21 16:04:21 2018 +0100
patch 8.1.0615: get_tv function names are not consistent
Problem: Get_tv function names are not consistent.
Solution: Rename to tv_get.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 21 Dec 2018 16:15:06 +0100 |
parents | aa877e0b7f62 |
children | 49bc670c3ee9 |
comparison
equal
deleted
inserted
replaced
15210:fbb2936c39b6 | 15211:de63593896b3 |
---|---|
494 cmd = (char_u *)"pty"; | 494 cmd = (char_u *)"pty"; |
495 } | 495 } |
496 else if (argvar->v_type != VAR_LIST | 496 else if (argvar->v_type != VAR_LIST |
497 || argvar->vval.v_list == NULL | 497 || argvar->vval.v_list == NULL |
498 || argvar->vval.v_list->lv_len < 1 | 498 || argvar->vval.v_list->lv_len < 1 |
499 || (cmd = get_tv_string_chk( | 499 || (cmd = tv_get_string_chk( |
500 &argvar->vval.v_list->lv_first->li_tv)) == NULL) | 500 &argvar->vval.v_list->lv_first->li_tv)) == NULL) |
501 cmd = (char_u*)""; | 501 cmd = (char_u*)""; |
502 | 502 |
503 len = STRLEN(cmd) + 10; | 503 len = STRLEN(cmd) + 10; |
504 p = alloc((int)len); | 504 p = alloc((int)len); |
567 | 567 |
568 ga_init2(&ga, 1, 100); | 568 ga_init2(&ga, 1, 100); |
569 for (item = argvar->vval.v_list->lv_first; | 569 for (item = argvar->vval.v_list->lv_first; |
570 item != NULL; item = item->li_next) | 570 item != NULL; item = item->li_next) |
571 { | 571 { |
572 char_u *s = get_tv_string_chk(&item->li_tv); | 572 char_u *s = tv_get_string_chk(&item->li_tv); |
573 char_u *p; | 573 char_u *p; |
574 | 574 |
575 if (s == NULL) | 575 if (s == NULL) |
576 break; | 576 break; |
577 p = vim_strsave_fnameescape(s, FALSE); | 577 p = vim_strsave_fnameescape(s, FALSE); |
1911 if (l != NULL) | 1911 if (l != NULL) |
1912 { | 1912 { |
1913 type = get_reg_type(c, ®len); | 1913 type = get_reg_type(c, ®len); |
1914 for (item = l->lv_first; item != NULL; item = item->li_next) | 1914 for (item = l->lv_first; item != NULL; item = item->li_next) |
1915 { | 1915 { |
1916 char_u *s = get_tv_string(&item->li_tv); | 1916 char_u *s = tv_get_string(&item->li_tv); |
1917 #ifdef WIN3264 | 1917 #ifdef WIN3264 |
1918 char_u *tmp = s; | 1918 char_u *tmp = s; |
1919 | 1919 |
1920 if (!enc_utf8 && enc_codepage > 0) | 1920 if (!enc_utf8 && enc_codepage > 0) |
1921 { | 1921 { |
3453 for (; li != NULL && n < 16; li = li->li_next, n++) | 3453 for (; li != NULL && n < 16; li = li->li_next, n++) |
3454 { | 3454 { |
3455 char_u *color_name; | 3455 char_u *color_name; |
3456 guicolor_T guicolor; | 3456 guicolor_T guicolor; |
3457 | 3457 |
3458 color_name = get_tv_string_chk(&li->li_tv); | 3458 color_name = tv_get_string_chk(&li->li_tv); |
3459 if (color_name == NULL) | 3459 if (color_name == NULL) |
3460 return FAIL; | 3460 return FAIL; |
3461 | 3461 |
3462 guicolor = GUI_GET_COLOR(color_name); | 3462 guicolor = GUI_GET_COLOR(color_name); |
3463 if (guicolor == INVALCOLOR) | 3463 if (guicolor == INVALCOLOR) |
3495 * "item" is the file name, "item->li_next" may have options. | 3495 * "item" is the file name, "item->li_next" may have options. |
3496 */ | 3496 */ |
3497 static void | 3497 static void |
3498 handle_drop_command(listitem_T *item) | 3498 handle_drop_command(listitem_T *item) |
3499 { | 3499 { |
3500 char_u *fname = get_tv_string(&item->li_tv); | 3500 char_u *fname = tv_get_string(&item->li_tv); |
3501 listitem_T *opt_item = item->li_next; | 3501 listitem_T *opt_item = item->li_next; |
3502 int bufnr; | 3502 int bufnr; |
3503 win_T *wp; | 3503 win_T *wp; |
3504 tabpage_T *tp; | 3504 tabpage_T *tp; |
3505 exarg_T ea; | 3505 exarg_T ea; |
3587 if (item->li_next == NULL) | 3587 if (item->li_next == NULL) |
3588 { | 3588 { |
3589 ch_log(channel, "Missing function arguments for call"); | 3589 ch_log(channel, "Missing function arguments for call"); |
3590 return; | 3590 return; |
3591 } | 3591 } |
3592 func = get_tv_string(&item->li_tv); | 3592 func = tv_get_string(&item->li_tv); |
3593 | 3593 |
3594 if (STRNCMP(func, "Tapi_", 5) != 0) | 3594 if (STRNCMP(func, "Tapi_", 5) != 0) |
3595 { | 3595 { |
3596 ch_log(channel, "Invalid function name: %s", func); | 3596 ch_log(channel, "Invalid function name: %s", func); |
3597 return; | 3597 return; |
3643 | 3643 |
3644 if (item == NULL) | 3644 if (item == NULL) |
3645 ch_log(channel, "Missing command"); | 3645 ch_log(channel, "Missing command"); |
3646 else | 3646 else |
3647 { | 3647 { |
3648 char_u *cmd = get_tv_string(&item->li_tv); | 3648 char_u *cmd = tv_get_string(&item->li_tv); |
3649 | 3649 |
3650 /* Make sure an invoked command doesn't delete the buffer (and the | 3650 /* Make sure an invoked command doesn't delete the buffer (and the |
3651 * terminal) under our fingers. */ | 3651 * terminal) under our fingers. */ |
3652 ++term->tl_buffer->b_locked; | 3652 ++term->tl_buffer->b_locked; |
3653 | 3653 |
3824 static buf_T * | 3824 static buf_T * |
3825 term_get_buf(typval_T *argvars, char *where) | 3825 term_get_buf(typval_T *argvars, char *where) |
3826 { | 3826 { |
3827 buf_T *buf; | 3827 buf_T *buf; |
3828 | 3828 |
3829 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ | 3829 (void)tv_get_number(&argvars[0]); /* issue errmsg if type error */ |
3830 ++emsg_off; | 3830 ++emsg_off; |
3831 buf = get_buf_tv(&argvars[0], FALSE); | 3831 buf = get_buf_tv(&argvars[0], FALSE); |
3832 --emsg_off; | 3832 --emsg_off; |
3833 if (buf == NULL || buf->b_term == NULL) | 3833 if (buf == NULL || buf->b_term == NULL) |
3834 { | 3834 { |
3919 max_height = dict_get_number(d, (char_u *)"rows"); | 3919 max_height = dict_get_number(d, (char_u *)"rows"); |
3920 max_width = dict_get_number(d, (char_u *)"columns"); | 3920 max_width = dict_get_number(d, (char_u *)"columns"); |
3921 } | 3921 } |
3922 } | 3922 } |
3923 | 3923 |
3924 fname = get_tv_string_chk(&argvars[1]); | 3924 fname = tv_get_string_chk(&argvars[1]); |
3925 if (fname == NULL) | 3925 if (fname == NULL) |
3926 return; | 3926 return; |
3927 if (mch_stat((char *)fname, &st) >= 0) | 3927 if (mch_stat((char *)fname, &st) >= 0) |
3928 { | 3928 { |
3929 EMSG2(_("E953: File exists: %s"), fname); | 3929 EMSG2(_("E953: File exists: %s"), fname); |
4368 FILE *fd1; | 4368 FILE *fd1; |
4369 FILE *fd2 = NULL; | 4369 FILE *fd2 = NULL; |
4370 char_u *textline = NULL; | 4370 char_u *textline = NULL; |
4371 | 4371 |
4372 /* First open the files. If this fails bail out. */ | 4372 /* First open the files. If this fails bail out. */ |
4373 fname1 = get_tv_string_buf_chk(&argvars[0], buf1); | 4373 fname1 = tv_get_string_buf_chk(&argvars[0], buf1); |
4374 if (do_diff) | 4374 if (do_diff) |
4375 fname2 = get_tv_string_buf_chk(&argvars[1], buf2); | 4375 fname2 = tv_get_string_buf_chk(&argvars[1], buf2); |
4376 if (fname1 == NULL || (do_diff && fname2 == NULL)) | 4376 if (fname1 == NULL || (do_diff && fname2 == NULL)) |
4377 { | 4377 { |
4378 EMSG(_(e_invarg)); | 4378 EMSG(_(e_invarg)); |
4379 return; | 4379 return; |
4380 } | 4380 } |
4738 {"underline", HL_UNDERLINE}, | 4738 {"underline", HL_UNDERLINE}, |
4739 {"strike", HL_STRIKETHROUGH}, | 4739 {"strike", HL_STRIKETHROUGH}, |
4740 {"reverse", HL_INVERSE}, | 4740 {"reverse", HL_INVERSE}, |
4741 }; | 4741 }; |
4742 | 4742 |
4743 attr = get_tv_number(&argvars[0]); | 4743 attr = tv_get_number(&argvars[0]); |
4744 name = get_tv_string_chk(&argvars[1]); | 4744 name = tv_get_string_chk(&argvars[1]); |
4745 if (name == NULL) | 4745 if (name == NULL) |
4746 return; | 4746 return; |
4747 | 4747 |
4748 for (i = 0; i < sizeof(attrs)/sizeof(attrs[0]); ++i) | 4748 for (i = 0; i < sizeof(attrs)/sizeof(attrs[0]); ++i) |
4749 if (STRCMP(name, attrs[i].name) == 0) | 4749 if (STRCMP(name, attrs[i].name) == 0) |
4809 { | 4809 { |
4810 if (tv->v_type == VAR_STRING | 4810 if (tv->v_type == VAR_STRING |
4811 && tv->vval.v_string != NULL | 4811 && tv->vval.v_string != NULL |
4812 && STRCMP(tv->vval.v_string, ".") == 0) | 4812 && STRCMP(tv->vval.v_string, ".") == 0) |
4813 return term->tl_cursor_pos.row; | 4813 return term->tl_cursor_pos.row; |
4814 return (int)get_tv_number(tv) - 1; | 4814 return (int)tv_get_number(tv) - 1; |
4815 } | 4815 } |
4816 | 4816 |
4817 /* | 4817 /* |
4818 * "term_getline(buf, row)" function | 4818 * "term_getline(buf, row)" function |
4819 */ | 4819 */ |
4909 return; | 4909 return; |
4910 } | 4910 } |
4911 if (buf->b_term->tl_vterm == NULL) | 4911 if (buf->b_term->tl_vterm == NULL) |
4912 return; | 4912 return; |
4913 term = buf->b_term; | 4913 term = buf->b_term; |
4914 rows = get_tv_number(&argvars[1]); | 4914 rows = tv_get_number(&argvars[1]); |
4915 rows = rows <= 0 ? term->tl_rows : rows; | 4915 rows = rows <= 0 ? term->tl_rows : rows; |
4916 cols = get_tv_number(&argvars[2]); | 4916 cols = tv_get_number(&argvars[2]); |
4917 cols = cols <= 0 ? term->tl_cols : cols; | 4917 cols = cols <= 0 ? term->tl_cols : cols; |
4918 vterm_set_size(term->tl_vterm, rows, cols); | 4918 vterm_set_size(term->tl_vterm, rows, cols); |
4919 /* handle_resize() will resize the windows */ | 4919 /* handle_resize() will resize the windows */ |
4920 | 4920 |
4921 /* Get and remember the size we ended up with. Update the pty. */ | 4921 /* Get and remember the size we ended up with. Update the pty. */ |
4975 | 4975 |
4976 rettv->v_type = VAR_STRING; | 4976 rettv->v_type = VAR_STRING; |
4977 if (buf == NULL) | 4977 if (buf == NULL) |
4978 return; | 4978 return; |
4979 if (argvars[1].v_type != VAR_UNKNOWN) | 4979 if (argvars[1].v_type != VAR_UNKNOWN) |
4980 num = get_tv_number(&argvars[1]); | 4980 num = tv_get_number(&argvars[1]); |
4981 | 4981 |
4982 switch (num) | 4982 switch (num) |
4983 { | 4983 { |
4984 case 0: | 4984 case 0: |
4985 if (buf->b_term->tl_job != NULL) | 4985 if (buf->b_term->tl_job != NULL) |
4988 case 1: | 4988 case 1: |
4989 if (buf->b_term->tl_job != NULL) | 4989 if (buf->b_term->tl_job != NULL) |
4990 p = buf->b_term->tl_job->jv_tty_in; | 4990 p = buf->b_term->tl_job->jv_tty_in; |
4991 break; | 4991 break; |
4992 default: | 4992 default: |
4993 EMSG2(_(e_invarg2), get_tv_string(&argvars[1])); | 4993 EMSG2(_(e_invarg2), tv_get_string(&argvars[1])); |
4994 return; | 4994 return; |
4995 } | 4995 } |
4996 if (p != NULL) | 4996 if (p != NULL) |
4997 rettv->vval.v_string = vim_strsave(p); | 4997 rettv->vval.v_string = vim_strsave(p); |
4998 } | 4998 } |
5137 | 5137 |
5138 rettv->v_type = VAR_UNKNOWN; | 5138 rettv->v_type = VAR_UNKNOWN; |
5139 if (buf == NULL) | 5139 if (buf == NULL) |
5140 return; | 5140 return; |
5141 | 5141 |
5142 msg = get_tv_string_chk(&argvars[1]); | 5142 msg = tv_get_string_chk(&argvars[1]); |
5143 if (msg == NULL) | 5143 if (msg == NULL) |
5144 return; | 5144 return; |
5145 term = buf->b_term; | 5145 term = buf->b_term; |
5146 if (term->tl_vterm == NULL) | 5146 if (term->tl_vterm == NULL) |
5147 return; | 5147 return; |
5239 | 5239 |
5240 if (buf == NULL) | 5240 if (buf == NULL) |
5241 return; | 5241 return; |
5242 term = buf->b_term; | 5242 term = buf->b_term; |
5243 vim_free(term->tl_command); | 5243 vim_free(term->tl_command); |
5244 cmd = get_tv_string_chk(&argvars[1]); | 5244 cmd = tv_get_string_chk(&argvars[1]); |
5245 if (cmd != NULL) | 5245 if (cmd != NULL) |
5246 term->tl_command = vim_strsave(cmd); | 5246 term->tl_command = vim_strsave(cmd); |
5247 else | 5247 else |
5248 term->tl_command = NULL; | 5248 term->tl_command = NULL; |
5249 #endif | 5249 #endif |
5261 | 5261 |
5262 if (buf == NULL) | 5262 if (buf == NULL) |
5263 return; | 5263 return; |
5264 term = buf->b_term; | 5264 term = buf->b_term; |
5265 vim_free(term->tl_kill); | 5265 vim_free(term->tl_kill); |
5266 how = get_tv_string_chk(&argvars[1]); | 5266 how = tv_get_string_chk(&argvars[1]); |
5267 if (how != NULL) | 5267 if (how != NULL) |
5268 term->tl_kill = vim_strsave(how); | 5268 term->tl_kill = vim_strsave(how); |
5269 else | 5269 else |
5270 term->tl_kill = NULL; | 5270 term->tl_kill = NULL; |
5271 } | 5271 } |
5345 mch_check_messages(); | 5345 mch_check_messages(); |
5346 parse_queued_messages(); | 5346 parse_queued_messages(); |
5347 | 5347 |
5348 /* Wait for some time for any channel I/O. */ | 5348 /* Wait for some time for any channel I/O. */ |
5349 if (argvars[1].v_type != VAR_UNKNOWN) | 5349 if (argvars[1].v_type != VAR_UNKNOWN) |
5350 wait = get_tv_number(&argvars[1]); | 5350 wait = tv_get_number(&argvars[1]); |
5351 ui_delay(wait, TRUE); | 5351 ui_delay(wait, TRUE); |
5352 mch_check_messages(); | 5352 mch_check_messages(); |
5353 | 5353 |
5354 /* Flushing messages on channels is hopefully sufficient. | 5354 /* Flushing messages on channels is hopefully sufficient. |
5355 * TODO: is there a better way? */ | 5355 * TODO: is there a better way? */ |