comparison src/popupwin.c @ 17206:8ca93f88b84a v8.1.1602

patch 8.1.1602: popup window cannot overflow on the left or right commit https://github.com/vim/vim/commit/711d02c96da996e3423a6518909687e1d45ce45a Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 28 04:06:50 2019 +0200 patch 8.1.1602: popup window cannot overflow on the left or right Problem: Popup window cannot overflow on the left or right. Solution: Only set the "fixed" option when it is in the dict. Set w_leftcol to allow for the popup overflowing on the left and use it when applying the mask.
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Jun 2019 04:15:05 +0200
parents 4b40e8821f56
children 11f3cf51d43b
comparison
equal deleted inserted replaced
17205:669885fa1421 17206:8ca93f88b84a
76 static void 76 static void
77 get_pos_options(win_T *wp, dict_T *dict) 77 get_pos_options(win_T *wp, dict_T *dict)
78 { 78 {
79 char_u *str; 79 char_u *str;
80 int nr; 80 int nr;
81 dictitem_T *di;
81 82
82 nr = popup_options_one(dict, (char_u *)"line"); 83 nr = popup_options_one(dict, (char_u *)"line");
83 if (nr > 0) 84 if (nr > 0)
84 wp->w_wantline = nr; 85 wp->w_wantline = nr;
85 nr = popup_options_one(dict, (char_u *)"col"); 86 nr = popup_options_one(dict, (char_u *)"col");
86 if (nr > 0) 87 if (nr > 0)
87 wp->w_wantcol = nr; 88 wp->w_wantcol = nr;
88 89
89 wp->w_popup_fixed = dict_get_number(dict, (char_u *)"fixed") != 0; 90 di = dict_find(dict, (char_u *)"fixed", -1);
91 if (di != NULL)
92 wp->w_popup_fixed = dict_get_number(dict, (char_u *)"fixed") != 0;
90 93
91 str = dict_get_string(dict, (char_u *)"pos", FALSE); 94 str = dict_get_string(dict, (char_u *)"pos", FALSE);
92 if (str != NULL) 95 if (str != NULL)
93 { 96 {
94 for (nr = 0; 97 for (nr = 0;
664 int extra_width = left_extra + right_extra; 667 int extra_width = left_extra + right_extra;
665 int org_winrow = wp->w_winrow; 668 int org_winrow = wp->w_winrow;
666 int org_wincol = wp->w_wincol; 669 int org_wincol = wp->w_wincol;
667 int org_width = wp->w_width; 670 int org_width = wp->w_width;
668 int org_height = wp->w_height; 671 int org_height = wp->w_height;
672 int org_leftcol = wp->w_leftcol;
669 int minwidth; 673 int minwidth;
670 674
671 wp->w_winrow = 0; 675 wp->w_winrow = 0;
672 wp->w_wincol = 0; 676 wp->w_wincol = 0;
677 wp->w_leftcol = 0;
673 if (wp->w_popup_pos == POPPOS_CENTER) 678 if (wp->w_popup_pos == POPPOS_CENTER)
674 { 679 {
675 // center after computing the size 680 // center after computing the size
676 center_vert = TRUE; 681 center_vert = TRUE;
677 center_hor = TRUE; 682 center_hor = TRUE;
783 wp->w_wincol = 0; 788 wp->w_wincol = 0;
784 } 789 }
785 else if (wp->w_popup_pos == POPPOS_BOTRIGHT 790 else if (wp->w_popup_pos == POPPOS_BOTRIGHT
786 || wp->w_popup_pos == POPPOS_TOPRIGHT) 791 || wp->w_popup_pos == POPPOS_TOPRIGHT)
787 { 792 {
793 int leftoff = wp->w_wantcol - (wp->w_width + extra_width);
794
788 // Right aligned: move to the right if needed. 795 // Right aligned: move to the right if needed.
789 // No truncation, because that would change the height. 796 // No truncation, because that would change the height.
790 if (wp->w_width + extra_width < wp->w_wantcol) 797 if (leftoff >= 0)
791 wp->w_wincol = wp->w_wantcol - (wp->w_width + extra_width); 798 wp->w_wincol = leftoff;
799 else if (wp->w_popup_fixed)
800 {
801 // "col" specifies the right edge, but popup doesn't fit, skip some
802 // columns when displaying the window.
803 wp->w_leftcol = -leftoff;
804 wp->w_width += leftoff;
805 if (wp->w_width < 0)
806 wp->w_width = 0;
807 }
792 } 808 }
793 809
794 wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline 810 wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline
795 + 1 + wrapped; 811 + 1 + wrapped;
796 if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight) 812 if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight)
821 837
822 // Need to update popup_mask if the position or size changed. 838 // Need to update popup_mask if the position or size changed.
823 // And redraw windows that were behind the popup. 839 // And redraw windows that were behind the popup.
824 if (org_winrow != wp->w_winrow 840 if (org_winrow != wp->w_winrow
825 || org_wincol != wp->w_wincol 841 || org_wincol != wp->w_wincol
842 || org_leftcol != wp->w_leftcol
826 || org_width != wp->w_width 843 || org_width != wp->w_width
827 || org_height != wp->w_height) 844 || org_height != wp->w_height)
828 { 845 {
829 redraw_all_later(VALID); 846 redraw_all_later(VALID);
830 popup_mask_refresh = TRUE; 847 popup_mask_refresh = TRUE;
1076 for (i = 0; i < 4; ++i) 1093 for (i = 0; i < 4; ++i)
1077 VIM_CLEAR(wp->w_border_highlight[i]); 1094 VIM_CLEAR(wp->w_border_highlight[i]);
1078 for (i = 0; i < 8; ++i) 1095 for (i = 0; i < 8; ++i)
1079 wp->w_border_char[i] = 0; 1096 wp->w_border_char[i] = 0;
1080 wp->w_want_scrollbar = 1; 1097 wp->w_want_scrollbar = 1;
1098 wp->w_popup_fixed = 0;
1081 1099
1082 // Deal with options. 1100 // Deal with options.
1083 apply_options(wp, argvars[1].vval.v_dict); 1101 apply_options(wp, argvars[1].vval.v_dict);
1084 1102
1085 #ifdef FEAT_TIMERS 1103 #ifdef FEAT_TIMERS
1907 * "col" and "line" are screen coordinates. 1925 * "col" and "line" are screen coordinates.
1908 */ 1926 */
1909 static int 1927 static int
1910 popup_masked(win_T *wp, int screencol, int screenline) 1928 popup_masked(win_T *wp, int screencol, int screenline)
1911 { 1929 {
1912 int col = screencol - wp->w_wincol + 1; 1930 int col = screencol - wp->w_wincol + 1 + wp->w_leftcol;
1913 int line = screenline - wp->w_winrow + 1; 1931 int line = screenline - wp->w_winrow + 1;
1914 listitem_T *lio, *li; 1932 listitem_T *lio, *li;
1915 int width, height; 1933 int width, height;
1916 1934
1917 if (wp->w_popup_mask == NULL) 1935 if (wp->w_popup_mask == NULL)
1986 linee = tv_get_number(&li->li_tv); 2004 linee = tv_get_number(&li->li_tv);
1987 if (linee < 0) 2005 if (linee < 0)
1988 linee = height + linee + 1; 2006 linee = height + linee + 1;
1989 2007
1990 --cols; 2008 --cols;
2009 cols -= wp->w_leftcol;
2010 if (cols < 0)
2011 cols = 0;
2012 cole -= wp->w_leftcol;
1991 --lines; 2013 --lines;
2014 if (lines < 0)
2015 lines = 0;
1992 for (line = lines; line < linee && line < screen_Rows; ++line) 2016 for (line = lines; line < linee && line < screen_Rows; ++line)
1993 for (col = cols; col < cole && col < screen_Columns; ++col) 2017 for (col = cols; col < cole && col < screen_Columns; ++col)
1994 popup_transparent[(line + wp->w_winrow) * screen_Columns 2018 popup_transparent[(line + wp->w_winrow) * screen_Columns
1995 + col + wp->w_wincol] = val; 2019 + col + wp->w_wincol] = val;
1996 } 2020 }