comparison src/testdir/test_termcodes.vim @ 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 5ffe112b1afd
children bf7453768034
comparison
equal deleted inserted replaced
20835:097884058719 20836:2616c5a337e0
920 " This must be after other tests, because it has side effects to xterm 920 " This must be after other tests, because it has side effects to xterm
921 " properties. 921 " properties.
922 func Test_xx01_term_style_response() 922 func Test_xx01_term_style_response()
923 " Termresponse is only parsed when t_RV is not empty. 923 " Termresponse is only parsed when t_RV is not empty.
924 set t_RV=x 924 set t_RV=x
925 call test_override('term_props', 1)
925 926
926 " send the termresponse to trigger requesting the XT codes 927 " send the termresponse to trigger requesting the XT codes
927 let seq = "\<Esc>[>41;337;0c" 928 let seq = "\<Esc>[>41;337;0c"
928 call feedkeys(seq, 'Lx!') 929 call feedkeys(seq, 'Lx!')
929 call assert_equal(seq, v:termresponse) 930 call assert_equal(seq, v:termresponse)
930 931
931 let seq = "\<Esc>P1$r2 q\<Esc>\\" 932 let seq = "\<Esc>P1$r2 q\<Esc>\\"
932 call feedkeys(seq, 'Lx!') 933 call feedkeys(seq, 'Lx!')
933 call assert_equal(seq, v:termstyleresp) 934 call assert_equal(seq, v:termstyleresp)
934 935
936 call assert_equal(#{
937 \ cursor_style: 'u',
938 \ cursor_blink_mode: 'u',
939 \ underline_rgb: 'u',
940 \ mouse: 's'
941 \ }, terminalprops())
942
935 set t_RV= 943 set t_RV=
944 call test_override('term_props', 0)
936 endfunc 945 endfunc
937 946
938 " This checks the iTerm2 version response. 947 " This checks the iTerm2 version response.
939 " This must be after other tests, because it has side effects to xterm 948 " This must be after other tests, because it has side effects to xterm
940 " properties. 949 " properties.
941 func Test_xx02_iTerm2_response() 950 func Test_xx02_iTerm2_response()
942 " Termresponse is only parsed when t_RV is not empty. 951 " Termresponse is only parsed when t_RV is not empty.
943 set t_RV=x 952 set t_RV=x
953 call test_override('term_props', 1)
944 954
945 " Old versions of iTerm2 used a different style term response. 955 " Old versions of iTerm2 used a different style term response.
946 set ttymouse=xterm 956 set ttymouse=xterm
947 call test_option_not_set('ttymouse') 957 call test_option_not_set('ttymouse')
948 let seq = "\<Esc>[>0;95;c" 958 let seq = "\<Esc>[>0;95;c"
955 let seq = "\<Esc>[>0;95;0c" 965 let seq = "\<Esc>[>0;95;0c"
956 call feedkeys(seq, 'Lx!') 966 call feedkeys(seq, 'Lx!')
957 call assert_equal(seq, v:termresponse) 967 call assert_equal(seq, v:termresponse)
958 call assert_equal('sgr', &ttymouse) 968 call assert_equal('sgr', &ttymouse)
959 969
970 call assert_equal(#{
971 \ cursor_style: 'n',
972 \ cursor_blink_mode: 'u',
973 \ underline_rgb: 'u',
974 \ mouse: 's'
975 \ }, terminalprops())
976
960 set t_RV= 977 set t_RV=
978 call test_override('term_props', 0)
961 endfunc 979 endfunc
962 980
963 " This checks the libvterm version response. 981 " This checks the libvterm version response.
964 " This must be after other tests, because it has side effects to xterm 982 " This must be after other tests, because it has side effects to xterm
965 " properties. 983 " properties.
966 func Test_xx03_libvterm_response() 984 func Test_xx03_libvterm_response()
967 " Termresponse is only parsed when t_RV is not empty. 985 " Termresponse is only parsed when t_RV is not empty.
968 set t_RV=x 986 set t_RV=x
987 call test_override('term_props', 1)
969 988
970 set ttymouse=xterm 989 set ttymouse=xterm
971 call test_option_not_set('ttymouse') 990 call test_option_not_set('ttymouse')
972 let seq = "\<Esc>[>0;100;0c" 991 let seq = "\<Esc>[>0;100;0c"
973 call feedkeys(seq, 'Lx!') 992 call feedkeys(seq, 'Lx!')
974 call assert_equal(seq, v:termresponse) 993 call assert_equal(seq, v:termresponse)
975 call assert_equal('sgr', &ttymouse) 994 call assert_equal('sgr', &ttymouse)
976 995
996 call assert_equal(#{
997 \ cursor_style: 'n',
998 \ cursor_blink_mode: 'u',
999 \ underline_rgb: 'u',
1000 \ mouse: 's'
1001 \ }, terminalprops())
1002
977 set t_RV= 1003 set t_RV=
1004 call test_override('term_props', 0)
978 endfunc 1005 endfunc
979 1006
980 " This checks the Mac Terminal.app version response. 1007 " This checks the Mac Terminal.app version response.
981 " This must be after other tests, because it has side effects to xterm 1008 " This must be after other tests, because it has side effects to xterm
982 " properties. 1009 " properties.
983 func Test_xx04_Mac_Terminal_response() 1010 func Test_xx04_Mac_Terminal_response()
984 " Termresponse is only parsed when t_RV is not empty. 1011 " Termresponse is only parsed when t_RV is not empty.
985 set t_RV=x 1012 set t_RV=x
1013 call test_override('term_props', 1)
986 1014
987 set ttymouse=xterm 1015 set ttymouse=xterm
988 call test_option_not_set('ttymouse') 1016 call test_option_not_set('ttymouse')
989 let seq = "\<Esc>[>1;95;0c" 1017 let seq = "\<Esc>[>1;95;0c"
990 call feedkeys(seq, 'Lx!') 1018 call feedkeys(seq, 'Lx!')
991 call assert_equal(seq, v:termresponse) 1019 call assert_equal(seq, v:termresponse)
992 call assert_equal('sgr', &ttymouse) 1020 call assert_equal('sgr', &ttymouse)
1021
1022 call assert_equal(#{
1023 \ cursor_style: 'n',
1024 \ cursor_blink_mode: 'u',
1025 \ underline_rgb: 'y',
1026 \ mouse: 's'
1027 \ }, terminalprops())
993 1028
994 " Reset is_not_xterm and is_mac_terminal. 1029 " Reset is_not_xterm and is_mac_terminal.
995 set t_RV= 1030 set t_RV=
996 set term=xterm 1031 set term=xterm
997 set t_RV=x 1032 set t_RV=x
1033 call test_override('term_props', 0)
998 endfunc 1034 endfunc
999 1035
1000 " This checks the mintty version response. 1036 " This checks the mintty version response.
1001 " This must be after other tests, because it has side effects to xterm 1037 " This must be after other tests, because it has side effects to xterm
1002 " properties. 1038 " properties.
1003 func Test_xx05_mintty_response() 1039 func Test_xx05_mintty_response()
1004 " Termresponse is only parsed when t_RV is not empty. 1040 " Termresponse is only parsed when t_RV is not empty.
1005 set t_RV=x 1041 set t_RV=x
1042 call test_override('term_props', 1)
1006 1043
1007 set ttymouse=xterm 1044 set ttymouse=xterm
1008 call test_option_not_set('ttymouse') 1045 call test_option_not_set('ttymouse')
1009 let seq = "\<Esc>[>77;20905;0c" 1046 let seq = "\<Esc>[>77;20905;0c"
1010 call feedkeys(seq, 'Lx!') 1047 call feedkeys(seq, 'Lx!')
1011 call assert_equal(seq, v:termresponse) 1048 call assert_equal(seq, v:termresponse)
1012 call assert_equal('sgr', &ttymouse) 1049 call assert_equal('sgr', &ttymouse)
1013 1050
1051 call assert_equal(#{
1052 \ cursor_style: 'n',
1053 \ cursor_blink_mode: 'u',
1054 \ underline_rgb: 'y',
1055 \ mouse: 's'
1056 \ }, terminalprops())
1057
1014 set t_RV= 1058 set t_RV=
1059 call test_override('term_props', 0)
1015 endfunc 1060 endfunc
1016 1061
1017 " This checks the screen version response. 1062 " This checks the screen version response.
1018 " This must be after other tests, because it has side effects to xterm 1063 " This must be after other tests, because it has side effects to xterm
1019 " properties. 1064 " properties.
1020 func Test_xx06_screen_response() 1065 func Test_xx06_screen_response()
1021 " Termresponse is only parsed when t_RV is not empty. 1066 " Termresponse is only parsed when t_RV is not empty.
1022 set t_RV=x 1067 set t_RV=x
1068 call test_override('term_props', 1)
1023 1069
1024 " Old versions of screen don't support SGR mouse mode. 1070 " Old versions of screen don't support SGR mouse mode.
1025 set ttymouse=xterm 1071 set ttymouse=xterm
1026 call test_option_not_set('ttymouse') 1072 call test_option_not_set('ttymouse')
1027 let seq = "\<Esc>[>83;40500;0c" 1073 let seq = "\<Esc>[>83;40500;0c"
1035 let seq = "\<Esc>[>83;40700;0c" 1081 let seq = "\<Esc>[>83;40700;0c"
1036 call feedkeys(seq, 'Lx!') 1082 call feedkeys(seq, 'Lx!')
1037 call assert_equal(seq, v:termresponse) 1083 call assert_equal(seq, v:termresponse)
1038 call assert_equal('sgr', &ttymouse) 1084 call assert_equal('sgr', &ttymouse)
1039 1085
1086 call assert_equal(#{
1087 \ cursor_style: 'n',
1088 \ cursor_blink_mode: 'n',
1089 \ underline_rgb: 'y',
1090 \ mouse: 's'
1091 \ }, terminalprops())
1092
1040 set t_RV= 1093 set t_RV=
1094 call test_override('term_props', 0)
1041 endfunc 1095 endfunc
1042 1096
1043 " This checks the xterm version response. 1097 " This checks the xterm version response.
1044 " This must be after other tests, because it has side effects to xterm 1098 " This must be after other tests, because it has side effects to xterm
1045 " properties. 1099 " properties.
1046 func Test_xx07_xterm_response() 1100 func Test_xx07_xterm_response()
1047 " Termresponse is only parsed when t_RV is not empty. 1101 " Termresponse is only parsed when t_RV is not empty.
1048 set t_RV=x 1102 set t_RV=x
1103 call test_override('term_props', 1)
1049 1104
1050 " Do Terminal.app first to check that is_mac_terminal is reset. 1105 " Do Terminal.app first to check that is_mac_terminal is reset.
1051 set ttymouse=xterm 1106 set ttymouse=xterm
1052 call test_option_not_set('ttymouse') 1107 call test_option_not_set('ttymouse')
1053 let seq = "\<Esc>[>1;95;0c" 1108 let seq = "\<Esc>[>1;95;0c"
1064 let seq = "\<Esc>[>0;94;0c" 1119 let seq = "\<Esc>[>0;94;0c"
1065 call feedkeys(seq, 'Lx!') 1120 call feedkeys(seq, 'Lx!')
1066 call assert_equal(seq, v:termresponse) 1121 call assert_equal(seq, v:termresponse)
1067 call assert_equal('xterm', &ttymouse) 1122 call assert_equal('xterm', &ttymouse)
1068 1123
1124 call assert_equal(#{
1125 \ cursor_style: 'n',
1126 \ cursor_blink_mode: 'u',
1127 \ underline_rgb: 'y',
1128 \ mouse: 'u'
1129 \ }, terminalprops())
1130
1069 " xterm >= 95 < 277 "xterm2" 1131 " xterm >= 95 < 277 "xterm2"
1070 set ttymouse=xterm 1132 set ttymouse=xterm
1071 call test_option_not_set('ttymouse') 1133 call test_option_not_set('ttymouse')
1072 let seq = "\<Esc>[>0;267;0c" 1134 let seq = "\<Esc>[>0;267;0c"
1073 call feedkeys(seq, 'Lx!') 1135 call feedkeys(seq, 'Lx!')
1074 call assert_equal(seq, v:termresponse) 1136 call assert_equal(seq, v:termresponse)
1075 call assert_equal('xterm2', &ttymouse) 1137 call assert_equal('xterm2', &ttymouse)
1076 1138
1139 call assert_equal(#{
1140 \ cursor_style: 'n',
1141 \ cursor_blink_mode: 'u',
1142 \ underline_rgb: 'u',
1143 \ mouse: '2'
1144 \ }, terminalprops())
1145
1077 " xterm >= 277: "sgr" 1146 " xterm >= 277: "sgr"
1078 set ttymouse=xterm 1147 set ttymouse=xterm
1079 call test_option_not_set('ttymouse') 1148 call test_option_not_set('ttymouse')
1080 let seq = "\<Esc>[>0;277;0c" 1149 let seq = "\<Esc>[>0;277;0c"
1081 call feedkeys(seq, 'Lx!') 1150 call feedkeys(seq, 'Lx!')
1082 call assert_equal(seq, v:termresponse) 1151 call assert_equal(seq, v:termresponse)
1083 call assert_equal('sgr', &ttymouse) 1152 call assert_equal('sgr', &ttymouse)
1084 1153
1154 call assert_equal(#{
1155 \ cursor_style: 'n',
1156 \ cursor_blink_mode: 'u',
1157 \ underline_rgb: 'u',
1158 \ mouse: 's'
1159 \ }, terminalprops())
1160
1161 " xterm >= 279: "sgr" and cursor_style not reset
1162 set ttymouse=xterm
1163 call test_option_not_set('ttymouse')
1164 let seq = "\<Esc>[>0;279;0c"
1165 call feedkeys(seq, 'Lx!')
1166 call assert_equal(seq, v:termresponse)
1167 call assert_equal('sgr', &ttymouse)
1168
1169 call assert_equal(#{
1170 \ cursor_style: 'u',
1171 \ cursor_blink_mode: 'u',
1172 \ underline_rgb: 'u',
1173 \ mouse: 's'
1174 \ }, terminalprops())
1175
1085 set t_RV= 1176 set t_RV=
1177 call test_override('term_props', 0)
1086 endfunc 1178 endfunc
1087 1179
1088 func Test_get_termcode() 1180 func Test_get_termcode()
1089 try 1181 try
1090 let k1 = &t_k1 1182 let k1 = &t_k1