annotate src/screen.c @ 242:a711f7a6852d v7.0067

updated for version 7.0067
author vimboss
date Sun, 17 Apr 2005 20:28:32 +0000
parents 4707450c2b33
children f93df7322443
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * screen.c: code for displaying on the screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * Output to the screen (console, terminal emulator or GUI window) is minimized
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * by remembering what is already on the screen, and only updating the parts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * that changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 * ScreenLines[off] Contains a copy of the whole screen, as it is currently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 * displayed (excluding text written by external commands).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 * ScreenAttrs[off] Contains the associated attributes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 * LineOffset[row] Contains the offset into ScreenLines*[] and ScreenAttrs[]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 * for each line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 * LineWraps[row] Flag for each line whether it wraps to the next line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 * For double-byte characters, two consecutive bytes in ScreenLines[] can form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 * one character which occupies two display cells.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 * For UTF-8 a multi-byte character is converted to Unicode and stored in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 * ScreenLinesUC[]. ScreenLines[] contains the first byte only. For an ASCII
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 * character without composing chars ScreenLinesUC[] will be 0. When the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 * character occupies two display cells the next byte in ScreenLines[] is 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 * ScreenLinesC1[] and ScreenLinesC2[] contain up to two composing characters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 * (drawn on top of the first character). They are 0 when not used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 * ScreenLines2[] is only used for euc-jp to store the second byte if the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 * first byte is 0x8e (single-width character).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 * The screen_*() functions write to the screen and handle updating
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 * ScreenLines[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 * update_screen() is the function that updates all windows and status lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 * It is called form the main loop when must_redraw is non-zero. It may be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 * called from other places when an immediated screen update is needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 * The part of the buffer that is displayed in a window is set with:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 * - w_topline (first buffer line in window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 * - w_topfill (filler line above the first line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 * - w_leftcol (leftmost window cell in window),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 * - w_skipcol (skipped window cells of first line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 * Commands that only move the cursor around in a window, do not need to take
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 * action to update the display. The main loop will check if w_topline is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 * valid and update it (scroll the window) when needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 * Commands that scroll a window change w_topline and must call
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 * check_cursor() to move the cursor into the visible part of the window, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 * call redraw_later(VALID) to have the window displayed by update_screen()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 * later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 * Commands that change text in the buffer must call changed_bytes() or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 * changed_lines() to mark the area that changed and will require updating
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 * later. The main loop will call update_screen(), which will update each
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 * window that shows the changed buffer. This assumes text above the change
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 * can remain displayed as it is. Text after the change may need updating for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 * scrolling, folding and syntax highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 * Commands that change how a window is displayed (e.g., setting 'list') or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 * invalidate the contents of a window in another way (e.g., change fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 * settings), must call redraw_later(NOT_VALID) to have the whole window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 * redisplayed by update_screen() later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 * Commands that change how a buffer is displayed (e.g., setting 'tabstop')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 * must call redraw_curbuf_later(NOT_VALID) to have all the windows for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 * buffer redisplayed by update_screen() later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 * Commands that move the window position must call redraw_later(NOT_VALID).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 * TODO: should minimize redrawing by scrolling when possible.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 * Commands that change everything (e.g., resizing the screen) must call
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 * redraw_all_later(NOT_VALID) or redraw_all_later(CLEAR).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 * Things that are handled indirectly:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 * - When messages scroll the screen up, msg_scrolled will be set and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 * update_screen() called to redraw.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 * The attributes that are actually active for writing to the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 static int screen_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 * Positioning the cursor is reduced by remembering the last position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 * Mostly used by windgoto() and screen_char().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 static int screen_cur_row, screen_cur_col; /* last known cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 * Struct used for highlighting 'hlsearch' matches for the last use search
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 * pattern or a ":match" item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 * For 'hlsearch' there is one pattern for all windows. For ":match" there is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 * a different pattern for each window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 regmmatch_T rm; /* points to the regexp program; contains last found
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 match (may continue in next line) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 buf_T *buf; /* the buffer to search for a match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 linenr_T lnum; /* the line to search for a match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 int attr; /* attributes to be used for a match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 int attr_cur; /* attributes currently active in win_line() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 linenr_T first_lnum; /* first lnum to search for multi-line pat */
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
113 colnr_T startcol; /* in win_line() points to char where HL starts */
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
114 colnr_T endcol; /* in win_line() points to char where HL ends */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 } match_T;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 static match_T search_hl; /* used for 'hlsearch' highlight matching */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 static match_T match_hl; /* used for ":match" highlight matching */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 static foldinfo_T win_foldinfo; /* info for 'foldcolumn' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 * Buffer for one screen line (characters and attributes).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 static schar_T *current_ScreenLine;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 static void win_update __ARGS((win_T *wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 static void win_draw_end __ARGS((win_T *wp, int c1, int c2, int row, int endrow, enum hlf_value hl));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 static void fold_line __ARGS((win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T lnum, int row));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 static void fill_foldcolumn __ARGS((char_u *p, win_T *wp, int closed, linenr_T lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 static void copy_text_attr __ARGS((int off, char_u *buf, int len, int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 static int win_line __ARGS((win_T *, linenr_T, int, int));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 static int char_needs_redraw __ARGS((int off_from, int off_to, int cols));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 static void screen_line __ARGS((int row, int coloff, int endcol, int clear_width, int rlflag));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 # define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c), (rl))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 static void screen_line __ARGS((int row, int coloff, int endcol, int clear_width));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 # define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 static void rl_mirror __ARGS((char_u *str));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 static void draw_vsep_win __ARGS((win_T *wp, int row));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 static void start_search_hl __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 static void end_search_hl __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 static void next_search_hl __ARGS((win_T *win, match_T *shl, linenr_T lnum, colnr_T mincol));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 static void screen_start_highlight __ARGS((int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 static void screen_char __ARGS((unsigned off, int row, int col));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 static void screen_char_2 __ARGS((unsigned off, int row, int col));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 static void screenclear2 __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 static void lineclear __ARGS((unsigned off, int width));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 static void lineinvalid __ARGS((unsigned off, int width));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 static void linecopy __ARGS((int to, int from, win_T *wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 static void redraw_block __ARGS((int row, int end, win_T *wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 static int win_do_lines __ARGS((win_T *wp, int row, int line_count, int mayclear, int del));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 static void win_rest_invalid __ARGS((win_T *wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 static int screen_ins_lines __ARGS((int, int, int, int, win_T *wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 static void msg_pos_mode __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 static int fillchar_status __ARGS((int *attr, int is_curwin));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 static int fillchar_vsep __ARGS((int *attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 #ifdef FEAT_STL_OPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 static void win_redr_custom __ARGS((win_T *wp, int Ruler));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 #ifdef FEAT_CMDL_INFO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 static void win_redr_ruler __ARGS((win_T *wp, int always));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 /* Ugly global: overrule attribute used by screen_char() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 static int screen_char_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 * Redraw the current window later, with update_screen(type).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 * Set must_redraw only if not already set to a higher value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 * e.g. if must_redraw is CLEAR, type NOT_VALID will do nothing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 redraw_later(type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 redraw_win_later(curwin, type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 redraw_win_later(wp, type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 if (wp->w_redr_type < type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 wp->w_redr_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 if (type >= NOT_VALID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 wp->w_lines_valid = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 if (must_redraw < type) /* must_redraw is the maximum of all windows */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 must_redraw = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 * Force a complete redraw later. Also resets the highlighting. To be used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 * after executing a shell command that messes up the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 redraw_later_clear()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 redraw_all_later(CLEAR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 screen_attr = HL_BOLD | HL_UNDERLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 * Mark all windows to be redrawn later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 redraw_all_later(type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 redraw_win_later(wp, type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 * Mark all windows that are editing the current buffer to be udpated later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 redraw_curbuf_later(type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 redraw_buf_later(curbuf, type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 redraw_buf_later(buf, type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 if (wp->w_buffer == buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 redraw_win_later(wp, type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 * Changed something in the current window, at buffer line "lnum", that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 * requires that line and possibly other lines to be redrawn.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 * Used when entering/leaving Insert mode with the cursor on a folded line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 * Used to remove the "$" from a change command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 * Note that when also inserting/deleting lines w_redraw_top and w_redraw_bot
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 * may become invalid and the whole window will have to be redrawn.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 redrawWinline(lnum, invalid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 int invalid; /* window line height is invalid now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 if (curwin->w_redraw_top == 0 || curwin->w_redraw_top > lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 curwin->w_redraw_top = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 if (curwin->w_redraw_bot == 0 || curwin->w_redraw_bot < lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 curwin->w_redraw_bot = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 if (invalid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 /* A w_lines[] entry for this lnum has become invalid. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 i = find_wl_entry(curwin, lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 if (i >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 curwin->w_lines[i].wl_valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 * update all windows that are editing the current buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 update_curbuf(type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 redraw_curbuf_later(type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 update_screen(type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 * update_screen()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 * Based on the current value of curwin->w_topline, transfer a screenfull
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 * of stuff from Filemem to ScreenLines[], and update curwin->w_botline.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 update_screen(type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 static int did_intro = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 int did_one;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 if (!screen_valid(TRUE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 if (must_redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 if (type < must_redraw) /* use maximal type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 type = must_redraw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 must_redraw = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 /* Need to update w_lines[]. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 if (curwin->w_lines_valid == 0 && type < NOT_VALID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 type = NOT_VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 if (!redrawing())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 redraw_later(type); /* remember type for next time */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 must_redraw = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 if (type > INVERTED_ALL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 curwin->w_lines_valid = 0; /* don't use w_lines[].wl_size now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 updating_screen = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 ++display_tick; /* let syntax code know we're in a next round of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 * display updating */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 * if the screen was scrolled up when displaying a message, scroll it down
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 if (msg_scrolled)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 clear_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 if (msg_scrolled > Rows - 5) /* clearing is faster */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 type = CLEAR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 else if (type != CLEAR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, NULL) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 type = CLEAR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 if (W_WINROW(wp) < msg_scrolled)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 if (W_WINROW(wp) + wp->w_height > msg_scrolled
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 && wp->w_redr_type < REDRAW_TOP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 && wp->w_lines_valid > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 && wp->w_topline == wp->w_lines[0].wl_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 wp->w_upd_rows = msg_scrolled - W_WINROW(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 wp->w_redr_type = REDRAW_TOP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 wp->w_redr_type = NOT_VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 if (W_WINROW(wp) + wp->w_height + W_STATUS_HEIGHT(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 <= msg_scrolled)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 msg_scrolled = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 /* reset cmdline_row now (may have been changed temporarily) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 compute_cmdrow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 /* Check for changed highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 if (need_highlight_changed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 highlight_changed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 if (type == CLEAR) /* first clear screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 screenclear(); /* will reset clear_cmdline */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 type = NOT_VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 if (clear_cmdline) /* going to clear cmdline (done below) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
418 #ifdef FEAT_LINEBREAK
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
419 /* Force redraw when width of 'number' column changes. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
420 if (curwin->w_redr_type < NOT_VALID
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
421 && curwin->w_nrwidth != number_width(curwin))
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
422 curwin->w_redr_type = NOT_VALID;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
423 #endif
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
424
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 * Only start redrawing if there is really something to do.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 if (type == INVERTED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 update_curswant();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 if (curwin->w_redr_type < type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 && !((type == VALID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 && curwin->w_lines[0].wl_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 && curwin->w_topfill == curwin->w_old_topfill
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 && curwin->w_botfill == curwin->w_old_botfill
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 && curwin->w_topline == curwin->w_lines[0].wl_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 || (type == INVERTED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 && curwin->w_old_cursor_lnum == curwin->w_cursor.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 && curwin->w_old_visual_mode == VIsual_mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 && (curwin->w_valid & VALID_VIRTCOL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 && curwin->w_old_curswant == curwin->w_curswant)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 ))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 curwin->w_redr_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 * Correct stored syntax highlighting info for changes in each displayed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 * buffer. Each buffer must only be done once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 if (wp->w_buffer->b_mod_set)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 # ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 win_T *wwp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 /* Check if we already did this buffer. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 for (wwp = firstwin; wwp != wp; wwp = wwp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 if (wwp->w_buffer == wp->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 # ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 wwp == wp &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 syntax_present(wp->w_buffer))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 syn_stack_apply_changes(wp->w_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 * Go from top to bottom through the windows, redrawing the ones that need
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 * it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 did_one = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 search_hl.rm.regprog = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 if (wp->w_redr_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 cursor_off();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 if (!did_one)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 did_one = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 # ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 start_search_hl();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 # ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 /* When Visual area changed, may have to update selection. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 if (clip_star.available && clip_isautosel())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 clip_update_selection();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 /* Remove the cursor before starting to do anything, because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 * scrolling may make it difficult to redraw the text under
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 * it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 gui_undraw_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 win_update(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 /* redraw status line after the window to minimize cursor movement */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 if (wp->w_redr_status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 cursor_off();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 win_redr_status(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 #if defined(FEAT_SEARCH_EXTRA)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 end_search_hl();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 /* Reset b_mod_set flags. Going through all windows is probably faster
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 * than going through all buffers (there could be many buffers). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 for (wp = firstwin; wp != NULL; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 wp->w_buffer->b_mod_set = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 curbuf->b_mod_set = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 updating_screen = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 gui_may_resize_shell();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 /* Clear or redraw the command line. Done last, because scrolling may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 * mess up the command line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 if (clear_cmdline || redraw_cmdline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 showmode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 /* May put up an introductory message when not editing a file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 if (!did_intro && bufempty()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 && curbuf->b_fname == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 && firstwin->w_next == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 && vim_strchr(p_shm, SHM_INTRO) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 intro_message(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 did_intro = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 /* Redraw the cursor and update the scrollbars when all screen updating is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 * done. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 out_flush(); /* required before updating the cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 if (did_one)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 gui_update_cursor(FALSE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 gui_update_scrollbars(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 #if defined(FEAT_SIGNS) || defined(FEAT_GUI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 static void update_prepare __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 static void update_finish __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 * Prepare for updating one or more windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 update_prepare()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 cursor_off();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 updating_screen = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 /* Remove the cursor before starting to do anything, because scrolling may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 * make it difficult to redraw the text under it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 gui_undraw_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 start_search_hl();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 * Finish updating one or more windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 update_finish()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 if (redraw_cmdline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 showmode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 # ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 end_search_hl();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 updating_screen = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 gui_may_resize_shell();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 /* Redraw the cursor and update the scrollbars when all screen updating is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 * done. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 out_flush(); /* required before updating the cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 gui_update_cursor(FALSE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 gui_update_scrollbars(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 #if defined(FEAT_SIGNS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 update_debug_sign(buf, lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 int doit = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 # ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 win_foldinfo.fi_level = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 /* update/delete a specific mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 if (buf != NULL && lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 if (wp->w_buffer == buf && lnum >= wp->w_topline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 && lnum < wp->w_botline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 wp->w_redraw_top = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 wp->w_redraw_bot = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 redraw_win_later(wp, VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 redraw_win_later(wp, VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 if (wp->w_redr_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 doit = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 if (!doit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 /* update all windows that need updating */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 update_prepare();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 # ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 for (wp = firstwin; wp; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 if (wp->w_redr_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 win_update(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 if (wp->w_redr_status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 win_redr_status(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 if (curwin->w_redr_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 win_update(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 update_finish();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 #if defined(FEAT_GUI) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 * Update a single window, its status line and maybe the command line msg.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 * Used for the GUI scrollbar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 updateWindow(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 update_prepare();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 #ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 /* When Visual area changed, may have to update selection. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 if (clip_star.available && clip_isautosel())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 clip_update_selection();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 win_update(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 if (wp->w_redr_status
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 # ifdef FEAT_CMDL_INFO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 || p_ru
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 # ifdef FEAT_STL_OPT
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
703 || *p_stl != NUL || *wp->w_p_stl != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 win_redr_status(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 update_finish();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 * Update a single window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 * This may cause the windows below it also to be redrawn (when clearing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 * screen or scrolling lines).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 * How the window is redrawn depends on wp->w_redr_type. Each type also
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 * implies the one below it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 * NOT_VALID redraw the whole window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 * REDRAW_TOP redraw the top w_upd_rows window lines, otherwise like VALID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 * INVERTED redraw the changed part of the Visual area
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 * INVERTED_ALL redraw the whole Visual area
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 * VALID 1. scroll up/down to adjust for a changed w_topline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 * 2. update lines at the top when scrolled down
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 * 3. redraw changed text:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 * - if wp->w_buffer->b_mod_set set, udpate lines between
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 * b_mod_top and b_mod_bot.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 * - if wp->w_redraw_top non-zero, redraw lines between
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 * wp->w_redraw_top and wp->w_redr_bot.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 * - continue redrawing when syntax status is invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 * 4. if scrolled up, update lines at the bottom.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 * This results in three areas that may need updating:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 * top: from first row to top_end (when scrolled down)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 * mid: from mid_start to mid_end (update inversion or changed text)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 * bot: from bot_start to last row (when scrolled up)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 win_update(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 buf_T *buf = wp->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 int top_end = 0; /* Below last row of the top area that needs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 updating. 0 when no top area updating. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 int mid_start = 999;/* first row of the mid area that needs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 updating. 999 when no mid area updating. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 int mid_end = 0; /* Below last row of the mid area that needs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 updating. 0 when no mid area updating. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 int bot_start = 999;/* first row of the bot area that needs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 updating. 999 when no bot area updating */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 int scrolled_down = FALSE; /* TRUE when scrolled down when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 w_topline got smaller a bit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 int top_to_mod = FALSE; /* redraw above mod_top */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 int row; /* current window row to display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 linenr_T lnum; /* current buffer lnum to display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 int idx; /* current index in w_lines[] */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 int srow; /* starting row of the current line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 int eof = FALSE; /* if TRUE, we hit the end of the file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 int didline = FALSE; /* if TRUE, we finished the last line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 long j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 static int recursive = FALSE; /* being called recursively */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 int old_botline = wp->w_botline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 long fold_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 /* remember what happened to the previous line, to know if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 * check_visual_highlight() can be used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 #define DID_NONE 1 /* didn't update a line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 #define DID_LINE 2 /* updated a normal line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 #define DID_FOLD 3 /* updated a folded line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 int did_update = DID_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 linenr_T syntax_last_parsed = 0; /* last parsed text line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 linenr_T mod_top = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 linenr_T mod_bot = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 int save_got_int;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 type = wp->w_redr_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 if (type == NOT_VALID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 wp->w_lines_valid = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 /* Window is zero-height: nothing to draw. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 if (wp->w_height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 wp->w_redr_type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 /* Window is zero-width: Only need to draw the separator. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 if (wp->w_width == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 /* draw the vertical separator right of this window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 draw_vsep_win(wp, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 wp->w_redr_type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 /* Setup for ":match" highlighting. Disable any previous match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 match_hl.rm = wp->w_match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 if (wp->w_match_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 match_hl.attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 match_hl.attr = syn_id2attr(wp->w_match_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 match_hl.buf = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 match_hl.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 search_hl.buf = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 search_hl.lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 search_hl.first_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
832 #ifdef FEAT_LINEBREAK
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
833 /* Force redraw when width of 'number' column changes. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
834 i = number_width(curwin);
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
835 if (curwin->w_nrwidth != i)
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
836 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
837 type = NOT_VALID;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
838 curwin->w_nrwidth = i;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
839 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
840 else
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
841 #endif
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
842
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 * When there are both inserted/deleted lines and specific lines to be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 * redrawn, w_redraw_top and w_redraw_bot may be invalid, just redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 * everything (only happens when redrawing is off for while).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 type = NOT_VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 * Set mod_top to the first line that needs displaying because of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 * changes. Set mod_bot to the first line after the changes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 mod_top = wp->w_redraw_top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 if (wp->w_redraw_bot != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 mod_bot = wp->w_redraw_bot + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 mod_bot = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 wp->w_redraw_top = 0; /* reset for next time */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 wp->w_redraw_bot = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 if (buf->b_mod_set)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 if (mod_top == 0 || mod_top > buf->b_mod_top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 mod_top = buf->b_mod_top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 /* Need to redraw lines above the change that may be included
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 * in a pattern match. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 if (syntax_present(buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 mod_top -= buf->b_syn_sync_linebreaks;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 if (mod_top < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 mod_top = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 if (mod_bot == 0 || mod_bot < buf->b_mod_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 mod_bot = buf->b_mod_bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 /* When 'hlsearch' is on and using a multi-line search pattern, a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 * change in one line may make the Search highlighting in a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 * previous line invalid. Simple solution: redraw all visible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 * lines above the change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 * Same for a ":match" pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 if ((search_hl.rm.regprog != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 && re_multiline(search_hl.rm.regprog))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 || (match_hl.rm.regprog != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 && re_multiline(match_hl.rm.regprog)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 top_to_mod = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 if (mod_top != 0 && hasAnyFolding(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 linenr_T lnumt, lnumb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 * A change in a line can cause lines above it to become folded or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 * unfolded. Find the top most buffer line that may be affected.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 * If the line was previously folded and displayed, get the first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 * line of that fold. If the line is folded now, get the first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 * folded line. Use the minimum of these two.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 /* Find last valid w_lines[] entry above mod_top. Set lnumt to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 * the line below it. If there is no valid entry, use w_topline.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 * Find the first valid w_lines[] entry below mod_bot. Set lnumb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 * to this line. If there is no valid entry, use MAXLNUM. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 lnumt = wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 lnumb = MAXLNUM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 for (i = 0; i < wp->w_lines_valid; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 if (wp->w_lines[i].wl_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 if (wp->w_lines[i].wl_lastlnum < mod_top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 lnumt = wp->w_lines[i].wl_lastlnum + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 if (lnumb == MAXLNUM && wp->w_lines[i].wl_lnum >= mod_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 lnumb = wp->w_lines[i].wl_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 /* When there is a fold column it might need updating
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 * in the next line ("J" just above an open fold). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 if (wp->w_p_fdc > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 ++lnumb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 (void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 if (mod_top > lnumt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 mod_top = lnumt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 /* Now do the same for the bottom line (one above mod_bot). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 --mod_bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 (void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 ++mod_bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 if (mod_bot < lnumb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 mod_bot = lnumb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 /* When a change starts above w_topline and the end is below
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 * w_topline, start redrawing at w_topline.
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
947 * If the end of the change is above w_topline: do like no change was
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
948 * made, but redraw the first line to find changes in syntax. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 if (mod_top != 0 && mod_top < wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 if (mod_bot > wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 mod_top = wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 else if (syntax_present(buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 top_end = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 }
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
958
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
959 /* When line numbers are displayed need to redraw all lines below
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
960 * inserted/deleted lines. */
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
961 if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu)
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
962 mod_bot = MAXLNUM;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 * When only displaying the lines at the top, set top_end. Used when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 * window has scrolled down for msg_scrolled.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 if (type == REDRAW_TOP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 j = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 for (i = 0; i < wp->w_lines_valid; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 j += wp->w_lines[i].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 if (j >= wp->w_upd_rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 top_end = j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 if (top_end == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 /* not found (cannot happen?): redraw everything */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 type = NOT_VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 /* top area defined, the rest is VALID */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 type = VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 * If there are no changes on the screen that require a complete redraw,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 * handle three cases:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 * 1: we are off the top of the screen by a few lines: scroll down
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 * 2: wp->w_topline is below wp->w_lines[0].wl_lnum: may scroll up
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 * 3: wp->w_topline is wp->w_lines[0].wl_lnum: find first entry in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 * w_lines[] that needs updating.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 if ((type == VALID || type == INVERTED || type == INVERTED_ALL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 && !wp->w_botfill && !wp->w_old_botfill
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 if (mod_top != 0 && wp->w_topline == mod_top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 * w_topline is the first changed line, the scrolling will be done
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 * further down.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 else if (wp->w_lines[0].wl_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 && (wp->w_topline < wp->w_lines[0].wl_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 || (wp->w_topline == wp->w_lines[0].wl_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 && wp->w_topfill > wp->w_old_topfill)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 ))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 * New topline is above old topline: May scroll down.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 if (hasAnyFolding(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 linenr_T ln;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 /* count the number of lines we are off, counting a sequence
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 * of folded lines as one */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 j = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 for (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ++ln)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 ++j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 if (j >= wp->w_height - 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 (void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 j = wp->w_lines[0].wl_lnum - wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 if (j < wp->w_height - 2) /* not too far off */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 i = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 /* insert extra lines for previously invisible filler lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 if (wp->w_lines[0].wl_lnum != wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 i += diff_check_fill(wp, wp->w_lines[0].wl_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 - wp->w_old_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 if (i < wp->w_height - 2) /* less than a screen off */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 * Try to insert the correct number of lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 * If not the last window, delete the lines at the bottom.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 * win_ins_lines may fail when the terminal can't do it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 if (i > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 if (win_ins_lines(wp, 0, i, FALSE, wp == firstwin) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 if (wp->w_lines_valid != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 /* Need to update rows that are new, stop at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 * first one that scrolled down. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 top_end = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 scrolled_down = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 /* Move the entries that were scrolled, disable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 * the entries for the lines to be redrawn. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 if ((wp->w_lines_valid += j) > wp->w_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 wp->w_lines_valid = wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 for (idx = wp->w_lines_valid; idx - j >= 0; idx--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 wp->w_lines[idx] = wp->w_lines[idx - j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 while (idx >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 wp->w_lines[idx--].wl_valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 mid_start = 0; /* redraw all lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 mid_start = 0; /* redraw all lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 mid_start = 0; /* redraw all lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 * New topline is at or below old topline: May scroll up.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 * When topline didn't change, find first entry in w_lines[] that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 * needs updating.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 /* try to find wp->w_topline in wp->w_lines[].wl_lnum */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 j = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 row = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 for (i = 0; i < wp->w_lines_valid; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 if (wp->w_lines[i].wl_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 && wp->w_lines[i].wl_lnum == wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 j = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 row += wp->w_lines[i].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 if (j == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 /* if wp->w_topline is not in wp->w_lines[].wl_lnum redraw all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 * lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 mid_start = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 * Try to delete the correct number of lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 * wp->w_topline is at wp->w_lines[i].wl_lnum.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 /* If the topline didn't change, delete old filler lines,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 * otherwise delete filler lines of the new topline... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 if (wp->w_lines[0].wl_lnum == wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 row += wp->w_old_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 row += diff_check_fill(wp, wp->w_topline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 /* ... but don't delete new filler lines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 row -= wp->w_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 if (row > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 if (win_del_lines(wp, 0, row, FALSE, wp == firstwin) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 bot_start = wp->w_height - row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 mid_start = 0; /* redraw all lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 if ((row == 0 || bot_start < 999) && wp->w_lines_valid != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 * Skip the lines (below the deleted lines) that are still
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 * valid and don't need redrawing. Copy their info
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 * upwards, to compensate for the deleted lines. Set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 * bot_start to the first row that needs redrawing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 bot_start = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 wp->w_lines[idx] = wp->w_lines[j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 /* stop at line that didn't fit, unless it is still
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 * valid (no lines deleted) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 if (row > 0 && bot_start + row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 + (int)wp->w_lines[j].wl_size > wp->w_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 wp->w_lines_valid = idx + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 bot_start += wp->w_lines[idx++].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 /* stop at the last valid entry in w_lines[].wl_size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 if (++j >= wp->w_lines_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 wp->w_lines_valid = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 /* Correct the first entry for filler lines at the top
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 * when it won't get updated below. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 if (wp->w_p_diff && bot_start > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 wp->w_lines[0].wl_size =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 plines_win_nofill(wp, wp->w_topline, TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 + wp->w_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 /* When starting redraw in the first line, redraw all lines. When
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 * there is only one window it's probably faster to clear the screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 * first. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 if (mid_start == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 mid_end = wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 if (lastwin == firstwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 screenclear();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 /* Not VALID or INVERTED: redraw all lines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 mid_start = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 mid_end = wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 /* check if we are updating or removing the inverted part */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 if ((VIsual_active && buf == curwin->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 || (wp->w_old_cursor_lnum != 0 && type != NOT_VALID))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 linenr_T from, to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 if (VIsual_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 if (VIsual_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 && (VIsual_mode != wp->w_old_visual_mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 || type == INVERTED_ALL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 * If the type of Visual selection changed, redraw the whole
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 * selection. Also when the ownership of the X selection is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 * gained or lost.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 if (curwin->w_cursor.lnum < VIsual.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 from = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 to = VIsual.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 from = VIsual.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 to = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 /* redraw more when the cursor moved as well */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 if (wp->w_old_cursor_lnum < from)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 from = wp->w_old_cursor_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 if (wp->w_old_cursor_lnum > to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 to = wp->w_old_cursor_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 if (wp->w_old_visual_lnum < from)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 from = wp->w_old_visual_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 if (wp->w_old_visual_lnum > to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 to = wp->w_old_visual_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 * Find the line numbers that need to be updated: The lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 * between the old cursor position and the current cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 * position. Also check if the Visual position changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 if (curwin->w_cursor.lnum < wp->w_old_cursor_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 from = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 to = wp->w_old_cursor_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 from = wp->w_old_cursor_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 to = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 if (from == 0) /* Visual mode just started */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 from = to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 if (VIsual.lnum != wp->w_old_visual_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 if (wp->w_old_visual_lnum < from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 && wp->w_old_visual_lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 from = wp->w_old_visual_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 if (wp->w_old_visual_lnum > to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 to = wp->w_old_visual_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 if (VIsual.lnum < from)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 from = VIsual.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 if (VIsual.lnum > to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 to = VIsual.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 * If in block mode and changed column or curwin->w_curswant:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 * update all lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 * First compute the actual start and end column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 if (VIsual_mode == Ctrl_V)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 colnr_T fromc, toc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 ++toc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 if (curwin->w_curswant == MAXCOL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 toc = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 if (fromc != wp->w_old_cursor_fcol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 || toc != wp->w_old_cursor_lcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 if (from > VIsual.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 from = VIsual.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 if (to < VIsual.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 to = VIsual.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 wp->w_old_cursor_fcol = fromc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 wp->w_old_cursor_lcol = toc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 /* Use the line numbers of the old Visual area. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 if (wp->w_old_cursor_lnum < wp->w_old_visual_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 from = wp->w_old_cursor_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 to = wp->w_old_visual_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 from = wp->w_old_visual_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 to = wp->w_old_cursor_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 * There is no need to update lines above the top of the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 if (from < wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 from = wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 * If we know the value of w_botline, use it to restrict the update to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 * the lines that are visible in the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 if (wp->w_valid & VALID_BOTLINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 if (from >= wp->w_botline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 from = wp->w_botline - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 if (to >= wp->w_botline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 to = wp->w_botline - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 * Find the minimal part to be updated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 * Watch out for scrolling that made entries in w_lines[] invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 * E.g., CTRL-U makes the first half of w_lines[] invalid and sets
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 * top_end; need to redraw from top_end to the "to" line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 * A middle mouse click with a Visual selection may change the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 * above the Visual area and reset wl_valid, do count these for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 * mid_end (in srow).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 if (mid_start > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 lnum = wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 srow = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 if (scrolled_down)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 mid_start = top_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 mid_start = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 while (lnum < from && idx < wp->w_lines_valid) /* find start */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 if (wp->w_lines[idx].wl_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 mid_start += wp->w_lines[idx].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 else if (!scrolled_down)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 srow += wp->w_lines[idx].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 # ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 if (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 lnum = wp->w_lines[idx].wl_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 srow += mid_start;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 mid_end = wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 for ( ; idx < wp->w_lines_valid; ++idx) /* find end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 if (wp->w_lines[idx].wl_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 && wp->w_lines[idx].wl_lnum >= to + 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 /* Only update until first row of this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 mid_end = srow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 srow += wp->w_lines[idx].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 if (VIsual_active && buf == curwin->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 wp->w_old_visual_mode = VIsual_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 wp->w_old_cursor_lnum = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 wp->w_old_visual_lnum = VIsual.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 wp->w_old_curswant = curwin->w_curswant;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 wp->w_old_visual_mode = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 wp->w_old_cursor_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 wp->w_old_visual_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 #endif /* FEAT_VISUAL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 /* reset got_int, otherwise regexp won't work */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 save_got_int = got_int;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 got_int = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 win_foldinfo.fi_level = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 * Update all the window rows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 idx = 0; /* first entry in w_lines[].wl_size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 row = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 srow = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 lnum = wp->w_topline; /* first line shown in window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 /* stop updating when reached the end of the window (check for _past_
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 * the end of the window is at the end of the loop) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 if (row == wp->w_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 didline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 /* stop updating when hit the end of the file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 if (lnum > buf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 eof = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 /* Remember the starting row of the line that is going to be dealt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 * with. It is used further down when the line doesn't fit. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 srow = row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 * Update a line when it is in an area that needs updating, when it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 * has changes or w_lines[idx] is invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 * bot_start may be halfway a wrapped line after using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 * win_del_lines(), check if the current line includes it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 * When syntax folding is being used, the saved syntax states will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 * already have been updated, we can't see where the syntax state is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 * the same again, just update until the end of the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 if (row < top_end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 || (row >= mid_start && row < mid_end)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 || top_to_mod
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 || idx >= wp->w_lines_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 || (row + wp->w_lines[idx].wl_size > bot_start)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 || (mod_top != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 && (lnum == mod_top
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 || (lnum >= mod_top
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 && (lnum < mod_bot
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 || did_update == DID_FOLD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 || (did_update == DID_LINE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 && syntax_present(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 && (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 # ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 (foldmethodIsSyntax(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 && hasAnyFolding(wp)) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 syntax_check_changed(lnum)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 )))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 if (lnum == mod_top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 top_to_mod = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 * When at start of changed lines: May scroll following lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 * up or down to minimize redrawing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 * Don't do this when the change continues until the end.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 * Don't scroll when dollar_vcol is non-zero, keep the "$".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 if (lnum == mod_top
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 && mod_bot != MAXLNUM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 && !(dollar_vcol != 0 && mod_bot == mod_top + 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 int old_rows = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 int new_rows = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 int xtra_rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 linenr_T l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 /* Count the old number of window rows, using w_lines[], which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 * should still contain the sizes for the lines as they are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 * currently displayed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 for (i = idx; i < wp->w_lines_valid; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 /* Only valid lines have a meaningful wl_lnum. Invalid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 * lines are part of the changed area. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 if (wp->w_lines[i].wl_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 && wp->w_lines[i].wl_lnum == mod_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 old_rows += wp->w_lines[i].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 if (wp->w_lines[i].wl_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 && wp->w_lines[i].wl_lastlnum + 1 == mod_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 /* Must have found the last valid entry above mod_bot.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 * Add following invalid entries. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 ++i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 while (i < wp->w_lines_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 && !wp->w_lines[i].wl_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 old_rows += wp->w_lines[i++].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 if (i >= wp->w_lines_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 /* We can't find a valid line below the changed lines,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 * need to redraw until the end of the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 * Inserting/deleting lines has no use. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 bot_start = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 /* Able to count old number of rows: Count new window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 * rows, and may insert/delete lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 j = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 for (l = lnum; l < mod_bot; ++l)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 ++new_rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 if (l == wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 new_rows += plines_win_nofill(wp, l, TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 + wp->w_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 new_rows += plines_win(wp, l, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 ++j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 if (new_rows > wp->w_height - row - 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 /* it's getting too much, must redraw the rest */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 new_rows = 9999;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 xtra_rows = new_rows - old_rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 if (xtra_rows < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 /* May scroll text up. If there is not enough
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 * remaining text or scrolling fails, must redraw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 * rest. If scrolling works, must redraw the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 * below the scrolled text. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 if (row - xtra_rows >= wp->w_height - 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 mod_bot = MAXLNUM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 if (win_del_lines(wp, row,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 -xtra_rows, FALSE, FALSE) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 mod_bot = MAXLNUM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 bot_start = wp->w_height + xtra_rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 else if (xtra_rows > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 /* May scroll text down. If there is not enough
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 * remaining text of scrolling fails, must redraw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 * rest. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 if (row + xtra_rows >= wp->w_height - 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 mod_bot = MAXLNUM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 if (win_ins_lines(wp, row + old_rows,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 xtra_rows, FALSE, FALSE) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 mod_bot = MAXLNUM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 else if (top_end > row + old_rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 /* Scrolled the part at the top that requires
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 * updating down. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 top_end += xtra_rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 /* When not updating the rest, may need to move w_lines[]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 * entries. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 if (mod_bot != MAXLNUM && i != j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 if (j < i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 int x = row + new_rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 /* move entries in w_lines[] upwards */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592 /* stop at last valid entry in w_lines[] */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 if (i >= wp->w_lines_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 wp->w_lines_valid = j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 wp->w_lines[j] = wp->w_lines[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 /* stop at a line that won't fit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 if (x + (int)wp->w_lines[j].wl_size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 > wp->w_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 wp->w_lines_valid = j + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 x += wp->w_lines[j++].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 ++i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 if (bot_start > x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 bot_start = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 else /* j > i */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614 /* move entries in w_lines[] downwards */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 j -= i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 wp->w_lines_valid += j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 if (wp->w_lines_valid > wp->w_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 wp->w_lines_valid = wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 for (i = wp->w_lines_valid; i - j >= idx; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 wp->w_lines[i] = wp->w_lines[i - j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 /* The w_lines[] entries for inserted lines are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 * now invalid, but wl_size may be used above.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 * Reset to zero. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 while (i >= idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627 wp->w_lines[i].wl_size = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 wp->w_lines[i--].wl_valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 * When lines are folded, display one line for all of them.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 * Otherwise, display normally (can be several display lines when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 * 'wrap' is on).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 fold_count = foldedCount(wp, lnum, &win_foldinfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 if (fold_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 fold_line(wp, fold_count, &win_foldinfo, lnum, row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 ++row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 --fold_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 wp->w_lines[idx].wl_folded = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 wp->w_lines[idx].wl_lastlnum = lnum + fold_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 # ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 did_update = DID_FOLD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 if (idx < wp->w_lines_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 && wp->w_lines[idx].wl_valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 && wp->w_lines[idx].wl_lnum == lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 && lnum > wp->w_topline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659 && !(dy_flags & DY_LASTLINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660 && srow + wp->w_lines[idx].wl_size > wp->w_height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 && diff_check_fill(wp, lnum) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 /* This line is not going to fit. Don't draw anything here,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 * will draw "@ " lines below. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 row = wp->w_height + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 prepare_search_hl(wp, lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 /* Let the syntax stuff know we skipped a few lines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 && syntax_present(buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 syntax_end_parsing(syntax_last_parsed + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 * Display one line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 row = win_line(wp, lnum, srow, wp->w_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 wp->w_lines[idx].wl_folded = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 wp->w_lines[idx].wl_lastlnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 did_update = DID_LINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 syntax_last_parsed = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 wp->w_lines[idx].wl_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 wp->w_lines[idx].wl_valid = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 if (row > wp->w_height) /* past end of screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 /* we may need the size of that too long line later on */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 if (dollar_vcol == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 wp->w_lines[idx].wl_size = plines_win(wp, lnum, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 if (dollar_vcol == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 wp->w_lines[idx].wl_size = row - srow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 lnum += fold_count + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 /* This line does not need updating, advance to the next one */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 row += wp->w_lines[idx++].wl_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 if (row > wp->w_height) /* past end of screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 lnum = wp->w_lines[idx - 1].wl_lastlnum + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 did_update = DID_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 if (lnum > buf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734 eof = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 * End of loop over all window lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 if (idx > wp->w_lines_valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 wp->w_lines_valid = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 * Let the syntax stuff know we stop parsing here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 if (syntax_last_parsed != 0 && syntax_present(buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 syntax_end_parsing(syntax_last_parsed + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 * If we didn't hit the end of the file, and we didn't finish the last
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 * line we were working on, then the line didn't fit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 wp->w_empty_rows = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 wp->w_filler_rows = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 if (!eof && !didline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 if (lnum == wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 * Single line that does not fit!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 * Don't overwrite it, it can be edited.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 wp->w_botline = lnum + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 else if (diff_check_fill(wp, lnum) >= wp->w_height - srow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 /* Window ends in filler lines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 wp->w_botline = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 wp->w_filler_rows = wp->w_height - srow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 else if (dy_flags & DY_LASTLINE) /* 'display' has "lastline" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 * Last line isn't finished: Display "@@@" at the end.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 screen_fill(W_WINROW(wp) + wp->w_height - 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 W_WINROW(wp) + wp->w_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 (int)W_ENDCOL(wp) - 3, (int)W_ENDCOL(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 '@', '@', hl_attr(HLF_AT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 set_empty_rows(wp, srow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 wp->w_botline = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 win_draw_end(wp, '@', ' ', srow, wp->w_height, HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 wp->w_botline = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 draw_vsep_win(wp, row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 if (eof) /* we hit the end of the file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 wp->w_botline = buf->b_ml.ml_line_count + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 j = diff_check_fill(wp, wp->w_botline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 if (j > 0 && !wp->w_botfill)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 * Display filler lines at the end of the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 if (char2cells(fill_diff) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 i = '-';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 i = fill_diff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 if (row + j > wp->w_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 j = wp->w_height - row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 win_draw_end(wp, i, i, row, row + (int)j, HLF_DED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 row += j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 else if (dollar_vcol == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 wp->w_botline = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 /* make sure the rest of the screen is blank */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 /* put '~'s on rows that aren't part of the file. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 win_draw_end(wp, '~', ' ', row, wp->w_height, HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 /* Reset the type of redrawing required, the window has been updated. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 wp->w_redr_type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 wp->w_old_topfill = wp->w_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 wp->w_old_botfill = wp->w_botfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 if (dollar_vcol == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 * There is a trick with w_botline. If we invalidate it on each
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 * change that might modify it, this will cause a lot of expensive
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 * calls to plines() in update_topline() each time. Therefore the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 * value of w_botline is often approximated, and this value is used to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 * compute the value of w_topline. If the value of w_botline was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 * wrong, check that the value of w_topline is correct (cursor is on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 * the visible part of the text). If it's not, we need to redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 * again. Mostly this just means scrolling up a few lines, so it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 * doesn't look too bad. Only do this for the current window (where
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 * changes are relevant).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 wp->w_valid |= VALID_BOTLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 if (wp == curwin && wp->w_botline != old_botline && !recursive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 recursive = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 curwin->w_valid &= ~VALID_TOPLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 update_topline(); /* may invalidate w_botline again */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 if (must_redraw != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 /* Don't update for changes in buffer again. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 i = curbuf->b_mod_set;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 curbuf->b_mod_set = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 win_update(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 must_redraw = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 curbuf->b_mod_set = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 recursive = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 /* restore got_int, unless CTRL-C was hit while redrawing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 if (!got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 got_int = save_got_int;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 #ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 static int draw_signcolumn __ARGS((win_T *wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883 * Return TRUE when window "wp" has a column to draw signs in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 draw_signcolumn(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 return (wp->w_buffer->b_signlist != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 # ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 || usingNetbeans
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 * Clear the rest of the window and mark the unused lines with "c1". use "c2"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 * as the filler character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 win_draw_end(wp, c1, c2, row, endrow, hl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 int c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 int c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 int endrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 enum hlf_value hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 #if defined(FEAT_FOLDING) || defined(FEAT_SIGNS) || defined(FEAT_CMDWIN)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 # define FDC_OFF n
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 # define FDC_OFF 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 /* No check for cmdline window: should never be right-left. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 # ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 n = wp->w_p_fdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 if (n > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 /* draw the fold column at the right */
119
e8f07016e34d updated for version 7.0042
vimboss
parents: 67
diff changeset
1927 if (n > W_WIDTH(wp))
e8f07016e34d updated for version 7.0042
vimboss
parents: 67
diff changeset
1928 n = W_WIDTH(wp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 W_ENDCOL(wp) - n, (int)W_ENDCOL(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 ' ', ' ', hl_attr(HLF_FC));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 # ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 if (draw_signcolumn(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937 int nn = n + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 /* draw the sign column left of the fold column */
119
e8f07016e34d updated for version 7.0042
vimboss
parents: 67
diff changeset
1940 if (nn > W_WIDTH(wp))
e8f07016e34d updated for version 7.0042
vimboss
parents: 67
diff changeset
1941 nn = W_WIDTH(wp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 W_ENDCOL(wp) - nn, (int)W_ENDCOL(wp) - n,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 ' ', ' ', hl_attr(HLF_SC));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 n = nn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 W_WINCOL(wp), W_ENDCOL(wp) - 1 - FDC_OFF,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 c2, c2, hl_attr(hl));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 W_ENDCOL(wp) - 1 - FDC_OFF, W_ENDCOL(wp) - FDC_OFF,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 c1, c2, hl_attr(hl));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 if (cmdwin_type != 0 && wp == curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 /* draw the cmdline character in the leftmost column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 n = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 if (n > wp->w_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 n = wp->w_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 W_WINCOL(wp), (int)W_WINCOL(wp) + n,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 cmdwin_type, ' ', hl_attr(HLF_AT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 if (wp->w_p_fdc > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 int nn = n + wp->w_p_fdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 /* draw the fold column at the left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 if (nn > W_WIDTH(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 nn = W_WIDTH(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 W_WINCOL(wp) + n, (int)W_WINCOL(wp) + nn,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 ' ', ' ', hl_attr(HLF_FC));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 n = nn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 #ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 if (draw_signcolumn(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 int nn = n + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 /* draw the sign column after the fold column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 if (nn > W_WIDTH(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 nn = W_WIDTH(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 W_WINCOL(wp) + n, (int)W_WINCOL(wp) + nn,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 ' ', ' ', hl_attr(HLF_SC));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 n = nn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 W_WINCOL(wp) + FDC_OFF, (int)W_ENDCOL(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 c1, c2, hl_attr(hl));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 set_empty_rows(wp, row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 * Display one folded line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 fold_line(wp, fold_count, foldinfo, lnum, row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 long fold_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 foldinfo_T *foldinfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 char_u buf[51];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 pos_T *top, *bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 linenr_T lnume = lnum + fold_count - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 int len;
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
2021 char_u *text;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 int fdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 int txtcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 int off = (int)(current_ScreenLine - ScreenLines);
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2026 int ri;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 /* Build the fold line:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 * 1. Add the cmdwin_type for the command-line window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 * 2. Add the 'foldcolumn'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 * 3. Add the 'number' column
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 * 4. Compose the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 * 5. Add the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 * 6. set highlighting for the Visual area an other text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 * 1. Add the cmdwin_type for the command-line window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 * Ignores 'rightleft', this window is never right-left.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 if (cmdwin_type != 0 && wp == curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 ScreenLines[off] = cmdwin_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 ScreenAttrs[off] = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 ScreenLinesUC[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 * 2. Add the 'foldcolumn'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 fdc = wp->w_p_fdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 if (fdc > W_WIDTH(wp) - col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 fdc = W_WIDTH(wp) - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 if (fdc > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 fill_foldcolumn(buf, wp, TRUE, lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 copy_text_attr(off + W_WIDTH(wp) - fdc - col, buf, fdc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 hl_attr(HLF_FC));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 /* reverse the fold column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 for (i = 0; i < fdc; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 ScreenLines[off + W_WIDTH(wp) - i - 1 - col] = buf[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 copy_text_attr(off + col, buf, fdc, hl_attr(HLF_FC));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 col += fdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 #ifdef FEAT_RIGHTLEFT
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2082 # define RL_MEMSET(p, v, l) if (wp->w_p_rl) \
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2083 for (ri = 0; ri < l; ++ri) \
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2084 ScreenAttrs[off + (W_WIDTH(wp) - (p) - (l)) + ri] = v; \
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2085 else \
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2086 for (ri = 0; ri < l; ++ri) \
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2087 ScreenAttrs[off + (p) + ri] = v
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 #else
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2089 # define RL_MEMSET(p, v, l) for (ri = 0; ri < l; ++ri) \
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2090 ScreenAttrs[off + (p) + ri] = v
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 /* Set all attributes of the 'number' column and the text */
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2094 RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 #ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 /* If signs are being displayed, add two spaces. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 if (draw_signcolumn(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 len = W_WIDTH(wp) - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 if (len > 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 len = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107 /* the line number isn't reversed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 copy_text_attr(off + W_WIDTH(wp) - len - col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 (char_u *)" ", len, hl_attr(HLF_FL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_FL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 col += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 * 3. Add the 'number' column
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 if (wp->w_p_nu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 len = W_WIDTH(wp) - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 {
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
2126 int w = number_width(wp);
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
2127
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
2128 if (len > w + 1)
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
2129 len = w + 1;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
2130 sprintf((char *)buf, "%*ld ", w, (long)lnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 /* the line number isn't reversed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 hl_attr(HLF_FL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 copy_text_attr(off + col, buf, len, hl_attr(HLF_FL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 col += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 * 4. Compose the folded-line string with 'foldtext', if set.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 */
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 26
diff changeset
2146 text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 txtcol = col; /* remember where text starts */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151 * 5. move the text to current_ScreenLine. Fill up with "fill_fold".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 * Right-left text is put in columns 0 - number-col, normal text is put
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 * in columns number-col - window-width.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 int cells;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 int u8c, u8c_c1, u8c_c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161 int c_len;
33
f6033dcbaf31 updated for version 7.0020
vimboss
parents: 29
diff changeset
2162 char_u *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 # ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 int prev_c = 0; /* previous Arabic character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 int prev_c1 = 0; /* first composing char for prev_c */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2168 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170 idx = off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 idx = off + col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 /* Store multibyte characters in ScreenLines[] et al. correctly. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 for (p = text; *p != NUL; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 cells = (*mb_ptr2cells)(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179 c_len = (*mb_ptr2len_check)(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 if (col + cells > W_WIDTH(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 - (wp->w_p_rl ? col : 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 ScreenLines[idx] = *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189 u8c = utfc_ptr2char(p, &u8c_c1, &u8c_c2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2190 if (*p < 0x80 && u8c_c1 == 0 && u8c_c2 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 ScreenLinesUC[idx] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 prev_c = u8c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2195 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2196 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2197 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2199 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202 /* Do Arabic shaping. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 int pc, pc1, nc, dummy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 int firstbyte = *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2206 /* The idea of what is the previous and next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207 * character depends on 'rightleft'. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 pc = prev_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211 pc1 = prev_c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2212 nc = utf_ptr2char(p + c_len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 prev_c1 = u8c_c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 pc = utfc_ptr2char(p + c_len, &pc1, &dummy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218 nc = prev_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 prev_c = u8c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222 u8c = arabic_shape(u8c, &firstbyte, &u8c_c1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 pc, pc1, nc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 ScreenLines[idx] = firstbyte;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 prev_c = u8c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 /* Non-BMP character: display as ? or fullwidth ?. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 if (u8c >= 0x10000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 ScreenLinesUC[idx] = (cells == 2) ? 0xff1f : (int)'?';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 ScreenLinesUC[idx] = u8c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 ScreenLinesC1[idx] = u8c_c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2235 ScreenLinesC2[idx] = u8c_c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 if (cells > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 ScreenLines[idx + 1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2239 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2240 else if (cells > 1) /* double-byte character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2242 if (enc_dbcs == DBCS_JPNU && *p == 0x8e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243 ScreenLines2[idx] = p[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245 ScreenLines[idx + 1] = p[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 col += cells;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 idx += cells;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 p += c_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 len = (int)STRLEN(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 if (len > W_WIDTH(wp) - col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 len = W_WIDTH(wp) - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 STRNCPY(current_ScreenLine, text, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 STRNCPY(current_ScreenLine + col, text, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 col += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 /* Fill the rest of the line with the fold filler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 col -= txtcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 while (col < W_WIDTH(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 - (wp->w_p_rl ? txtcol : 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 if (fill_fold >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 ScreenLinesUC[off + col] = fill_fold;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 ScreenLinesC1[off + col] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 ScreenLinesC2[off + col] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 ScreenLinesUC[off + col] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 ScreenLines[off + col++] = fill_fold;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 if (text != buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 vim_free(text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 * 6. set highlighting for the Visual area an other text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 * If all folded lines are in the Visual area, highlight the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 if (VIsual_active && wp->w_buffer == curwin->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 if (ltoreq(curwin->w_cursor, VIsual))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 /* Visual is after curwin->w_cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 top = &curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 bot = &VIsual;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 /* Visual is before curwin->w_cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 top = &VIsual;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 bot = &curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 if (lnum >= top->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 && lnume <= bot->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 && (VIsual_mode != 'v'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 || ((lnum > top->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 || (lnum == top->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 && top->col == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 && (lnume < bot->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326 || (lnume == bot->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 && (bot->col - (*p_sel == 'e'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 >= STRLEN(ml_get_buf(wp->w_buffer, lnume, FALSE)))))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 if (VIsual_mode == Ctrl_V)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 /* Visual block mode: highlight the chars part of the block */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 if (wp->w_old_cursor_fcol + txtcol < (colnr_T)W_WIDTH(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335 if (wp->w_old_cursor_lcol + txtcol < (colnr_T)W_WIDTH(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336 len = wp->w_old_cursor_lcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 len = W_WIDTH(wp) - txtcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 RL_MEMSET(wp->w_old_cursor_fcol + txtcol, hl_attr(HLF_V),
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 227
diff changeset
2340 len - (int)wp->w_old_cursor_fcol);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 else
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2344 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 /* Set all attributes of the text */
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2346 RL_MEMSET(txtcol, hl_attr(HLF_V), W_WIDTH(wp) - txtcol);
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2347 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 SCREEN_LINE(row + W_WINROW(wp), W_WINCOL(wp), (int)W_WIDTH(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 (int)W_WIDTH(wp), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 * Update w_cline_height and w_cline_folded if the cursor line was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358 * updated (saves a call to plines() later).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 if (wp == curwin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 && lnum <= curwin->w_cursor.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2362 && lnume >= curwin->w_cursor.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364 curwin->w_cline_row = row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365 curwin->w_cline_height = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 curwin->w_cline_folded = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 * Copy "buf[len]" to ScreenLines["off"] and set attributes to "attr".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2374 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 copy_text_attr(off, buf, len, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376 int off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2377 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 {
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2381 int i;
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2382
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 mch_memmove(ScreenLines + off, buf, (size_t)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 vim_memset(ScreenLinesUC + off, 0, sizeof(u8char_T) * (size_t)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 # endif
216
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2388 for (i = 0; i < len; ++i)
da182deebec7 updated for version 7.0061
vimboss
parents: 205
diff changeset
2389 ScreenAttrs[off + i] = attr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 * Fill the foldcolumn at "p" for window "wp".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 fill_foldcolumn(p, wp, closed, lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 int closed; /* TRUE of FALSE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400 linenr_T lnum; /* current line number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 int i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 int level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 int first_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406 /* Init to all spaces. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 copy_spaces(p, (size_t)wp->w_p_fdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 level = win_foldinfo.fi_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 if (level > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 /* If the column is too narrow, we start at the lowest level that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413 * fits and use numbers to indicated the depth. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 first_level = level - wp->w_p_fdc - closed + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 if (first_level < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 first_level = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 for (i = 0; i + 1 < wp->w_p_fdc; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 if (win_foldinfo.fi_lnum == lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 && first_level + i >= win_foldinfo.fi_low_level)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 p[i] = '-';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 else if (first_level == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424 p[i] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 else if (first_level + i <= 9)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 p[i] = '0' + first_level + i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 p[i] = '>';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 if (first_level + i == level)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 if (closed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 p[i] = '+';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 #endif /* FEAT_FOLDING */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 * Display line "lnum" of window 'wp' on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 * Start at row "startrow", stop when "endrow" is reached.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 * wp->w_virtcol needs to be valid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 * Return the number of last row the line occupies.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 win_line(wp, lnum, startrow, endrow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 int startrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 int endrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2451 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 int col; /* visual column on screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 unsigned off; /* offset in ScreenLines/ScreenAttrs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 int c = 0; /* init for GCC */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 long vcol = 0; /* virtual column (for tabs) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 long vcol_prev = -1; /* "vcol" of previous character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 char_u *line; /* current line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 char_u *ptr; /* current position in "line" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 int row; /* row in the window, excl w_winrow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 int screen_row; /* row on the screen, incl w_winrow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 char_u extra[18]; /* "%ld" and 'fdc' must fit in here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 int n_extra = 0; /* number of extra chars */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 char_u *p_extra = NULL; /* string of extra chars */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 int c_extra = NUL; /* extra chars, all the same */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 int extra_attr = 0; /* attributes when n_extra != 0 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 static char_u *at_end_str = (char_u *)""; /* used for p_extra when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 displaying lcs_eol at end-of-line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 int lcs_eol_one = lcs_eol; /* lcs_eol until it's been used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 int lcs_prec_todo = lcs_prec; /* lcs_prec until it's been used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2472 /* saved "extra" items for when draw_state becomes WL_LINE (again) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 int saved_n_extra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 char_u *saved_p_extra = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 int saved_c_extra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 int saved_char_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 int n_attr = 0; /* chars with special attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479 int saved_attr2 = 0; /* char_attr saved for n_attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 int n_attr3 = 0; /* chars with overruling special attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 int saved_attr3 = 0; /* char_attr saved for n_attr3 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 int n_skip = 0; /* nr of chars to skip for 'nowrap' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 int fromcol, tocol; /* start/end of inverting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 int fromcol_prev = -2; /* start of inverting after cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 int noinvcur = FALSE; /* don't invert the cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 pos_T *top, *bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 long v;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 int char_attr = 0; /* attributes for next character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 int area_highlighting = FALSE; /* Visual or incsearch highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 in this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 int attr = 0; /* attributes for area highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 int area_attr = 0; /* attributes desired by highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 int search_attr = 0; /* attributes desired by 'hlsearch' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 int syntax_attr = 0; /* attributes desired by syntax */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 int has_syntax = FALSE; /* this buffer has syntax highl. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 int save_did_emsg;
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2504 int has_spell = FALSE; /* this buffer has spell checking */
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2505 int spell_attr = 0; /* attributes desired by spelling */
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2506 int word_end = 0; /* last byte with same spell_attr */
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2507 int iswordc; /* prev. char was a word character */
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2508 int prev_iswordc = FALSE; /* prev. char was a word character */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 int extra_check; /* has syntax or linebreak */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 int multi_attr = 0; /* attributes desired by multibyte */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 int mb_l = 1; /* multi-byte byte length */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514 int mb_c = 0; /* decoded multi-byte character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 int mb_utf8 = FALSE; /* screen char is UTF-8 char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 int u8c_c1 = 0; /* first composing UTF-8 char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 int u8c_c2 = 0; /* second composing UTF-8 char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 int filler_lines; /* nr of filler lines to be drawn */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 int filler_todo; /* nr of filler lines still to do + 1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 enum hlf_value diff_hlf = (enum hlf_value)0; /* type of diff highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 int change_start = MAXCOL; /* first col of changed area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 int change_end = -1; /* last col of changed area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 colnr_T trailcol = MAXCOL; /* start of trailing spaces */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 #ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 int need_showbreak = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 #if defined(FEAT_SIGNS) || (defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 # define LINE_ATTR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 int line_attr = 0; /* atrribute for the whole line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 match_T *shl; /* points to search_hl or match_hl */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 int prev_c = 0; /* previous Arabic character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 int prev_c1 = 0; /* first composing char for prev_c */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 /* draw_state: items that are drawn in sequence: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 #define WL_START 0 /* nothing done yet */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 # define WL_CMDLINE WL_START + 1 /* cmdline window column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 # define WL_CMDLINE WL_START
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 # define WL_FOLD WL_CMDLINE + 1 /* 'foldcolumn' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 # define WL_FOLD WL_CMDLINE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 #ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 # define WL_SIGN WL_FOLD + 1 /* column for signs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 # define WL_SIGN WL_FOLD /* column for signs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 #define WL_NR WL_SIGN + 1 /* line number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 # define WL_SBR WL_NR + 1 /* 'showbreak' or 'diff' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 # define WL_SBR WL_NR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 #define WL_LINE WL_SBR + 1 /* text in the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 int draw_state = WL_START; /* what to draw next */
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 7
diff changeset
2567 #if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 int feedback_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 int feedback_old_attr = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 if (startrow > endrow) /* past the end already! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 return startrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 row = startrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 screen_row = row + W_WINROW(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 * To speed up the loop below, set extra_check when there is linebreak,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 * trailing white space and/or syntax processing to be done.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583 #ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 extra_check = wp->w_p_lbr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 extra_check = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 if (syntax_present(wp->w_buffer))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 /* Prepare for syntax highlighting in this line. When there is an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 * error, stop syntax highlighting. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 save_did_emsg = did_emsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 did_emsg = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 syntax_start(wp, lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2596 if (did_emsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 syntax_clear(wp->w_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 did_emsg = save_did_emsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601 has_syntax = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 extra_check = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 }
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2605
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2606 if (wp->w_p_spell && *wp->w_buffer->b_p_spl != NUL)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2607 {
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2608 /* Prepare for spell checking. */
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2609 has_spell = TRUE;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2610 extra_check = TRUE;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
2611 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 * handle visual active in this window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 fromcol = -10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 tocol = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 if (VIsual_active && wp->w_buffer == curwin->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 /* Visual is after curwin->w_cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 if (ltoreq(curwin->w_cursor, VIsual))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 top = &curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 bot = &VIsual;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 else /* Visual is before curwin->w_cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 top = &VIsual;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 bot = &curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 if (VIsual_mode == Ctrl_V) /* block mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 if (lnum >= top->lnum && lnum <= bot->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2637 fromcol = wp->w_old_cursor_fcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 tocol = wp->w_old_cursor_lcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 else /* non-block mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 if (lnum > top->lnum && lnum <= bot->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 fromcol = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 else if (lnum == top->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 if (VIsual_mode == 'V') /* linewise */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 fromcol = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 if (gchar_pos(top) == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 tocol = fromcol + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 if (VIsual_mode != 'V' && lnum == bot->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658 if (*p_sel == 'e' && bot->col == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660 && bot->coladd == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 fromcol = -10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 tocol = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 }
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2667 else if (bot->col == MAXCOL)
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2668 tocol = MAXCOL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 pos = *bot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 if (*p_sel == 'e')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 getvvcol(wp, &pos, NULL, NULL, (colnr_T *)&tocol);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 ++tocol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 #ifndef MSDOS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 /* Check if the character under the cursor should not be inverted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 if (!highlight_match && lnum == curwin->w_cursor.lnum && wp == curwin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 && !gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 noinvcur = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 /* if inverting in this line set area_highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 if (fromcol >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696 area_highlighting = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 attr = hl_attr(HLF_V);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699 if (clip_star.available && !clip_star.owned && clip_isautosel())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 attr = hl_attr(HLF_VNC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 * handle 'insearch' and ":s///c" highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 #endif /* FEAT_VISUAL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 if (highlight_match
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 && wp == curwin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 && lnum >= curwin->w_cursor.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 && lnum <= curwin->w_cursor.lnum + search_match_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 if (lnum == curwin->w_cursor.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 getvcol(curwin, &(curwin->w_cursor),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717 (colnr_T *)&fromcol, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 fromcol = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 if (lnum == curwin->w_cursor.lnum + search_match_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 pos.lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 pos.col = search_match_endcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 tocol = MAXCOL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728 if (fromcol == tocol) /* do at least one character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 tocol = fromcol + 1; /* happens when past end of line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 area_highlighting = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 attr = hl_attr(HLF_I);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 filler_lines = diff_check(wp, lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 if (filler_lines < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738 if (filler_lines == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 if (diff_find_change(wp, lnum, &change_start, &change_end))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 diff_hlf = HLF_ADD; /* added line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742 else if (change_start == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743 diff_hlf = HLF_TXD; /* changed text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745 diff_hlf = HLF_CHD; /* changed line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 diff_hlf = HLF_ADD; /* added line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 filler_lines = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 area_highlighting = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2752 if (lnum == wp->w_topline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 filler_lines = wp->w_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 filler_todo = filler_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 #ifdef LINE_ATTR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 # ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 /* If this line has a sign with line highlighting set line_attr. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 v = buf_getsigntype(wp->w_buffer, lnum, SIGN_LINEHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761 if (v != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 line_attr = sign_get_attr((int)v, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2764 # if defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765 /* Highlight the current line in the quickfix window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 if (bt_quickfix(wp->w_buffer) && qf_current_entry() == lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 line_attr = hl_attr(HLF_L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 if (line_attr != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770 area_highlighting = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774 ptr = line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 /* find start of trailing whitespace */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 if (wp->w_p_list && lcs_trail)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 trailcol = (colnr_T)STRLEN(ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 --trailcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2782 trailcol += (colnr_T) (ptr - line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 extra_check = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 * 'nowrap' or 'wrap' and a single line that doesn't fit: Advance to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 * first character to be displayed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 if (wp->w_p_wrap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 v = wp->w_skipcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 v = wp->w_leftcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 if (v > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 char_u *prev_ptr = ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 while (vcol < v && *ptr != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 vcol += c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 prev_ptr = ptr;
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2805 #endif
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2806 mb_ptr_adv(ptr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810 /* When 'virtualedit' is set the end of the line may be before the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 * start of the displayed part. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2812 if (vcol < v && *ptr == NUL && virtual_active())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 vcol = v;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2815
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 /* Handle a character that's not completely on the screen: Put ptr at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2817 * that character but skip the first few screen characters. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 if (vcol > v)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2819 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 vcol -= c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822 ptr = prev_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824 --ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 n_skip = v - vcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 * Adjust for when the inverted text is before the screen,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 * and when the start of the inverted text is before the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 if (tocol <= vcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 fromcol = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 else if (fromcol >= 0 && fromcol < vcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 fromcol = vcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 #ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 /* When w_skipcol is non-zero, first line needs 'showbreak' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 if (wp->w_p_wrap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 need_showbreak = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2844
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 * Correct highlighting for cursor that can't be disabled.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 * Avoids having to check this for each character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 if (fromcol >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851 if (noinvcur)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853 if ((colnr_T)fromcol == wp->w_virtcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2854 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2855 /* highlighting starts at cursor, let it start just after the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856 * cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857 fromcol_prev = fromcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 fromcol = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 else if ((colnr_T)fromcol < wp->w_virtcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 /* restart highlighting after the cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 fromcol_prev = wp->w_virtcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 if (fromcol >= tocol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865 fromcol = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 * Handle highlighting the last used search pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 * Do this for both search_hl and match_hl.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2873 shl = &search_hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2875 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2876 shl->startcol = MAXCOL;
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2877 shl->endcol = MAXCOL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 shl->attr_cur = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 if (shl->rm.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 v = (long)(ptr - line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882 next_search_hl(wp, shl, lnum, (colnr_T)v);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 /* Need to get the line again, a multi-line regexp may have made it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 * invalid. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 ptr = line + v;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2889 if (shl->lnum != 0 && shl->lnum <= lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 if (shl->lnum == lnum)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2892 shl->startcol = shl->rm.startpos[0].col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 else
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2894 shl->startcol = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895 if (lnum == shl->lnum + shl->rm.endpos[0].lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 - shl->rm.startpos[0].lnum)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2897 shl->endcol = shl->rm.endpos[0].col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898 else
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2899 shl->endcol = MAXCOL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2900 /* Highlight one character for an empty match. */
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2901 if (shl->startcol == shl->endcol)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 #ifdef FEAT_MBYTE
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2904 if (has_mbyte && line[shl->endcol] != NUL)
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2905 shl->endcol += (*mb_ptr2len_check)(line + shl->endcol);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907 #endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2908 ++shl->endcol;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2909 }
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
2910 if ((long)shl->startcol < v) /* match at leftcol */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 shl->attr_cur = shl->attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 search_attr = shl->attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2915 area_highlighting = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 if (shl == &match_hl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2919 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2920 shl = &match_hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2923
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924 off = (unsigned) (current_ScreenLine - ScreenLines);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2925 col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2926 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2928 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929 /* Rightleft window: process the text in the normal direction, but put
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 * it in current_ScreenLine[] from right to left. Start at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931 * rightmost column of the window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 col = W_WIDTH(wp) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2933 off += col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2937 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938 * Repeat for the whole displayed line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2942 /* Skip this quickly when working on the text. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 if (draw_state != WL_LINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2945 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2946 if (draw_state == WL_CMDLINE - 1 && n_extra == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2947 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948 draw_state = WL_CMDLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2949 if (cmdwin_type != 0 && wp == curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2950 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951 /* Draw the cmdline character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952 *extra = cmdwin_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2953 n_extra = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 p_extra = extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2955 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956 char_attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962 if (draw_state == WL_FOLD - 1 && n_extra == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 draw_state = WL_FOLD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965 if (wp->w_p_fdc > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 /* Draw the 'foldcolumn'. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2968 fill_foldcolumn(extra, wp, FALSE, lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969 n_extra = wp->w_p_fdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970 p_extra = extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972 char_attr = hl_attr(HLF_FC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2974 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2975 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2977 #ifdef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2978 if (draw_state == WL_SIGN - 1 && n_extra == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2980 draw_state = WL_SIGN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2981 /* Show the sign column when there are any signs in this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2982 * buffer or when using Netbeans. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 if (draw_signcolumn(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2984 # ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2985 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2986 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2987 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2989 int_u text_sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2990 # ifdef FEAT_SIGN_ICONS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2991 int_u icon_sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994 /* Draw two cells with the sign value or blank. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2995 c_extra = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2996 char_attr = hl_attr(HLF_SC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2997 n_extra = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2999 if (row == startrow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3000 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3001 text_sign = buf_getsigntype(wp->w_buffer, lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3002 SIGN_TEXT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3003 # ifdef FEAT_SIGN_ICONS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3004 icon_sign = buf_getsigntype(wp->w_buffer, lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 SIGN_ICON);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3006 if (gui.in_use && icon_sign != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3008 /* Use the image in this position. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3009 c_extra = SIGN_BYTE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3010 # ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 if (buf_signcount(wp->w_buffer, lnum) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 c_extra = MULTISIGN_BYTE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3013 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3014 char_attr = icon_sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3015 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3016 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3018 if (text_sign != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3019 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3020 p_extra = sign_get_text(text_sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3021 if (p_extra != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3022 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3023 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3024 n_extra = STRLEN(p_extra);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3025 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3026 char_attr = sign_get_attr(text_sign, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3027 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3028 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3031 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3032
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3033 if (draw_state == WL_NR - 1 && n_extra == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3034 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3035 draw_state = WL_NR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3036 /* Display the line number. After the first fill with blanks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3037 * when the 'n' flag isn't in 'cpo' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3038 if (wp->w_p_nu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3039 && (row == startrow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3040 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3041 + filler_lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3042 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3043 || vim_strchr(p_cpo, CPO_NUMCOL) == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3044 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3045 /* Draw the line number (empty space after wrapping). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3046 if (row == startrow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3048 + filler_lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3049 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3050 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3051 {
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
3052 sprintf((char *)extra, "%*ld ",
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
3053 number_width(wp), (long)lnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3054 if (wp->w_skipcol > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3055 for (p_extra = extra; *p_extra == ' '; ++p_extra)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3056 *p_extra = '-';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3057 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3058 if (wp->w_p_rl) /* reverse line numbers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3059 rl_mirror(extra);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3060 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3061 p_extra = extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3062 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3063 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3064 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3065 c_extra = ' ';
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
3066 n_extra = number_width(wp) + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3067 char_attr = hl_attr(HLF_N);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3070
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3071 #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3072 if (draw_state == WL_SBR - 1 && n_extra == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074 draw_state = WL_SBR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3075 # ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 if (filler_todo > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3078 /* Draw "deleted" diff line(s). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079 if (char2cells(fill_diff) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3080 c_extra = '-';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3081 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3082 c_extra = fill_diff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3083 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085 n_extra = col + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3086 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3087 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3088 n_extra = W_WIDTH(wp) - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3089 char_attr = hl_attr(HLF_DED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3090 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3091 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3092 # ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3093 if (*p_sbr != NUL && need_showbreak)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3094 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3095 /* Draw 'showbreak' at the start of each broken line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096 p_extra = p_sbr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 n_extra = (int)STRLEN(p_sbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 char_attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100 need_showbreak = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3101 /* Correct end of highlighted area for 'showbreak',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3102 * required when 'linebreak' is also set. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3103 if (tocol == vcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3104 tocol += n_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3105 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3106 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3108 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110 if (draw_state == WL_LINE - 1 && n_extra == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 draw_state = WL_LINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3113 if (saved_n_extra)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3115 /* Continue item from end of wrapped line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3116 n_extra = saved_n_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3117 c_extra = saved_c_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3118 p_extra = saved_p_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3119 char_attr = saved_char_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3121 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3122 char_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3123 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3124 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126 /* When still displaying '$' of change command, stop at cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 if (dollar_vcol != 0 && wp == curwin && vcol >= (long)wp->w_virtcol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3129 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3131 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 SCREEN_LINE(screen_row, W_WINCOL(wp), col, -(int)W_WIDTH(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3134 wp->w_p_rl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135 /* Pretend we have finished updating the window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3136 row = wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3137 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3140 if (draw_state == WL_LINE && area_highlighting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3141 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3142 /* handle Visual or match highlighting in this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3143 if (vcol == fromcol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3144 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3145 || (has_mbyte && vcol + 1 == fromcol && n_extra == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3146 && (*mb_ptr2cells)(ptr) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3147 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3148 || ((int)vcol_prev == fromcol_prev
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3149 && vcol < tocol))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3150 area_attr = attr; /* start highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3151 else if (area_attr != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3152 && (vcol == tocol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3153 || (noinvcur && (colnr_T)vcol == wp->w_virtcol)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3154 #ifdef LINE_ATTR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3155 area_attr = line_attr; /* stop highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 else if (line_attr && ((fromcol == -10 && tocol == MAXCOL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157 || (vcol < fromcol || vcol > tocol)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 area_attr = line_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 area_attr = 0; /* stop highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3161 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3163 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3164 if (!n_extra)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3165 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3166 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3167 * Check for start/end of search pattern match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3168 * After end, check for start/end of next match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3169 * When another match, have to check for start again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3170 * Watch out for matching an empty string!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3171 * Do this first for search_hl, then for match_hl, so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3172 * ":match" overrules 'hlsearch'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3173 */
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3174 v = (long)(ptr - line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3175 shl = &search_hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3176 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3178 while (shl->rm.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3179 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3180 if (shl->startcol != MAXCOL
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3181 && v >= (long)shl->startcol
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3182 && v < (long)shl->endcol)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3183 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3184 shl->attr_cur = shl->attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3185 }
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3186 else if (v == (long)shl->endcol)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3187 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3188 shl->attr_cur = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3190 next_search_hl(wp, shl, lnum, (colnr_T)v);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3191
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3192 /* Need to get the line again, a multi-line regexp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3193 * may have made it invalid. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3194 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3195 ptr = line + v;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3197 if (shl->lnum == lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3198 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3199 shl->startcol = shl->rm.startpos[0].col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3200 if (shl->rm.endpos[0].lnum == 0)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3201 shl->endcol = shl->rm.endpos[0].col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3202 else
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3203 shl->endcol = MAXCOL;
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3204
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3205 if (shl->startcol == shl->endcol)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3206 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3207 /* highlight empty match, try again after
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3208 * it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3209 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3210 if (has_mbyte)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3211 shl->endcol += (*mb_ptr2len_check)(line
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3212 + shl->endcol);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3213 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3214 #endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3215 ++shl->endcol;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3216 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3218 /* Loop to check if the match starts at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3219 * current position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3220 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3223 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3224 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3225 if (shl == &match_hl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3226 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3227 shl = &match_hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3228 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3229 /* ":match" highlighting overrules 'hlsearch' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3230 if (match_hl.attr_cur != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3231 search_attr = match_hl.attr_cur;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3232 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3233 search_attr = search_hl.attr_cur;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3234 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3235 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3237 if (area_attr != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3238 char_attr = area_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3239 #ifdef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3240 else if (search_attr == 0 && has_syntax)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3241 char_attr = syntax_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3243 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3244 char_attr = search_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3245
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3246 #ifdef FEAT_SYN_HL
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3247 if (spell_attr != 0)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3248 char_attr = hl_combine_attr(char_attr, spell_attr);
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3249 #endif
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3250
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3252 if (diff_hlf != (enum hlf_value)0 && n_extra == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3253 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3254 if (diff_hlf == HLF_CHD && ptr - line >= change_start)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3255 diff_hlf = HLF_TXD; /* changed text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3256 if (diff_hlf == HLF_TXD && ptr - line > change_end)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3257 diff_hlf = HLF_CHD; /* changed line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3258 if (attr == 0 || area_attr != attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3259 area_attr = hl_attr(diff_hlf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3260 if (attr == 0 || char_attr != attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3262 if (search_attr != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3263 char_attr = search_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3264 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3265 char_attr = hl_attr(diff_hlf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3268 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3271 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3272 * Get the next character to put on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3273 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3274 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3275 * The 'extra' array contains the extra stuff that is inserted to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3276 * represent special characters (non-printable stuff). When all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3277 * characters are the same, c_extra is used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3278 * For the '$' of the 'list' option, n_extra == 1, p_extra == "".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3279 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3280 if (n_extra > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3281 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3282 if (c_extra != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3283 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3284 c = c_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3285 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3286 mb_c = c; /* doesn't handle non-utf-8 multi-byte! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3287 if (enc_utf8 && (*mb_char2len)(c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3288 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3289 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3290 u8c_c1 = u8c_c2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3291 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3292 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3293 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3294 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3296 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3297 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3298 c = *p_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3299 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3300 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3302 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3303 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3304 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3305 /* If the UTF-8 character is more than one byte:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3306 * Decode it into "mb_c". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3307 mb_l = (*mb_ptr2len_check)(p_extra);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3308 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3309 if (mb_l > n_extra)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3310 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3311 else if (mb_l > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3312 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3313 mb_c = utfc_ptr2char(p_extra, &u8c_c1, &u8c_c2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3314 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3316 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3317 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3318 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 /* if this is a DBCS character, put it in "mb_c" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 mb_l = MB_BYTE2LEN(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3321 if (mb_l >= n_extra)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3323 else if (mb_l > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3324 mb_c = (c << 8) + p_extra[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326 /* If a double-width char doesn't fit display a '>' in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 * last column. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3328 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 wp->w_p_rl ? (col <= 0) :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 (col >= W_WIDTH(wp) - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333 && (*mb_char2cells)(mb_c) == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3335 c = '>';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3336 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 multi_attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3340 /* put the pointer back to output the double-width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3341 * character at the start of the next line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3342 ++n_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3343 --p_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3346 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3347 n_extra -= mb_l - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 p_extra += mb_l - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352 ++p_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3354 --n_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3356 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3358 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3359 * Get a character from the line itself.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3360 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3361 c = *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3362 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3363 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3364 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3365 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3368 /* If the UTF-8 character is more than one byte: Decode it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3369 * into "mb_c". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3370 mb_l = (*mb_ptr2len_check)(ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3371 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3372 if (mb_l > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3374 mb_c = utfc_ptr2char(ptr, &u8c_c1, &u8c_c2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3375 /* Overlong encoded ASCII or ASCII with composing char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3376 * is displayed normally, except a NUL. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3377 if (mb_c < 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3378 c = mb_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3379 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3382 if ((mb_l == 1 && c >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3383 || (mb_l >= 1 && mb_c == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3384 || (mb_l > 1 && (!vim_isprintc(mb_c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3385 || mb_c >= 0x10000)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3386 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3387 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3388 * Illegal UTF-8 byte: display as <xx>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3389 * Non-BMP character : display as ? or fullwidth ?.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3390 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3391 if (mb_c < 0x10000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3393 transchar_hex(extra, mb_c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3394 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3395 if (wp->w_p_rl) /* reverse */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3396 rl_mirror(extra);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3397 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3399 else if (utf_char2cells(mb_c) != 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3400 STRCPY(extra, "?");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3401 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3402 /* 0xff1f in UTF-8: full-width '?' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3403 STRCPY(extra, "\357\274\237");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3405 p_extra = extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3406 c = *p_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3407 mb_c = mb_ptr2char_adv(&p_extra);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3408 mb_utf8 = (c >= 0x80);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3409 n_extra = (int)STRLEN(p_extra);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3410 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3411 if (area_attr == 0 && search_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3412 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3413 n_attr = n_extra + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3414 extra_attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3415 saved_attr2 = char_attr; /* save current attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3416 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3418 else if (mb_l == 0) /* at the NUL at end-of-line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3419 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3420 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3421 else if (p_arshape && !p_tbidi && ARABIC_CHAR(mb_c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3422 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3423 /* Do Arabic shaping. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3424 int pc, pc1, nc, dummy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3426 /* The idea of what is the previous and next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3427 * character depends on 'rightleft'. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3428 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3429 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3430 pc = prev_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3431 pc1 = prev_c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3432 nc = utf_ptr2char(ptr + mb_l);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3433 prev_c1 = u8c_c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3435 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3437 pc = utfc_ptr2char(ptr + mb_l, &pc1, &dummy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438 nc = prev_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3440 prev_c = mb_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3441
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3442 mb_c = arabic_shape(mb_c, &c, &u8c_c1, pc, pc1, nc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3443 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3444 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3445 prev_c = mb_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3446 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3448 else /* enc_dbcs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3450 mb_l = MB_BYTE2LEN(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3451 if (mb_l == 0) /* at the NUL at end-of-line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3452 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3453 else if (mb_l > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3454 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3455 /* We assume a second byte below 32 is illegal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3456 * Hopefully this is OK for all double-byte encodings!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3457 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3458 if (ptr[1] >= 32)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3459 mb_c = (c << 8) + ptr[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3460 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3461 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3462 if (ptr[1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3463 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3464 /* head byte at end of line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3465 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3466 transchar_nonprint(extra, c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3467 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3468 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3470 /* illegal tail byte */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3471 mb_l = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3472 STRCPY(extra, "XX");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3473 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3474 p_extra = extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3475 n_extra = (int)STRLEN(extra) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3476 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3477 c = *p_extra++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3478 if (area_attr == 0 && search_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3480 n_attr = n_extra + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3481 extra_attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3482 saved_attr2 = char_attr; /* save current attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3483 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3484 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3486 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3487 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3488 /* If a double-width char doesn't fit display a '>' in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3489 * last column; the character is displayed at the start of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3490 * next line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3491 if ((
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3492 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3493 wp->w_p_rl ? (col <= 0) :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3494 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3495 (col >= W_WIDTH(wp) - 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3496 && (*mb_char2cells)(mb_c) == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3497 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3498 c = '>';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3499 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3500 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3501 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3502 multi_attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3503 /* Put pointer back so that the character will be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3504 * displayed at the start of the next line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3505 --ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3506 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3507 else if (*ptr != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3508 ptr += mb_l - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3509
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3510 /* If a double-width char doesn't fit at the left side display
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3511 * a '<' in the first column. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3512 if (n_skip > 0 && mb_l > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3513 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3514 extra[0] = '<';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3515 p_extra = extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3516 n_extra = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3517 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3518 c = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3519 if (area_attr == 0 && search_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3520 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3521 n_attr = n_extra + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3522 extra_attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523 saved_attr2 = char_attr; /* save current attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3524 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3525 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3526 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3527 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3528 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3531 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3532 ++ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3533
12
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3534 /* 'list' : change char 160 to lcs_nbsp. */
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3535 if (wp->w_p_list && c == 160 && lcs_nbsp)
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3536 {
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3537 c = lcs_nbsp;
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3538 if (area_attr == 0 && search_attr == 0)
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3539 {
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3540 n_attr = 1;
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3541 extra_attr = hl_attr(HLF_8);
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3542 saved_attr2 = char_attr; /* save current attr */
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3543 }
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3544 #ifdef FEAT_MBYTE
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3545 mb_c = c;
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3546 if (enc_utf8 && (*mb_char2len)(c) > 1)
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3547 {
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3548 mb_utf8 = TRUE;
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3549 u8c_c1 = u8c_c2 = 0;
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3550 }
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3551 else
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3552 mb_utf8 = FALSE;
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3553 #endif
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3554 }
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
3555
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3556 if (extra_check)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3557 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3558 #ifdef FEAT_SYN_HL
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3559 int can_spell = TRUE;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3560
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3561 /* Get syntax attribute, unless still at the start of the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3562 * (double-wide char that doesn't fit). */
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3563 v = (long)(ptr - line);
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3564 if (has_syntax && v > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3565 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3566 /* Get the syntax attribute for the character. If there
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3567 * is an error, disable syntax highlighting. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3568 save_did_emsg = did_emsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3569 did_emsg = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3570
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3571 syntax_attr = get_syntax_attr((colnr_T)v - 1,
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3572 has_spell ? &can_spell : NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3574 if (did_emsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3575 syntax_clear(wp->w_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3576 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3577 did_emsg = save_did_emsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3579 /* Need to get the line again, a multi-line regexp may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3580 * have made it invalid. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3581 line = ml_get_buf(wp->w_buffer, lnum, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3582 ptr = line + v;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3584 if (area_attr == 0 && search_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3585 char_attr = syntax_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3586 }
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3587
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3588 /* Check spelling at the start of a word.
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3589 * Only do this when there is no syntax highlighting, there is
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3590 * on @Spell cluster or the current syntax item contains the
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3591 * @Spell cluster. */
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3592 if (has_spell && v >= word_end)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3593 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 227
diff changeset
3594 spell_attr = 0;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 227
diff changeset
3595 if (area_attr == 0 && search_attr == 0)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 227
diff changeset
3596 char_attr = syntax_attr;
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3597 if (!has_syntax || can_spell)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3598 {
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3599 char_u *prev_ptr = ptr - (
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3600 # ifdef FEAT_MBYTE
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3601 has_mbyte ? mb_l :
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3602 # endif
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3603 1);
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3604
227
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
3605 iswordc = spell_iswordc(prev_ptr);
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3606 if (iswordc && !prev_iswordc)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3607 {
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 230
diff changeset
3608 word_end = v + spell_check(wp, line, prev_ptr,
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3609 &spell_attr);
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3610 /* In Insert mode only highlight a word that
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3611 * doesn't touch the cursor. */
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3612 if (spell_attr != 0
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3613 && (State & INSERT) != 0
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3614 && wp->w_cursor.lnum == lnum
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3615 && wp->w_cursor.col >=
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3616 (colnr_T)(prev_ptr - line)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3617 && wp->w_cursor.col < (colnr_T)word_end)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3618 {
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3619 spell_attr = 0;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3620 spell_redraw_lnum = lnum;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3621 }
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3622 }
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3623 prev_iswordc = iswordc;
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3624 }
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3625 }
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3626 if (spell_attr != 0)
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3627 char_attr = hl_combine_attr(char_attr, spell_attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3628 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3629 #ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3630 /*
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 216
diff changeset
3631 * Found last space before word: check for line break.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3632 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3633 if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3634 && !wp->w_p_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3635 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3636 n_extra = win_lbr_chartabsize(wp, ptr - (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3637 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3638 has_mbyte ? mb_l :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3640 1), (colnr_T)vcol, NULL) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3641 c_extra = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3642 if (vim_iswhite(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3643 c = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3644 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3645 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3646
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3647 if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3648 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3649 c = lcs_trail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3650 if (area_attr == 0 && search_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3652 n_attr = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3653 extra_attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3654 saved_attr2 = char_attr; /* save current attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3655 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3656 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3657 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3658 if (enc_utf8 && (*mb_char2len)(c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3659 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3660 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3661 u8c_c1 = u8c_c2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3662 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3663 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3664 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3665 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3666 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3669 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3670 * Handling of non-printable characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3671 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3672 if (!(chartab[c] & CT_PRINT_CHAR))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3673 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3674 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3675 * when getting a character from the file, we may have to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3676 * turn it into something else on the way to putting it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3677 * into "ScreenLines".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3678 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3679 if (c == TAB && (!wp->w_p_list || lcs_tab1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3680 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3681 /* tab amount depends on current column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3682 n_extra = (int)wp->w_buffer->b_p_ts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3683 - vcol % (int)wp->w_buffer->b_p_ts - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3684 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3685 mb_utf8 = FALSE; /* don't draw as UTF-8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3686 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3687 if (wp->w_p_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3688 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3689 c = lcs_tab1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3690 c_extra = lcs_tab2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3691 n_attr = n_extra + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3692 extra_attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3693 saved_attr2 = char_attr; /* save current attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3694 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 if (enc_utf8 && (*mb_char2len)(c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3697 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3698 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3699 u8c_c1 = u8c_c2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3701 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3702 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3703 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3705 c_extra = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3706 c = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3708 }
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3709 else if (c == NUL
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3710 && ((wp->w_p_list && lcs_eol > 0)
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3711 || ((fromcol >= 0 || fromcol_prev >= 0)
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3712 && tocol > vcol
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3713 #ifdef FEAT_VISUAL
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3714 && VIsual_mode != Ctrl_V
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3715 #endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3716 && (
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3717 # ifdef FEAT_RIGHTLEFT
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3718 wp->w_p_rl ? (col >= 0) :
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3719 # endif
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3720 (col < W_WIDTH(wp)))
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3721 && !(noinvcur
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3722 && (colnr_T)vcol == wp->w_virtcol)))
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3723 && lcs_eol_one >= 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3724 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3725 /* Display a '$' after the line or highlight an extra
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3726 * character if the line break is included. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3727 #if defined(FEAT_DIFF) || defined(LINE_ATTR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3728 /* For a diff line the highlighting continues after the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3729 * "$". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3730 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3731 # ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3732 diff_hlf == (enum hlf_value)0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3733 # ifdef LINE_ATTR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3734 &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3735 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3736 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3737 # ifdef LINE_ATTR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3738 line_attr == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3739 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3740 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3741 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3742 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3743 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3744 /* In virtualedit, visual selections may extend
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3745 * beyond end of line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3746 if (area_highlighting && virtual_active()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3747 && tocol != MAXCOL && vcol < tocol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3748 n_extra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3749 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3750 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3751 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3752 p_extra = at_end_str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3753 n_extra = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3754 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3755 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3756 }
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3757 if (wp->w_p_list)
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3758 c = lcs_eol;
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3759 else
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3760 c = ' ';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3761 lcs_eol_one = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3762 --ptr; /* put it back at the NUL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3763 if (area_attr == 0 && search_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3764 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3765 extra_attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3766 n_attr = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3767 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3768 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3769 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3770 if (enc_utf8 && (*mb_char2len)(c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3772 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3773 u8c_c1 = u8c_c2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3774 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3775 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3776 mb_utf8 = FALSE; /* don't draw as UTF-8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3777 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3778 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3779 else if (c != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3780 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3781 p_extra = transchar(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3782 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3783 if ((dy_flags & DY_UHEX) && wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3784 rl_mirror(p_extra); /* reverse "<12>" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3785 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3786 n_extra = byte2cells(c) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3787 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3788 c = *p_extra++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3789 if (area_attr == 0 && search_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3790 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3791 n_attr = n_extra + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3792 extra_attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3793 saved_attr2 = char_attr; /* save current attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3795 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3796 mb_utf8 = FALSE; /* don't draw as UTF-8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3797 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3799 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3800 else if (VIsual_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801 && (VIsual_mode == Ctrl_V
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3802 || VIsual_mode == 'v')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3803 && virtual_active()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3804 && tocol != MAXCOL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3805 && vcol < tocol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3806 && (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3807 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3808 wp->w_p_rl ? (col >= 0) :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3809 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3810 (col < W_WIDTH(wp))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3811 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3812 c = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3813 --ptr; /* put it back at the NUL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3814 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3815 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3816 #if defined(FEAT_DIFF) || defined(LINE_ATTR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3817 else if ((
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3818 # ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3819 diff_hlf != (enum hlf_value)0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3820 # ifdef LINE_ATTR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3821 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3822 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3823 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3824 # ifdef LINE_ATTR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3825 line_attr != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3826 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3827 ) && (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3828 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3829 wp->w_p_rl ? (col >= 0) :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3830 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3831 (col < W_WIDTH(wp))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3832 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3833 /* Highlight until the right side of the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3834 c = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3835 --ptr; /* put it back at the NUL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3836 # ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3837 if (diff_hlf == HLF_TXD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3838 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3839 diff_hlf = HLF_CHD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3840 if (attr == 0 || char_attr != attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3841 char_attr = hl_attr(diff_hlf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3842 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3843 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3844 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3845 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3846 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3847 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3849 /* Don't override visual selection highlighting. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3850 if (n_attr > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3851 && draw_state == WL_LINE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3852 && (area_attr == 0 || char_attr != area_attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3853 && (search_attr == 0 || char_attr != search_attr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3854 char_attr = extra_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3855
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 40
diff changeset
3856 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3857 /* XIM don't send preedit_start and preedit_end, but they send
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3858 * preedit_changed and commit. Thus Vim can't set "im_is_active", use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3859 * im_is_preediting() here. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3860 if (xic != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3861 && lnum == curwin->w_cursor.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3862 && (State & INSERT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3863 && !p_imdisable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3864 && im_is_preediting()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3865 && draw_state == WL_LINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3866 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3867 colnr_T tcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3869 if (preedit_end_col == MAXCOL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3870 getvcol(curwin, &(curwin->w_cursor), &tcol, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3871 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3872 tcol = preedit_end_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3873 if ((long)preedit_start_col <= vcol && vcol < (long)tcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3874 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3875 if (feedback_old_attr < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3876 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3877 feedback_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3878 feedback_old_attr = char_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3879 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3880 char_attr = im_get_feedback_attr(feedback_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3881 if (char_attr < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3882 char_attr = feedback_old_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3883 feedback_col++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3885 else if (feedback_old_attr >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3886 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3887 char_attr = feedback_old_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3888 feedback_old_attr = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3889 feedback_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3891 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3892 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3893 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3894 * Handle the case where we are in column 0 but not on the first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3895 * character of the line and the user wants us to show us a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3896 * special character (via 'listchars' option "precedes:<char>".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3897 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3898 if (lcs_prec_todo != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3899 && (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3900 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3901 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3902 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3903 && draw_state > WL_NR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3904 && c != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3905 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3906 c = lcs_prec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3907 lcs_prec_todo = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3908 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3909 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3910 if (enc_utf8 && (*mb_char2len)(c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3911 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3912 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3913 u8c_c1 = u8c_c2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3915 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3916 mb_utf8 = FALSE; /* don't draw as UTF-8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3917 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3918 if ((area_attr == 0 || char_attr != area_attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3919 && (search_attr == 0 || char_attr != search_attr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3920 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3921 saved_attr3 = char_attr; /* save current attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3922 char_attr = hl_attr(HLF_AT); /* later copied to char_attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3923 n_attr3 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3926
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3927 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3928 * At end of the text line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3929 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3930 if (c == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3931 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3932 /* invert at least one char, used for Visual and empty line or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3933 * highlight match at end of line. If it's beyond the last
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3934 * char on the screen, just overwrite that one (tricky!) Not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3935 * needed when a '$' was displayed for 'list'. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3936 if (lcs_eol == lcs_eol_one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3937 && ((area_attr != 0 && vcol == fromcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3938 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3939 /* highlight 'hlsearch' match at end of line */
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3940 || (ptr - line) - 1 == (long)search_hl.startcol
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3941 || (ptr - line) - 1 == (long)match_hl.startcol
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3942 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3943 ))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3945 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3946
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3947 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3948 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3949 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3950 if (col < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3951 n = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3952 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3953 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3954 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3955 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3956 if (col >= W_WIDTH(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3957 n = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3958 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3959 if (n != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3960 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3961 /* At the window boundary, highlight the last character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3962 * instead (better than nothing). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3963 off += n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3964 col += n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3965 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3966 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3967 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3968 /* Add a blank character to highlight. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3969 ScreenLines[off] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3970 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3971 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3972 ScreenLinesUC[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3973 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3974 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3975 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3976 if (area_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3977 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
3978 if ((ptr - line) - 1 == (long)match_hl.startcol)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3979 char_attr = match_hl.attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3980 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3981 char_attr = search_hl.attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3983 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3984 ScreenAttrs[off] = char_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3985 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3986 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3987 --col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3988 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3989 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3990 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3991 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3993 SCREEN_LINE(screen_row, W_WINCOL(wp), col, (int)W_WIDTH(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3994 wp->w_p_rl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3995 row++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3997 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3998 * Update w_cline_height and w_cline_folded if the cursor line was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3999 * updated (saves a call to plines() later).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4000 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4001 if (wp == curwin && lnum == curwin->w_cursor.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4002 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4003 curwin->w_cline_row = startrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4004 curwin->w_cline_height = row - startrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4005 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4006 curwin->w_cline_folded = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4007 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4008 curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4009 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4010
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4011 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4014 /* line continues beyond line end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4015 if (lcs_ext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4016 && !wp->w_p_wrap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4017 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4018 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4019 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4020 && (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4021 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4022 wp->w_p_rl ? col == 0 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4023 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4024 col == W_WIDTH(wp) - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4025 && (*ptr != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4026 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4027 || (n_extra && (c_extra != NUL || *p_extra != NUL))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4028 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4029 c = lcs_ext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4030 char_attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4031 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4032 mb_c = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4033 if (enc_utf8 && (*mb_char2len)(c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4034 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4035 mb_utf8 = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4036 u8c_c1 = u8c_c2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4037 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4038 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4039 mb_utf8 = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4040 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4041 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4043 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4044 * Store character to be displayed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4045 * Skip characters that are left of the screen for 'nowrap'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4046 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4047 vcol_prev = vcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4048 if (draw_state < WL_LINE || n_skip <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4049 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4050 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4051 * Store the character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4052 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4053 #if defined(FEAT_RIGHTLEFT) && defined(FEAT_MBYTE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4054 if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4055 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4056 /* A double-wide character is: put first halve in left cell. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4057 --off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4058 --col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4060 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4061 ScreenLines[off] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4062 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4063 if (enc_dbcs == DBCS_JPNU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4064 ScreenLines2[off] = mb_c & 0xff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4065 else if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4066 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4067 if (mb_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4069 ScreenLinesUC[off] = mb_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4070 ScreenLinesC1[off] = u8c_c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4071 ScreenLinesC2[off] = u8c_c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4073 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4074 ScreenLinesUC[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4075 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4076 if (multi_attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4078 ScreenAttrs[off] = multi_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4079 multi_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4080 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4081 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4082 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4083 ScreenAttrs[off] = char_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4085 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4086 if (has_mbyte && (*mb_char2cells)(mb_c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4087 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4088 /* Need to fill two screen columns. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4089 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4090 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4091 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4092 /* UTF-8: Put a 0 in the second screen char. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4093 ScreenLines[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4094 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4095 /* DBCS: Put second byte in the second screen char. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4096 ScreenLines[off] = mb_c & 0xff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4097 ++vcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4098 /* When "tocol" is halfway a character, set it to the end of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4099 * the character, otherwise highlighting won't stop. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100 if (tocol == vcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101 ++tocol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4102 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4103 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 /* now it's time to backup one cell */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4106 --off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4107 --col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4109 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4110 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4111 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4112 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4113 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4115 --off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4116 --col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4118 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4119 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4121 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4122 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4123 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4124 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4125 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4126 --n_skip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4128 /* Only advance the "vcol" when after the 'number' column. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4129 if (draw_state >= WL_SBR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4130 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4131 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4132 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4133 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4134 ++vcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4136 /* restore attributes after "predeces" in 'listchars' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4137 if (draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4138 char_attr = saved_attr3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4140 /* restore attributes after last 'listchars' or 'number' char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4141 if (n_attr > 0 && draw_state == WL_LINE && --n_attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4142 char_attr = saved_attr2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4144 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4145 * At end of screen line and there is more to come: Display the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4146 * so far. If there is no more to display it is catched above.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4147 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4148 if ((
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4149 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4150 wp->w_p_rl ? (col < 0) :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4151 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4152 (col >= W_WIDTH(wp)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4153 && (*ptr != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4154 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4155 || filler_todo > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4156 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4157 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4158 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4159 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4160 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4161 SCREEN_LINE(screen_row, W_WINCOL(wp), col, (int)W_WIDTH(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4162 wp->w_p_rl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4163 ++row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4164 ++screen_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4166 /* When not wrapping and finished diff lines, or when displayed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4167 * '$' and highlighting until last column, break here. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4168 if ((!wp->w_p_wrap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4169 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4170 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4171 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4172 ) || lcs_eol_one == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4173 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4175 /* When the window is too narrow draw all "@" lines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4176 if (draw_state != WL_LINE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4177 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4178 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4179 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4180 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4181 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4182 win_draw_end(wp, '@', ' ', row, wp->w_height, HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4183 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4184 draw_vsep_win(wp, row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4185 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4186 row = endrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4187 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4189 /* When line got too long for screen break here. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4190 if (row == endrow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4192 ++row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4193 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4194 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4196 if (screen_cur_row == screen_row - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4197 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4198 && filler_todo <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4199 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4200 && W_WIDTH(wp) == Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4201 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4202 /* Remember that the line wraps, used for modeless copy. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4203 LineWraps[screen_row - 1] = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4205 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4206 * Special trick to make copy/paste of wrapped lines work with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4207 * xterm/screen: write an extra character beyond the end of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4208 * the line. This will work with all terminal types
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4209 * (regardless of the xn,am settings).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4210 * Only do this on a fast tty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4211 * Only do this if the cursor is on the current line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4212 * (something has been written in it).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4213 * Don't do this for the GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4214 * Don't do this for double-width characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4215 * Don't do this for a window not at the right screen border.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4216 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4217 if (p_tf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4218 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4219 && !gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4220 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4221 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4222 && !(has_mbyte
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4223 && ((*mb_off2cells)(LineOffset[screen_row]) == 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4224 || (*mb_off2cells)(LineOffset[screen_row - 1]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4225 + (int)Columns - 2) == 2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4226 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4227 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4228 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4229 /* First make sure we are at the end of the screen line,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4230 * then output the same character again to let the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4231 * terminal know about the wrap. If the terminal doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4232 * auto-wrap, we overwrite the character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4233 if (screen_cur_col != W_WIDTH(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4234 screen_char(LineOffset[screen_row - 1]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4235 + (unsigned)Columns - 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4236 screen_row - 1, (int)(Columns - 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4238 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4239 /* When there is a multi-byte character, just output a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4240 * space to keep it simple. */
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 119
diff changeset
4241 if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 119
diff changeset
4242 screen_row - 1] + (Columns - 1)]) > 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4243 out_char(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4244 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4245 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4246 out_char(ScreenLines[LineOffset[screen_row - 1]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4247 + (Columns - 1)]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4248 /* force a redraw of the first char on the next line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4249 ScreenAttrs[LineOffset[screen_row]] = (sattr_T)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4250 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4252 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4254 col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4255 off = (unsigned)(current_ScreenLine - ScreenLines);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4256 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4257 if (wp->w_p_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4258 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4259 col = W_WIDTH(wp) - 1; /* col is not used if breaking! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4260 off += col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4261 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4262 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4264 /* reset the drawing state for the start of a wrapped line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4265 draw_state = WL_START;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4266 saved_n_extra = n_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4267 saved_p_extra = p_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4268 saved_c_extra = c_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4269 saved_char_attr = char_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4270 n_extra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4271 lcs_prec_todo = lcs_prec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4272 #ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4273 # ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4274 if (filler_todo <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4275 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4276 need_showbreak = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4277 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4278 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4279 --filler_todo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4280 /* When the filler lines are actually below the last line of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4281 * file, don't draw the line itself, break here. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4282 if (filler_todo == 0 && wp->w_botfill)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4283 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4284 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4285 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4287 } /* for every character in the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4289 return row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4290 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4292 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4293 * Check whether the given character needs redrawing:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4294 * - the (first byte of the) character is different
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4295 * - the attributes are different
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4296 * - the character is multi-byte and the next byte is different
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4297 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4298 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4299 char_needs_redraw(off_from, off_to, cols)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4300 int off_from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4301 int off_to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4302 int cols;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4303 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4304 if (cols > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4305 && ((ScreenLines[off_from] != ScreenLines[off_to]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4306 || ScreenAttrs[off_from] != ScreenAttrs[off_to])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4308 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4309 || (enc_dbcs != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4310 && MB_BYTE2LEN(ScreenLines[off_from]) > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4311 && (enc_dbcs == DBCS_JPNU && ScreenLines[off_from] == 0x8e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4312 ? ScreenLines2[off_from] != ScreenLines2[off_to]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4313 : (cols > 1 && ScreenLines[off_from + 1]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4314 != ScreenLines[off_to + 1])))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4315 || (enc_utf8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4316 && (ScreenLinesUC[off_from] != ScreenLinesUC[off_to]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4317 || (ScreenLinesUC[off_from] != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4318 && (ScreenLinesC1[off_from]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4319 != ScreenLinesC1[off_to]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4320 || ScreenLinesC2[off_from]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4321 != ScreenLinesC2[off_to]))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4322 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4323 ))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4324 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4325 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4326 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4328 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4329 * Move one "cooked" screen line to the screen, but only the characters that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4330 * have actually changed. Handle insert/delete character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4331 * "coloff" gives the first column on the screen for this line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4332 * "endcol" gives the columns where valid characters are.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4333 * "clear_width" is the width of the window. It's > 0 if the rest of the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4334 * needs to be cleared, negative otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4335 * "rlflag" is TRUE in a rightleft window:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4336 * When TRUE and "clear_width" > 0, clear columns 0 to "endcol"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4337 * When FALSE and "clear_width" > 0, clear columns "endcol" to "clear_width"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4338 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4339 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4340 screen_line(row, coloff, endcol, clear_width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4341 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4342 , rlflag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4343 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4344 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4345 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4346 int coloff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4347 int endcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4348 int clear_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4349 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4350 int rlflag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4351 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4353 unsigned off_from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4354 unsigned off_to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4355 int col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4356 #if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4357 int hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4358 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4359 int force = FALSE; /* force update rest of the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4360 int redraw_this /* bool: does character need redraw? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4361 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4362 = TRUE /* For GUI when while-loop empty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4363 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4364 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4365 int redraw_next; /* redraw_this for next character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4366 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4367 int clear_next = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4368 int char_cells; /* 1: normal char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4369 /* 2: occupies two display cells */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4370 # define CHAR_CELLS char_cells
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4371 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4372 # define CHAR_CELLS 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4373 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4374
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4375 # ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4376 clip_may_clear_selection(row, row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4377 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4379 off_from = (unsigned)(current_ScreenLine - ScreenLines);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4380 off_to = LineOffset[row] + coloff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4382 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4383 if (rlflag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4384 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4385 /* Clear rest first, because it's left of the text. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4386 if (clear_width > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4387 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4388 while (col <= endcol && ScreenLines[off_to] == ' '
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4389 && ScreenAttrs[off_to] == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4390 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4391 && (!enc_utf8 || ScreenLinesUC[off_to] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4392 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4393 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4395 ++off_to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4396 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4398 if (col <= endcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4399 screen_fill(row, row + 1, col + coloff,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4400 endcol + coloff + 1, ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4401 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4402 col = endcol + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4403 off_to = LineOffset[row] + col + coloff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4404 off_from += col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4405 endcol = (clear_width > 0 ? clear_width : -clear_width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4406 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4407 #endif /* FEAT_RIGHTLEFT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4409 redraw_next = char_needs_redraw(off_from, off_to, endcol - col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4411 while (col < endcol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4412 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4413 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4414 if (has_mbyte && (col + 1 < endcol))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4415 char_cells = (*mb_off2cells)(off_from);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4416 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4417 char_cells = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4418 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4420 redraw_this = redraw_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4421 redraw_next = force || char_needs_redraw(off_from + CHAR_CELLS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4422 off_to + CHAR_CELLS, endcol - col - CHAR_CELLS);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4424 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4425 /* If the next character was bold, then redraw the current character to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4426 * remove any pixels that might have spilt over into us. This only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4427 * happens in the GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4428 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4429 if (redraw_next && gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4430 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4431 hl = ScreenAttrs[off_to + CHAR_CELLS];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4432 if (hl > HL_ALL || (hl & HL_BOLD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4433 redraw_this = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4435 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4437 if (redraw_this)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4438 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4439 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4440 * Special handling when 'xs' termcap flag set (hpterm):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4441 * Attributes for characters are stored at the position where the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4442 * cursor is when writing the highlighting code. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4443 * start-highlighting code must be written with the cursor on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4444 * first highlighted character. The stop-highlighting code must
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4445 * be written with the cursor just after the last highlighted
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4446 * character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4447 * Overwriting a character doesn't remove it's highlighting. Need
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4448 * to clear the rest of the line, and force redrawing it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4449 * completely.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4450 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4451 if ( p_wiv
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4452 && !force
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4453 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4454 && !gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4455 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4456 && ScreenAttrs[off_to] != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4457 && ScreenAttrs[off_from] != ScreenAttrs[off_to])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4458 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4459 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4460 * Need to remove highlighting attributes here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4461 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4462 windgoto(row, col + coloff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4463 out_str(T_CE); /* clear rest of this screen line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4464 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4465 force = TRUE; /* force redraw of rest of the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4466 redraw_next = TRUE; /* or else next char would miss out */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4468 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4469 * If the previous character was highlighted, need to stop
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4470 * highlighting at this character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4471 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4472 if (col + coloff > 0 && ScreenAttrs[off_to - 1] != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4473 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4474 screen_attr = ScreenAttrs[off_to - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4475 term_windgoto(row, col + coloff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4476 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4477 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4478 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4479 screen_attr = 0; /* highlighting has stopped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4480 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4481 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4482 if (enc_dbcs != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4483 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4484 /* Check if overwriting a double-byte with a single-byte or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4485 * the other way around requires another character to be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4486 * redrawn. For UTF-8 this isn't needed, because comparing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4487 * ScreenLinesUC[] is sufficient. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4488 if (char_cells == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4489 && col + 1 < endcol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4490 && (*mb_off2cells)(off_to) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4491 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4492 /* Writing a single-cell character over a double-cell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4493 * character: need to redraw the next cell. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4494 ScreenLines[off_to + 1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4495 redraw_next = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4496 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4497 else if (char_cells == 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4498 && col + 2 < endcol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4499 && (*mb_off2cells)(off_to) == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4500 && (*mb_off2cells)(off_to + 1) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4501 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4502 /* Writing the second half of a double-cell character over
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4503 * a double-cell character: need to redraw the second
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4504 * cell. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4505 ScreenLines[off_to + 2] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4506 redraw_next = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4509 if (enc_dbcs == DBCS_JPNU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4510 ScreenLines2[off_to] = ScreenLines2[off_from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4511 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4512 /* When writing a single-width character over a double-width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4513 * character and at the end of the redrawn text, need to clear out
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4514 * the right halve of the old character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4515 * Also required when writing the right halve of a double-width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4516 * char over the left halve of an existing one. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4517 if (has_mbyte && col + char_cells == endcol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4518 && ((char_cells == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4519 && (*mb_off2cells)(off_to) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4520 || (char_cells == 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4521 && (*mb_off2cells)(off_to) == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4522 && (*mb_off2cells)(off_to + 1) > 1)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4523 clear_next = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4524 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4525
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4526 ScreenLines[off_to] = ScreenLines[off_from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4527 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4528 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4530 ScreenLinesUC[off_to] = ScreenLinesUC[off_from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4531 if (ScreenLinesUC[off_from] != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4532 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4533 ScreenLinesC1[off_to] = ScreenLinesC1[off_from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4534 ScreenLinesC2[off_to] = ScreenLinesC2[off_from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4535 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4536 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4537 if (char_cells == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4538 ScreenLines[off_to + 1] = ScreenLines[off_from + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4539 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4541 #if defined(FEAT_GUI) || defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4542 /* The bold trick makes a single row of pixels appear in the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4543 * character. When a bold character is removed, the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4544 * character should be redrawn too. This happens for our own GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4545 * and for some xterms. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4546 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4547 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4548 gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4549 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4550 # if defined(FEAT_GUI) && defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4551 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4552 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4553 # ifdef UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4554 term_is_xterm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4555 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4556 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4557 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4558 hl = ScreenAttrs[off_to];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4559 if (hl > HL_ALL || (hl & HL_BOLD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4560 redraw_next = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4562 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4563 ScreenAttrs[off_to] = ScreenAttrs[off_from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4564 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4565 if (enc_dbcs != 0 && char_cells == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4566 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4567 /* just a hack: It makes two bytes of DBCS have same attr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4568 ScreenAttrs[off_to + 1] = ScreenAttrs[off_from];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4569 screen_char_2(off_to, row, col + coloff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4571 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4572 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4573 screen_char(off_to, row, col + coloff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4575 else if ( p_wiv
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4576 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4577 && !gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4578 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4579 && col + coloff > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4580 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4581 if (ScreenAttrs[off_to] == ScreenAttrs[off_to - 1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4583 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4584 * Don't output stop-highlight when moving the cursor, it will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4585 * stop the highlighting when it should continue.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4586 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4587 screen_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4588 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4589 else if (screen_attr != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4590 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4593 off_to += CHAR_CELLS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4594 off_from += CHAR_CELLS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4595 col += CHAR_CELLS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4596 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4598 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4599 if (clear_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4601 /* Clear the second half of a double-wide character of which the left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4602 * half was overwritten with a single-wide character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4603 ScreenLines[off_to] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4604 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4605 ScreenLinesUC[off_to] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4606 screen_char(off_to, row, col + coloff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4607 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4608 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4609
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4610 if (clear_width > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4611 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4612 && !rlflag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4613 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4614 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4615 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4616 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4617 int startCol = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4618 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4620 /* blank out the rest of the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4621 while (col < clear_width && ScreenLines[off_to] == ' '
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4622 && ScreenAttrs[off_to] == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4623 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4624 && (!enc_utf8 || ScreenLinesUC[off_to] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4625 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4626 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4628 ++off_to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4629 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4630 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4631 if (col < clear_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4632 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4633 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4634 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4635 * In the GUI, clearing the rest of the line may leave pixels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4636 * behind if the first character cleared was bold. Some bold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4637 * fonts spill over the left. In this case we redraw the previous
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4638 * character too. If we didn't skip any blanks above, then we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4639 * only redraw if the character wasn't already redrawn anyway.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4640 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4641 if (gui.in_use && (col > startCol || !redraw_this)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4642 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4643 && enc_dbcs == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4644 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4645 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4647 hl = ScreenAttrs[off_to];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4648 if (hl > HL_ALL || (hl & HL_BOLD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4649 screen_char(off_to - 1, row, col + coloff - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4650 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4651 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4652 screen_fill(row, row + 1, col + coloff, clear_width + coloff,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4653 ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4654 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4655 off_to += clear_width - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4656 col = clear_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4657 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4658 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4659 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4661 if (clear_width > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4662 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4663 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4664 /* For a window that's left of another, draw the separator char. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4665 if (col + coloff < Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4666 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4667 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4669 c = fillchar_vsep(&hl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4670 if (ScreenLines[off_to] != c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4671 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4672 || (enc_utf8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4673 && ScreenLinesUC[off_to] != (c >= 0x80 ? c : 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4674 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4675 || ScreenAttrs[off_to] != hl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4676 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4677 ScreenLines[off_to] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4678 ScreenAttrs[off_to] = hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4679 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4680 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4681 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4682 if (c >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4683 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4684 ScreenLinesUC[off_to] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4685 ScreenLinesC1[off_to] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4686 ScreenLinesC2[off_to] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4687 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4688 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4689 ScreenLinesUC[off_to] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4690 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4691 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4692 screen_char(off_to, row, col + coloff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4693 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4695 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4696 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4697 LineWraps[row] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4699 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4701 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4702 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4703 * Mirror text "str" for right-lieft displaying.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4705 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4706 rl_mirror(str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4707 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4708 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4709 char_u *p1, *p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4710 int t;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 for (p1 = str, p2 = str + STRLEN(str) - 1; p1 < p2; ++p1, --p2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4714 t = *p1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4715 *p1 = *p2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 *p2 = t;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4717 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4719 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4721 #if defined(FEAT_WINDOWS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4722 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4723 * mark all status lines for redraw; used after first :cd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4724 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4725 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4726 status_redraw_all()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4727 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4728 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4730 for (wp = firstwin; wp; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4731 if (wp->w_status_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4732 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4733 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4734 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4735 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4738 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4739 * mark all status lines of the current buffer for redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4740 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4741 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4742 status_redraw_curbuf()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4743 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4744 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4746 for (wp = firstwin; wp; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4747 if (wp->w_status_height != 0 && wp->w_buffer == curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4748 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4749 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4750 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4751 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4752 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4754 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4755 * Redraw all status lines that need to be redrawn.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4756 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4757 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4758 redraw_statuslines()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4759 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4760 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4761
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4762 for (wp = firstwin; wp; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4763 if (wp->w_redr_status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4764 win_redr_status(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4766 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4768 #if (defined(FEAT_WILDMENU) && defined(FEAT_VERTSPLIT)) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4769 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4770 * Redraw all status lines at the bottom of frame "frp".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4771 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4772 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4773 win_redraw_last_status(frp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4774 frame_T *frp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4775 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4776 if (frp->fr_layout == FR_LEAF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4777 frp->fr_win->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4778 else if (frp->fr_layout == FR_ROW)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4779 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4780 for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4781 win_redraw_last_status(frp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4783 else /* frp->fr_layout == FR_COL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4784 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4785 frp = frp->fr_child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4786 while (frp->fr_next != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4787 frp = frp->fr_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4788 win_redraw_last_status(frp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4789 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4790 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4791 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4792
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4793 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4794 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4795 * Draw the verticap separator right of window "wp" starting with line "row".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4796 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4797 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4798 draw_vsep_win(wp, row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4799 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4800 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4801 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4802 int hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4803 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4804
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4805 if (wp->w_vsep_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4806 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4807 /* draw the vertical separator right of this window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4808 c = fillchar_vsep(&hl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4809 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4810 W_ENDCOL(wp), W_ENDCOL(wp) + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4811 c, ' ', hl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4812 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4814 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4816 #ifdef FEAT_WILDMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 static int status_match_len __ARGS((expand_T *xp, char_u *s));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4818
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4819 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4820 * Get the lenght of an item as it will be shown in the status line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4821 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4822 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4823 status_match_len(xp, s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4824 expand_T *xp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4825 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4826 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4827 int len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4829 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4830 int emenu = (xp->xp_context == EXPAND_MENUS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4831 || xp->xp_context == EXPAND_MENUNAMES);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4833 /* Check for menu separators - replace with '|'. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4834 if (emenu && menu_is_separator(s))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4835 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4836 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4838 while (*s != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4839 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4840 /* Don't display backslashes used for escaping, they look ugly. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4841 if (rem_backslash(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4842 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4843 || (emenu && (s[0] == '\\' && s[1] != NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4844 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4845 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4846 ++s;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 40
diff changeset
4847 len += ptr2cells(s);
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
4848 mb_ptr_adv(s);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4851 return len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4854 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4855 * Show wildchar matches in the status line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4856 * Show at least the "match" item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4857 * We start at item 'first_match' in the list and show all matches that fit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4858 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4859 * If inversion is possible we use it. Else '=' characters are used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4860 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4861 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4862 win_redr_status_matches(xp, num_matches, matches, match, showtail)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4863 expand_T *xp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4864 int num_matches;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4865 char_u **matches; /* list of matches */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4866 int match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4867 int showtail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4868 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4869 #define L_MATCH(m) (showtail ? sm_gettail(matches[m]) : matches[m])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4870 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4871 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4872 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4873 int clen; /* lenght in screen cells */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4874 int fillchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4875 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4876 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4877 int highlight = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4878 char_u *selstart = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4879 int selstart_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4880 char_u *selend = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4881 static int first_match = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4882 int add_left = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4883 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4884 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4885 int emenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4886 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4887 #if defined(FEAT_MBYTE) || defined(FEAT_MENU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4888 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4889 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4890
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4891 if (matches == NULL) /* interrupted completion? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4892 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4893
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
4894 #ifdef FEAT_MBYTE
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
4895 if (has_mbyte)
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
4896 buf = alloc((unsigned)Columns * MB_MAXBYTES + 1);
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
4897 else
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
4898 #endif
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
4899 buf = alloc((unsigned)Columns + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4900 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4901 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4903 if (match == -1) /* don't show match but original text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4904 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4905 match = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4906 highlight = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4908 /* count 1 for the ending ">" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4909 clen = status_match_len(xp, L_MATCH(match)) + 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4910 if (match == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4911 first_match = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4912 else if (match < first_match)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4913 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4914 /* jumping left, as far as we can go */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4915 first_match = match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4916 add_left = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4918 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4919 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4920 /* check if match fits on the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4921 for (i = first_match; i < match; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4922 clen += status_match_len(xp, L_MATCH(i)) + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4923 if (first_match > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4924 clen += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4925 /* jumping right, put match at the left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4926 if ((long)clen > Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4927 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4928 first_match = match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4929 /* if showing the last match, we can add some on the left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4930 clen = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4931 for (i = match; i < num_matches; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4932 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4933 clen += status_match_len(xp, L_MATCH(i)) + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4934 if ((long)clen >= Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4935 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4936 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4937 if (i == num_matches)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4938 add_left = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4939 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4940 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4941 if (add_left)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4942 while (first_match > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4944 clen += status_match_len(xp, L_MATCH(first_match - 1)) + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4945 if ((long)clen >= Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4946 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4947 --first_match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4949
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4950 fillchar = fillchar_status(&attr, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4951
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4952 if (first_match == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4953 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4954 *buf = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4955 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4956 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4957 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4958 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4959 STRCPY(buf, "< ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4960 len = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4962 clen = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4963
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4964 i = first_match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4965 while ((long)(clen + status_match_len(xp, L_MATCH(i)) + 2) < Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4966 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4967 if (i == match)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4968 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4969 selstart = buf + len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4970 selstart_col = clen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4971 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4972
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4973 s = L_MATCH(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4974 /* Check for menu separators - replace with '|' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4975 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4976 emenu = (xp->xp_context == EXPAND_MENUS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4977 || xp->xp_context == EXPAND_MENUNAMES);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4978 if (emenu && menu_is_separator(s))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4980 STRCPY(buf + len, transchar('|'));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4981 l = (int)STRLEN(buf + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4982 len += l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4983 clen += l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4984 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4985 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4986 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4987 for ( ; *s != NUL; ++s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4988 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4989 /* Don't display backslashes used for escaping, they look ugly. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4990 if (rem_backslash(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4992 || (emenu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4993 && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4994 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4995 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4996 ++s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4997 clen += ptr2cells(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4998 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4999 if (has_mbyte && (l = (*mb_ptr2len_check)(s)) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5000 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5001 STRNCPY(buf + len, s, l);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5002 s += l - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5003 len += l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5004 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5005 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5006 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5008 STRCPY(buf + len, transchar_byte(*s));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5009 len += (int)STRLEN(buf + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5010 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5011 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5012 if (i == match)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5013 selend = buf + len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5014
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5015 *(buf + len++) = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5016 *(buf + len++) = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5017 clen += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5018 if (++i == num_matches)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5020 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5022 if (i != num_matches)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5023 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 *(buf + len++) = '>';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5025 ++clen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5026 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5027
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5028 buf[len] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5029
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5030 row = cmdline_row - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5031 if (row >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5032 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5033 if (wild_menu_showing == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5034 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5035 if (msg_scrolled > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5036 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5037 /* Put the wildmenu just above the command line. If there is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5038 * no room, scroll the screen one line up. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5039 if (cmdline_row == Rows - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5041 screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5042 ++msg_scrolled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5043 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5044 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5045 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5046 ++cmdline_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5047 ++row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5048 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5049 wild_menu_showing = WM_SCROLLED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5050 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5051 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5052 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5053 /* Create status line if needed by setting 'laststatus' to 2.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5054 * Set 'winminheight' to zero to avoid that the window is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5055 * resized. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5056 if (lastwin->w_status_height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5057 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5058 save_p_ls = p_ls;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5059 save_p_wmh = p_wmh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5060 p_ls = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5061 p_wmh = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5062 last_status(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5063 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5064 wild_menu_showing = WM_SHOWN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5065 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5066 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5067
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5068 screen_puts(buf, row, 0, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5069 if (selstart != NULL && highlight)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5071 *selend = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5072 screen_puts(selstart, row, selstart_col, hl_attr(HLF_WM));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5074
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5075 screen_fill(row, row + 1, clen, (int)Columns, fillchar, fillchar, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5076 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5078 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5079 win_redraw_last_status(topframe);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5080 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5081 lastwin->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5082 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5083 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5084 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5085 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5086
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087 #if defined(FEAT_WINDOWS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5088 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5089 * Redraw the status line of window wp.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5090 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091 * If inversion is possible we use it. Else '=' characters are used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5093 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 win_redr_status(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5097 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5098 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5099 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5100 int fillchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5101 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5102 int this_ru_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5104 wp->w_redr_status = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5105 if (wp->w_status_height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107 /* no status line, can only be last window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5108 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5109 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5110 else if (!redrawing())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5112 /* Don't redraw right now, do it later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5115 #ifdef FEAT_STL_OPT
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
5116 else if (*p_stl != NUL || *wp->w_p_stl != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 /* redraw custom status line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5119 win_redr_custom(wp, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5122 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5124 fillchar = fillchar_status(&attr, wp == curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126 if (buf_spname(wp->w_buffer) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5127 STRCPY(NameBuff, buf_spname(wp->w_buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5129 home_replace(wp->w_buffer, wp->w_buffer->b_fname, NameBuff,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5130 MAXPATHL, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5131 trans_characters(NameBuff, MAXPATHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5132 p = NameBuff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5133 len = (int)STRLEN(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5135 if (wp->w_buffer->b_help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5136 #ifdef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5137 || wp->w_p_pvw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5138 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5139 || bufIsChanged(wp->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140 || wp->w_buffer->b_p_ro)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5141 *(p + len++) = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 if (wp->w_buffer->b_help)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5143 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5144 STRCPY(p + len, _("[help]"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5145 len += (int)STRLEN(p + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5146 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5147 #ifdef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5148 if (wp->w_p_pvw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5149 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5150 STRCPY(p + len, _("[Preview]"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5151 len += (int)STRLEN(p + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5152 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5153 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5154 if (bufIsChanged(wp->w_buffer))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5155 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5156 STRCPY(p + len, "[+]");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5157 len += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5158 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5159 if (wp->w_buffer->b_p_ro)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5160 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5161 STRCPY(p + len, "[RO]");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5162 len += 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5163 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5165 #ifndef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5166 this_ru_col = ru_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5167 if (this_ru_col < (Columns + 1) / 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5168 this_ru_col = (Columns + 1) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5169 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5170 this_ru_col = ru_col - (Columns - W_WIDTH(wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5171 if (this_ru_col < (W_WIDTH(wp) + 1) / 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5172 this_ru_col = (W_WIDTH(wp) + 1) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5173 if (this_ru_col <= 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5175 p = (char_u *)"<"; /* No room for file name! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5176 len = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5178 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5179 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5180 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5181 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5182 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5183 int clen = 0, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5185 /* Count total number of display cells. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5186 for (i = 0; p[i] != NUL; i += (*mb_ptr2len_check)(p + i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5187 clen += (*mb_ptr2cells)(p + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5188 /* Find first character that will fit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5189 * Going from start to end is much faster for DBCS. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5190 for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5191 i += (*mb_ptr2len_check)(p + i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5192 clen -= (*mb_ptr2cells)(p + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5193 len = clen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5194 if (i > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5195 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5196 p = p + i - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5197 *p = '<';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5198 ++len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5199 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5202 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5203 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5204 if (len > this_ru_col - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5205 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5206 p += len - (this_ru_col - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5207 *p = '<';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5208 len = this_ru_col - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5209 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5211 row = W_WINROW(wp) + wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5212 screen_puts(p, row, W_WINCOL(wp), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5213 screen_fill(row, row + 1, len + W_WINCOL(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5214 this_ru_col + W_WINCOL(wp), fillchar, fillchar, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5216 if (get_keymap_str(wp, NameBuff, MAXPATHL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5217 && (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5218 screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5219 - 1 + W_WINCOL(wp)), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5221 #ifdef FEAT_CMDL_INFO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5222 win_redr_ruler(wp, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5223 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5224 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5226 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5227 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5228 * May need to draw the character below the vertical separator.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5229 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5230 if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5232 if (stl_connected(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5233 fillchar = fillchar_status(&attr, wp == curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5234 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5235 fillchar = fillchar_vsep(&attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5236 screen_putchar(fillchar, W_WINROW(wp) + wp->w_height, W_ENDCOL(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5237 attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5239 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5240 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5242 # ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5243 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244 * Return TRUE if the status line of window "wp" is connected to the status
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245 * line of the window right of it. If not, then it's a vertical separator.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5246 * Only call if (wp->w_vsep_width != 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5247 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5248 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5249 stl_connected(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5250 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5251 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5252 frame_T *fr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5254 fr = wp->w_frame;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5255 while (fr->fr_parent != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5257 if (fr->fr_parent->fr_layout == FR_COL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5258 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5259 if (fr->fr_next != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5260 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5261 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5262 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5264 if (fr->fr_next != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5265 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5267 fr = fr->fr_parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5269 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5270 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5271 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5273 #endif /* FEAT_WINDOWS */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5274
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5275 #if defined(FEAT_WINDOWS) || defined(FEAT_STL_OPT) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5276 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5277 * Get the value to show for the language mappings, active 'keymap'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5278 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5280 get_keymap_str(wp, buf, len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5281 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5282 char_u *buf; /* buffer for the result */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5283 int len; /* length of buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5285 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5287 if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5288 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5291 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5292 buf_T *old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5293 win_T *old_curwin = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5294 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5296 curbuf = wp->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5297 curwin = wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298 STRCPY(buf, "b:keymap_name"); /* must be writable */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5299 ++emsg_skip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5300 s = p = eval_to_string(buf, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301 --emsg_skip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5302 curbuf = old_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5303 curwin = old_curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5304 if (p == NULL || *p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307 #ifdef FEAT_KEYMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5309 p = wp->w_buffer->b_p_keymap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5310 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5311 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5312 p = (char_u *)"lang";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5314 if ((int)(STRLEN(p) + 3) < len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5315 sprintf((char *)buf, "<%s>", p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317 buf[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319 vim_free(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5320 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5321 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5322 return buf[0] != NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5323 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5324 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5326 #if defined(FEAT_STL_OPT) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5328 * Redraw the status line or ruler of window wp.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 win_redr_custom(wp, Ruler)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5332 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 int Ruler;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5335 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5336 int curattr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5337 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5338 int col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5339 int maxwidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340 int width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5341 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5342 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5343 int fillchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5344 char_u buf[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5345 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5346 struct stl_hlrec hl[STL_MAX_ITEM];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5348 /* setup environment for the task at hand */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5349 row = W_WINROW(wp) + wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5350 fillchar = fillchar_status(&attr, wp == curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5351 maxwidth = W_WIDTH(wp);
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
5352 if (*wp->w_p_stl != NUL)
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
5353 p = wp->w_p_stl;
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
5354 else
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
5355 p = p_stl;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 if (Ruler)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5358 p = p_ruf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5359 /* advance past any leading group spec - implicit in ru_col */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5360 if (*p == '%')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5362 if (*++p == '-')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5363 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5364 if (atoi((char *) p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5365 while (VIM_ISDIGIT(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5366 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5367 if (*p++ != '(')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368 p = p_ruf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5370 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5371 col = ru_col - (Columns - W_WIDTH(wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5372 if (col < (W_WIDTH(wp) + 1) / 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5373 col = (W_WIDTH(wp) + 1) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5374 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5375 col = ru_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5376 if (col > (Columns + 1) / 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5377 col = (Columns + 1) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5378 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5379 maxwidth = W_WIDTH(wp) - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5380 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5381 if (!wp->w_status_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5382 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5383 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5384 row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5385 --maxwidth; /* writing in last column may cause scrolling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5386 fillchar = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5387 attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5388 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5389 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5390 if (maxwidth <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5391 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5392 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5393 col += W_WINCOL(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5396 width = build_stl_str_hl(wp, buf, sizeof(buf), p, fillchar, maxwidth, hl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5397 len = STRLEN(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5398
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5399 while (width < maxwidth && len < sizeof(buf) - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5401 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5402 len += (*mb_char2bytes)(fillchar, buf + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5403 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5404 buf[len++] = fillchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5405 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5406 ++width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5408 buf[len] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5410 curattr = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5411 p = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5412 for (n = 0; hl[n].start != NULL; n++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5413 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5414 len = (int)(hl[n].start - p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 screen_puts_len(p, len, row, col, curattr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5416 col += vim_strnsize(p, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417 p = hl[n].start;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5418
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5419 if (hl[n].userhl == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 curattr = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5422 else if (wp != curwin && wp->w_status_height != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5423 curattr = highlight_stlnc[hl[n].userhl - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5424 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5425 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426 curattr = highlight_user[hl[n].userhl - 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 screen_puts(p, row, col, curattr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431 #endif /* FEAT_STL_OPT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5434 * Output a single character directly to the screen and update ScreenLines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5435 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5436 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 screen_putchar(c, row, col, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 int row, col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5441 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5442 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5443 char_u buf[MB_MAXBYTES + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445 buf[(*mb_char2bytes)(c, buf)] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5446 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5447 char_u buf[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5448
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5449 buf[0] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5450 buf[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5451 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5452 screen_puts(buf, row, col, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5454
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5455 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5456 * Get a single character directly from ScreenLines into "bytes[]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5457 * Also return its attribute in *attrp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5458 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5459 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5460 screen_getbytes(row, col, bytes, attrp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5461 int row, col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5462 char_u *bytes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5463 int *attrp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5464 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5465 unsigned off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5467 /* safety check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5468 if (ScreenLines != NULL && row < screen_Rows && col < screen_Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5470 off = LineOffset[row] + col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5471 *attrp = ScreenAttrs[off];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5472 bytes[0] = ScreenLines[off];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5473 bytes[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5475 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5476 if (enc_utf8 && ScreenLinesUC[off] != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5477 bytes[utfc_char2bytes(off, bytes)] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5478 else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5480 bytes[0] = ScreenLines[off];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5481 bytes[1] = ScreenLines2[off];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5482 bytes[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5483 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5484 else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5485 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5486 bytes[1] = ScreenLines[off + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5487 bytes[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5488 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5489 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5490 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5491 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5493 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5494 * Put string '*text' on the screen at position 'row' and 'col', with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5495 * attributes 'attr', and update ScreenLines[] and ScreenAttrs[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5496 * Note: only outputs within one row, message is truncated at screen boundary!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5497 * Note: if ScreenLines[], row and/or col is invalid, nothing is done.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5498 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5499 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500 screen_puts(text, row, col, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5502 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5503 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5504 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5506 screen_puts_len(text, -1, row, col, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5509 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5510 * Like screen_puts(), but output "text[len]". When "len" is -1 output up to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5511 * a NUL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5512 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5513 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5514 screen_puts_len(text, len, row, col, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5515 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5516 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5517 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5518 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5520 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5521 unsigned off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5522 char_u *ptr = text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5523 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5524 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5525 int mbyte_blen = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5526 int mbyte_cells = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5527 int u8c = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5528 int u8c_c1 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5529 int u8c_c2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5530 int clear_next_cell = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5531 # ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5532 int prev_c = 0; /* previous Arabic character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5533 int pc, nc, nc1, dummy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5534 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5535 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5537 if (ScreenLines == NULL || row >= screen_Rows) /* safety check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5538 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5540 off = LineOffset[row] + col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5541 while (*ptr != NUL && col < screen_Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5542 && (len < 0 || (int)(ptr - text) < len))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5544 c = *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5545 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5546 /* check if this is the first byte of a multibyte */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5547 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5548 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5549 if (enc_utf8 && len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5550 mbyte_blen = utfc_ptr2len_check_len(ptr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5551 (int)((text + len) - ptr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5552 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5553 mbyte_blen = (*mb_ptr2len_check)(ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5554 if (enc_dbcs == DBCS_JPNU && c == 0x8e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5555 mbyte_cells = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5556 else if (enc_dbcs != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5557 mbyte_cells = mbyte_blen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5558 else /* enc_utf8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5559 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5560 if (len >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5561 u8c = utfc_ptr2char_len(ptr, &u8c_c1, &u8c_c2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5562 (int)((text + len) - ptr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5563 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5564 u8c = utfc_ptr2char(ptr, &u8c_c1, &u8c_c2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5565 mbyte_cells = utf_char2cells(u8c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5566 /* Non-BMP character: display as ? or fullwidth ?. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5567 if (u8c >= 0x10000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5568 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5569 u8c = (mbyte_cells == 2) ? 0xff1f : (int)'?';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5570 if (attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5571 attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5572 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5573 # ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5574 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5575 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5576 /* Do Arabic shaping. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5577 if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5578 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5579 /* Past end of string to be displayed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5580 nc = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5581 nc1 = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5582 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5583 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5584 nc = utfc_ptr2char(ptr + mbyte_blen, &nc1, &dummy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 pc = prev_c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 prev_c = u8c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5587 u8c = arabic_shape(u8c, &c, &u8c_c1, nc, nc1, pc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5589 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5590 prev_c = u8c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5591 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5592 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5594 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5595
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5596 if (ScreenLines[off] != c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5597 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5598 || (mbyte_cells == 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5599 && ScreenLines[off + 1] != (enc_dbcs ? ptr[1] : 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5600 || (enc_dbcs == DBCS_JPNU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 && c == 0x8e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5602 && ScreenLines2[off] != ptr[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603 || (enc_utf8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5604 && mbyte_blen > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5605 && (ScreenLinesUC[off] != u8c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5606 || ScreenLinesC1[off] != u8c_c1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5607 || ScreenLinesC2[off] != u8c_c2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5608 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5609 || ScreenAttrs[off] != attr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5610 || exmode_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5611 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5612 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5613 #if defined(FEAT_GUI) || defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5614 /* The bold trick makes a single row of pixels appear in the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5615 * character. When a bold character is removed, the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5616 * character should be redrawn too. This happens for our own GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5617 * and for some xterms.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5618 * Force the redraw by setting the attribute to a different value
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5619 * than "attr", the contents of ScreenLines[] may be needed by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5620 * mb_off2cells() further on.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5621 * Don't do this for the last drawn character, because the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5622 * character may not be redrawn. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5623 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5624 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5625 gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5626 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5627 # if defined(FEAT_GUI) && defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5628 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5629 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5630 # ifdef UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5631 term_is_xterm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5632 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5633 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5634 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5635 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5637 n = ScreenAttrs[off];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5638 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5639 if (col + mbyte_cells < screen_Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5640 && (n > HL_ALL || (n & HL_BOLD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5641 && (len < 0 ? ptr[mbyte_blen] != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5642 : ptr + mbyte_blen < text + len))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5643 ScreenAttrs[off + mbyte_cells] = attr + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5644 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5645 if (col + 1 < screen_Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5646 && (n > HL_ALL || (n & HL_BOLD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5647 && (len < 0 ? ptr[1] != NUL : ptr + 1 < text + len))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5648 ScreenLines[off + 1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5649 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5650 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5651 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5652 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5653 /* When at the end of the text and overwriting a two-cell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5654 * character with a one-cell character, need to clear the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5655 * cell. Also when overwriting the left halve of a two-cell char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5656 * with the right halve of a two-cell char. Do this only once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5657 * (mb_off2cells() may return 2 on the right halve). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5658 if (clear_next_cell)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5659 clear_next_cell = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5660 else if (has_mbyte
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5661 && (len < 0 ? ptr[mbyte_blen] == NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5662 : ptr + mbyte_blen >= text + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5663 && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 || (mbyte_cells == 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 && (*mb_off2cells)(off) == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5666 && (*mb_off2cells)(off + 1) > 1)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5667 clear_next_cell = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5669 /* Make sure we never leave a second byte of a double-byte behind,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5670 * it confuses mb_off2cells(). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5671 if (enc_dbcs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5672 && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5673 || (mbyte_cells == 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5674 && (*mb_off2cells)(off) == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5675 && (*mb_off2cells)(off + 1) > 1)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5676 ScreenLines[off + mbyte_blen] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5677 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678 ScreenLines[off] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5679 ScreenAttrs[off] = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5680 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5681 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5682 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5683 if (c < 0x80 && u8c_c1 == 0 && u8c_c2 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 ScreenLinesUC[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5686 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 ScreenLinesUC[off] = u8c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 ScreenLinesC1[off] = u8c_c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 ScreenLinesC2[off] = u8c_c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5690 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5691 if (mbyte_cells == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5692 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5693 ScreenLines[off + 1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694 ScreenAttrs[off + 1] = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5696 screen_char(off, row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5698 else if (mbyte_cells == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5699 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700 ScreenLines[off + 1] = ptr[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701 ScreenAttrs[off + 1] = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 screen_char_2(off, row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5703 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 else if (enc_dbcs == DBCS_JPNU && c == 0x8e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5706 ScreenLines2[off] = ptr[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5707 screen_char(off, row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5709 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5710 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 screen_char(off, row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5714 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5715 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5716 off += mbyte_cells;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5717 col += mbyte_cells;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5718 ptr += mbyte_blen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5719 if (clear_next_cell)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5720 ptr = (char_u *)" ";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5722 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5723 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5724 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5725 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5726 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5727 ++ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5728 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5729 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5730 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5732 #ifdef FEAT_SEARCH_EXTRA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5733 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5734 * Prepare for 'searchhl' highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5735 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5736 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5737 start_search_hl()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5738 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5739 if (p_hls && !no_hlsearch)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5740 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5741 last_pat_prog(&search_hl.rm);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5742 search_hl.attr = hl_attr(HLF_L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5743 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5744 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5746 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5747 * Clean up for 'searchhl' highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5748 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5749 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5750 end_search_hl()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5751 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5752 if (search_hl.rm.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5753 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5754 vim_free(search_hl.rm.regprog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5755 search_hl.rm.regprog = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5756 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5757 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5758
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5759 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5760 * Advance to the match in window "wp" line "lnum" or past it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5761 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5762 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5763 prepare_search_hl(wp, lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5764 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5765 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5767 match_T *shl; /* points to search_hl or match_hl */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771 * When using a multi-line pattern, start searching at the top
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 * of the window or just after a closed fold.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 * Do this both for search_hl and match_hl.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 shl = &search_hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 if (shl->rm.regprog != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779 && shl->lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 && re_multiline(shl->rm.regprog))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 if (shl->first_lnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784 # ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 for (shl->first_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786 shl->first_lnum > wp->w_topline; --shl->first_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 if (hasFoldingWin(wp, shl->first_lnum - 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 NULL, NULL, TRUE, NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5790 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791 shl->first_lnum = wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5792 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5793 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5794 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795 while (shl->first_lnum < lnum && shl->rm.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5796 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5797 next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5798 if (shl->lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5800 shl->first_lnum = shl->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5801 + shl->rm.endpos[0].lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 - shl->rm.startpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5803 n = shl->rm.endpos[0].col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5805 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5806 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5807 ++shl->first_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5808 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5809 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5810 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5811 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5812 if (shl == &match_hl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5813 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5814 shl = &match_hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5816 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5817
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5818 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5819 * Search for a next 'searchl' or ":match" match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820 * Uses shl->buf.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5821 * Sets shl->lnum and shl->rm contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5822 * Note: Assumes a previous match is always before "lnum", unless
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 * shl->lnum is zero.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5824 * Careful: Any pointers for buffer lines will become invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5825 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5826 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 next_search_hl(win, shl, lnum, mincol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5828 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5829 match_T *shl; /* points to search_hl or match_hl */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5831 colnr_T mincol; /* minimal column for a match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5832 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5833 linenr_T l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5834 colnr_T matchcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835 long nmatched;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 if (shl->lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5838 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 /* Check for three situations:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 * 1. If the "lnum" is below a previous match, start a new search.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841 * 2. If the previous match includes "mincol", use it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842 * 3. Continue after the previous match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5843 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844 l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5845 if (lnum > l)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846 shl->lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 else if (lnum < l || shl->rm.endpos[0].col > mincol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5851 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5852 * Repeat searching for a match until one is found that includes "mincol"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5853 * or none is found in this line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5854 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5855 called_emsg = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5856 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5858 /* Three situations:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5859 * 1. No useful previous match: search from start of line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5860 * 2. Not Vi compatible or empty match: continue at next character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5861 * Break the loop if this is beyond the end of the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5862 * 3. Vi compatible searching: continue at end of previous match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5863 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5864 if (shl->lnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5865 matchcol = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5866 else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5867 || (shl->rm.endpos[0].lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5868 && shl->rm.endpos[0].col == shl->rm.startpos[0].col))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5870 matchcol = shl->rm.startpos[0].col + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5871 if (ml_get_buf(shl->buf, lnum, FALSE)[matchcol - 1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 shl->lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5874 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5875 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5876 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5877 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5878 matchcol = shl->rm.endpos[0].col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5880 shl->lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5881 nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, matchcol);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5882 if (called_emsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5883 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5884 /* Error while handling regexp: stop using this regexp. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5885 vim_free(shl->rm.regprog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5886 shl->rm.regprog = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5887 no_hlsearch = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5888 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5889 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5890 if (nmatched == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892 shl->lnum = 0; /* no match found */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5893 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5894 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5895 if (shl->rm.startpos[0].lnum > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5896 || shl->rm.startpos[0].col >= mincol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5897 || nmatched > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5898 || shl->rm.endpos[0].col > mincol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5899 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5900 shl->lnum += shl->rm.startpos[0].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5901 break; /* useful match found */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5904 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5905 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5907 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5908 screen_start_highlight(attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5909 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5911 attrentry_T *aep = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5912
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913 screen_attr = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5914 if (full_screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5915 #ifdef WIN3264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5916 && termcap_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5917 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5918 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5919 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5920 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5923 char buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5925 sprintf(buf, IF_EB("\033|%dh", ESC_STR "|%dh"), attr); /* internal GUI code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 OUT_STR(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5928 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5929 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5930 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5931 if (attr > HL_ALL) /* special HL attr. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5932 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5933 if (t_colors > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5934 aep = syn_cterm_attr2entry(attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5935 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936 aep = syn_term_attr2entry(attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5937 if (aep == NULL) /* did ":syntax clear" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5938 attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5939 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5940 attr = aep->ae_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942 if ((attr & HL_BOLD) && T_MD != NULL) /* bold */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943 out_str(T_MD);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944 if ((attr & HL_STANDOUT) && T_SO != NULL) /* standout */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945 out_str(T_SO);
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 168
diff changeset
5946 if ((attr & (HL_UNDERLINE | HL_UNDERCURL)) && T_US != NULL)
d292c40ca788 updated for version 7.0060
vimboss
parents: 168
diff changeset
5947 /* underline or undercurl */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 out_str(T_US);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5949 if ((attr & HL_ITALIC) && T_CZH != NULL) /* italic */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 out_str(T_CZH);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5951 if ((attr & HL_INVERSE) && T_MR != NULL) /* inverse (reverse) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5952 out_str(T_MR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5954 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5955 * Output the color or start string after bold etc., in case the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956 * bold etc. override the color setting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5957 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958 if (aep != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5959 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5960 if (t_colors > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5961 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5962 if (aep->ae_u.cterm.fg_color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5963 term_fg_color(aep->ae_u.cterm.fg_color - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5964 if (aep->ae_u.cterm.bg_color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5965 term_bg_color(aep->ae_u.cterm.bg_color - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5966 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5967 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5968 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5969 if (aep->ae_u.term.start != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970 out_str(aep->ae_u.term.start);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5971 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5973 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5974 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5975 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5976
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5977 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5978 screen_stop_highlight()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5980 int do_ME = FALSE; /* output T_ME code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5981
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5982 if (screen_attr != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5983 #ifdef WIN3264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5984 && termcap_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5985 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5986 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5987 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5988 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5989 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5990 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5991 char buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5993 /* use internal GUI code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5994 sprintf(buf, IF_EB("\033|%dH", ESC_STR "|%dH"), screen_attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5995 OUT_STR(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5996 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5997 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5998 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5999 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6000 if (screen_attr > HL_ALL) /* special HL attr. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6001 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6002 attrentry_T *aep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6004 if (t_colors > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6006 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6007 * Assume that t_me restores the original colors!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6008 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6009 aep = syn_cterm_attr2entry(screen_attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6010 if (aep != NULL && (aep->ae_u.cterm.fg_color
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6011 || aep->ae_u.cterm.bg_color))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6012 do_ME = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6013 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6014 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6015 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6016 aep = syn_term_attr2entry(screen_attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6017 if (aep != NULL && aep->ae_u.term.stop != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6018 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6019 if (STRCMP(aep->ae_u.term.stop, T_ME) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6020 do_ME = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6021 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6022 out_str(aep->ae_u.term.stop);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6023 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6024 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6025 if (aep == NULL) /* did ":syntax clear" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6026 screen_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6027 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6028 screen_attr = aep->ae_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6030
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6031 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6032 * Often all ending-codes are equal to T_ME. Avoid outputting the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6033 * same sequence several times.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6034 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6035 if (screen_attr & HL_STANDOUT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6037 if (STRCMP(T_SE, T_ME) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 do_ME = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6039 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6040 out_str(T_SE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041 }
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 168
diff changeset
6042 if (screen_attr & (HL_UNDERLINE | HL_UNDERCURL))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6044 if (STRCMP(T_UE, T_ME) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6045 do_ME = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6046 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6047 out_str(T_UE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6048 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6049 if (screen_attr & HL_ITALIC)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6050 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6051 if (STRCMP(T_CZR, T_ME) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6052 do_ME = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6053 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6054 out_str(T_CZR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056 if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 out_str(T_ME);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6058
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6059 if (t_colors > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6060 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6061 /* set Normal cterm colors */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6062 if (cterm_normal_fg_color != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6063 term_fg_color(cterm_normal_fg_color - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6064 if (cterm_normal_bg_color != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065 term_bg_color(cterm_normal_bg_color - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6066 if (cterm_normal_fg_bold)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 out_str(T_MD);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6070 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6071 screen_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6074 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6075 * Reset the colors for a cterm. Used when leaving Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6076 * The machine specific code may override this again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6077 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6078 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6079 reset_cterm_colors()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6080 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6081 if (t_colors > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6083 /* set Normal cterm colors */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6084 if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6085 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6086 out_str(T_OP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6087 screen_attr = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6089 if (cterm_normal_fg_bold)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6090 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6091 out_str(T_ME);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6092 screen_attr = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6093 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6094 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6095 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6096
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6097 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6098 * Put character ScreenLines["off"] on the screen at position "row" and "col",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6099 * using the attributes from ScreenAttrs["off"].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6100 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6101 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6102 screen_char(off, row, col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6103 unsigned off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6104 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6105 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6107 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6109 /* Check for illegal values, just in case (could happen just after
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6110 * resizing). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6111 if (row >= screen_Rows || col >= screen_Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6112 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6114 /* Outputting the last character on the screen may scrollup the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6115 * Don't to it! Mark the character invalid (update it when scrolled up) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6116 if (row == screen_Rows - 1 && col == screen_Columns - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6117 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6118 /* account for first command-line character in rightleft mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6119 && !cmdmsg_rl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6120 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6121 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6123 ScreenAttrs[off] = (sattr_T)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6124 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6128 * Stop highlighting first, so it's easier to move the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6129 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6130 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6131 if (screen_char_attr != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6132 attr = screen_char_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6133 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6134 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6135 attr = ScreenAttrs[off];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6136 if (screen_attr != attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6137 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6139 windgoto(row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6141 if (screen_attr != attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6142 screen_start_highlight(attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6144 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6145 if (enc_utf8 && ScreenLinesUC[off] != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6147 char_u buf[MB_MAXBYTES + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6149 /* Convert UTF-8 character to bytes and write it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6151 buf[utfc_char2bytes(off, buf)] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6153 out_str(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6154 if (utf_char2cells(ScreenLinesUC[off]) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6155 ++screen_cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6156 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6157 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6158 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6159 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6160 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6161 out_flush_check();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6162 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6163 out_char(ScreenLines[off]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6164 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6165 /* double-byte character in single-width cell */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6166 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6167 out_char(ScreenLines2[off]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6168 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6169 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6171 screen_cur_col++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6172 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6174 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6176 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6177 * Used for enc_dbcs only: Put one double-wide character at ScreenLines["off"]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6178 * on the screen at position 'row' and 'col'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6179 * The attributes of the first byte is used for all. This is required to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6180 * output the two bytes of a double-byte character with nothing in between.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6181 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6182 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6183 screen_char_2(off, row, col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6184 unsigned off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6185 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6186 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6187 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6188 /* Check for illegal values (could be wrong when screen was resized). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6189 if (off + 1 >= (unsigned)(screen_Rows * screen_Columns))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6190 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6191
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6192 /* Outputting the last character on the screen may scrollup the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6193 * Don't to it! Mark the character invalid (update it when scrolled up) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6194 if (row == screen_Rows - 1 && col >= screen_Columns - 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6195 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6196 ScreenAttrs[off] = (sattr_T)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6197 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6198 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6200 /* Output the first byte normally (positions the cursor), then write the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6201 * second byte directly. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6202 screen_char(off, row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6203 out_char(ScreenLines[off + 1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6204 ++screen_cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6206 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6208 #if defined(FEAT_CLIPBOARD) || defined(FEAT_VERTSPLIT) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6209 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6210 * Draw a rectangle of the screen, inverted when "invert" is TRUE.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6211 * This uses the contents of ScreenLines[] and doesn't change it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6212 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6213 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6214 screen_draw_rectangle(row, col, height, width, invert)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6215 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6216 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6217 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6218 int width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6219 int invert;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6220 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6221 int r, c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6222 int off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6224 if (invert)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6225 screen_char_attr = HL_INVERSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6226 for (r = row; r < row + height; ++r)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6227 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6228 off = LineOffset[r];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6229 for (c = col; c < col + width; ++c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6230 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6231 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6232 if (enc_dbcs != 0 && dbcs_off2cells(off + c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6233 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6234 screen_char_2(off + c, r, c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6235 ++c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6237 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6238 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6239 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6240 screen_char(off + c, r, c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6241 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6242 if (utf_off2cells(off + c) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6243 ++c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6244 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6246 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6247 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6248 screen_char_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6249 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6250 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6252 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6253 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6254 * Redraw the characters for a vertically split window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6255 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6256 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6257 redraw_block(row, end, wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6258 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6259 int end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6260 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6262 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6263 int width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6265 # ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6266 clip_may_clear_selection(row, end - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6267 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6269 if (wp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6270 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6271 col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6272 width = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6273 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6274 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6275 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6276 col = wp->w_wincol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6277 width = wp->w_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6278 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6279 screen_draw_rectangle(row, col, end - row, width, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6281 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6283 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6284 * Fill the screen from 'start_row' to 'end_row', from 'start_col' to 'end_col'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6285 * with character 'c1' in first column followed by 'c2' in the other columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6286 * Use attributes 'attr'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6287 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6288 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6289 screen_fill(start_row, end_row, start_col, end_col, c1, c2, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6290 int start_row, end_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6291 int start_col, end_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6292 int c1, c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6293 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6294 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6295 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6296 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6297 int off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6298 int end_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6299 int did_delete;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6300 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6301 int norm_term;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6302 #if defined(FEAT_GUI) || defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6303 int force_next = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6304 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6306 if (end_row > screen_Rows) /* safety check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6307 end_row = screen_Rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6308 if (end_col > screen_Columns) /* safety check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6309 end_col = screen_Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6310 if (ScreenLines == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6311 || start_row >= end_row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6312 || start_col >= end_col) /* nothing to do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6313 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6315 /* it's a "normal" terminal when not in a GUI or cterm */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6316 norm_term = (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6317 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6318 !gui.in_use &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6319 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6320 t_colors <= 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6321 for (row = start_row; row < end_row; ++row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6322 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6323 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6324 * Try to use delete-line termcap code, when no attributes or in a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6325 * "normal" terminal, where a bold/italic space is just a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6326 * space.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6327 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6328 did_delete = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6329 if (c2 == ' '
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6330 && end_col == Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6331 && can_clear(T_CE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6332 && (attr == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6333 || (norm_term
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6334 && attr <= HL_ALL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6335 && ((attr & ~(HL_BOLD | HL_ITALIC)) == 0))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6337 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6338 * check if we really need to clear something
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6339 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6340 col = start_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6341 if (c1 != ' ') /* don't clear first char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6342 ++col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6344 off = LineOffset[row] + col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6345 end_off = LineOffset[row] + end_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6346
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6347 /* skip blanks (used often, keep it fast!) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6348 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6349 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6350 while (off < end_off && ScreenLines[off] == ' '
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6351 && ScreenAttrs[off] == 0 && ScreenLinesUC[off] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6352 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6353 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6354 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6355 while (off < end_off && ScreenLines[off] == ' '
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6356 && ScreenAttrs[off] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6357 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6358 if (off < end_off) /* something to be cleared */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6360 col = off - LineOffset[row];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6361 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6362 term_windgoto(row, col);/* clear rest of this screen line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6363 out_str(T_CE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6364 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6365 col = end_col - col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6366 while (col--) /* clear chars in ScreenLines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6368 ScreenLines[off] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6369 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6370 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6371 ScreenLinesUC[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6372 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6373 ScreenAttrs[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6374 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6375 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6377 did_delete = TRUE; /* the chars are cleared now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6380 off = LineOffset[row] + start_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6381 c = c1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6382 for (col = start_col; col < end_col; ++col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6383 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6384 if (ScreenLines[off] != c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6385 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6386 || (enc_utf8 && ScreenLinesUC[off] != (c >= 0x80 ? c : 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6387 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6388 || ScreenAttrs[off] != attr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6389 #if defined(FEAT_GUI) || defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6390 || force_next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6391 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6392 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6393 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6394 #if defined(FEAT_GUI) || defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6395 /* The bold trick may make a single row of pixels appear in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6396 * the next character. When a bold character is removed, the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6397 * next character should be redrawn too. This happens for our
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6398 * own GUI and for some xterms. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6399 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6400 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6401 gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6402 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6403 # if defined(FEAT_GUI) && defined(UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6404 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6405 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6406 # ifdef UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6407 term_is_xterm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6408 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6409 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6410 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6411 if (ScreenLines[off] != ' '
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6412 && (ScreenAttrs[off] > HL_ALL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6413 || ScreenAttrs[off] & HL_BOLD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6414 force_next = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6415 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6416 force_next = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6418 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6419 ScreenLines[off] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6420 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6421 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6422 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6423 if (c >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6424 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6425 ScreenLinesUC[off] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6426 ScreenLinesC1[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6427 ScreenLinesC2[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6429 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6430 ScreenLinesUC[off] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6432 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6433 ScreenAttrs[off] = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6434 if (!did_delete || c != ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6435 screen_char(off, row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6436 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6437 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6438 if (col == start_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6439 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6440 if (did_delete)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6441 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6442 c = c2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6443 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6444 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6445 if (end_col == Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6446 LineWraps[row] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6447 if (row == Rows - 1) /* overwritten the command line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6448 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6449 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6450 if (c1 == ' ' && c2 == ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6451 clear_cmdline = FALSE; /* command line has been cleared */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6454 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6455
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6456 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6457 * Check if there should be a delay. Used before clearing or redrawing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6458 * screen or the command line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6459 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6460 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6461 check_for_delay(check_msg_scroll)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6462 int check_msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6463 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6464 if ((emsg_on_display || (check_msg_scroll && msg_scroll))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465 && !did_wait_return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6466 && emsg_silent == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6468 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6469 ui_delay(1000L, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6470 emsg_on_display = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6471 if (check_msg_scroll)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6472 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6473 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6476 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6477 * screen_valid - allocate screen buffers if size changed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6478 * If "clear" is TRUE: clear screen if it has been resized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6479 * Returns TRUE if there is a valid screen to write to.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6480 * Returns FALSE when starting up and screen not initialized yet.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6481 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6482 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6483 screen_valid(clear)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6484 int clear;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6485 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6486 screenalloc(clear); /* allocate screen buffers if size changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6487 return (ScreenLines != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6488 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6490 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6491 * Resize the shell to Rows and Columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6492 * Allocate ScreenLines[] and associated items.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6493 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6494 * There may be some time between setting Rows and Columns and (re)allocating
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6495 * ScreenLines[]. This happens when starting up and when (manually) changing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6496 * the shell size. Always use screen_Rows and screen_Columns to access items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6497 * in ScreenLines[]. Use Rows and Columns for positioning text etc. where the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6498 * final size of the shell is needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6499 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6500 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6501 screenalloc(clear)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6502 int clear;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6504 int new_row, old_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6505 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6506 int old_Rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6507 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6508 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6509 int outofmem = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6510 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6511 schar_T *new_ScreenLines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6512 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6513 u8char_T *new_ScreenLinesUC = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6514 u8char_T *new_ScreenLinesC1 = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6515 u8char_T *new_ScreenLinesC2 = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6516 schar_T *new_ScreenLines2 = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6517 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6518 sattr_T *new_ScreenAttrs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6519 unsigned *new_LineOffset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6520 char_u *new_LineWraps;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6521 static int entered = FALSE; /* avoid recursiveness */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6523 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6524 * Allocation of the screen buffers is done only when the size changes and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6525 * when Rows and Columns have been set and we have started doing full
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6526 * screen stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6527 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6528 if ((ScreenLines != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6529 && Rows == screen_Rows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6530 && Columns == screen_Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6531 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6532 && enc_utf8 == (ScreenLinesUC != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6533 && (enc_dbcs == DBCS_JPNU) == (ScreenLines2 != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6534 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6535 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6536 || Rows == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6537 || Columns == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6538 || (!full_screen && ScreenLines == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6539 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6541 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6542 * It's possible that we produce an out-of-memory message below, which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6543 * will cause this function to be called again. To break the loop, just
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6544 * return here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6545 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6546 if (entered)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6547 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6548 entered = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6549
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6550 win_new_shellsize(); /* fit the windows in the new sized shell */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6552 comp_col(); /* recompute columns for shown command and ruler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6553
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6554 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6555 * We're changing the size of the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6556 * - Allocate new arrays for ScreenLines and ScreenAttrs.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6557 * - Move lines from the old arrays into the new arrays, clear extra
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6558 * lines (unless the screen is going to be cleared).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6559 * - Free the old arrays.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6560 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6561 * If anything fails, make ScreenLines NULL, so we don't do anything!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6562 * Continuing with the old ScreenLines may result in a crash, because the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6563 * size is wrong.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6564 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6565 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6566 for (wp = firstwin; wp; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6567 win_free_lsize(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6568 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6569 win_free_lsize(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6570 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6572 new_ScreenLines = (schar_T *)lalloc((long_u)(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6573 (Rows + 1) * Columns * sizeof(schar_T)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6574 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6575 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6576 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6577 new_ScreenLinesUC = (u8char_T *)lalloc((long_u)(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6578 (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6579 new_ScreenLinesC1 = (u8char_T *)lalloc((long_u)(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6580 (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6581 new_ScreenLinesC2 = (u8char_T *)lalloc((long_u)(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6582 (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6583 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6584 if (enc_dbcs == DBCS_JPNU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6585 new_ScreenLines2 = (schar_T *)lalloc((long_u)(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6586 (Rows + 1) * Columns * sizeof(schar_T)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6587 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6588 new_ScreenAttrs = (sattr_T *)lalloc((long_u)(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6589 (Rows + 1) * Columns * sizeof(sattr_T)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6590 new_LineOffset = (unsigned *)lalloc((long_u)(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6591 Rows * sizeof(unsigned)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6592 new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6593
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6594 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6595 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6596 if (win_alloc_lines(wp) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6597 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6598 outofmem = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6599 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6600 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6601 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6603 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6605 if (new_ScreenLines == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6606 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6607 || (enc_utf8 && (new_ScreenLinesUC == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6608 || new_ScreenLinesC1 == NULL || new_ScreenLinesC2 == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6609 || (enc_dbcs == DBCS_JPNU && new_ScreenLines2 == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6610 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6611 || new_ScreenAttrs == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6612 || new_LineOffset == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6613 || new_LineWraps == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6614 || outofmem)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6615 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6616 do_outofmem_msg((long_u)((Rows + 1) * Columns)); /* guess the size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6617 vim_free(new_ScreenLines);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6618 new_ScreenLines = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6619 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6620 vim_free(new_ScreenLinesUC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6621 new_ScreenLinesUC = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6622 vim_free(new_ScreenLinesC1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6623 new_ScreenLinesC1 = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6624 vim_free(new_ScreenLinesC2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6625 new_ScreenLinesC2 = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6626 vim_free(new_ScreenLines2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6627 new_ScreenLines2 = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6628 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6629 vim_free(new_ScreenAttrs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6630 new_ScreenAttrs = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6631 vim_free(new_LineOffset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6632 new_LineOffset = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6633 vim_free(new_LineWraps);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6634 new_LineWraps = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6635 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6636 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6637 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6638 for (new_row = 0; new_row < Rows; ++new_row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6640 new_LineOffset[new_row] = new_row * Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6641 new_LineWraps[new_row] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6643 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6644 * If the screen is not going to be cleared, copy as much as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6645 * possible from the old screen to the new one and clear the rest
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6646 * (used when resizing the window at the "--more--" prompt or when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6647 * executing an external command, for the GUI).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6648 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6649 if (!clear)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6651 (void)vim_memset(new_ScreenLines + new_row * Columns,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6652 ' ', (size_t)Columns * sizeof(schar_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6653 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6654 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6655 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6656 (void)vim_memset(new_ScreenLinesUC + new_row * Columns,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6657 0, (size_t)Columns * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6658 (void)vim_memset(new_ScreenLinesC1 + new_row * Columns,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6659 0, (size_t)Columns * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6660 (void)vim_memset(new_ScreenLinesC2 + new_row * Columns,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6661 0, (size_t)Columns * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6662 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6663 if (enc_dbcs == DBCS_JPNU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6664 (void)vim_memset(new_ScreenLines2 + new_row * Columns,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6665 0, (size_t)Columns * sizeof(schar_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6666 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6667 (void)vim_memset(new_ScreenAttrs + new_row * Columns,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6668 0, (size_t)Columns * sizeof(sattr_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6669 old_row = new_row + (screen_Rows - Rows);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6670 if (old_row >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6672 if (screen_Columns < Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6673 len = screen_Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6674 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6675 len = Columns;
26
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6676 #ifdef FEAT_MBYTE
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6677 /* When switching to utf-8 dont copy characters, they
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6678 * may be invalid now. */
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6679 if (!(enc_utf8 && ScreenLinesUC == NULL))
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6680 #endif
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6681 mch_memmove(new_ScreenLines + new_LineOffset[new_row],
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6682 ScreenLines + LineOffset[old_row],
404aac550f35 updated for version 7.0017
vimboss
parents: 13
diff changeset
6683 (size_t)len * sizeof(schar_T));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6684 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6685 if (enc_utf8 && ScreenLinesUC != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6686 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6687 mch_memmove(new_ScreenLinesUC + new_LineOffset[new_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6688 ScreenLinesUC + LineOffset[old_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6689 (size_t)len * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6690 mch_memmove(new_ScreenLinesC1 + new_LineOffset[new_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6691 ScreenLinesC1 + LineOffset[old_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6692 (size_t)len * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6693 mch_memmove(new_ScreenLinesC2 + new_LineOffset[new_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6694 ScreenLinesC2 + LineOffset[old_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6695 (size_t)len * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6696 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6697 if (enc_dbcs == DBCS_JPNU && ScreenLines2 != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6698 mch_memmove(new_ScreenLines2 + new_LineOffset[new_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6699 ScreenLines2 + LineOffset[old_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6700 (size_t)len * sizeof(schar_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6701 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6702 mch_memmove(new_ScreenAttrs + new_LineOffset[new_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6703 ScreenAttrs + LineOffset[old_row],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6704 (size_t)len * sizeof(sattr_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6705 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6708 /* Use the last line of the screen for the current line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6709 current_ScreenLine = new_ScreenLines + Rows * Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6710 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6712 vim_free(ScreenLines);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6713 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6714 vim_free(ScreenLinesUC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6715 vim_free(ScreenLinesC1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6716 vim_free(ScreenLinesC2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6717 vim_free(ScreenLines2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6718 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6719 vim_free(ScreenAttrs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6720 vim_free(LineOffset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6721 vim_free(LineWraps);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6722 ScreenLines = new_ScreenLines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6723 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6724 ScreenLinesUC = new_ScreenLinesUC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6725 ScreenLinesC1 = new_ScreenLinesC1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6726 ScreenLinesC2 = new_ScreenLinesC2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6727 ScreenLines2 = new_ScreenLines2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6728 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6729 ScreenAttrs = new_ScreenAttrs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6730 LineOffset = new_LineOffset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6731 LineWraps = new_LineWraps;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6732
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6733 /* It's important that screen_Rows and screen_Columns reflect the actual
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6734 * size of ScreenLines[]. Set them before calling anything. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6735 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6736 old_Rows = screen_Rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6737 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6738 screen_Rows = Rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6739 screen_Columns = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6740
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6741 must_redraw = CLEAR; /* need to clear the screen later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6742 if (clear)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6743 screenclear2();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6745 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6746 else if (gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6747 && !gui.starting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6748 && ScreenLines != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6749 && old_Rows != Rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6750 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6751 (void)gui_redraw_block(0, 0, (int)Rows - 1, (int)Columns - 1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6752 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6753 * Adjust the position of the cursor, for when executing an external
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6754 * command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6755 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6756 if (msg_row >= Rows) /* Rows got smaller */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6757 msg_row = Rows - 1; /* put cursor at last row */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6758 else if (Rows > old_Rows) /* Rows got bigger */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6759 msg_row += Rows - old_Rows; /* put cursor in same place */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6760 if (msg_col >= Columns) /* Columns got smaller */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6761 msg_col = Columns - 1; /* put cursor at last column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6762 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6763 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6764
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6765 entered = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6766 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6768 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6769 screenclear()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6770 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6771 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6772 screenalloc(FALSE); /* allocate screen buffers if size changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6773 screenclear2(); /* clear the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6774 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6775
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6776 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6777 screenclear2()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6778 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6779 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6780
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6781 if (starting == NO_SCREEN || ScreenLines == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6782 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6783 || (gui.in_use && gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6784 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6785 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6786 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6787
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6788 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6789 if (!gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6790 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6791 screen_attr = -1; /* force setting the Normal colors */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6792 screen_stop_highlight(); /* don't want highlighting here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6793
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6794 #ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6795 /* disable selection without redrawing it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6796 clip_scroll_selection(9999);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6797 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6798
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6799 /* blank out ScreenLines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6800 for (i = 0; i < Rows; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6801 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6802 lineclear(LineOffset[i], (int)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6803 LineWraps[i] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6806 if (can_clear(T_CL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6807 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6808 out_str(T_CL); /* clear the display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6809 clear_cmdline = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6810 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6811 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6812 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6813 /* can't clear the screen, mark all chars with invalid attributes */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6814 for (i = 0; i < Rows; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6815 lineinvalid(LineOffset[i], (int)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6816 clear_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6817 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6818
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6819 screen_cleared = TRUE; /* can use contents of ScreenLines now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6820
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6821 win_rest_invalid(firstwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6822 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6823 if (must_redraw == CLEAR) /* no need to clear again */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6824 must_redraw = NOT_VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6825 compute_cmdrow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6826 msg_row = cmdline_row; /* put cursor on last line for messages */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6827 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6828 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6829 msg_scrolled = 0; /* can't scroll back */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6830 msg_didany = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6831 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6832 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6833
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6834 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6835 * Clear one line in ScreenLines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6836 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6837 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6838 lineclear(off, width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6839 unsigned off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6840 int width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6841 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6842 (void)vim_memset(ScreenLines + off, ' ', (size_t)width * sizeof(schar_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6843 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6844 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6845 (void)vim_memset(ScreenLinesUC + off, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6846 (size_t)width * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6847 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6848 (void)vim_memset(ScreenAttrs + off, 0, (size_t)width * sizeof(sattr_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6851 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6852 * Mark one line in ScreenLines invalid by setting the attributes to an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6853 * invalid value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6854 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6855 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6856 lineinvalid(off, width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6857 unsigned off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6858 int width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6859 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6860 (void)vim_memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6861 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6863 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6864 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6865 * Copy part of a Screenline for vertically split window "wp".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6866 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6867 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6868 linecopy(to, from, wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6869 int to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6870 int from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6871 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6872 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6873 unsigned off_to = LineOffset[to] + wp->w_wincol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6874 unsigned off_from = LineOffset[from] + wp->w_wincol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6875
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6876 mch_memmove(ScreenLines + off_to, ScreenLines + off_from,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6877 wp->w_width * sizeof(schar_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6878 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6879 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6881 mch_memmove(ScreenLinesUC + off_to, ScreenLinesUC + off_from,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6882 wp->w_width * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6883 mch_memmove(ScreenLinesC1 + off_to, ScreenLinesC1 + off_from,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6884 wp->w_width * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6885 mch_memmove(ScreenLinesC2 + off_to, ScreenLinesC2 + off_from,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6886 wp->w_width * sizeof(u8char_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6887 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6888 if (enc_dbcs == DBCS_JPNU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6889 mch_memmove(ScreenLines2 + off_to, ScreenLines2 + off_from,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6890 wp->w_width * sizeof(schar_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6891 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6892 mch_memmove(ScreenAttrs + off_to, ScreenAttrs + off_from,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6893 wp->w_width * sizeof(sattr_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6894 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6895 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6896
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6897 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6898 * Return TRUE if clearing with term string "p" would work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6899 * It can't work when the string is empty or it won't set the right background.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6900 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6901 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6902 can_clear(p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6903 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6904 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6905 return (*p != NUL && (t_colors <= 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6906 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6907 || gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6908 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6909 || cterm_normal_bg_color == 0 || *T_UT != NUL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6912 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6913 * Reset cursor position. Use whenever cursor was moved because of outputting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6914 * something directly to the screen (shell commands) or a terminal control
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6915 * code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6916 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6917 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6918 screen_start()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6919 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6920 screen_cur_row = screen_cur_col = 9999;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6922
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6923 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6924 * Move the cursor to position "row","col" in the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6925 * This tries to find the most efficient way to move, minimizing the number of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6926 * characters sent to the terminal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6927 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6928 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6929 windgoto(row, col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6930 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6931 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6932 {
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 168
diff changeset
6933 sattr_T *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6934 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6935 int plan;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6936 int cost;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6937 int wouldbe_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6938 int noinvcurs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6939 char_u *bs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6940 int goto_cost;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6941 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6942
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6943 #define GOTO_COST 7 /* asssume a term_windgoto() takes about 7 chars */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6944 #define HIGHL_COST 5 /* assume unhighlight takes 5 chars */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6945
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6946 #define PLAN_LE 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6947 #define PLAN_CR 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6948 #define PLAN_NL 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6949 #define PLAN_WRITE 4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6950 /* Can't use ScreenLines unless initialized */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6951 if (ScreenLines == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6952 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6954 if (col != screen_cur_col || row != screen_cur_row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6955 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6956 /* Check for valid position. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6957 if (row < 0) /* window without text lines? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6958 row = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6959 if (row >= screen_Rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6960 row = screen_Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6961 if (col >= screen_Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6962 col = screen_Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6963
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6964 /* check if no cursor movement is allowed in highlight mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6965 if (screen_attr && *T_MS == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6966 noinvcurs = HIGHL_COST;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6967 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6968 noinvcurs = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6969 goto_cost = GOTO_COST + noinvcurs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6971 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6972 * Plan how to do the positioning:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6973 * 1. Use CR to move it to column 0, same row.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6974 * 2. Use T_LE to move it a few columns to the left.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6975 * 3. Use NL to move a few lines down, column 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6976 * 4. Move a few columns to the right with T_ND or by writing chars.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6977 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6978 * Don't do this if the cursor went beyond the last column, the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6979 * position is unknown then (some terminals wrap, some don't )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6980 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6981 * First check if the highlighting attibutes allow us to write
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6982 * characters to move the cursor to the right.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6983 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6984 if (row >= screen_cur_row && screen_cur_col < Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6985 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6986 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6987 * If the cursor is in the same row, bigger col, we can use CR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6988 * or T_LE.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6989 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6990 bs = NULL; /* init for GCC */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6991 attr = screen_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6992 if (row == screen_cur_row && col < screen_cur_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6993 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6994 /* "le" is preferred over "bc", because "bc" is obsolete */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6995 if (*T_LE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6996 bs = T_LE; /* "cursor left" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6997 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6998 bs = T_BC; /* "backspace character (old) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6999 if (*bs)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7000 cost = (screen_cur_col - col) * (int)STRLEN(bs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7001 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7002 cost = 999;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7003 if (col + 1 < cost) /* using CR is less characters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7004 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7005 plan = PLAN_CR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7006 wouldbe_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7007 cost = 1; /* CR is just one character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7008 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7009 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7010 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7011 plan = PLAN_LE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7012 wouldbe_col = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7013 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7014 if (noinvcurs) /* will stop highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7015 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7016 cost += noinvcurs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7017 attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7018 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7019 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7021 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7022 * If the cursor is above where we want to be, we can use CR LF.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7023 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7024 else if (row > screen_cur_row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7025 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7026 plan = PLAN_NL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7027 wouldbe_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7028 cost = (row - screen_cur_row) * 2; /* CR LF */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7029 if (noinvcurs) /* will stop highlighting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7030 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7031 cost += noinvcurs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7032 attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7033 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7035
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7036 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7037 * If the cursor is in the same row, smaller col, just use write.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7038 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7039 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7041 plan = PLAN_WRITE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7042 wouldbe_col = screen_cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7043 cost = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7045
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7046 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7047 * Check if any characters that need to be written have the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7048 * correct attributes. Also avoid UTF-8 characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7049 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7050 i = col - wouldbe_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7051 if (i > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7052 cost += i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7053 if (cost < goto_cost && i > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7055 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7056 * Check if the attributes are correct without additionally
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7057 * stopping highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7058 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7059 p = ScreenAttrs + LineOffset[row] + wouldbe_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7060 while (i && *p++ == attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7061 --i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7062 if (i != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7063 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7064 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7065 * Try if it works when highlighting is stopped here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7066 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7067 if (*--p == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7069 cost += noinvcurs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7070 while (i && *p++ == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7071 --i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7073 if (i != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7074 cost = 999; /* different attributes, don't do it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7075 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7076 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7077 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7078 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7079 /* Don't use an UTF-8 char for positioning, it's slow. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7080 for (i = wouldbe_col; i < col; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7081 if (ScreenLinesUC[LineOffset[row] + i] != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7083 cost = 999;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7084 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7085 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7086 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7087 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7090 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7091 * We can do it without term_windgoto()!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7092 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7093 if (cost < goto_cost)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7094 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7095 if (plan == PLAN_LE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7096 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7097 if (noinvcurs)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7098 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7099 while (screen_cur_col > col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7100 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7101 out_str(bs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7102 --screen_cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7103 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7104 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7105 else if (plan == PLAN_CR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7107 if (noinvcurs)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7108 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7109 out_char('\r');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7110 screen_cur_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7112 else if (plan == PLAN_NL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7113 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7114 if (noinvcurs)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7115 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7116 while (screen_cur_row < row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7118 out_char('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7119 ++screen_cur_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7121 screen_cur_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7122 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7124 i = col - screen_cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7125 if (i > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7126 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7128 * Use cursor-right if it's one character only. Avoids
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7129 * removing a line of pixels from the last bold char, when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7130 * using the bold trick in the GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7131 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7132 if (T_ND[0] != NUL && T_ND[1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7133 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7134 while (i-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7135 out_char(*T_ND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7137 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7138 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7139 int off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7141 off = LineOffset[row] + screen_cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7142 while (i-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7143 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7144 if (ScreenAttrs[off] != screen_attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7145 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7146 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7147 out_flush_check();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7148 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7149 out_char(ScreenLines[off]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7150 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7151 if (enc_dbcs == DBCS_JPNU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7152 && ScreenLines[off] == 0x8e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7153 out_char(ScreenLines2[off]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7154 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7155 ++off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7156 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7157 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7158 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7160 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7161 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7162 cost = 999;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7164 if (cost >= goto_cost)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7165 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7166 if (noinvcurs)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7167 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7168 if (row == screen_cur_row && (col > screen_cur_col) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7169 *T_CRI != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7170 term_cursor_right(col - screen_cur_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7171 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7172 term_windgoto(row, col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7173 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7174 screen_cur_row = row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7175 screen_cur_col = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7179 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7180 * Set cursor to its position in the current window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7181 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7182 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7183 setcursor()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7185 if (redrawing())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7186 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7187 validate_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7188 windgoto(W_WINROW(curwin) + curwin->w_wrow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7189 W_WINCOL(curwin) + (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7190 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7191 curwin->w_p_rl ? ((int)W_WIDTH(curwin) - curwin->w_wcol - (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7192 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7193 has_mbyte ? (*mb_ptr2cells)(ml_get_cursor()) :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7194 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7195 1)) :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7196 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7197 curwin->w_wcol));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7198 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7199 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7201
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7202 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7203 * insert 'line_count' lines at 'row' in window 'wp'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7204 * if 'invalid' is TRUE the wp->w_lines[].wl_lnum is invalidated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7205 * if 'mayclear' is TRUE the screen will be cleared if it is faster than
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7206 * scrolling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7207 * Returns FAIL if the lines are not inserted, OK for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7208 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7209 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7210 win_ins_lines(wp, row, line_count, invalid, mayclear)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7211 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7212 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7213 int line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7214 int invalid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7215 int mayclear;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7216 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7217 int did_delete;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7218 int nextrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7219 int lastrow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7220 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7222 if (invalid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7223 wp->w_lines_valid = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7225 if (wp->w_height < 5)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7226 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7228 if (line_count > wp->w_height - row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7229 line_count = wp->w_height - row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7231 retval = win_do_lines(wp, row, line_count, mayclear, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7232 if (retval != MAYBE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7233 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7235 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7236 * If there is a next window or a status line, we first try to delete the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7237 * lines at the bottom to avoid messing what is after the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7238 * If this fails and there are following windows, don't do anything to avoid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7239 * messing up those windows, better just redraw.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7240 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7241 did_delete = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7242 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7243 if (wp->w_next != NULL || wp->w_status_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7245 if (screen_del_lines(0, W_WINROW(wp) + wp->w_height - line_count,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7246 line_count, (int)Rows, FALSE, NULL) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7247 did_delete = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7248 else if (wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7249 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7251 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7252 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7253 * if no lines deleted, blank the lines that will end up below the window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7254 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7255 if (!did_delete)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7257 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7258 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7259 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7260 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7261 nextrow = W_WINROW(wp) + wp->w_height + W_STATUS_HEIGHT(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7262 lastrow = nextrow + line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7263 if (lastrow > Rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7264 lastrow = Rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7265 screen_fill(nextrow - line_count, lastrow - line_count,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7266 W_WINCOL(wp), (int)W_ENDCOL(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7267 ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7270 if (screen_ins_lines(0, W_WINROW(wp) + row, line_count, (int)Rows, NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7271 == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7272 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7273 /* deletion will have messed up other windows */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7274 if (did_delete)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7275 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7276 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7277 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7278 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7279 win_rest_invalid(W_NEXT(wp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7281 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7284 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7285 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7287 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7288 * delete "line_count" window lines at "row" in window "wp"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7289 * If "invalid" is TRUE curwin->w_lines[] is invalidated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7290 * If "mayclear" is TRUE the screen will be cleared if it is faster than
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7291 * scrolling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7292 * Return OK for success, FAIL if the lines are not deleted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7293 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7294 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7295 win_del_lines(wp, row, line_count, invalid, mayclear)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7296 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7297 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7298 int line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7299 int invalid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7300 int mayclear;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7302 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7304 if (invalid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7305 wp->w_lines_valid = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7307 if (line_count > wp->w_height - row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7308 line_count = wp->w_height - row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7310 retval = win_do_lines(wp, row, line_count, mayclear, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7311 if (retval != MAYBE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7312 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7314 if (screen_del_lines(0, W_WINROW(wp) + row, line_count,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7315 (int)Rows, FALSE, NULL) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7316 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7318 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7319 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7320 * If there are windows or status lines below, try to put them at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7321 * correct place. If we can't do that, they have to be redrawn.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7322 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7323 if (wp->w_next || wp->w_status_height || cmdline_row < Rows - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7325 if (screen_ins_lines(0, W_WINROW(wp) + wp->w_height - line_count,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7326 line_count, (int)Rows, NULL) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7327 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7328 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7329 win_rest_invalid(wp->w_next);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7330 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7331 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7332 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7333 * If this is the last window and there is no status line, redraw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7334 * command line later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7335 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7336 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7337 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7338 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7339 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7341
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7342 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7343 * Common code for win_ins_lines() and win_del_lines().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7344 * Returns OK or FAIL when the work has been done.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7345 * Returns MAYBE when not finished yet.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7346 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7347 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7348 win_do_lines(wp, row, line_count, mayclear, del)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7349 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7350 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7351 int line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7352 int mayclear;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7353 int del;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7354 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7355 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7357 if (!redrawing() || line_count <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7358 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7360 /* only a few lines left: redraw is faster */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7361 if (mayclear && Rows - line_count < 5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7362 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7363 && wp->w_width == Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7364 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7365 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7367 screenclear(); /* will set wp->w_lines_valid to 0 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7368 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7371 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7372 * Delete all remaining lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7373 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7374 if (row + line_count >= wp->w_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7375 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7376 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7377 W_WINCOL(wp), (int)W_ENDCOL(wp),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7378 ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7379 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7382 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7383 * when scrolling, the message on the command line should be cleared,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7384 * otherwise it will stay there forever.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7385 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7386 clear_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7388 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7389 * If the terminal can set a scroll region, use that.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7390 * Always do this in a vertically split window. This will redraw from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7391 * ScreenLines[] when t_CV isn't defined. That's faster than using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7392 * win_line().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7393 * Don't use a scroll region when we are going to redraw the text, writing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7394 * a character in the lower right corner of the scroll region causes a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7395 * scroll-up in the DJGPP version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7396 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7397 if (scroll_region
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7398 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7399 || W_WIDTH(wp) != Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7400 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7401 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7402 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7403 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7404 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7405 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7406 scroll_region_set(wp, row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7407 if (del)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7408 retval = screen_del_lines(W_WINROW(wp) + row, 0, line_count,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7409 wp->w_height - row, FALSE, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7410 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7411 retval = screen_ins_lines(W_WINROW(wp) + row, 0, line_count,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7412 wp->w_height - row, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7413 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7414 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7415 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7416 scroll_region_reset();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7417 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7420 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7421 if (wp->w_next != NULL && p_tf) /* don't delete/insert on fast terminal */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7422 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7423 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7425 return MAYBE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7426 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7428 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7429 * window 'wp' and everything after it is messed up, mark it for redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7430 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7431 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7432 win_rest_invalid(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7433 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7435 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7436 while (wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7437 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7438 if (wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7439 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7440 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7441 redraw_win_later(wp, NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7442 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7443 wp->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7444 wp = wp->w_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7445 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7446 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7447 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7449
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7450 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7451 * The rest of the routines in this file perform screen manipulations. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7452 * given operation is performed physically on the screen. The corresponding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7453 * change is also made to the internal screen image. In this way, the editor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7454 * anticipates the effect of editing changes on the appearance of the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7455 * That way, when we call screenupdate a complete redraw isn't usually
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7456 * necessary. Another advantage is that we can keep adding code to anticipate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7457 * screen changes, and in the meantime, everything still works.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7458 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7460 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7461 * types for inserting or deleting lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7462 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7463 #define USE_T_CAL 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7464 #define USE_T_CDL 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7465 #define USE_T_AL 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7466 #define USE_T_CE 4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7467 #define USE_T_DL 5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7468 #define USE_T_SR 6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7469 #define USE_NL 7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7470 #define USE_T_CD 8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7471 #define USE_REDRAW 9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7472
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7473 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7474 * insert lines on the screen and update ScreenLines[]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7475 * 'end' is the line after the scrolled part. Normally it is Rows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7476 * When scrolling region used 'off' is the offset from the top for the region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7477 * 'row' and 'end' are relative to the start of the region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7478 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7479 * return FAIL for failure, OK for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7480 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7481 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7482 screen_ins_lines(off, row, line_count, end, wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7483 int off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7484 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7485 int line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7486 int end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7487 win_T *wp; /* NULL or window to use width from */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7488 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7489 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7490 int j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7491 unsigned temp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7492 int cursor_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7493 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7494 int result_empty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7495 int can_ce = can_clear(T_CE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7498 * FAIL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7499 * - there is no valid screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7500 * - the screen has to be redrawn completely
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7501 * - the line count is less than one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7502 * - the line count is more than 'ttyscroll'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7503 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7504 if (!screen_valid(TRUE) || line_count <= 0 || line_count > p_ttyscroll)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7505 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7506
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7507 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7508 * There are seven ways to insert lines:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7509 * 0. When in a vertically split window and t_CV isn't set, redraw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7510 * characters from ScreenLines[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7511 * 1. Use T_CD (clear to end of display) if it exists and the result of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7512 * the insert is just empty lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7513 * 2. Use T_CAL (insert multiple lines) if it exists and T_AL is not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7514 * present or line_count > 1. It looks better if we do all the inserts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7515 * at once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7516 * 3. Use T_CDL (delete multiple lines) if it exists and the result of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7517 * insert is just empty lines and T_CE is not present or line_count >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7518 * 1.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7519 * 4. Use T_AL (insert line) if it exists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7520 * 5. Use T_CE (erase line) if it exists and the result of the insert is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7521 * just empty lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7522 * 6. Use T_DL (delete line) if it exists and the result of the insert is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7523 * just empty lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7524 * 7. Use T_SR (scroll reverse) if it exists and inserting at row 0 and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7525 * the 'da' flag is not set or we have clear line capability.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7526 * 8. redraw the characters from ScreenLines[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7527 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7528 * Careful: In a hpterm scroll reverse doesn't work as expected, it moves
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7529 * the scrollbar for the window. It does have insert line, use that if it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7530 * exists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7531 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7532 result_empty = (row + line_count >= end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7533 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7534 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7535 type = USE_REDRAW;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7536 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7537 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7538 if (can_clear(T_CD) && result_empty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7539 type = USE_T_CD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7540 else if (*T_CAL != NUL && (line_count > 1 || *T_AL == NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7541 type = USE_T_CAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7542 else if (*T_CDL != NUL && result_empty && (line_count > 1 || !can_ce))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7543 type = USE_T_CDL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7544 else if (*T_AL != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7545 type = USE_T_AL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7546 else if (can_ce && result_empty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7547 type = USE_T_CE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7548 else if (*T_DL != NUL && result_empty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7549 type = USE_T_DL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7550 else if (*T_SR != NUL && row == 0 && (*T_DA == NUL || can_ce))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7551 type = USE_T_SR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7552 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7553 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7555 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7556 * For clearing the lines screen_del_lines() is used. This will also take
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7557 * care of t_db if necessary.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7558 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7559 if (type == USE_T_CD || type == USE_T_CDL ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7560 type == USE_T_CE || type == USE_T_DL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7561 return screen_del_lines(off, row, line_count, end, FALSE, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7563 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7564 * If text is retained below the screen, first clear or delete as many
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7565 * lines at the bottom of the window as are about to be inserted so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7566 * the deleted lines won't later surface during a screen_del_lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7567 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7568 if (*T_DB)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7569 screen_del_lines(off, end - line_count, line_count, end, FALSE, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7571 #ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7572 /* Remove a modeless selection when inserting lines halfway the screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7573 * or not the full width of the screen. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7574 if (off + row > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7575 # ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7576 || (wp != NULL && wp->w_width != Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7577 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7578 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7579 clip_clear_selection();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7580 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7581 clip_scroll_selection(-line_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7582 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7584 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7585 /* Don't update the GUI cursor here, ScreenLines[] is invalid until the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7586 * scrolling is actually carried out. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7587 gui_dont_update_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7588 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7589
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7590 if (*T_CCS != NUL) /* cursor relative to region */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7591 cursor_row = row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7592 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7593 cursor_row = row + off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7595 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7596 * Shift LineOffset[] line_count down to reflect the inserted lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7597 * Clear the inserted lines in ScreenLines[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7598 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7599 row += off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7600 end += off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7601 for (i = 0; i < line_count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7602 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7603 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7604 if (wp != NULL && wp->w_width != Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7605 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7606 /* need to copy part of a line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7607 j = end - 1 - i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7608 while ((j -= line_count) >= row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7609 linecopy(j + line_count, j, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7610 j += line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7611 if (can_clear((char_u *)" "))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7612 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7613 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7614 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7615 LineWraps[j] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7616 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7617 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7618 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7620 j = end - 1 - i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7621 temp = LineOffset[j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7622 while ((j -= line_count) >= row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7624 LineOffset[j + line_count] = LineOffset[j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7625 LineWraps[j + line_count] = LineWraps[j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7627 LineOffset[j + line_count] = temp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7628 LineWraps[j + line_count] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7629 if (can_clear((char_u *)" "))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7630 lineclear(temp, (int)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7631 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7632 lineinvalid(temp, (int)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7633 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7634 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7636 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7637 windgoto(cursor_row, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7638
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7639 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7640 /* redraw the characters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7641 if (type == USE_REDRAW)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7642 redraw_block(row, end, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7643 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7644 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7645 if (type == USE_T_CAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7647 term_append_lines(line_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7648 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7649 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7650 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7652 for (i = 0; i < line_count; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7653 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7654 if (type == USE_T_AL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7655 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7656 if (i && cursor_row != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7657 windgoto(cursor_row, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7658 out_str(T_AL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7659 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7660 else /* type == USE_T_SR */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7661 out_str(T_SR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7662 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7663 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7664 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7665
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7666 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7667 * With scroll-reverse and 'da' flag set we need to clear the lines that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7668 * have been scrolled down into the region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7669 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7670 if (type == USE_T_SR && *T_DA)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7672 for (i = 0; i < line_count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7673 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7674 windgoto(off + i, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7675 out_str(T_CE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7676 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7677 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7678 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7680 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7681 gui_can_update_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7682 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7683 out_flush(); /* always flush after a scroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7684 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7685 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7687
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7688 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7689 * delete lines on the screen and update ScreenLines[]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7690 * 'end' is the line after the scrolled part. Normally it is Rows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7691 * When scrolling region used 'off' is the offset from the top for the region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7692 * 'row' and 'end' are relative to the start of the region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7693 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7694 * Return OK for success, FAIL if the lines are not deleted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7695 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7696 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7697 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7698 screen_del_lines(off, row, line_count, end, force, wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7699 int off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7700 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7701 int line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7702 int end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7703 int force; /* even when line_count > p_ttyscroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7704 win_T *wp; /* NULL or window to use width from */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7706 int j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7707 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7708 unsigned temp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7709 int cursor_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7710 int cursor_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7711 int result_empty; /* result is empty until end of region */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7712 int can_delete; /* deleting line codes can be used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7713 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7715 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7716 * FAIL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7717 * - there is no valid screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7718 * - the screen has to be redrawn completely
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7719 * - the line count is less than one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7720 * - the line count is more than 'ttyscroll'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7721 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7722 if (!screen_valid(TRUE) || line_count <= 0 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7723 (!force && line_count > p_ttyscroll))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7724 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7725
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7726 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7727 * Check if the rest of the current region will become empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7728 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7729 result_empty = row + line_count >= end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7730
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7731 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7732 * We can delete lines only when 'db' flag not set or when 'ce' option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7733 * available.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7734 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7735 can_delete = (*T_DB == NUL || can_clear(T_CE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7736
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7737 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7738 * There are six ways to delete lines:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7739 * 0. When in a vertically split window and t_CV isn't set, redraw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7740 * characters from ScreenLines[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7741 * 1. Use T_CD if it exists and the result is empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7742 * 2. Use newlines if row == 0 and count == 1 or T_CDL does not exist.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7743 * 3. Use T_CDL (delete multiple lines) if it exists and line_count > 1 or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7744 * none of the other ways work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7745 * 4. Use T_CE (erase line) if the result is empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7746 * 5. Use T_DL (delete line) if it exists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7747 * 6. redraw the characters from ScreenLines[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7748 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7749 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7750 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7751 type = USE_REDRAW;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7752 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7753 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7754 if (can_clear(T_CD) && result_empty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7755 type = USE_T_CD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7756 #if defined(__BEOS__) && defined(BEOS_DR8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7757 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7758 * USE_NL does not seem to work in Terminal of DR8 so we set T_DB="" in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7759 * its internal termcap... this works okay for tests which test *T_DB !=
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7760 * NUL. It has the disadvantage that the user cannot use any :set t_*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7761 * command to get T_DB (back) to empty_option, only :set term=... will do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7762 * the trick...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7763 * Anyway, this hack will hopefully go away with the next OS release.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7764 * (Olaf Seibert)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7765 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7766 else if (row == 0 && T_DB == empty_option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7767 && (line_count == 1 || *T_CDL == NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7768 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7769 else if (row == 0 && (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7770 #ifndef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7771 /* On the Amiga, somehow '\n' on the last line doesn't always scroll
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7772 * up, so use delete-line command */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7773 line_count == 1 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7774 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7775 *T_CDL == NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7776 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7777 type = USE_NL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7778 else if (*T_CDL != NUL && line_count > 1 && can_delete)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7779 type = USE_T_CDL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7780 else if (can_clear(T_CE) && result_empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7781 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7782 && (wp == NULL || wp->w_width == Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7783 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7784 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7785 type = USE_T_CE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7786 else if (*T_DL != NUL && can_delete)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7787 type = USE_T_DL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7788 else if (*T_CDL != NUL && can_delete)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7789 type = USE_T_CDL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7790 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7791 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7792
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7793 #ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7794 /* Remove a modeless selection when deleting lines halfway the screen or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7795 * not the full width of the screen. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7796 if (off + row > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7797 # ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7798 || (wp != NULL && wp->w_width != Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7799 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7800 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7801 clip_clear_selection();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7802 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7803 clip_scroll_selection(line_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7804 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7806 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7807 /* Don't update the GUI cursor here, ScreenLines[] is invalid until the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7808 * scrolling is actually carried out. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7809 gui_dont_update_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7810 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7811
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7812 if (*T_CCS != NUL) /* cursor relative to region */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7813 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7814 cursor_row = row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7815 cursor_end = end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7816 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7817 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7818 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7819 cursor_row = row + off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7820 cursor_end = end + off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7823 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7824 * Now shift LineOffset[] line_count up to reflect the deleted lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7825 * Clear the inserted lines in ScreenLines[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7826 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7827 row += off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7828 end += off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7829 for (i = 0; i < line_count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7830 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7831 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7832 if (wp != NULL && wp->w_width != Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7833 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7834 /* need to copy part of a line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7835 j = row + i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7836 while ((j += line_count) <= end - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7837 linecopy(j - line_count, j, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7838 j -= line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7839 if (can_clear((char_u *)" "))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7840 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7841 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7842 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7843 LineWraps[j] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7844 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7845 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7846 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7847 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7848 /* whole width, moving the line pointers is faster */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7849 j = row + i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7850 temp = LineOffset[j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7851 while ((j += line_count) <= end - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7853 LineOffset[j - line_count] = LineOffset[j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7854 LineWraps[j - line_count] = LineWraps[j];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7855 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7856 LineOffset[j - line_count] = temp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7857 LineWraps[j - line_count] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7858 if (can_clear((char_u *)" "))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7859 lineclear(temp, (int)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7860 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7861 lineinvalid(temp, (int)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7862 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7865 screen_stop_highlight();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7866
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7867 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7868 /* redraw the characters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7869 if (type == USE_REDRAW)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7870 redraw_block(row, end, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7871 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7872 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7873 if (type == USE_T_CD) /* delete the lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7874 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7875 windgoto(cursor_row, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7876 out_str(T_CD);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7877 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7878 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7879 else if (type == USE_T_CDL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7881 windgoto(cursor_row, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7882 term_delete_lines(line_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7883 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7885 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7886 * Deleting lines at top of the screen or scroll region: Just scroll
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7887 * the whole screen (scroll region) up by outputting newlines on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7888 * last line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7889 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7890 else if (type == USE_NL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7892 windgoto(cursor_end - 1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7893 for (i = line_count; --i >= 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7894 out_char('\n'); /* cursor will remain on same line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7895 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7896 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7897 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7898 for (i = line_count; --i >= 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7899 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7900 if (type == USE_T_DL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7901 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7902 windgoto(cursor_row, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7903 out_str(T_DL); /* delete a line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7904 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7905 else /* type == USE_T_CE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7906 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7907 windgoto(cursor_row + i, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7908 out_str(T_CE); /* erase a line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7909 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7910 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7911 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7913
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7914 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7915 * If the 'db' flag is set, we need to clear the lines that have been
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7916 * scrolled up at the bottom of the region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7917 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7918 if (*T_DB && (type == USE_T_DL || type == USE_T_CDL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7919 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7920 for (i = line_count; i > 0; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7921 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7922 windgoto(cursor_end - i, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7923 out_str(T_CE); /* erase a line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7924 screen_start(); /* don't know where cursor is now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7926 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7928 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7929 gui_can_update_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7930 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7931 out_flush(); /* always flush after a scroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7932 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7933
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7934 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7937 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7938 * show the current mode and ruler
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7939 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7940 * If clear_cmdline is TRUE, clear the rest of the cmdline.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7941 * If clear_cmdline is FALSE there may be a message there that needs to be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7942 * cleared only if a mode is shown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7943 * Return the length of the message (0 if no message).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7944 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7945 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7946 showmode()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7947 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7948 int need_clear;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7949 int length = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7950 int do_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7951 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7952 int nwr_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7953 #ifdef FEAT_INS_EXPAND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7954 int sub_attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7955 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7957 do_mode = (p_smd && ((State & INSERT) || restart_edit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7958 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7959 || VIsual_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7960 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7961 ));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7962 if (do_mode || Recording)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7964 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7965 * Don't show mode right now, when not redrawing or inside a mapping.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7966 * Call char_avail() only when we are going to show something, because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7967 * it takes a bit of time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7968 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7969 if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7970 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7971 redraw_cmdline = TRUE; /* show mode later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7972 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7973 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7974
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7975 nwr_save = need_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7976
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7977 /* wait a bit before overwriting an important message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7978 check_for_delay(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7979
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7980 /* if the cmdline is more than one line high, erase top lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7981 need_clear = clear_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7982 if (clear_cmdline && cmdline_row < Rows - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7983 msg_clr_cmdline(); /* will reset clear_cmdline */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7984
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7985 /* Position on the last line in the window, column 0 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7986 msg_pos_mode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7987 cursor_off();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7988 attr = hl_attr(HLF_CM); /* Highlight mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7989 if (do_mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7990 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7991 MSG_PUTS_ATTR("--", attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7992 #if defined(FEAT_XIM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7993 if (xic != NULL && im_get_status() && !p_imdisable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7994 && curbuf->b_p_iminsert == B_IMODE_IM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7995 # ifdef HAVE_GTK2 /* most of the time, it's not XIM being used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7996 MSG_PUTS_ATTR(" IM", attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7997 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7998 MSG_PUTS_ATTR(" XIM", attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7999 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8000 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8001 #if defined(FEAT_HANGULIN) && defined(FEAT_GUI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8002 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8003 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8004 if (hangul_input_state_get())
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 230
diff changeset
8005 MSG_PUTS_ATTR(" \307\321\261\333", attr); /* HANGUL */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8006 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8007 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8008 #ifdef FEAT_INS_EXPAND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8009 if (edit_submode != NULL) /* CTRL-X in Insert mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8010 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8011 /* These messages can get long, avoid a wrap in a narrow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8012 * window. Prefer showing edit_submode_extra. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8013 length = (Rows - msg_row) * Columns - 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8014 if (edit_submode_extra != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8015 length -= vim_strsize(edit_submode_extra);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8016 if (length > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8017 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8018 if (edit_submode_pre != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8019 length -= vim_strsize(edit_submode_pre);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8020 if (length - vim_strsize(edit_submode) > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8021 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8022 if (edit_submode_pre != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8023 msg_puts_attr(edit_submode_pre, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8024 msg_puts_attr(edit_submode, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8025 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8026 if (edit_submode_extra != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8027 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8028 MSG_PUTS_ATTR(" ", attr); /* add a space in between */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8029 if ((int)edit_submode_highl < (int)HLF_COUNT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8030 sub_attr = hl_attr(edit_submode_highl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8031 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8032 sub_attr = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8033 msg_puts_attr(edit_submode_extra, sub_attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8035 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8036 length = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8037 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8038 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8039 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8041 #ifdef FEAT_VREPLACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8042 if (State & VREPLACE_FLAG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8043 MSG_PUTS_ATTR(_(" VREPLACE"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8044 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8045 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8046 if (State & REPLACE_FLAG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8047 MSG_PUTS_ATTR(_(" REPLACE"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8048 else if (State & INSERT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8049 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8050 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8051 if (p_ri)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8052 MSG_PUTS_ATTR(_(" REVERSE"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8053 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8054 MSG_PUTS_ATTR(_(" INSERT"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8055 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8056 else if (restart_edit == 'I')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8057 MSG_PUTS_ATTR(_(" (insert)"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8058 else if (restart_edit == 'R')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8059 MSG_PUTS_ATTR(_(" (replace)"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8060 else if (restart_edit == 'V')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8061 MSG_PUTS_ATTR(_(" (vreplace)"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8062 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8063 if (p_hkmap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8064 MSG_PUTS_ATTR(_(" Hebrew"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8065 # ifdef FEAT_FKMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8066 if (p_fkmap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8067 MSG_PUTS_ATTR(farsi_text_5, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8068 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8069 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8070 #ifdef FEAT_KEYMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8071 if (State & LANGMAP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8072 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8073 # ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8074 if (curwin->w_p_arab)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8075 MSG_PUTS_ATTR(_(" Arabic"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8076 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8077 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8078 MSG_PUTS_ATTR(_(" (lang)"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8080 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8081 if ((State & INSERT) && p_paste)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8082 MSG_PUTS_ATTR(_(" (paste)"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8083
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8084 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8085 if (VIsual_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8086 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8087 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8088
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8089 /* Don't concatenate separate words to avoid translation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8090 * problems. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8091 switch ((VIsual_select ? 4 : 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8092 + (VIsual_mode == Ctrl_V) * 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8093 + (VIsual_mode == 'V'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8094 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8095 case 0: p = N_(" VISUAL"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8096 case 1: p = N_(" VISUAL LINE"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8097 case 2: p = N_(" VISUAL BLOCK"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8098 case 4: p = N_(" SELECT"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8099 case 5: p = N_(" SELECT LINE"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8100 default: p = N_(" SELECT BLOCK"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8101 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8102 MSG_PUTS_ATTR(_(p), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8103 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8104 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8105 MSG_PUTS_ATTR(" --", attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8107 need_clear = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8109 if (Recording
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8110 #ifdef FEAT_INS_EXPAND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8111 && edit_submode == NULL /* otherwise it gets too long */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8112 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8113 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8115 MSG_PUTS_ATTR(_("recording"), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8116 need_clear = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8118 if (need_clear || clear_cmdline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8119 msg_clr_eos();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8120 msg_didout = FALSE; /* overwrite this message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8121 length = msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8122 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8123 need_wait_return = nwr_save; /* never ask for hit-return for this */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8124 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8125 else if (clear_cmdline && msg_silent == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8126 /* Clear the whole command line. Will reset "clear_cmdline". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8127 msg_clr_cmdline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8129 #ifdef FEAT_CMDL_INFO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8130 # ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8131 /* In Visual mode the size of the selected area must be redrawn. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8132 if (VIsual_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8133 clear_showcmd();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8134 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8136 /* If the last window has no status line, the ruler is after the mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8137 * message and must be redrawn */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8138 if (redrawing()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8139 # ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8140 && lastwin->w_status_height == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8141 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8142 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8143 win_redr_ruler(lastwin, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8144 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8145 redraw_cmdline = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8146 clear_cmdline = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8148 return length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8149 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8151 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8152 * Position for a mode message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8153 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8154 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8155 msg_pos_mode()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8156 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8157 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8158 msg_row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8161 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8162 * Delete mode message. Used when ESC is typed which is expected to end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8163 * Insert mode (but Insert mode didn't end yet!).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8164 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8165 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8166 unshowmode(force)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8167 int force;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8168 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8169 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8170 * Don't delete it right now, when not redrawing or insided a mapping.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8171 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8172 if (!redrawing() || (!force && char_avail() && !KeyTyped))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8173 redraw_cmdline = TRUE; /* delete mode later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8174 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8175 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8176 msg_pos_mode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8177 if (Recording)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8178 MSG_PUTS_ATTR(_("recording"), hl_attr(HLF_CM));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8179 msg_clr_eos();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8181 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8183 #if defined(FEAT_WINDOWS) || defined(FEAT_WILDMENU) || defined(FEAT_STL_OPT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8184 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8185 * Get the character to use in a status line. Get its attributes in "*attr".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8186 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8187 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8188 fillchar_status(attr, is_curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8189 int *attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8190 int is_curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8192 int fill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8193 if (is_curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8194 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8195 *attr = hl_attr(HLF_S);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8196 fill = fill_stl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8197 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8198 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8199 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8200 *attr = hl_attr(HLF_SNC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8201 fill = fill_stlnc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8202 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8203 /* Use fill when there is highlighting, and highlighting of current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8204 * window differs, or the fillchars differ, or this is not the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8205 * current window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8206 if (*attr != 0 && ((hl_attr(HLF_S) != hl_attr(HLF_SNC)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8207 || !is_curwin || firstwin == lastwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8208 || (fill_stl != fill_stlnc)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8209 return fill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8210 if (is_curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8211 return '^';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8212 return '=';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8213 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8214 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8216 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8217 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8218 * Get the character to use in a separator between vertically split windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8219 * Get its attributes in "*attr".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8220 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8221 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8222 fillchar_vsep(attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8223 int *attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8224 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8225 *attr = hl_attr(HLF_C);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8226 if (*attr == 0 && fill_vert == ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8227 return '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8228 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8229 return fill_vert;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8230 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8231 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8233 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8234 * Return TRUE if redrawing should currently be done.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8235 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8236 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8237 redrawing()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8239 return (!RedrawingDisabled
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8240 && !(p_lz && char_avail() && !KeyTyped && !do_redraw));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8242
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8243 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8244 * Return TRUE if printing messages should currently be done.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8245 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8246 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8247 messaging()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8248 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8249 return (!(p_lz && char_avail() && !KeyTyped));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8252 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8253 * Show current status info in ruler and various other places
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8254 * If always is FALSE, only show ruler if position has changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8255 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8256 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8257 showruler(always)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8258 int always;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8259 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8260 if (!always && !redrawing())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8261 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8262 #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
8263 if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8264 win_redr_custom(curwin, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8265 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8266 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8267 #ifdef FEAT_CMDL_INFO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8268 win_redr_ruler(curwin, always);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8269 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8271 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8272 if (need_maketitle
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8273 # ifdef FEAT_STL_OPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8274 || (p_icon && (stl_syntax & STL_IN_ICON))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8275 || (p_title && (stl_syntax & STL_IN_TITLE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8276 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8277 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8278 maketitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8279 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8282 #ifdef FEAT_CMDL_INFO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8283 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8284 win_redr_ruler(wp, always)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8285 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8286 int always;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8287 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8288 char_u buffer[70];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8289 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8290 int fillchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8291 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8292 int empty_line = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8293 colnr_T virtcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8294 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8295 int o;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8296 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8297 int this_ru_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8298 int off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8299 int width = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8300 # define WITH_OFF(x) x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8301 # define WITH_WIDTH(x) x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8302 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8303 # define WITH_OFF(x) 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8304 # define WITH_WIDTH(x) Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8305 # define this_ru_col ru_col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8306 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8308 /* If 'ruler' off or redrawing disabled, don't do anything */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8309 if (!p_ru)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8310 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8312 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8313 * Check if cursor.lnum is valid, since win_redr_ruler() may be called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8314 * after deleting lines, before cursor.lnum is corrected.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8315 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8316 if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8317 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8319 #ifdef FEAT_INS_EXPAND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8320 /* Don't draw the ruler while doing insert-completion, it might overwrite
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8321 * the (long) mode message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8322 # ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8323 if (wp == lastwin && lastwin->w_status_height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8324 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8325 if (edit_submode != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8326 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8327 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8329 #ifdef FEAT_STL_OPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8330 if (*p_ruf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8331 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8332 win_redr_custom(wp, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8333 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8334 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8335 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8337 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8338 * Check if not in Insert mode and the line is empty (will show "0-1").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8339 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8340 if (!(State & INSERT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8341 && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8342 empty_line = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8344 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8345 * Only draw the ruler when something changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8346 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8347 validate_virtcol_win(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8348 if ( redraw_cmdline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8349 || always
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8350 || wp->w_cursor.lnum != wp->w_ru_cursor.lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8351 || wp->w_cursor.col != wp->w_ru_cursor.col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8352 || wp->w_virtcol != wp->w_ru_virtcol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8353 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8354 || wp->w_cursor.coladd != wp->w_ru_cursor.coladd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8355 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8356 || wp->w_topline != wp->w_ru_topline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8357 || wp->w_buffer->b_ml.ml_line_count != wp->w_ru_line_count
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8358 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8359 || wp->w_topfill != wp->w_ru_topfill
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8360 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8361 || empty_line != wp->w_ru_empty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8362 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8363 cursor_off();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8364 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8365 if (wp->w_status_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8367 row = W_WINROW(wp) + wp->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8368 fillchar = fillchar_status(&attr, wp == curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8369 # ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8370 off = W_WINCOL(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8371 width = W_WIDTH(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8372 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8374 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8375 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8376 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8377 row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8378 fillchar = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8379 attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8380 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8381 width = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8382 off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8383 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8384 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8386 /* In list mode virtcol needs to be recomputed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8387 virtcol = wp->w_virtcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8388 if (wp->w_p_list && lcs_tab1 == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8390 wp->w_p_list = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8391 getvvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8392 wp->w_p_list = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8393 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8395 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8396 * Some sprintfs return the length, some return a pointer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8397 * To avoid portability problems we use strlen() here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8398 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8399 sprintf((char *)buffer, "%ld,",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8400 (wp->w_buffer->b_ml.ml_flags & ML_EMPTY)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8401 ? 0L
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8402 : (long)(wp->w_cursor.lnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8403 col_print(buffer + STRLEN(buffer),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8404 empty_line ? 0 : (int)wp->w_cursor.col + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8405 (int)virtcol + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8407 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8408 * Add a "50%" if there is room for it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8409 * On the last line, don't print in the last column (scrolls the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8410 * screen up on some terminals).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8411 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8412 i = (int)STRLEN(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8413 get_rel_pos(wp, buffer + i + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8414 o = i + vim_strsize(buffer + i + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8415 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8416 if (wp->w_status_height == 0) /* can't use last char of screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8417 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8418 ++o;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8419 #ifdef FEAT_VERTSPLIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8420 this_ru_col = ru_col - (Columns - width);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8421 if (this_ru_col < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8422 this_ru_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8423 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8424 /* Never use more than half the window/screen width, leave the other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8425 * half for the filename. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8426 if (this_ru_col < (WITH_WIDTH(width) + 1) / 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8427 this_ru_col = (WITH_WIDTH(width) + 1) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8428 if (this_ru_col + o < WITH_WIDTH(width))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8429 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8430 while (this_ru_col + o < WITH_WIDTH(width))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8432 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8433 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8434 i += (*mb_char2bytes)(fillchar, buffer + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8435 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8436 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8437 buffer[i++] = fillchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8438 ++o;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8440 get_rel_pos(wp, buffer + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8441 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8442 /* Truncate at window boundary. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8443 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8444 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8445 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8446 o = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8447 for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len_check)(buffer + i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8448 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8449 o += (*mb_ptr2cells)(buffer + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8450 if (this_ru_col + o > WITH_WIDTH(width))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8451 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8452 buffer[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8453 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8454 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8455 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8456 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8457 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8458 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8459 if (this_ru_col + (int)STRLEN(buffer) > WITH_WIDTH(width))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8460 buffer[WITH_WIDTH(width) - this_ru_col] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8462 screen_puts(buffer, row, this_ru_col + WITH_OFF(off), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8463 i = redraw_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8464 screen_fill(row, row + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8465 this_ru_col + WITH_OFF(off) + (int)STRLEN(buffer),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8466 (int)(WITH_OFF(off) + WITH_WIDTH(width)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8467 fillchar, fillchar, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8468 /* don't redraw the cmdline because of showing the ruler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8469 redraw_cmdline = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8470 wp->w_ru_cursor = wp->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8471 wp->w_ru_virtcol = wp->w_virtcol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8472 wp->w_ru_empty = empty_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8473 wp->w_ru_topline = wp->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8474 wp->w_ru_line_count = wp->w_buffer->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8475 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8476 wp->w_ru_topfill = wp->w_topfill;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8477 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8478 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8480 #endif
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8481
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8482 #if defined(FEAT_LINEBREAK) || defined(PROTO)
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8483 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8484 * Return the width of the 'number' column.
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8485 * Zero when 'number' isn't set.
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8486 * Otherwise it depends on 'numberwidth' and the line count.
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8487 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8488 int
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8489 number_width(wp)
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8490 win_T *wp;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8491 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8492 int n;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8493 linenr_T lnum;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8494
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8495 if (!wp->w_p_nu)
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8496 return 0;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8497
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8498 lnum = wp->w_buffer->b_ml.ml_line_count;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8499 if (lnum == wp->w_nrwidth_line_count)
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8500 return wp->w_nrwidth_width;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8501 wp->w_nrwidth_line_count = lnum;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8502
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8503 n = 0;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8504 do
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8505 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8506 lnum /= 10;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8507 ++n;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8508 } while (lnum > 0);
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8509
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8510 /* 'numberwidth' gives the minimal width plus one */
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8511 if (n < wp->w_p_nuw - 1)
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8512 n = wp->w_p_nuw - 1;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8513
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8514 wp->w_nrwidth_width = n;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8515 return n;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8516 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
8517 #endif