Mercurial > vim
comparison src/popupwin.c @ 18432:ee8db42dacf6 v8.1.2210
patch 8.1.2210: using negative offset for popup_create() does not work
Commit: https://github.com/vim/vim/commit/b754b5bf6d9ac1f3654552973aa6f9c11239af3d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 24 19:25:00 2019 +0200
patch 8.1.2210: using negative offset for popup_create() does not work
Problem: Using negative offset for popup_create() does not work.
Solution: Use -1 instead of zero. (closes https://github.com/vim/vim/issues/5111)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Oct 2019 19:30:03 +0200 |
parents | 21c25bee9df8 |
children | 144fa40ee706 |
comparison
equal
deleted
inserted
replaced
18431:412a997e6ea9 | 18432:ee8db42dacf6 |
---|---|
69 if (STRCMP(key, "line") == 0) | 69 if (STRCMP(key, "line") == 0) |
70 n = screen_screenrow() + 1 + n; | 70 n = screen_screenrow() + 1 + n; |
71 else // "col" | 71 else // "col" |
72 n = screen_screencol() + 1 + n; | 72 n = screen_screencol() + 1 + n; |
73 | 73 |
74 if (n < 1) | 74 // Zero means "not set", use -1 instead. |
75 n = 1; | 75 if (n == 0) |
76 n = -1; | |
76 return n; | 77 return n; |
77 } | 78 } |
78 | 79 |
79 static void | 80 static void |
80 set_padding_border(dict_T *dict, int *array, char *name, int max_val) | 81 set_padding_border(dict_T *dict, int *array, char *name, int max_val) |
220 void | 221 void |
221 popup_start_drag(win_T *wp, int row, int col) | 222 popup_start_drag(win_T *wp, int row, int col) |
222 { | 223 { |
223 drag_start_row = mouse_row; | 224 drag_start_row = mouse_row; |
224 drag_start_col = mouse_col; | 225 drag_start_col = mouse_col; |
225 if (wp->w_wantline == 0) | 226 if (wp->w_wantline <= 0) |
226 drag_start_wantline = wp->w_winrow + 1; | 227 drag_start_wantline = wp->w_winrow + 1; |
227 else | 228 else |
228 drag_start_wantline = wp->w_wantline; | 229 drag_start_wantline = wp->w_wantline; |
229 if (wp->w_wantcol == 0) | 230 if (wp->w_wantcol == 0) |
230 drag_start_wantcol = wp->w_wincol + 1; | 231 drag_start_wantcol = wp->w_wincol + 1; |
1079 int org_height = wp->w_height; | 1080 int org_height = wp->w_height; |
1080 int org_leftcol = wp->w_leftcol; | 1081 int org_leftcol = wp->w_leftcol; |
1081 int org_leftoff = wp->w_popup_leftoff; | 1082 int org_leftoff = wp->w_popup_leftoff; |
1082 int minwidth; | 1083 int minwidth; |
1083 int wantline = wp->w_wantline; // adjusted for textprop | 1084 int wantline = wp->w_wantline; // adjusted for textprop |
1085 int use_wantline = wantline != 0; | |
1084 int wantcol = wp->w_wantcol; // adjusted for textprop | 1086 int wantcol = wp->w_wantcol; // adjusted for textprop |
1087 int use_wantcol = wantcol != 0; | |
1085 | 1088 |
1086 wp->w_winrow = 0; | 1089 wp->w_winrow = 0; |
1087 wp->w_wincol = 0; | 1090 wp->w_wincol = 0; |
1088 wp->w_leftcol = 0; | 1091 wp->w_leftcol = 0; |
1089 wp->w_popup_leftoff = 0; | 1092 wp->w_popup_leftoff = 0; |
1095 popup_highlight_curline(wp); | 1098 popup_highlight_curline(wp); |
1096 | 1099 |
1097 // If no line was specified default to vertical centering. | 1100 // If no line was specified default to vertical centering. |
1098 if (wantline == 0) | 1101 if (wantline == 0) |
1099 center_vert = TRUE; | 1102 center_vert = TRUE; |
1103 else if (wantline < 0) | |
1104 // If "wantline" is negative it actually means zero. | |
1105 wantline = 0; | |
1106 if (wantcol < 0) | |
1107 wantcol = 0; | |
1100 | 1108 |
1101 if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win)) | 1109 if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win)) |
1102 { | 1110 { |
1103 win_T *prop_win = wp->w_popup_prop_win; | 1111 win_T *prop_win = wp->w_popup_prop_win; |
1104 textprop_T prop; | 1112 textprop_T prop; |
1159 center_vert = TRUE; | 1167 center_vert = TRUE; |
1160 center_hor = TRUE; | 1168 center_hor = TRUE; |
1161 } | 1169 } |
1162 else | 1170 else |
1163 { | 1171 { |
1164 if (wantline > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT | 1172 if (use_wantline && (wp->w_popup_pos == POPPOS_TOPLEFT |
1165 || wp->w_popup_pos == POPPOS_TOPRIGHT)) | 1173 || wp->w_popup_pos == POPPOS_TOPRIGHT)) |
1166 { | 1174 { |
1167 wp->w_winrow = wantline - 1; | 1175 wp->w_winrow = wantline - 1; |
1168 if (wp->w_winrow >= Rows) | 1176 if (wp->w_winrow >= Rows) |
1169 wp->w_winrow = Rows - 1; | 1177 wp->w_winrow = Rows - 1; |
1170 } | 1178 } |
1171 | 1179 |
1172 if (wantcol == 0) | 1180 if (!use_wantcol) |
1173 center_hor = TRUE; | 1181 center_hor = TRUE; |
1174 else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT | 1182 else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT |
1175 || wp->w_popup_pos == POPPOS_BOTLEFT)) | 1183 || wp->w_popup_pos == POPPOS_BOTLEFT)) |
1176 { | 1184 { |
1177 wp->w_wincol = wantcol - 1; | 1185 wp->w_wincol = wantcol - 1; |
1370 { | 1378 { |
1371 if ((wp->w_height + extra_height) <= wantline) | 1379 if ((wp->w_height + extra_height) <= wantline) |
1372 // bottom aligned: may move down | 1380 // bottom aligned: may move down |
1373 wp->w_winrow = wantline - (wp->w_height + extra_height); | 1381 wp->w_winrow = wantline - (wp->w_height + extra_height); |
1374 else | 1382 else |
1375 // not enough space, make top aligned | 1383 // Not enough space, make top aligned. |
1376 wp->w_winrow = wantline + 1; | 1384 wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1; |
1377 } | 1385 } |
1378 if (wp->w_winrow >= Rows) | 1386 if (wp->w_winrow >= Rows) |
1379 wp->w_winrow = Rows - 1; | 1387 wp->w_winrow = Rows - 1; |
1380 else if (wp->w_winrow < 0) | 1388 else if (wp->w_winrow < 0) |
1381 wp->w_winrow = 0; | 1389 wp->w_winrow = 0; |