Mercurial > vim
comparison src/screen.c @ 16888:ec61b6b79865 v8.1.1445
patch 8.1.1445: popup window border highlight not implemented yet
commit https://github.com/vim/vim/commit/790498b509443f96f39431d2bc87b777efbe250f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 1 22:15:29 2019 +0200
patch 8.1.1445: popup window border highlight not implemented yet
Problem: Popup window border highlight not implemented yet.
Solution: Implement the "borderhighlight" option.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Jun 2019 22:30:05 +0200 |
parents | 2bd51fdcc793 |
children | 236c182c6300 |
comparison
equal
deleted
inserted
replaced
16887:a8aa4c4ffa4a | 16888:ec61b6b79865 |
---|---|
1028 int top_off; | 1028 int top_off; |
1029 int left_off; | 1029 int left_off; |
1030 int total_width; | 1030 int total_width; |
1031 int total_height; | 1031 int total_height; |
1032 int popup_attr; | 1032 int popup_attr; |
1033 int border_attr[4]; | |
1034 int border_char[8] = {'-', '|', '-', '|', '+', '+', '+', '+', }; | |
1035 char_u buf[MB_MAXBYTES]; | |
1033 int row; | 1036 int row; |
1034 int tl_corner_char = '+'; | 1037 int i; |
1035 char *tr_corner_str = "+"; | |
1036 int bl_corner_char = '+'; | |
1037 char *br_corner_str = "+"; | |
1038 int hor_line_char = '-'; | |
1039 char *ver_line_str = "|"; | |
1040 | 1038 |
1041 // Find the window with the lowest zindex that hasn't been updated yet, | 1039 // Find the window with the lowest zindex that hasn't been updated yet, |
1042 // so that the window with a higher zindex is drawn later, thus goes on | 1040 // so that the window with a higher zindex is drawn later, thus goes on |
1043 // top. | 1041 // top. |
1044 // TODO: don't redraw every popup every time. | 1042 // TODO: don't redraw every popup every time. |
1068 + wp->w_height + wp->w_popup_padding[2] + wp->w_popup_border[2]; | 1066 + wp->w_height + wp->w_popup_padding[2] + wp->w_popup_border[2]; |
1069 popup_attr = get_wcr_attr(wp); | 1067 popup_attr = get_wcr_attr(wp); |
1070 | 1068 |
1071 if (enc_utf8) | 1069 if (enc_utf8) |
1072 { | 1070 { |
1073 tl_corner_char = 0x2554; | 1071 border_char[0] = border_char[2] = 0x2550; |
1074 tr_corner_str = "\xe2\x95\x97"; | 1072 border_char[1] = border_char[3] = 0x2551; |
1075 bl_corner_char = 0x255a; | 1073 border_char[4] = 0x2554; |
1076 br_corner_str = "\xe2\x95\x9d"; | 1074 border_char[5] = 0x2557; |
1077 hor_line_char = 0x2550; | 1075 border_char[6] = 0x255d; |
1078 ver_line_str = "\xe2\x95\x91"; | 1076 border_char[7] = 0x255a; |
1077 } | |
1078 for (i = 0; i < 8; ++i) | |
1079 if (wp->w_border_char[i] != 0) | |
1080 border_char[i] = wp->w_border_char[i]; | |
1081 | |
1082 for (i = 0; i < 4; ++i) | |
1083 { | |
1084 border_attr[i] = popup_attr; | |
1085 if (wp->w_border_highlight[i] != NULL) | |
1086 border_attr[i] = syn_name2attr(wp->w_border_highlight[i]); | |
1079 } | 1087 } |
1080 | 1088 |
1081 if (wp->w_popup_border[0] > 0) | 1089 if (wp->w_popup_border[0] > 0) |
1082 { | 1090 { |
1083 // top border | 1091 // top border |
1084 screen_fill(wp->w_winrow, wp->w_winrow + 1, | 1092 screen_fill(wp->w_winrow, wp->w_winrow + 1, |
1085 wp->w_wincol, | 1093 wp->w_wincol, |
1086 wp->w_wincol + total_width, | 1094 wp->w_wincol + total_width, |
1087 wp->w_popup_border[3] != 0 | 1095 wp->w_popup_border[3] != 0 |
1088 ? tl_corner_char : hor_line_char, | 1096 ? border_char[4] : border_char[0], |
1089 hor_line_char, popup_attr); | 1097 border_char[0], border_attr[0]); |
1090 if (wp->w_popup_border[1] > 0) | 1098 if (wp->w_popup_border[1] > 0) |
1091 screen_puts((char_u *)tr_corner_str, wp->w_winrow, | 1099 { |
1092 wp->w_wincol + total_width - 1, popup_attr); | 1100 buf[mb_char2bytes(border_char[5], buf)] = NUL; |
1101 screen_puts(buf, wp->w_winrow, | |
1102 wp->w_wincol + total_width - 1, border_attr[1]); | |
1103 } | |
1093 } | 1104 } |
1094 | 1105 |
1095 if (wp->w_popup_padding[0] > 0) | 1106 if (wp->w_popup_padding[0] > 0) |
1096 { | 1107 { |
1097 // top padding | 1108 // top padding |
1106 row < wp->w_winrow + total_height - wp->w_popup_border[2]; | 1117 row < wp->w_winrow + total_height - wp->w_popup_border[2]; |
1107 ++row) | 1118 ++row) |
1108 { | 1119 { |
1109 // left border | 1120 // left border |
1110 if (wp->w_popup_border[3] > 0) | 1121 if (wp->w_popup_border[3] > 0) |
1111 screen_puts((char_u *)ver_line_str, row, wp->w_wincol, popup_attr); | 1122 { |
1123 buf[mb_char2bytes(border_char[3], buf)] = NUL; | |
1124 screen_puts(buf, row, wp->w_wincol, border_attr[3]); | |
1125 } | |
1112 // left padding | 1126 // left padding |
1113 if (wp->w_popup_padding[3] > 0) | 1127 if (wp->w_popup_padding[3] > 0) |
1114 screen_puts(get_spaces(wp->w_popup_padding[3]), row, | 1128 screen_puts(get_spaces(wp->w_popup_padding[3]), row, |
1115 wp->w_wincol + wp->w_popup_border[3], popup_attr); | 1129 wp->w_wincol + wp->w_popup_border[3], popup_attr); |
1116 // right border | 1130 // right border |
1117 if (wp->w_popup_border[1] > 0) | 1131 if (wp->w_popup_border[1] > 0) |
1118 screen_puts((char_u *)ver_line_str, row, | 1132 { |
1119 wp->w_wincol + total_width - 1, popup_attr); | 1133 buf[mb_char2bytes(border_char[1], buf)] = NUL; |
1134 screen_puts(buf, row, | |
1135 wp->w_wincol + total_width - 1, border_attr[1]); | |
1136 } | |
1120 // right padding | 1137 // right padding |
1121 if (wp->w_popup_padding[1] > 0) | 1138 if (wp->w_popup_padding[1] > 0) |
1122 screen_puts(get_spaces(wp->w_popup_padding[1]), row, | 1139 screen_puts(get_spaces(wp->w_popup_padding[1]), row, |
1123 wp->w_wincol + wp->w_popup_border[3] | 1140 wp->w_wincol + wp->w_popup_border[3] |
1124 + wp->w_popup_padding[3] + wp->w_width, popup_attr); | 1141 + wp->w_popup_padding[3] + wp->w_width, popup_attr); |
1140 // bottom border | 1157 // bottom border |
1141 row = wp->w_winrow + total_height - 1; | 1158 row = wp->w_winrow + total_height - 1; |
1142 screen_fill(row , row + 1, | 1159 screen_fill(row , row + 1, |
1143 wp->w_wincol, | 1160 wp->w_wincol, |
1144 wp->w_wincol + total_width, | 1161 wp->w_wincol + total_width, |
1145 wp->w_popup_border[3] != 0 ? bl_corner_char : hor_line_char, | 1162 wp->w_popup_border[3] != 0 |
1146 hor_line_char, popup_attr); | 1163 ? border_char[7] : border_char[2], |
1164 border_char[2], border_attr[2]); | |
1147 if (wp->w_popup_border[1] > 0) | 1165 if (wp->w_popup_border[1] > 0) |
1148 screen_puts((char_u *)br_corner_str, row, | 1166 { |
1149 wp->w_wincol + total_width - 1, popup_attr); | 1167 buf[mb_char2bytes(border_char[6], buf)] = NUL; |
1168 screen_puts(buf, row, | |
1169 wp->w_wincol + total_width - 1, border_attr[2]); | |
1170 } | |
1150 } | 1171 } |
1151 } | 1172 } |
1152 } | 1173 } |
1153 #endif | 1174 #endif |
1154 | 1175 |