comparison src/screen.c @ 677:e649c78407e6 v7.0202

updated for version 7.0202
author vimboss
date Mon, 20 Feb 2006 21:37:40 +0000
parents 4b8583e82cb8
children 5b101ff9d4c4
comparison
equal deleted inserted replaced
676:9cdb8018cdf1 677:e649c78407e6
166 #endif 166 #endif
167 static int win_do_lines __ARGS((win_T *wp, int row, int line_count, int mayclear, int del)); 167 static int win_do_lines __ARGS((win_T *wp, int row, int line_count, int mayclear, int del));
168 static void win_rest_invalid __ARGS((win_T *wp)); 168 static void win_rest_invalid __ARGS((win_T *wp));
169 static void msg_pos_mode __ARGS((void)); 169 static void msg_pos_mode __ARGS((void));
170 #if defined(FEAT_WINDOWS) 170 #if defined(FEAT_WINDOWS)
171 static void draw_tabpage __ARGS((void)); 171 static void draw_tabline __ARGS((void));
172 #endif 172 #endif
173 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT) 173 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT)
174 static int fillchar_status __ARGS((int *attr, int is_curwin)); 174 static int fillchar_status __ARGS((int *attr, int is_curwin));
175 #endif 175 #endif
176 #ifdef FEAT_VERTSPLIT 176 #ifdef FEAT_VERTSPLIT
418 check_for_delay(FALSE); 418 check_for_delay(FALSE);
419 419
420 #ifdef FEAT_LINEBREAK 420 #ifdef FEAT_LINEBREAK
421 /* Force redraw when width of 'number' column changes. */ 421 /* Force redraw when width of 'number' column changes. */
422 if (curwin->w_redr_type < NOT_VALID 422 if (curwin->w_redr_type < NOT_VALID
423 && curwin->w_nrwidth != number_width(curwin)) 423 && curwin->w_nrwidth != (curwin->w_p_nu ? number_width(curwin) : 0))
424 curwin->w_redr_type = NOT_VALID; 424 curwin->w_redr_type = NOT_VALID;
425 #endif 425 #endif
426 426
427 /* 427 /*
428 * Only start redrawing if there is really something to do. 428 * Only start redrawing if there is really something to do.
475 #endif 475 #endif
476 476
477 #ifdef FEAT_WINDOWS 477 #ifdef FEAT_WINDOWS
478 /* Redraw the tab pages line if needed. */ 478 /* Redraw the tab pages line if needed. */
479 if (redraw_tabline || type >= NOT_VALID) 479 if (redraw_tabline || type >= NOT_VALID)
480 draw_tabpage(); 480 draw_tabline();
481 #endif 481 #endif
482 482
483 /* 483 /*
484 * Go from top to bottom through the windows, redrawing the ones that need 484 * Go from top to bottom through the windows, redrawing the ones that need
485 * it. 485 * it.
705 win_update(wp); 705 win_update(wp);
706 706
707 #ifdef FEAT_WINDOWS 707 #ifdef FEAT_WINDOWS
708 /* When the screen was cleared redraw the tab pages line. */ 708 /* When the screen was cleared redraw the tab pages line. */
709 if (redraw_tabline) 709 if (redraw_tabline)
710 draw_tabpage(); 710 draw_tabline();
711 711
712 if (wp->w_redr_status 712 if (wp->w_redr_status
713 # ifdef FEAT_CMDL_INFO 713 # ifdef FEAT_CMDL_INFO
714 || p_ru 714 || p_ru
715 # endif 715 # endif
843 search_hl.first_lnum = 0; 843 search_hl.first_lnum = 0;
844 #endif 844 #endif
845 845
846 #ifdef FEAT_LINEBREAK 846 #ifdef FEAT_LINEBREAK
847 /* Force redraw when width of 'number' column changes. */ 847 /* Force redraw when width of 'number' column changes. */
848 i = number_width(curwin); 848 i = wp->w_p_nu ? number_width(wp) : 0;
849 if (curwin->w_nrwidth != i) 849 if (wp->w_nrwidth != i)
850 { 850 {
851 type = NOT_VALID; 851 type = NOT_VALID;
852 curwin->w_nrwidth = i; 852 wp->w_nrwidth = i;
853 } 853 }
854 else 854 else
855 #endif 855 #endif
856 856
857 if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0) 857 if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0)
4963 4963
4964 for (wp = firstwin; wp; wp = wp->w_next) 4964 for (wp = firstwin; wp; wp = wp->w_next)
4965 if (wp->w_redr_status) 4965 if (wp->w_redr_status)
4966 win_redr_status(wp); 4966 win_redr_status(wp);
4967 if (redraw_tabline) 4967 if (redraw_tabline)
4968 draw_tabpage(); 4968 draw_tabline();
4969 } 4969 }
4970 #endif 4970 #endif
4971 4971
4972 #if (defined(FEAT_WILDMENU) && defined(FEAT_VERTSPLIT)) || defined(PROTO) 4972 #if (defined(FEAT_WILDMENU) && defined(FEAT_VERTSPLIT)) || defined(PROTO)
4973 /* 4973 /*
5541 } 5541 }
5542 #endif 5542 #endif
5543 5543
5544 #if defined(FEAT_STL_OPT) || defined(PROTO) 5544 #if defined(FEAT_STL_OPT) || defined(PROTO)
5545 /* 5545 /*
5546 * Redraw the status line or ruler of window wp. 5546 * Redraw the status line or ruler of window "wp".
5547 * When "wp" is NULL redraw the tab pages line from 'tabline'.
5547 */ 5548 */
5548 static void 5549 static void
5549 win_redr_custom(wp, draw_ruler) 5550 win_redr_custom(wp, draw_ruler)
5550 win_T *wp; 5551 win_T *wp;
5551 int draw_ruler; /* TRUE or FALSE */ 5552 int draw_ruler; /* TRUE or FALSE */
5560 int len; 5561 int len;
5561 int fillchar; 5562 int fillchar;
5562 char_u buf[MAXPATHL]; 5563 char_u buf[MAXPATHL];
5563 char_u *p; 5564 char_u *p;
5564 struct stl_hlrec hl[STL_MAX_ITEM]; 5565 struct stl_hlrec hl[STL_MAX_ITEM];
5566 int use_sandbox = FALSE;
5565 5567
5566 /* setup environment for the task at hand */ 5568 /* setup environment for the task at hand */
5567 row = W_WINROW(wp) + wp->w_height; 5569 if (wp == NULL)
5568 fillchar = fillchar_status(&attr, wp == curwin); 5570 {
5569 maxwidth = W_WIDTH(wp); 5571 /* Use 'tabline'. Always at the first line of the screen. */
5570 if (*wp->w_p_stl != NUL) 5572 p = p_tal;
5571 p = wp->w_p_stl; 5573 row = 0;
5574 fillchar = t_colors < 8 ? '_' : ' ';
5575 attr = hl_attr(HLF_TPF);
5576 maxwidth = Columns;
5577 # ifdef FEAT_EVAL
5578 use_sandbox = was_set_insecurely((char_u *)"tabline");
5579 # endif
5580 }
5572 else 5581 else
5573 p = p_stl; 5582 {
5574 if (draw_ruler) 5583 row = W_WINROW(wp) + wp->w_height;
5575 { 5584 fillchar = fillchar_status(&attr, wp == curwin);
5576 p = p_ruf; 5585 maxwidth = W_WIDTH(wp);
5577 /* advance past any leading group spec - implicit in ru_col */ 5586
5578 if (*p == '%') 5587 if (draw_ruler)
5579 { 5588 {
5580 if (*++p == '-') 5589 p = p_ruf;
5581 p++; 5590 /* advance past any leading group spec - implicit in ru_col */
5582 if (atoi((char *) p)) 5591 if (*p == '%')
5583 while (VIM_ISDIGIT(*p)) 5592 {
5593 if (*++p == '-')
5584 p++; 5594 p++;
5585 if (*p++ != '(') 5595 if (atoi((char *) p))
5586 p = p_ruf; 5596 while (VIM_ISDIGIT(*p))
5587 } 5597 p++;
5598 if (*p++ != '(')
5599 p = p_ruf;
5600 }
5588 #ifdef FEAT_VERTSPLIT 5601 #ifdef FEAT_VERTSPLIT
5589 col = ru_col - (Columns - W_WIDTH(wp)); 5602 col = ru_col - (Columns - W_WIDTH(wp));
5590 if (col < (W_WIDTH(wp) + 1) / 2) 5603 if (col < (W_WIDTH(wp) + 1) / 2)
5591 col = (W_WIDTH(wp) + 1) / 2; 5604 col = (W_WIDTH(wp) + 1) / 2;
5592 #else 5605 #else
5593 col = ru_col; 5606 col = ru_col;
5594 if (col > (Columns + 1) / 2) 5607 if (col > (Columns + 1) / 2)
5595 col = (Columns + 1) / 2; 5608 col = (Columns + 1) / 2;
5596 #endif 5609 #endif
5597 maxwidth = W_WIDTH(wp) - col; 5610 maxwidth = W_WIDTH(wp) - col;
5598 #ifdef FEAT_WINDOWS 5611 #ifdef FEAT_WINDOWS
5599 if (!wp->w_status_height) 5612 if (!wp->w_status_height)
5600 #endif 5613 #endif
5601 { 5614 {
5602 row = Rows - 1; 5615 row = Rows - 1;
5603 --maxwidth; /* writing in last column may cause scrolling */ 5616 --maxwidth; /* writing in last column may cause scrolling */
5604 fillchar = ' '; 5617 fillchar = ' ';
5605 attr = 0; 5618 attr = 0;
5606 } 5619 }
5607 } 5620
5621 # ifdef FEAT_EVAL
5622 use_sandbox = was_set_insecurely((char_u *)"rulerformat");
5623 # endif
5624 }
5625 else
5626 {
5627 if (*wp->w_p_stl != NUL)
5628 p = wp->w_p_stl;
5629 else
5630 p = p_stl;
5631 # ifdef FEAT_EVAL
5632 use_sandbox = was_set_insecurely((char_u *)"statusline");
5633 # endif
5634 }
5635
5636 #ifdef FEAT_VERTSPLIT
5637 col += W_WINCOL(wp);
5638 #endif
5639 }
5640
5608 if (maxwidth <= 0) 5641 if (maxwidth <= 0)
5609 return; 5642 return;
5610 #ifdef FEAT_VERTSPLIT 5643
5611 col += W_WINCOL(wp); 5644 width = build_stl_str_hl(wp == NULL ? curwin : wp,
5612 #endif 5645 buf, sizeof(buf),
5613 5646 p, use_sandbox,
5614 width = build_stl_str_hl(wp, buf, sizeof(buf), p, fillchar, maxwidth, hl); 5647 fillchar, maxwidth, hl);
5615 len = STRLEN(buf); 5648 len = STRLEN(buf);
5616 5649
5617 while (width < maxwidth && len < sizeof(buf) - 1) 5650 while (width < maxwidth && len < sizeof(buf) - 1)
5618 { 5651 {
5619 #ifdef FEAT_MBYTE 5652 #ifdef FEAT_MBYTE
6820 new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE); 6853 new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE);
6821 #ifdef FEAT_WINDOWS 6854 #ifdef FEAT_WINDOWS
6822 new_TabPageIdxs = (char_u *)lalloc((long_u)(Columns * sizeof(char_u)), FALSE); 6855 new_TabPageIdxs = (char_u *)lalloc((long_u)(Columns * sizeof(char_u)), FALSE);
6823 #endif 6856 #endif
6824 6857
6825 FOR_ALL_WINDOWS(wp) 6858 FOR_ALL_TAB_WINDOWS(tp, wp)
6826 { 6859 {
6827 if (win_alloc_lines(wp) == FAIL) 6860 if (win_alloc_lines(wp) == FAIL)
6828 { 6861 {
6829 outofmem = TRUE; 6862 outofmem = TRUE;
6830 #ifdef FEAT_WINDOWS 6863 #ifdef FEAT_WINDOWS
8454 #if defined(FEAT_WINDOWS) 8487 #if defined(FEAT_WINDOWS)
8455 /* 8488 /*
8456 * Draw the tab pages line at the top of the Vim window. 8489 * Draw the tab pages line at the top of the Vim window.
8457 */ 8490 */
8458 static void 8491 static void
8459 draw_tabpage() 8492 draw_tabline()
8460 { 8493 {
8461 int tabcount = 0; 8494 int tabcount = 0;
8462 tabpage_T *tp; 8495 tabpage_T *tp;
8463 int tabwidth; 8496 int tabwidth;
8464 int col = 0; 8497 int col = 0;
8465 int scol = 0; 8498 int scol = 0;
8466 int had_current = FALSE;
8467 int attr; 8499 int attr;
8468 win_T *wp; 8500 win_T *wp;
8469 win_T *cwp; 8501 win_T *cwp;
8470 int wincount; 8502 int wincount;
8471 int modified; 8503 int modified;
8473 int len; 8505 int len;
8474 int attr_sel = hl_attr(HLF_TPS); 8506 int attr_sel = hl_attr(HLF_TPS);
8475 int attr_nosel = hl_attr(HLF_TP); 8507 int attr_nosel = hl_attr(HLF_TP);
8476 int attr_fill = hl_attr(HLF_TPF); 8508 int attr_fill = hl_attr(HLF_TPF);
8477 char_u *p; 8509 char_u *p;
8510 int room;
8511 int use_sep_chars = (t_colors < 8
8512 #ifdef FEAT_GUI
8513 && !gui.in_use
8514 #endif
8515 );
8478 8516
8479 redraw_tabline = FALSE; 8517 redraw_tabline = FALSE;
8480 8518
8481 if (tabpageline_height() < 1) 8519 if (tabpageline_height() < 1)
8482 return; 8520 return;
8521
8522 #if defined(FEAT_STL_OPT)
8523 /* Use the 'tabline' option if it's set. */
8524 if (*p_tal != NUL)
8525 {
8526 win_redr_custom(NULL, FALSE);
8527 return;
8528 }
8529 #endif
8483 8530
8484 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) 8531 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
8485 ++tabcount; 8532 ++tabcount;
8486 8533
8487 tabwidth = (Columns - 1 + tabcount / 2) / tabcount; 8534 tabwidth = (Columns - 1 + tabcount / 2) / tabcount;
8493 for (tp = first_tabpage; tp != NULL && col < Columns; tp = tp->tp_next) 8540 for (tp = first_tabpage; tp != NULL && col < Columns; tp = tp->tp_next)
8494 { 8541 {
8495 scol = col; 8542 scol = col;
8496 8543
8497 if (tp->tp_topframe == topframe) 8544 if (tp->tp_topframe == topframe)
8498 {
8499 c = '/';
8500 had_current = TRUE;
8501 attr = attr_sel; 8545 attr = attr_sel;
8502 } 8546 if (use_sep_chars && col > 0)
8503 else if (!had_current) 8547 screen_putchar('|', 0, col++, attr);
8504 c = '/';
8505 else
8506 c = '\\';
8507 if (t_colors < 8)
8508 screen_putchar(c, 0, col++, attr);
8509 8548
8510 if (tp->tp_topframe != topframe) 8549 if (tp->tp_topframe != topframe)
8511 attr = attr_nosel; 8550 attr = attr_nosel;
8512 8551
8513 screen_putchar(' ', 0, col++, attr); 8552 screen_putchar(' ', 0, col++, attr);
8529 modified = TRUE; 8568 modified = TRUE;
8530 if (modified || wincount > 1) 8569 if (modified || wincount > 1)
8531 { 8570 {
8532 if (wincount > 1) 8571 if (wincount > 1)
8533 { 8572 {
8534 vim_snprintf((char *)NameBuff, MAXPATHL, "#%d", wincount); 8573 vim_snprintf((char *)NameBuff, MAXPATHL, "%d", wincount);
8535 len = STRLEN(NameBuff); 8574 len = STRLEN(NameBuff);
8536 screen_puts_len(NameBuff, len, 0, col, attr); 8575 screen_puts_len(NameBuff, len, 0, col,
8576 #if defined(FEAT_SYN_HL)
8577 hl_combine_attr(attr, hl_attr(HLF_T))
8578 #else
8579 attr
8580 #endif
8581 );
8537 col += len; 8582 col += len;
8538 } 8583 }
8539 if (modified) 8584 if (modified)
8540 screen_puts_len((char_u *)"+", 2, 0, col++, attr); 8585 screen_puts_len((char_u *)"+", 1, 0, col++, attr);
8541 screen_putchar(' ', 0, col++, attr); 8586 screen_putchar(' ', 0, col++, attr);
8542 } 8587 }
8543 8588
8544 if (buf_spname(cwp->w_buffer) != NULL) 8589 room = scol - col + tabwidth - 1;
8545 STRCPY(NameBuff, buf_spname(cwp->w_buffer)); 8590 if (room > 0)
8546 else 8591 {
8547 home_replace(cwp->w_buffer, cwp->w_buffer->b_fname, NameBuff, 8592 if (buf_spname(cwp->w_buffer) != NULL)
8593 STRCPY(NameBuff, buf_spname(cwp->w_buffer));
8594 else
8595 home_replace(cwp->w_buffer, cwp->w_buffer->b_fname, NameBuff,
8548 MAXPATHL, TRUE); 8596 MAXPATHL, TRUE);
8549 trans_characters(NameBuff, MAXPATHL); 8597 trans_characters(NameBuff, MAXPATHL);
8550 len = STRLEN(NameBuff); 8598 len = vim_strsize(NameBuff);
8551 p = NameBuff; 8599 p = NameBuff;
8552 if (len > scol - col + tabwidth - 1) /* TODO: multi-byte chars */ 8600 #ifdef FEAT_MBYTE
8553 { 8601 if (has_mbyte)
8554 p += len - (scol - col + tabwidth - 1); 8602 while (len > room)
8555 len = scol - col + tabwidth - 1; 8603 {
8556 } 8604 len -= ptr2cells(p);
8557 if (len > 0) 8605 mb_ptr_adv(p);
8558 { 8606 }
8559 screen_puts_len(p, len, 0, col, attr); 8607 else
8608 #endif
8609 if (len > room)
8610 {
8611 p += len - room;
8612 len = room;
8613 }
8614
8615 screen_puts_len(p, STRLEN(p), 0, col, attr);
8560 col += len; 8616 col += len;
8561 } 8617 }
8562 screen_putchar(' ', 0, col++, attr); 8618 screen_putchar(' ', 0, col++, attr);
8563 8619
8564 /* Store the tab page number in TabPageIdxs[], so that jump_to_mouse() 8620 /* Store the tab page number in TabPageIdxs[], so that jump_to_mouse()
8566 ++tabcount; 8622 ++tabcount;
8567 while (scol < col) 8623 while (scol < col)
8568 TabPageIdxs[scol++] = tabcount; 8624 TabPageIdxs[scol++] = tabcount;
8569 } 8625 }
8570 8626
8571 if (t_colors < 8) 8627 if (use_sep_chars)
8572 {
8573 screen_putchar('\\', 0, col++, attr);
8574 c = '_'; 8628 c = '_';
8575 }
8576 else 8629 else
8577 c = ' '; 8630 c = ' ';
8578 screen_fill(0, 1, col, (int)Columns, c, c, attr_fill); 8631 screen_fill(0, 1, col, (int)Columns, c, c, attr_fill);
8579 8632
8580 /* Put an "X" for closing the current tab if there are several. */ 8633 /* Put an "X" for closing the current tab if there are several. */
8900 #endif 8953 #endif
8901 8954
8902 #if defined(FEAT_LINEBREAK) || defined(PROTO) 8955 #if defined(FEAT_LINEBREAK) || defined(PROTO)
8903 /* 8956 /*
8904 * Return the width of the 'number' column. 8957 * Return the width of the 'number' column.
8905 * Zero when 'number' isn't set. 8958 * Caller may need to check if 'number' is set.
8906 * Otherwise it depends on 'numberwidth' and the line count. 8959 * Otherwise it depends on 'numberwidth' and the line count.
8907 */ 8960 */
8908 int 8961 int
8909 number_width(wp) 8962 number_width(wp)
8910 win_T *wp; 8963 win_T *wp;
8911 { 8964 {
8912 int n; 8965 int n;
8913 linenr_T lnum; 8966 linenr_T lnum;
8914 8967
8915 if (!wp->w_p_nu)
8916 return 0;
8917
8918 lnum = wp->w_buffer->b_ml.ml_line_count; 8968 lnum = wp->w_buffer->b_ml.ml_line_count;
8919 if (lnum == wp->w_nrwidth_line_count) 8969 if (lnum == wp->w_nrwidth_line_count)
8920 return wp->w_nrwidth_width; 8970 return wp->w_nrwidth_width;
8921 wp->w_nrwidth_line_count = lnum; 8971 wp->w_nrwidth_line_count = lnum;
8922 8972