Mercurial > vim
diff src/term.c @ 20836:2616c5a337e0 v8.2.0970
patch 8.2.0970: terminal properties are not available in Vim script
Commit: https://github.com/vim/vim/commit/0c0eddd3ddd266bcc2036362fae7b2b8b9d2c7bf
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 13 15:47:25 2020 +0200
patch 8.2.0970: terminal properties are not available in Vim script
Problem: Terminal properties are not available in Vim script.
Solution: Add the terminalprops() function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 13 Jun 2020 16:00:04 +0200 |
parents | 9064044fd4f6 |
children | 020aec2e8de9 |
line wrap: on
line diff
--- a/src/term.c +++ b/src/term.c @@ -1470,7 +1470,7 @@ static termprop_T term_props[TPR_COUNT]; * When "all" is FALSE only set those that are detected from the version * response. */ - static void + void init_term_props(int all) { int i; @@ -1490,6 +1490,29 @@ init_term_props(int all) } #endif +#if defined(FEAT_EVAL) || defined(PROTO) + void +f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv) +{ +# ifdef FEAT_TERMRESPONSE + int i; +# endif + + if (rettv_dict_alloc(rettv) != OK) + return; +# ifdef FEAT_TERMRESPONSE + for (i = 0; i < TPR_COUNT; ++i) + { + char_u value[2]; + + value[0] = term_props[i].tpr_status; + value[1] = NUL; + dict_add_string(rettv->vval.v_dict, term_props[i].tpr_name, value); + } +# endif +} +#endif + static struct builtin_term * find_builtin_term(char_u *term) { @@ -3676,8 +3699,6 @@ check_terminal_behavior(void) { int did_send = FALSE; - init_term_props(TRUE); - if (!can_get_termresponse() || starting != 0 || *T_U7 == NUL) return; @@ -4516,7 +4537,8 @@ handle_version_response(int first, int * // Reset terminal properties that are set based on the termresponse. // Mainly useful for tests that send the termresponse multiple times. - init_term_props(FALSE); + // For testing all props can be reset. + init_term_props(reset_term_props_on_termresponse); // If this code starts with CSI, you can bet that the // terminal uses 8-bit codes.