Mercurial > vim
comparison src/buffer.c @ 22721:92a100fc5e17 v8.2.1909
patch 8.2.1909: number of status line items is limited to 80
Commit: https://github.com/vim/vim/commit/8133cc6bf454eb90bb0868f7cf806fce5c0c9fe6
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Oct 26 21:05:27 2020 +0100
patch 8.2.1909: number of status line items is limited to 80
Problem: Number of status line items is limited to 80.
Solution: Dynamically allocate the arrays. (Rom Grk, closes https://github.com/vim/vim/issues/7181)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 26 Oct 2020 21:15:06 +0100 |
parents | e871a824efc9 |
children | f7f2d73ff85e |
comparison
equal
deleted
inserted
replaced
22720:51ceeb95d655 | 22721:92a100fc5e17 |
---|---|
671 // windows, so that autocommands in buf_freeall() don't get confused. | 671 // windows, so that autocommands in buf_freeall() don't get confused. |
672 is_curbuf = (buf == curbuf); | 672 is_curbuf = (buf == curbuf); |
673 buf->b_nwindows = nwindows; | 673 buf->b_nwindows = nwindows; |
674 | 674 |
675 buf_freeall(buf, (del_buf ? BFA_DEL : 0) | 675 buf_freeall(buf, (del_buf ? BFA_DEL : 0) |
676 + (wipe_buf ? BFA_WIPE : 0) | 676 + (wipe_buf ? BFA_WIPE : 0) |
677 + (ignore_abort ? BFA_IGNORE_ABORT : 0)); | 677 + (ignore_abort ? BFA_IGNORE_ABORT : 0)); |
678 | 678 |
679 // Autocommands may have deleted the buffer. | 679 // Autocommands may have deleted the buffer. |
680 if (!bufref_valid(&bufref)) | 680 if (!bufref_valid(&bufref)) |
681 return; | 681 return; |
4015 # endif | 4015 # endif |
4016 | 4016 |
4017 #endif // FEAT_TITLE | 4017 #endif // FEAT_TITLE |
4018 | 4018 |
4019 #if defined(FEAT_STL_OPT) || defined(FEAT_GUI_TABLINE) || defined(PROTO) | 4019 #if defined(FEAT_STL_OPT) || defined(FEAT_GUI_TABLINE) || defined(PROTO) |
4020 | |
4021 /* | |
4022 * Used for building in the status line. | |
4023 */ | |
4024 typedef struct | |
4025 { | |
4026 char_u *stl_start; | |
4027 int stl_minwid; | |
4028 int stl_maxwid; | |
4029 enum { | |
4030 Normal, | |
4031 Empty, | |
4032 Group, | |
4033 Middle, | |
4034 Highlight, | |
4035 TabPage, | |
4036 Trunc | |
4037 } stl_type; | |
4038 } stl_item_T; | |
4039 | |
4040 static size_t stl_items_len = 20; // Initial value, grows as needed. | |
4041 static stl_item_T *stl_items = NULL; | |
4042 static int *stl_groupitem = NULL; | |
4043 static stl_hlrec_T *stl_hltab = NULL; | |
4044 static stl_hlrec_T *stl_tabtab = NULL; | |
4045 | |
4020 /* | 4046 /* |
4021 * Build a string from the status line items in "fmt". | 4047 * Build a string from the status line items in "fmt". |
4022 * Return length of string in screen cells. | 4048 * Return length of string in screen cells. |
4023 * | 4049 * |
4024 * Normally works for window "wp", except when working for 'tabline' then it | 4050 * Normally works for window "wp", except when working for 'tabline' then it |
4038 size_t outlen, // length of out[] | 4064 size_t outlen, // length of out[] |
4039 char_u *fmt, | 4065 char_u *fmt, |
4040 int use_sandbox UNUSED, // "fmt" was set insecurely, use sandbox | 4066 int use_sandbox UNUSED, // "fmt" was set insecurely, use sandbox |
4041 int fillchar, | 4067 int fillchar, |
4042 int maxwidth, | 4068 int maxwidth, |
4043 struct stl_hlrec *hltab, // return: HL attributes (can be NULL) | 4069 stl_hlrec_T **hltab, // return: HL attributes (can be NULL) |
4044 struct stl_hlrec *tabtab) // return: tab page nrs (can be NULL) | 4070 stl_hlrec_T **tabtab) // return: tab page nrs (can be NULL) |
4045 { | 4071 { |
4046 linenr_T lnum; | 4072 linenr_T lnum; |
4047 size_t len; | 4073 size_t len; |
4048 char_u *p; | 4074 char_u *p; |
4049 char_u *s; | 4075 char_u *s; |
4067 int width; | 4093 int width; |
4068 int itemcnt; | 4094 int itemcnt; |
4069 int curitem; | 4095 int curitem; |
4070 int group_end_userhl; | 4096 int group_end_userhl; |
4071 int group_start_userhl; | 4097 int group_start_userhl; |
4072 int groupitem[STL_MAX_ITEM]; | |
4073 int groupdepth; | 4098 int groupdepth; |
4074 struct stl_item | |
4075 { | |
4076 char_u *start; | |
4077 int minwid; | |
4078 int maxwid; | |
4079 enum | |
4080 { | |
4081 Normal, | |
4082 Empty, | |
4083 Group, | |
4084 Middle, | |
4085 Highlight, | |
4086 TabPage, | |
4087 Trunc | |
4088 } type; | |
4089 } item[STL_MAX_ITEM]; | |
4090 int minwid; | 4099 int minwid; |
4091 int maxwid; | 4100 int maxwid; |
4092 int zeropad; | 4101 int zeropad; |
4093 char_u base; | 4102 char_u base; |
4094 char_u opt; | 4103 char_u opt; |
4095 #define TMPLEN 70 | 4104 #define TMPLEN 70 |
4096 char_u buf_tmp[TMPLEN]; | 4105 char_u buf_tmp[TMPLEN]; |
4097 char_u win_tmp[TMPLEN]; | 4106 char_u win_tmp[TMPLEN]; |
4098 char_u *usefmt = fmt; | 4107 char_u *usefmt = fmt; |
4099 struct stl_hlrec *sp; | 4108 stl_hlrec_T *sp; |
4100 int save_must_redraw = must_redraw; | 4109 int save_must_redraw = must_redraw; |
4101 int save_redr_type = curwin->w_redr_type; | 4110 int save_redr_type = curwin->w_redr_type; |
4111 | |
4112 if (stl_items == NULL) | |
4113 { | |
4114 stl_items = ALLOC_MULT(stl_item_T, stl_items_len); | |
4115 stl_groupitem = ALLOC_MULT(int, stl_items_len); | |
4116 stl_hltab = ALLOC_MULT(stl_hlrec_T, stl_items_len); | |
4117 stl_tabtab = ALLOC_MULT(stl_hlrec_T, stl_items_len); | |
4118 } | |
4102 | 4119 |
4103 #ifdef FEAT_EVAL | 4120 #ifdef FEAT_EVAL |
4104 /* | 4121 /* |
4105 * When the format starts with "%!" then evaluate it as an expression and | 4122 * When the format starts with "%!" then evaluate it as an expression and |
4106 * use the result as the actual format string. | 4123 * use the result as the actual format string. |
4160 curitem = 0; | 4177 curitem = 0; |
4161 prevchar_isflag = TRUE; | 4178 prevchar_isflag = TRUE; |
4162 prevchar_isitem = FALSE; | 4179 prevchar_isitem = FALSE; |
4163 for (s = usefmt; *s; ) | 4180 for (s = usefmt; *s; ) |
4164 { | 4181 { |
4165 if (curitem == STL_MAX_ITEM) | 4182 if (curitem == (int)stl_items_len) |
4166 { | 4183 { |
4167 // There are too many items. Add the error code to the statusline | 4184 size_t new_len = stl_items_len * 3 / 2; |
4168 // to give the user a hint about what went wrong. | 4185 stl_item_T *new_items; |
4169 if (p + 6 < out + outlen) | 4186 int *new_groupitem; |
4170 { | 4187 stl_hlrec_T *new_hlrec; |
4171 mch_memmove(p, " E541", (size_t)5); | 4188 |
4172 p += 5; | 4189 new_items = vim_realloc(stl_items, sizeof(stl_item_T) * new_len); |
4173 } | 4190 if (new_items == NULL) |
4174 break; | 4191 break; |
4192 stl_items = new_items; | |
4193 new_groupitem = vim_realloc(stl_groupitem, sizeof(int) * new_len); | |
4194 if (new_groupitem == NULL) | |
4195 break; | |
4196 stl_groupitem = new_groupitem; | |
4197 new_hlrec = vim_realloc(stl_hltab, sizeof(stl_hlrec_T) * new_len); | |
4198 if (new_hlrec == NULL) | |
4199 break; | |
4200 stl_hltab = new_hlrec; | |
4201 new_hlrec = vim_realloc(stl_tabtab, sizeof(stl_hlrec_T) * new_len); | |
4202 if (new_hlrec == NULL) | |
4203 break; | |
4204 stl_tabtab = new_hlrec; | |
4205 stl_items_len = new_len; | |
4175 } | 4206 } |
4176 | 4207 |
4177 if (*s != NUL && *s != '%') | 4208 if (*s != NUL && *s != '%') |
4178 prevchar_isflag = prevchar_isitem = FALSE; | 4209 prevchar_isflag = prevchar_isitem = FALSE; |
4179 | 4210 |
4202 if (*s == STL_MIDDLEMARK) | 4233 if (*s == STL_MIDDLEMARK) |
4203 { | 4234 { |
4204 s++; | 4235 s++; |
4205 if (groupdepth > 0) | 4236 if (groupdepth > 0) |
4206 continue; | 4237 continue; |
4207 item[curitem].type = Middle; | 4238 stl_items[curitem].stl_type = Middle; |
4208 item[curitem++].start = p; | 4239 stl_items[curitem++].stl_start = p; |
4209 continue; | 4240 continue; |
4210 } | 4241 } |
4211 if (*s == STL_TRUNCMARK) | 4242 if (*s == STL_TRUNCMARK) |
4212 { | 4243 { |
4213 s++; | 4244 s++; |
4214 item[curitem].type = Trunc; | 4245 stl_items[curitem].stl_type = Trunc; |
4215 item[curitem++].start = p; | 4246 stl_items[curitem++].stl_start = p; |
4216 continue; | 4247 continue; |
4217 } | 4248 } |
4218 if (*s == ')') | 4249 if (*s == ')') |
4219 { | 4250 { |
4220 s++; | 4251 s++; |
4221 if (groupdepth < 1) | 4252 if (groupdepth < 1) |
4222 continue; | 4253 continue; |
4223 groupdepth--; | 4254 groupdepth--; |
4224 | 4255 |
4225 t = item[groupitem[groupdepth]].start; | 4256 t = stl_items[stl_groupitem[groupdepth]].stl_start; |
4226 *p = NUL; | 4257 *p = NUL; |
4227 l = vim_strsize(t); | 4258 l = vim_strsize(t); |
4228 if (curitem > groupitem[groupdepth] + 1 | 4259 if (curitem > stl_groupitem[groupdepth] + 1 |
4229 && item[groupitem[groupdepth]].minwid == 0) | 4260 && stl_items[stl_groupitem[groupdepth]].stl_minwid == 0) |
4230 { | 4261 { |
4231 // remove group if all items are empty and highlight group | 4262 // remove group if all items are empty and highlight group |
4232 // doesn't change | 4263 // doesn't change |
4233 group_start_userhl = group_end_userhl = 0; | 4264 group_start_userhl = group_end_userhl = 0; |
4234 for (n = groupitem[groupdepth] - 1; n >= 0; n--) | 4265 for (n = stl_groupitem[groupdepth] - 1; n >= 0; n--) |
4235 { | 4266 { |
4236 if (item[n].type == Highlight) | 4267 if (stl_items[n].stl_type == Highlight) |
4237 { | 4268 { |
4238 group_start_userhl = group_end_userhl = item[n].minwid; | 4269 group_start_userhl = group_end_userhl = |
4270 stl_items[n].stl_minwid; | |
4239 break; | 4271 break; |
4240 } | 4272 } |
4241 } | 4273 } |
4242 for (n = groupitem[groupdepth] + 1; n < curitem; n++) | 4274 for (n = stl_groupitem[groupdepth] + 1; n < curitem; n++) |
4243 { | 4275 { |
4244 if (item[n].type == Normal) | 4276 if (stl_items[n].stl_type == Normal) |
4245 break; | 4277 break; |
4246 if (item[n].type == Highlight) | 4278 if (stl_items[n].stl_type == Highlight) |
4247 group_end_userhl = item[n].minwid; | 4279 group_end_userhl = stl_items[n].stl_minwid; |
4248 } | 4280 } |
4249 if (n == curitem && group_start_userhl == group_end_userhl) | 4281 if (n == curitem && group_start_userhl == group_end_userhl) |
4250 { | 4282 { |
4251 // empty group | 4283 // empty group |
4252 p = t; | 4284 p = t; |
4253 l = 0; | 4285 l = 0; |
4254 for (n = groupitem[groupdepth] + 1; n < curitem; n++) | 4286 for (n = stl_groupitem[groupdepth] + 1; n < curitem; n++) |
4255 { | 4287 { |
4256 // do not use the highlighting from the removed group | 4288 // do not use the highlighting from the removed group |
4257 if (item[n].type == Highlight) | 4289 if (stl_items[n].stl_type == Highlight) |
4258 item[n].type = Empty; | 4290 stl_items[n].stl_type = Empty; |
4259 // adjust the start position of TabPage to the next | 4291 // adjust the start position of TabPage to the next |
4260 // item position | 4292 // item position |
4261 if (item[n].type == TabPage) | 4293 if (stl_items[n].stl_type == TabPage) |
4262 item[n].start = p; | 4294 stl_items[n].stl_start = p; |
4263 } | 4295 } |
4264 } | 4296 } |
4265 } | 4297 } |
4266 if (l > item[groupitem[groupdepth]].maxwid) | 4298 if (l > stl_items[stl_groupitem[groupdepth]].stl_maxwid) |
4267 { | 4299 { |
4268 // truncate, remove n bytes of text at the start | 4300 // truncate, remove n bytes of text at the start |
4269 if (has_mbyte) | 4301 if (has_mbyte) |
4270 { | 4302 { |
4271 // Find the first character that should be included. | 4303 // Find the first character that should be included. |
4272 n = 0; | 4304 n = 0; |
4273 while (l >= item[groupitem[groupdepth]].maxwid) | 4305 while (l >= stl_items[stl_groupitem[groupdepth]].stl_maxwid) |
4274 { | 4306 { |
4275 l -= ptr2cells(t + n); | 4307 l -= ptr2cells(t + n); |
4276 n += (*mb_ptr2len)(t + n); | 4308 n += (*mb_ptr2len)(t + n); |
4277 } | 4309 } |
4278 } | 4310 } |
4279 else | 4311 else |
4280 n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1; | 4312 n = (long)(p - t) - stl_items[stl_groupitem[groupdepth]] |
4313 .stl_maxwid + 1; | |
4281 | 4314 |
4282 *t = '<'; | 4315 *t = '<'; |
4283 mch_memmove(t + 1, t + n, (size_t)(p - (t + n))); | 4316 mch_memmove(t + 1, t + n, (size_t)(p - (t + n))); |
4284 p = p - n + 1; | 4317 p = p - n + 1; |
4285 | 4318 |
4286 // Fill up space left over by half a double-wide char. | 4319 // Fill up space left over by half a double-wide char. |
4287 while (++l < item[groupitem[groupdepth]].minwid) | 4320 while (++l < stl_items[stl_groupitem[groupdepth]].stl_minwid) |
4288 *p++ = fillchar; | 4321 *p++ = fillchar; |
4289 | 4322 |
4290 // correct the start of the items for the truncation | 4323 // correct the start of the items for the truncation |
4291 for (l = groupitem[groupdepth] + 1; l < curitem; l++) | 4324 for (l = stl_groupitem[groupdepth] + 1; l < curitem; l++) |
4292 { | 4325 { |
4293 item[l].start -= n; | 4326 stl_items[l].stl_start -= n; |
4294 if (item[l].start < t) | 4327 if (stl_items[l].stl_start < t) |
4295 item[l].start = t; | 4328 stl_items[l].stl_start = t; |
4296 } | 4329 } |
4297 } | 4330 } |
4298 else if (abs(item[groupitem[groupdepth]].minwid) > l) | 4331 else if (abs(stl_items[stl_groupitem[groupdepth]].stl_minwid) > l) |
4299 { | 4332 { |
4300 // fill | 4333 // fill |
4301 n = item[groupitem[groupdepth]].minwid; | 4334 n = stl_items[stl_groupitem[groupdepth]].stl_minwid; |
4302 if (n < 0) | 4335 if (n < 0) |
4303 { | 4336 { |
4304 // fill by appending characters | 4337 // fill by appending characters |
4305 n = 0 - n; | 4338 n = 0 - n; |
4306 while (l++ < n && p + 1 < out + outlen) | 4339 while (l++ < n && p + 1 < out + outlen) |
4312 mch_memmove(t + n - l, t, (size_t)(p - t)); | 4345 mch_memmove(t + n - l, t, (size_t)(p - t)); |
4313 l = n - l; | 4346 l = n - l; |
4314 if (p + l >= out + outlen) | 4347 if (p + l >= out + outlen) |
4315 l = (long)((out + outlen) - p - 1); | 4348 l = (long)((out + outlen) - p - 1); |
4316 p += l; | 4349 p += l; |
4317 for (n = groupitem[groupdepth] + 1; n < curitem; n++) | 4350 for (n = stl_groupitem[groupdepth] + 1; n < curitem; n++) |
4318 item[n].start += l; | 4351 stl_items[n].stl_start += l; |
4319 for ( ; l > 0; l--) | 4352 for ( ; l > 0; l--) |
4320 *t++ = fillchar; | 4353 *t++ = fillchar; |
4321 } | 4354 } |
4322 } | 4355 } |
4323 continue; | 4356 continue; |
4342 if (minwid < 0) // overflow | 4375 if (minwid < 0) // overflow |
4343 minwid = 0; | 4376 minwid = 0; |
4344 } | 4377 } |
4345 if (*s == STL_USER_HL) | 4378 if (*s == STL_USER_HL) |
4346 { | 4379 { |
4347 item[curitem].type = Highlight; | 4380 stl_items[curitem].stl_type = Highlight; |
4348 item[curitem].start = p; | 4381 stl_items[curitem].stl_start = p; |
4349 item[curitem].minwid = minwid > 9 ? 1 : minwid; | 4382 stl_items[curitem].stl_minwid = minwid > 9 ? 1 : minwid; |
4350 s++; | 4383 s++; |
4351 curitem++; | 4384 curitem++; |
4352 continue; | 4385 continue; |
4353 } | 4386 } |
4354 if (*s == STL_TABPAGENR || *s == STL_TABCLOSENR) | 4387 if (*s == STL_TABPAGENR || *s == STL_TABCLOSENR) |
4358 if (minwid == 0) | 4391 if (minwid == 0) |
4359 { | 4392 { |
4360 // %X ends the close label, go back to the previously | 4393 // %X ends the close label, go back to the previously |
4361 // define tab label nr. | 4394 // define tab label nr. |
4362 for (n = curitem - 1; n >= 0; --n) | 4395 for (n = curitem - 1; n >= 0; --n) |
4363 if (item[n].type == TabPage && item[n].minwid >= 0) | 4396 if (stl_items[n].stl_type == TabPage |
4397 && stl_items[n].stl_minwid >= 0) | |
4364 { | 4398 { |
4365 minwid = item[n].minwid; | 4399 minwid = stl_items[n].stl_minwid; |
4366 break; | 4400 break; |
4367 } | 4401 } |
4368 } | 4402 } |
4369 else | 4403 else |
4370 // close nrs are stored as negative values | 4404 // close nrs are stored as negative values |
4371 minwid = - minwid; | 4405 minwid = - minwid; |
4372 } | 4406 } |
4373 item[curitem].type = TabPage; | 4407 stl_items[curitem].stl_type = TabPage; |
4374 item[curitem].start = p; | 4408 stl_items[curitem].stl_start = p; |
4375 item[curitem].minwid = minwid; | 4409 stl_items[curitem].stl_minwid = minwid; |
4376 s++; | 4410 s++; |
4377 curitem++; | 4411 curitem++; |
4378 continue; | 4412 continue; |
4379 } | 4413 } |
4380 if (*s == '.') | 4414 if (*s == '.') |
4388 } | 4422 } |
4389 } | 4423 } |
4390 minwid = (minwid > 50 ? 50 : minwid) * l; | 4424 minwid = (minwid > 50 ? 50 : minwid) * l; |
4391 if (*s == '(') | 4425 if (*s == '(') |
4392 { | 4426 { |
4393 groupitem[groupdepth++] = curitem; | 4427 stl_groupitem[groupdepth++] = curitem; |
4394 item[curitem].type = Group; | 4428 stl_items[curitem].stl_type = Group; |
4395 item[curitem].start = p; | 4429 stl_items[curitem].stl_start = p; |
4396 item[curitem].minwid = minwid; | 4430 stl_items[curitem].stl_minwid = minwid; |
4397 item[curitem].maxwid = maxwid; | 4431 stl_items[curitem].stl_maxwid = maxwid; |
4398 s++; | 4432 s++; |
4399 curitem++; | 4433 curitem++; |
4400 continue; | 4434 continue; |
4401 } | 4435 } |
4402 if (vim_strchr(STL_ALL, *s) == NULL) | 4436 if (vim_strchr(STL_ALL, *s) == NULL) |
4645 t = s; | 4679 t = s; |
4646 while (*s != '#' && *s != NUL) | 4680 while (*s != '#' && *s != NUL) |
4647 ++s; | 4681 ++s; |
4648 if (*s == '#') | 4682 if (*s == '#') |
4649 { | 4683 { |
4650 item[curitem].type = Highlight; | 4684 stl_items[curitem].stl_type = Highlight; |
4651 item[curitem].start = p; | 4685 stl_items[curitem].stl_start = p; |
4652 item[curitem].minwid = -syn_namen2id(t, (int)(s - t)); | 4686 stl_items[curitem].stl_minwid = -syn_namen2id(t, (int)(s - t)); |
4653 curitem++; | 4687 curitem++; |
4654 } | 4688 } |
4655 if (*s != NUL) | 4689 if (*s != NUL) |
4656 ++s; | 4690 ++s; |
4657 continue; | 4691 continue; |
4658 } | 4692 } |
4659 | 4693 |
4660 item[curitem].start = p; | 4694 stl_items[curitem].stl_start = p; |
4661 item[curitem].type = Normal; | 4695 stl_items[curitem].stl_type = Normal; |
4662 if (str != NULL && *str) | 4696 if (str != NULL && *str) |
4663 { | 4697 { |
4664 t = str; | 4698 t = str; |
4665 if (itemisflag) | 4699 if (itemisflag) |
4666 { | 4700 { |
4755 vim_snprintf((char *)p, outlen - (p - out), (char *)nstr, | 4789 vim_snprintf((char *)p, outlen - (p - out), (char *)nstr, |
4756 minwid, num); | 4790 minwid, num); |
4757 p += STRLEN(p); | 4791 p += STRLEN(p); |
4758 } | 4792 } |
4759 else | 4793 else |
4760 item[curitem].type = Empty; | 4794 stl_items[curitem].stl_type = Empty; |
4761 | 4795 |
4762 if (opt == STL_VIM_EXPR) | 4796 if (opt == STL_VIM_EXPR) |
4763 vim_free(str); | 4797 vim_free(str); |
4764 | 4798 |
4765 if (num >= 0 || (!itemisflag && str && *str)) | 4799 if (num >= 0 || (!itemisflag && str && *str)) |
4782 if (itemcnt == 0) | 4816 if (itemcnt == 0) |
4783 s = out; | 4817 s = out; |
4784 else | 4818 else |
4785 { | 4819 { |
4786 for ( ; l < itemcnt; l++) | 4820 for ( ; l < itemcnt; l++) |
4787 if (item[l].type == Trunc) | 4821 if (stl_items[l].stl_type == Trunc) |
4788 { | 4822 { |
4789 // Truncate at %< item. | 4823 // Truncate at %< item. |
4790 s = item[l].start; | 4824 s = stl_items[l].stl_start; |
4791 break; | 4825 break; |
4792 } | 4826 } |
4793 if (l == itemcnt) | 4827 if (l == itemcnt) |
4794 { | 4828 { |
4795 // No %< item, truncate first item. | 4829 // No %< item, truncate first item. |
4796 s = item[0].start; | 4830 s = stl_items[0].stl_start; |
4797 l = 0; | 4831 l = 0; |
4798 } | 4832 } |
4799 } | 4833 } |
4800 | 4834 |
4801 if (width - vim_strsize(s) >= maxwidth) | 4835 if (width - vim_strsize(s) >= maxwidth) |
4817 *s++ = fillchar; | 4851 *s++ = fillchar; |
4818 } | 4852 } |
4819 else | 4853 else |
4820 s = out + maxwidth - 1; | 4854 s = out + maxwidth - 1; |
4821 for (l = 0; l < itemcnt; l++) | 4855 for (l = 0; l < itemcnt; l++) |
4822 if (item[l].start > s) | 4856 if (stl_items[l].stl_start > s) |
4823 break; | 4857 break; |
4824 itemcnt = l; | 4858 itemcnt = l; |
4825 *s++ = '>'; | 4859 *s++ = '>'; |
4826 *s = 0; | 4860 *s = 0; |
4827 } | 4861 } |
4851 } | 4885 } |
4852 | 4886 |
4853 --n; // count the '<' | 4887 --n; // count the '<' |
4854 for (; l < itemcnt; l++) | 4888 for (; l < itemcnt; l++) |
4855 { | 4889 { |
4856 if (item[l].start - n >= s) | 4890 if (stl_items[l].stl_start - n >= s) |
4857 item[l].start -= n; | 4891 stl_items[l].stl_start -= n; |
4858 else | 4892 else |
4859 item[l].start = s; | 4893 stl_items[l].stl_start = s; |
4860 } | 4894 } |
4861 } | 4895 } |
4862 width = maxwidth; | 4896 width = maxwidth; |
4863 } | 4897 } |
4864 else if (width < maxwidth && STRLEN(out) + maxwidth - width + 1 < outlen) | 4898 else if (width < maxwidth && STRLEN(out) + maxwidth - width + 1 < outlen) |
4865 { | 4899 { |
4866 // Apply STL_MIDDLE if any | 4900 // Apply STL_MIDDLE if any |
4867 for (l = 0; l < itemcnt; l++) | 4901 for (l = 0; l < itemcnt; l++) |
4868 if (item[l].type == Middle) | 4902 if (stl_items[l].stl_type == Middle) |
4869 break; | 4903 break; |
4870 if (l < itemcnt) | 4904 if (l < itemcnt) |
4871 { | 4905 { |
4872 p = item[l].start + maxwidth - width; | 4906 p = stl_items[l].stl_start + maxwidth - width; |
4873 STRMOVE(p, item[l].start); | 4907 STRMOVE(p, stl_items[l].stl_start); |
4874 for (s = item[l].start; s < p; s++) | 4908 for (s = stl_items[l].stl_start; s < p; s++) |
4875 *s = fillchar; | 4909 *s = fillchar; |
4876 for (l++; l < itemcnt; l++) | 4910 for (l++; l < itemcnt; l++) |
4877 item[l].start += maxwidth - width; | 4911 stl_items[l].stl_start += maxwidth - width; |
4878 width = maxwidth; | 4912 width = maxwidth; |
4879 } | 4913 } |
4880 } | 4914 } |
4881 | 4915 |
4882 // Store the info about highlighting. | 4916 // Store the info about highlighting. |
4883 if (hltab != NULL) | 4917 if (hltab != NULL) |
4884 { | 4918 { |
4885 sp = hltab; | 4919 *hltab = stl_hltab; |
4920 sp = stl_hltab; | |
4886 for (l = 0; l < itemcnt; l++) | 4921 for (l = 0; l < itemcnt; l++) |
4887 { | 4922 { |
4888 if (item[l].type == Highlight) | 4923 if (stl_items[l].stl_type == Highlight) |
4889 { | 4924 { |
4890 sp->start = item[l].start; | 4925 sp->start = stl_items[l].stl_start; |
4891 sp->userhl = item[l].minwid; | 4926 sp->userhl = stl_items[l].stl_minwid; |
4892 sp++; | 4927 sp++; |
4893 } | 4928 } |
4894 } | 4929 } |
4895 sp->start = NULL; | 4930 sp->start = NULL; |
4896 sp->userhl = 0; | 4931 sp->userhl = 0; |
4897 } | 4932 } |
4898 | 4933 |
4899 // Store the info about tab pages labels. | 4934 // Store the info about tab pages labels. |
4900 if (tabtab != NULL) | 4935 if (tabtab != NULL) |
4901 { | 4936 { |
4902 sp = tabtab; | 4937 *tabtab = stl_tabtab; |
4938 sp = stl_tabtab; | |
4903 for (l = 0; l < itemcnt; l++) | 4939 for (l = 0; l < itemcnt; l++) |
4904 { | 4940 { |
4905 if (item[l].type == TabPage) | 4941 if (stl_items[l].stl_type == TabPage) |
4906 { | 4942 { |
4907 sp->start = item[l].start; | 4943 sp->start = stl_items[l].stl_start; |
4908 sp->userhl = item[l].minwid; | 4944 sp->userhl = stl_items[l].stl_minwid; |
4909 sp++; | 4945 sp++; |
4910 } | 4946 } |
4911 } | 4947 } |
4912 sp->start = NULL; | 4948 sp->start = NULL; |
4913 sp->userhl = 0; | 4949 sp->userhl = 0; |
5532 */ | 5568 */ |
5533 int | 5569 int |
5534 bt_dontwrite(buf_T *buf) | 5570 bt_dontwrite(buf_T *buf) |
5535 { | 5571 { |
5536 return buf != NULL && (buf->b_p_bt[0] == 'n' | 5572 return buf != NULL && (buf->b_p_bt[0] == 'n' |
5537 || buf->b_p_bt[0] == 't' | 5573 || buf->b_p_bt[0] == 't' |
5538 || buf->b_p_bt[0] == 'p'); | 5574 || buf->b_p_bt[0] == 'p'); |
5539 } | 5575 } |
5540 | 5576 |
5541 #if defined(FEAT_QUICKFIX) || defined(PROTO) | 5577 #if defined(FEAT_QUICKFIX) || defined(PROTO) |
5542 int | 5578 int |
5543 bt_dontwrite_msg(buf_T *buf) | 5579 bt_dontwrite_msg(buf_T *buf) |