Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
20835:097884058719 | 20836:2616c5a337e0 |
---|---|
1468 /* | 1468 /* |
1469 * Initialize the term_props table. | 1469 * Initialize the term_props table. |
1470 * When "all" is FALSE only set those that are detected from the version | 1470 * When "all" is FALSE only set those that are detected from the version |
1471 * response. | 1471 * response. |
1472 */ | 1472 */ |
1473 static void | 1473 void |
1474 init_term_props(int all) | 1474 init_term_props(int all) |
1475 { | 1475 { |
1476 int i; | 1476 int i; |
1477 | 1477 |
1478 term_props[TPR_CURSOR_STYLE].tpr_name = "cursor_style"; | 1478 term_props[TPR_CURSOR_STYLE].tpr_name = "cursor_style"; |
1485 term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE; | 1485 term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE; |
1486 | 1486 |
1487 for (i = 0; i < TPR_COUNT; ++i) | 1487 for (i = 0; i < TPR_COUNT; ++i) |
1488 if (all || term_props[i].tpr_set_by_termresponse) | 1488 if (all || term_props[i].tpr_set_by_termresponse) |
1489 term_props[i].tpr_status = TPR_UNKNOWN; | 1489 term_props[i].tpr_status = TPR_UNKNOWN; |
1490 } | |
1491 #endif | |
1492 | |
1493 #if defined(FEAT_EVAL) || defined(PROTO) | |
1494 void | |
1495 f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv) | |
1496 { | |
1497 # ifdef FEAT_TERMRESPONSE | |
1498 int i; | |
1499 # endif | |
1500 | |
1501 if (rettv_dict_alloc(rettv) != OK) | |
1502 return; | |
1503 # ifdef FEAT_TERMRESPONSE | |
1504 for (i = 0; i < TPR_COUNT; ++i) | |
1505 { | |
1506 char_u value[2]; | |
1507 | |
1508 value[0] = term_props[i].tpr_status; | |
1509 value[1] = NUL; | |
1510 dict_add_string(rettv->vval.v_dict, term_props[i].tpr_name, value); | |
1511 } | |
1512 # endif | |
1490 } | 1513 } |
1491 #endif | 1514 #endif |
1492 | 1515 |
1493 static struct builtin_term * | 1516 static struct builtin_term * |
1494 find_builtin_term(char_u *term) | 1517 find_builtin_term(char_u *term) |
3674 void | 3697 void |
3675 check_terminal_behavior(void) | 3698 check_terminal_behavior(void) |
3676 { | 3699 { |
3677 int did_send = FALSE; | 3700 int did_send = FALSE; |
3678 | 3701 |
3679 init_term_props(TRUE); | |
3680 | |
3681 if (!can_get_termresponse() || starting != 0 || *T_U7 == NUL) | 3702 if (!can_get_termresponse() || starting != 0 || *T_U7 == NUL) |
3682 return; | 3703 return; |
3683 | 3704 |
3684 if (u7_status.tr_progress == STATUS_GET | 3705 if (u7_status.tr_progress == STATUS_GET |
3685 && !option_was_set((char_u *)"ambiwidth")) | 3706 && !option_was_set((char_u *)"ambiwidth")) |
4514 crv_status.tr_progress = STATUS_GOT; | 4535 crv_status.tr_progress = STATUS_GOT; |
4515 did_cursorhold = TRUE; | 4536 did_cursorhold = TRUE; |
4516 | 4537 |
4517 // Reset terminal properties that are set based on the termresponse. | 4538 // Reset terminal properties that are set based on the termresponse. |
4518 // Mainly useful for tests that send the termresponse multiple times. | 4539 // Mainly useful for tests that send the termresponse multiple times. |
4519 init_term_props(FALSE); | 4540 // For testing all props can be reset. |
4541 init_term_props(reset_term_props_on_termresponse); | |
4520 | 4542 |
4521 // If this code starts with CSI, you can bet that the | 4543 // If this code starts with CSI, you can bet that the |
4522 // terminal uses 8-bit codes. | 4544 // terminal uses 8-bit codes. |
4523 if (tp[0] == CSI) | 4545 if (tp[0] == CSI) |
4524 switch_to_8bit(); | 4546 switch_to_8bit(); |