@@ -991,11 +991,46 @@ update_debug_sign(buf_T *buf, linenr_T lnum)
991991}
992992#endif
993993
994+ /*
995+ * Get 'wincolor' attribute for window "wp". If not set and "wp" is a popup
996+ * window then get the "Pmenu" highlight attribute.
997+ */
998+ static int
999+ get_wcr_attr (win_T * wp )
1000+ {
1001+ int wcr_attr = 0 ;
1002+
1003+ if (* wp -> w_p_wcr != NUL )
1004+ wcr_attr = syn_name2attr (wp -> w_p_wcr );
9941005#ifdef FEAT_TEXT_PROP
1006+ if (bt_popup (wp -> w_buffer ) && wcr_attr == 0 )
1007+ wcr_attr = HL_ATTR (HLF_PNI );
1008+ #endif
1009+ return wcr_attr ;
1010+ }
1011+
1012+ #ifdef FEAT_TEXT_PROP
1013+ /*
1014+ * Return a string of "len" spaces in IObuff.
1015+ */
1016+ static char_u *
1017+ get_spaces (int len )
1018+ {
1019+ vim_memset (IObuff , ' ' , (size_t )len );
1020+ IObuff [len ] = NUL ;
1021+ return IObuff ;
1022+ }
1023+
9951024 static void
9961025update_popups (void )
9971026{
9981027 win_T * wp ;
1028+ int top_off ;
1029+ int left_off ;
1030+ int total_width ;
1031+ int total_height ;
1032+ int popup_attr ;
1033+ int row ;
9991034
10001035 // Find the window with the lowest zindex that hasn't been updated yet,
10011036 // so that the window with a higher zindex is drawn later, thus goes on
@@ -1008,29 +1043,98 @@ update_popups(void)
10081043 if (wp -> w_popup_last_changedtick != CHANGEDTICK (wp -> w_buffer ))
10091044 popup_adjust_position (wp );
10101045
1046+ // adjust w_winrow and w_wincol for border and padding, since
1047+ // win_update() doesn't handle them.
1048+ top_off = wp -> w_popup_padding [0 ] + wp -> w_popup_border [0 ];
1049+ left_off = wp -> w_popup_padding [3 ] + wp -> w_popup_border [3 ];
1050+ wp -> w_winrow += top_off ;
1051+ wp -> w_wincol += left_off ;
1052+
1053+ // Draw the popup text.
10111054 win_update (wp );
1055+
1056+ wp -> w_winrow -= top_off ;
1057+ wp -> w_wincol -= left_off ;
1058+
1059+ total_width = wp -> w_popup_border [3 ] + wp -> w_popup_padding [3 ]
1060+ + wp -> w_width + wp -> w_popup_padding [1 ] + wp -> w_popup_border [1 ];
1061+ total_height = wp -> w_popup_border [0 ] + wp -> w_popup_padding [0 ]
1062+ + wp -> w_height + wp -> w_popup_padding [2 ] + wp -> w_popup_border [2 ];
1063+ popup_attr = get_wcr_attr (wp );
1064+
1065+ if (wp -> w_popup_border [0 ] > 0 )
1066+ {
1067+ // top border
1068+ screen_fill (wp -> w_winrow , wp -> w_winrow + 1 ,
1069+ wp -> w_wincol ,
1070+ wp -> w_wincol + total_width ,
1071+ wp -> w_popup_border [3 ] != 0 ? '+' : '-' ,
1072+ '-' , popup_attr );
1073+ if (wp -> w_popup_border [1 ] > 0 )
1074+ screen_puts ((char_u * )"+" , wp -> w_winrow ,
1075+ wp -> w_wincol + total_width - 1 , popup_attr );
1076+ }
1077+
1078+ if (wp -> w_popup_padding [0 ] > 0 )
1079+ {
1080+ // top padding
1081+ row = wp -> w_winrow + wp -> w_popup_border [0 ];
1082+ screen_fill (row , row + wp -> w_popup_padding [0 ],
1083+ wp -> w_wincol + wp -> w_popup_border [3 ],
1084+ wp -> w_wincol + total_width - wp -> w_popup_border [1 ],
1085+ ' ' , ' ' , popup_attr );
1086+ }
1087+
1088+ for (row = wp -> w_winrow + wp -> w_popup_border [0 ];
1089+ row < wp -> w_winrow + total_height - wp -> w_popup_border [2 ];
1090+ ++ row )
1091+ {
1092+ // left border
1093+ if (wp -> w_popup_border [3 ] > 0 )
1094+ screen_puts ((char_u * )"|" , row , wp -> w_wincol , popup_attr );
1095+ // left padding
1096+ if (wp -> w_popup_padding [3 ] > 0 )
1097+ screen_puts (get_spaces (wp -> w_popup_padding [3 ]), row ,
1098+ wp -> w_wincol + wp -> w_popup_border [3 ], popup_attr );
1099+ // right border
1100+ if (wp -> w_popup_border [1 ] > 0 )
1101+ screen_puts ((char_u * )"|" , row ,
1102+ wp -> w_wincol + total_width - 1 , popup_attr );
1103+ // right padding
1104+ if (wp -> w_popup_padding [1 ] > 0 )
1105+ screen_puts (get_spaces (wp -> w_popup_padding [1 ]), row ,
1106+ wp -> w_wincol + wp -> w_popup_border [3 ]
1107+ + wp -> w_popup_padding [3 ] + wp -> w_width , popup_attr );
1108+ }
1109+
1110+ if (wp -> w_popup_padding [2 ] > 0 )
1111+ {
1112+ // bottom padding
1113+ row = wp -> w_winrow + wp -> w_popup_border [0 ]
1114+ + wp -> w_popup_padding [0 ] + wp -> w_height ;
1115+ screen_fill (row , row + wp -> w_popup_padding [2 ],
1116+ wp -> w_wincol + wp -> w_popup_border [3 ],
1117+ wp -> w_wincol + total_width - wp -> w_popup_border [1 ],
1118+ ' ' , ' ' , popup_attr );
1119+ }
1120+
1121+ if (wp -> w_popup_border [2 ] > 0 )
1122+ {
1123+ // bottom border
1124+ row = wp -> w_winrow + total_height - 1 ;
1125+ screen_fill (row , row + 1 ,
1126+ wp -> w_wincol ,
1127+ wp -> w_wincol + total_width ,
1128+ wp -> w_popup_border [3 ] != 0 ? '+' : '-' ,
1129+ '-' , popup_attr );
1130+ if (wp -> w_popup_border [1 ] > 0 )
1131+ screen_puts ((char_u * )"+" , row ,
1132+ wp -> w_wincol + total_width - 1 , popup_attr );
1133+ }
10121134 }
10131135}
10141136#endif
10151137
1016- /*
1017- * Get 'wincolor' attribute for window "wp". If not set and "wp" is a popup
1018- * window then get the "Pmenu" highlight attribute.
1019- */
1020- static int
1021- get_wcr_attr (win_T * wp )
1022- {
1023- int wcr_attr = 0 ;
1024-
1025- if (* wp -> w_p_wcr != NUL )
1026- wcr_attr = syn_name2attr (wp -> w_p_wcr );
1027- #ifdef FEAT_TEXT_PROP
1028- if (bt_popup (wp -> w_buffer ) && wcr_attr == 0 )
1029- wcr_attr = HL_ATTR (HLF_PNI );
1030- #endif
1031- return wcr_attr ;
1032- }
1033-
10341138#if defined(FEAT_GUI ) || defined(PROTO )
10351139/*
10361140 * Update a single window, its status line and maybe the command line msg.
0 commit comments