comparison src/screen.c @ 6026:d42a1d3b74d4 v7.4.353

updated for version 7.4.353 Problem: 'breakindent' doesn't work with the 'list' option. Solution: Make it work. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 02 Jul 2014 20:00:47 +0200
parents 79950dae1d7d
children 5deaa4e9812d
comparison
equal deleted inserted replaced
6025:ad317f586374 6026:d42a1d3b74d4
2841 int screen_row; /* row on the screen, incl w_winrow */ 2841 int screen_row; /* row on the screen, incl w_winrow */
2842 2842
2843 char_u extra[18]; /* "%ld" and 'fdc' must fit in here */ 2843 char_u extra[18]; /* "%ld" and 'fdc' must fit in here */
2844 int n_extra = 0; /* number of extra chars */ 2844 int n_extra = 0; /* number of extra chars */
2845 char_u *p_extra = NULL; /* string of extra chars, plus NUL */ 2845 char_u *p_extra = NULL; /* string of extra chars, plus NUL */
2846 char_u *p_extra_free = NULL; /* p_extra needs to be freed */
2846 int c_extra = NUL; /* extra chars, all the same */ 2847 int c_extra = NUL; /* extra chars, all the same */
2847 int extra_attr = 0; /* attributes when n_extra != 0 */ 2848 int extra_attr = 0; /* attributes when n_extra != 0 */
2848 static char_u *at_end_str = (char_u *)""; /* used for p_extra when 2849 static char_u *at_end_str = (char_u *)""; /* used for p_extra when
2849 displaying lcs_eol at end-of-line */ 2850 displaying lcs_eol at end-of-line */
2850 int lcs_eol_one = lcs_eol; /* lcs_eol until it's been used */ 2851 int lcs_eol_one = lcs_eol; /* lcs_eol until it's been used */
4051 } 4052 }
4052 --n_extra; 4053 --n_extra;
4053 } 4054 }
4054 else 4055 else
4055 { 4056 {
4057 if (p_extra_free != NULL)
4058 {
4059 vim_free(p_extra_free);
4060 p_extra_free = NULL;
4061 }
4056 /* 4062 /*
4057 * Get a character from the line itself. 4063 * Get a character from the line itself.
4058 */ 4064 */
4059 c = *ptr; 4065 c = *ptr;
4060 #ifdef FEAT_MBYTE 4066 #ifdef FEAT_MBYTE
4422 #endif 4428 #endif
4423 #ifdef FEAT_LINEBREAK 4429 #ifdef FEAT_LINEBREAK
4424 /* 4430 /*
4425 * Found last space before word: check for line break. 4431 * Found last space before word: check for line break.
4426 */ 4432 */
4427 if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr) 4433 if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr))
4428 && !wp->w_p_list)
4429 { 4434 {
4430 char_u *p = ptr - ( 4435 char_u *p = ptr - (
4431 # ifdef FEAT_MBYTE 4436 # ifdef FEAT_MBYTE
4432 has_mbyte ? mb_l : 4437 has_mbyte ? mb_l :
4433 # endif 4438 # endif
4434 1); 4439 1);
4435 /* TODO: is passing p for start of the line OK? */ 4440 /* TODO: is passing p for start of the line OK? */
4436 n_extra = win_lbr_chartabsize(wp, p, p, (colnr_T)vcol, 4441 n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
4437 NULL) - 1; 4442 NULL) - 1;
4438 c_extra = ' '; 4443 c_extra = ' ';
4439 if (vim_iswhite(c)) 4444 if (vim_iswhite(c))
4440 { 4445 {
4441 #ifdef FEAT_CONCEAL 4446 #ifdef FEAT_CONCEAL
4442 if (c == TAB) 4447 if (c == TAB)
4443 /* See "Tab alignment" below. */ 4448 /* See "Tab alignment" below. */
4444 FIX_FOR_BOGUSCOLS; 4449 FIX_FOR_BOGUSCOLS;
4445 #endif 4450 #endif
4446 c = ' '; 4451 if (!wp->w_p_list)
4452 c = ' ';
4447 } 4453 }
4448 } 4454 }
4449 #endif 4455 #endif
4450 4456
4451 if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ') 4457 if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
4481 * turn it into something else on the way to putting it 4487 * turn it into something else on the way to putting it
4482 * into "ScreenLines". 4488 * into "ScreenLines".
4483 */ 4489 */
4484 if (c == TAB && (!wp->w_p_list || lcs_tab1)) 4490 if (c == TAB && (!wp->w_p_list || lcs_tab1))
4485 { 4491 {
4492 int tab_len = 0;
4486 /* tab amount depends on current column */ 4493 /* tab amount depends on current column */
4487 n_extra = (int)wp->w_buffer->b_p_ts 4494 tab_len = (int)wp->w_buffer->b_p_ts
4488 - vcol % (int)wp->w_buffer->b_p_ts - 1; 4495 - vcol % (int)wp->w_buffer->b_p_ts - 1;
4496 #ifdef FEAT_LINEBREAK
4497 if (!wp->w_p_lbr)
4498 #endif
4499 /* tab amount depends on current column */
4500 n_extra = tab_len;
4501 #ifdef FEAT_LINEBREAK
4502 else
4503 {
4504 char_u *p;
4505 int len = n_extra;
4506 int i;
4507 int saved_nextra = n_extra;
4508
4509 /* if n_extra > 0, it gives the number of chars, to
4510 * use for a tab, else we need to calculate the width
4511 * for a tab */
4512 #ifdef FEAT_MBYTE
4513 len = (tab_len * mb_char2len(lcs_tab2));
4514 if (n_extra > 0)
4515 len += n_extra - tab_len;
4516 #endif
4517 c = lcs_tab1;
4518 p = alloc((unsigned)(len + 1));
4519 vim_memset(p, ' ', len);
4520 p[len] = NUL;
4521 p_extra_free = p;
4522 for (i = 0; i < tab_len; i++)
4523 {
4524 #ifdef FEAT_MBYTE
4525 mb_char2bytes(lcs_tab2, p);
4526 p += mb_char2len(lcs_tab2);
4527 n_extra += mb_char2len(lcs_tab2)
4528 - (saved_nextra > 0 ? 1 : 0);
4529 #else
4530 p[i] = lcs_tab2;
4531 #endif
4532 }
4533 p_extra = p_extra_free;
4534 }
4535 #endif
4489 #ifdef FEAT_CONCEAL 4536 #ifdef FEAT_CONCEAL
4490 /* Tab alignment should be identical regardless of 4537 /* Tab alignment should be identical regardless of
4491 * 'conceallevel' value. So tab compensates of all 4538 * 'conceallevel' value. So tab compensates of all
4492 * previous concealed characters, and thus resets vcol_off 4539 * previous concealed characters, and thus resets vcol_off
4493 * and boguscols accumulated so far in the line. Note that 4540 * and boguscols accumulated so far in the line. Note that
4499 mb_utf8 = FALSE; /* don't draw as UTF-8 */ 4546 mb_utf8 = FALSE; /* don't draw as UTF-8 */
4500 #endif 4547 #endif
4501 if (wp->w_p_list) 4548 if (wp->w_p_list)
4502 { 4549 {
4503 c = lcs_tab1; 4550 c = lcs_tab1;
4504 c_extra = lcs_tab2; 4551 #ifdef FEAT_LINEBREAK
4505 n_attr = n_extra + 1; 4552 if (wp->w_p_lbr)
4553 c_extra = NUL; /* using p_extra from above */
4554 else
4555 #endif
4556 c_extra = lcs_tab2;
4557 n_attr = tab_len + 1;
4506 extra_attr = hl_attr(HLF_8); 4558 extra_attr = hl_attr(HLF_8);
4507 saved_attr2 = char_attr; /* save current attr */ 4559 saved_attr2 = char_attr; /* save current attr */
4508 #ifdef FEAT_MBYTE 4560 #ifdef FEAT_MBYTE
4509 mb_c = c; 4561 mb_c = c;
4510 if (enc_utf8 && (*mb_char2len)(c) > 1) 4562 if (enc_utf8 && (*mb_char2len)(c) > 1)
4596 p_extra = transchar(c); 4648 p_extra = transchar(c);
4597 #ifdef FEAT_RIGHTLEFT 4649 #ifdef FEAT_RIGHTLEFT
4598 if ((dy_flags & DY_UHEX) && wp->w_p_rl) 4650 if ((dy_flags & DY_UHEX) && wp->w_p_rl)
4599 rl_mirror(p_extra); /* reverse "<12>" */ 4651 rl_mirror(p_extra); /* reverse "<12>" */
4600 #endif 4652 #endif
4601 n_extra = byte2cells(c) - 1;
4602 c_extra = NUL; 4653 c_extra = NUL;
4603 c = *p_extra++; 4654 #ifdef FEAT_LINEBREAK
4655 if (wp->w_p_lbr)
4656 {
4657 char_u *p;
4658
4659 c = *p_extra;
4660 p = alloc((unsigned)n_extra + 1);
4661 vim_memset(p, ' ', n_extra);
4662 STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
4663 p[n_extra] = NUL;
4664 p_extra_free = p_extra = p;
4665 }
4666 else
4667 #endif
4668 {
4669 n_extra = byte2cells(c) - 1;
4670 c = *p_extra++;
4671 }
4604 if (!attr_pri) 4672 if (!attr_pri)
4605 { 4673 {
4606 n_attr = n_extra + 1; 4674 n_attr = n_extra + 1;
4607 extra_attr = hl_attr(HLF_8); 4675 extra_attr = hl_attr(HLF_8);
4608 saved_attr2 = char_attr; /* save current attr */ 4676 saved_attr2 = char_attr; /* save current attr */