annotate src/screen.c @ 32669:448aef880252

normalize line endings
author Christian Brabandt <cb@256bit.org>
date Mon, 26 Jun 2023 09:54:34 +0200
parents aa64fdad1f60
children 695b50472e85
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32669
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
7 * See README.txt for an overview of the Vim source code.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
8 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
9
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
10 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
11 * screen.c: Lower level code for displaying on the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
12 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
13 * Output to the screen (console, terminal emulator or GUI window) is minimized
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
14 * by remembering what is already on the screen, and only updating the parts
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
15 * that changed.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
16 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
17 * ScreenLines[off] Contains a copy of the whole screen, as it is currently
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
18 * displayed (excluding text written by external commands).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
19 * ScreenAttrs[off] Contains the associated attributes.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
20 * ScreenCols[off] Contains the byte offset in the line. -1 means not
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
21 * available (below last line), MAXCOL means after the end
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
22 * of the line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
23 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
24 * LineOffset[row] Contains the offset into ScreenLines*[], ScreenAttrs[]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
25 * and ScreenCols[] for each line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
26 * LineWraps[row] Flag for each line whether it wraps to the next line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
27 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
28 * For double-byte characters, two consecutive bytes in ScreenLines[] can form
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
29 * one character which occupies two display cells.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
30 * For UTF-8 a multi-byte character is converted to Unicode and stored in
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
31 * ScreenLinesUC[]. ScreenLines[] contains the first byte only. For an ASCII
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
32 * character without composing chars ScreenLinesUC[] will be 0 and
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
33 * ScreenLinesC[][] is not used. When the character occupies two display
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
34 * cells the next byte in ScreenLines[] is 0.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
35 * ScreenLinesC[][] contain up to 'maxcombine' composing characters
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
36 * (drawn on top of the first character). There is 0 after the last one used.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
37 * ScreenLines2[] is only used for euc-jp to store the second byte if the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
38 * first byte is 0x8e (single-width character).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
39 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
40 * The screen_*() functions write to the screen and handle updating
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
41 * ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
42 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
43
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
44 #include "vim.h"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
45
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
46 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
47 * The attributes that are actually active for writing to the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
48 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
49 static int screen_attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
50
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
51 static void screen_char_2(unsigned off, int row, int col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
52 static int screenclear2(int doclear);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
53 static void lineclear(unsigned off, int width, int attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
54 static void lineinvalid(unsigned off, int width);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
55 static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int del, int clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
56 static void win_rest_invalid(win_T *wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
57 static void msg_pos_mode(void);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
58 static void recording_mode(int attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
59
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
60 // Ugly global: overrule attribute used by screen_char()
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
61 static int screen_char_attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
62
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
63 #if defined(FEAT_CONCEAL) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
64 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
65 * Return TRUE if the cursor line in window "wp" may be concealed, according
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
66 * to the 'concealcursor' option.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
67 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
68 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
69 conceal_cursor_line(win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
70 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
71 int c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
72
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
73 if (*wp->w_p_cocu == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
74 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
75 if (get_real_state() & MODE_VISUAL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
76 c = 'v';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
77 else if (State & MODE_INSERT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
78 c = 'i';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
79 else if (State & MODE_NORMAL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
80 c = 'n';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
81 else if (State & MODE_CMDLINE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
82 c = 'c';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
83 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
84 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
85 return vim_strchr(wp->w_p_cocu, c) != NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
86 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
87
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
88 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
89 * Check if the cursor line needs to be redrawn because of 'concealcursor'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
90 * To be called after changing the state, "was_concealed" is the value of
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
91 * "conceal_cursor_line()" before the change.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
92 * "
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
93 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
94 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
95 conceal_check_cursor_line(int was_concealed)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
96 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
97 if (curwin->w_p_cole <= 0 || conceal_cursor_line(curwin) == was_concealed)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
98 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
99
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
100 int wcol = curwin->w_wcol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
101
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
102 need_cursor_line_redraw = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
103 // Need to recompute cursor column, e.g., when starting Visual mode
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
104 // without concealing.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
105 curs_columns(TRUE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
106
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
107 // When concealing now w_wcol will be computed wrong, keep the previous
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
108 // value, it will be updated in win_line().
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
109 if (!was_concealed)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
110 curwin->w_wcol = wcol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
111 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
112 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
113
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
114 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
115 * Get 'wincolor' attribute for window "wp". If not set and "wp" is a popup
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
116 * window then get the "Pmenu" highlight attribute.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
117 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
118 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
119 get_wcr_attr(win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
120 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
121 int wcr_attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
122
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
123 if (*wp->w_p_wcr != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
124 wcr_attr = syn_name2attr(wp->w_p_wcr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
125 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
126 else if (WIN_IS_POPUP(wp))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
127 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
128 if (wp->w_popup_flags & POPF_INFO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
129 wcr_attr = HL_ATTR(HLF_PSI); // PmenuSel
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
130 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
131 wcr_attr = HL_ATTR(HLF_PNI); // Pmenu
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
132 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
133 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
134 return wcr_attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
135 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
136
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
137 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
138 * Call screen_fill() with the columns adjusted for 'rightleft' if needed.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
139 * Return the new offset.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
140 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
141 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
142 screen_fill_end(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
143 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
144 int c1,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
145 int c2,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
146 int off,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
147 int width,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
148 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
149 int endrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
150 int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
151 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
152 int nn = off + width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
153
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
154 if (nn > wp->w_width)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
155 nn = wp->w_width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
156 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
157 if (wp->w_p_rl)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
158 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
159 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
160 W_ENDCOL(wp) - nn, (int)W_ENDCOL(wp) - off,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
161 c1, c2, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
162 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
163 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
164 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
165 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
166 wp->w_wincol + off, (int)wp->w_wincol + nn,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
167 c1, c2, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
168 return nn;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
169 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
170
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
171 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
172 * Clear lines near the end the window and mark the unused lines with "c1".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
173 * use "c2" as the filler character.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
174 * When "draw_margin" is TRUE then draw the sign, fold and number columns.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
175 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
176 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
177 win_draw_end(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
178 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
179 int c1,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
180 int c2,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
181 int draw_margin,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
182 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
183 int endrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
184 hlf_T hl)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
185 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
186 int n = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
187 int attr = HL_ATTR(hl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
188 int wcr_attr = get_wcr_attr(wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
189
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
190 attr = hl_combine_attr(wcr_attr, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
191
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
192 if (draw_margin)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
193 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
194 #ifdef FEAT_FOLDING
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
195 int fdc = compute_foldcolumn(wp, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
196
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
197 if (fdc > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
198 // draw the fold column
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
199 n = screen_fill_end(wp, ' ', ' ', n, fdc,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
200 row, endrow, hl_combine_attr(wcr_attr, HL_ATTR(HLF_FC)));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
201 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
202 #ifdef FEAT_SIGNS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
203 if (signcolumn_on(wp))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
204 // draw the sign column
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
205 n = screen_fill_end(wp, ' ', ' ', n, 2,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
206 row, endrow, hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC)));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
207 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
208 if ((wp->w_p_nu || wp->w_p_rnu)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
209 && vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
210 // draw the number column
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
211 n = screen_fill_end(wp, ' ', ' ', n, number_width(wp) + 1,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
212 row, endrow, hl_combine_attr(wcr_attr, HL_ATTR(HLF_N)));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
213 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
214
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
215 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
216 if (wp->w_p_rl)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
217 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
218 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
219 wp->w_wincol, W_ENDCOL(wp) - 1 - n,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
220 c2, c2, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
221 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
222 W_ENDCOL(wp) - 1 - n, W_ENDCOL(wp) - n,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
223 c1, c2, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
224 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
225 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
226 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
227 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
228 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
229 wp->w_wincol + n, (int)W_ENDCOL(wp),
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
230 c1, c2, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
231 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
232
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
233 set_empty_rows(wp, row);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
234 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
235
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
236 #if defined(FEAT_FOLDING) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
237 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
238 * Compute the width of the foldcolumn. Based on 'foldcolumn' and how much
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
239 * space is available for window "wp", minus "col".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
240 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
241 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
242 compute_foldcolumn(win_T *wp, int col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
243 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
244 int fdc = wp->w_p_fdc;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
245 int wmw = wp == curwin && p_wmw == 0 ? 1 : p_wmw;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
246 int wwidth = wp->w_width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
247
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
248 if (fdc > wwidth - (col + wmw))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
249 fdc = wwidth - (col + wmw);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
250 return fdc;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
251 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
252
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
253 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
254 * Fill the foldcolumn at "p" for window "wp".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
255 * Only to be called when 'foldcolumn' > 0.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
256 * Returns the number of bytes stored in 'p'. When non-multibyte characters are
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
257 * used for the fold column markers, this is equal to 'fdc' setting. Otherwise,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
258 * this will be greater than 'fdc'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
259 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
260 size_t
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
261 fill_foldcolumn(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
262 char_u *p,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
263 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
264 int closed, // TRUE of FALSE
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
265 linenr_T lnum) // current line number
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
266 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
267 int i = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
268 int level;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
269 int first_level;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
270 int empty;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
271 int fdc = compute_foldcolumn(wp, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
272 size_t byte_counter = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
273 int symbol = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
274 int len = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
275
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
276 // Init to all spaces.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
277 vim_memset(p, ' ', MAX_MCO * fdc + 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
278
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
279 level = win_foldinfo.fi_level;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
280 empty = (fdc == 1) ? 0 : 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
281
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
282 // If the column is too narrow, we start at the lowest level that
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
283 // fits and use numbers to indicate the depth.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
284 first_level = level - fdc - closed + 1 + empty;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
285 if (first_level < 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
286 first_level = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
287
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
288 for (i = 0; i < MIN(fdc, level); i++)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
289 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
290 if (win_foldinfo.fi_lnum == lnum
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
291 && first_level + i >= win_foldinfo.fi_low_level)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
292 symbol = wp->w_fill_chars.foldopen;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
293 else if (first_level == 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
294 symbol = wp->w_fill_chars.foldsep;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
295 else if (first_level + i <= 9)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
296 symbol = '0' + first_level + i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
297 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
298 symbol = '>';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
299
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
300 len = utf_char2bytes(symbol, &p[byte_counter]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
301 byte_counter += len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
302 if (first_level + i >= level)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
303 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
304 i++;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
305 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
306 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
307 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
308
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
309 if (closed)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
310 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
311 if (symbol != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
312 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
313 // rollback length and the character
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
314 byte_counter -= len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
315 if (len > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
316 // for a multibyte character, erase all the bytes
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
317 vim_memset(p + byte_counter, ' ', len);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
318 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
319 symbol = wp->w_fill_chars.foldclosed;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
320 len = utf_char2bytes(symbol, &p[byte_counter]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
321 byte_counter += len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
322 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
323
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
324 return MAX(byte_counter + (fdc - i), (size_t)fdc);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
325 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
326 #endif // FEAT_FOLDING
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
327
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
328 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
329 * Return if the composing characters at "off_from" and "off_to" differ.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
330 * Only to be used when ScreenLinesUC[off_from] != 0.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
331 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
332 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
333 comp_char_differs(int off_from, int off_to)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
334 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
335 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
336
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
337 for (i = 0; i < Screen_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
338 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
339 if (ScreenLinesC[i][off_from] != ScreenLinesC[i][off_to])
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
340 return TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
341 if (ScreenLinesC[i][off_from] == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
342 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
343 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
344 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
345 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
346
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
347 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
348 * Check whether the given character needs redrawing:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
349 * - the (first byte of the) character is different
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
350 * - the attributes are different
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
351 * - the character is multi-byte and the next byte is different
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
352 * - the character is two cells wide and the second cell differs.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
353 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
354 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
355 char_needs_redraw(int off_from, int off_to, int cols)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
356 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
357 if (cols > 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
358 && ((ScreenLines[off_from] != ScreenLines[off_to]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
359 || ScreenAttrs[off_from] != ScreenAttrs[off_to])
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
360 || (enc_dbcs != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
361 && MB_BYTE2LEN(ScreenLines[off_from]) > 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
362 && (enc_dbcs == DBCS_JPNU && ScreenLines[off_from] == 0x8e
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
363 ? ScreenLines2[off_from] != ScreenLines2[off_to]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
364 : (cols > 1 && ScreenLines[off_from + 1]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
365 != ScreenLines[off_to + 1])))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
366 || (enc_utf8
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
367 && (ScreenLinesUC[off_from] != ScreenLinesUC[off_to]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
368 || (ScreenLinesUC[off_from] != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
369 && comp_char_differs(off_from, off_to))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
370 || ((*mb_off2cells)(off_from, off_from + cols) > 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
371 && ScreenLines[off_from + 1]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
372 != ScreenLines[off_to + 1])))))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
373 return TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
374 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
375 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
376
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
377 #if defined(FEAT_TERMINAL) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
378 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
379 * Return the index in ScreenLines[] for the current screen line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
380 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
381 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
382 screen_get_current_line_off(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
383 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
384 return (int)(current_ScreenLine - ScreenLines);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
385 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
386 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
387
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
388 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
389 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
390 * Return TRUE if this position has a higher level popup or this cell is
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
391 * transparent in the current popup.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
392 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
393 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
394 blocked_by_popup(int row, int col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
395 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
396 int off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
397
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
398 if (!popup_visible)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
399 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
400 off = row * screen_Columns + col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
401 return popup_mask[off] > screen_zindex || popup_transparent[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
402 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
403 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
404
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
405 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
406 * Reset the highlighting. Used before clearing the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
407 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
408 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
409 reset_screen_attr(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
410 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
411 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
412 if (gui.in_use)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
413 // Use a code that will reset gui.highlight_mask in
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
414 // gui_stop_highlight().
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
415 screen_attr = HL_ALL + 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
416 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
417 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
418 // Use attributes that is very unlikely to appear in text.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
419 screen_attr = HL_BOLD | HL_UNDERLINE | HL_INVERSE | HL_STRIKETHROUGH;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
420 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
421
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
422 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
423 * Return TRUE if the character at "row" / "col" is under the popup menu and it
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
424 * will be redrawn soon or it is under another popup.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
425 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
426 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
427 skip_for_popup(int row, int col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
428 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
429 // Popup windows with zindex higher than POPUPMENU_ZINDEX go on top.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
430 if (pum_under_menu(row, col, TRUE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
431 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
432 && screen_zindex <= POPUPMENU_ZINDEX
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
433 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
434 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
435 return TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
436 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
437 if (blocked_by_popup(row, col))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
438 return TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
439 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
440 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
441 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
442
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
443 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
444 * Move one "cooked" screen line to the screen, but only the characters that
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
445 * have actually changed. Handle insert/delete character.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
446 * "coloff" gives the first column on the screen for this line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
447 * "endcol" gives the columns where valid characters are.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
448 * "clear_width" is the width of the window. It's > 0 if the rest of the line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
449 * needs to be cleared, negative otherwise.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
450 * "flags" can have bits:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
451 * SLF_POPUP popup window
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
452 * SLF_RIGHTLEFT rightleft window:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
453 * When TRUE and "clear_width" > 0, clear columns 0 to "endcol"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
454 * When FALSE and "clear_width" > 0, clear columns "endcol" to "clear_width"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
455 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
456 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
457 screen_line(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
458 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
459 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
460 int coloff,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
461 int endcol,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
462 int clear_width,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
463 int flags UNUSED)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
464 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
465 unsigned off_from;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
466 unsigned off_to;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
467 unsigned max_off_from;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
468 unsigned max_off_to;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
469 int col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
470 int hl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
471 int force = FALSE; // force update rest of the line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
472 int redraw_this // bool: does character need redraw?
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
473 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
474 = TRUE // For GUI when while-loop empty
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
475 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
476 ;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
477 int redraw_next; // redraw_this for next character
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
478 #ifdef FEAT_GUI_MSWIN
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
479 int changed_this; // TRUE if character changed
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
480 int changed_next; // TRUE if next character changed
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
481 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
482 int clear_next = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
483 int char_cells; // 1: normal char
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
484 // 2: occupies two display cells
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
485
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
486 // Check for illegal row and col, just in case.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
487 if (row >= Rows)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
488 row = Rows - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
489 if (endcol > Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
490 endcol = Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
491
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
492 # ifdef FEAT_CLIPBOARD
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
493 clip_may_clear_selection(row, row);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
494 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
495
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
496 off_from = (unsigned)(current_ScreenLine - ScreenLines);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
497 off_to = LineOffset[row] + coloff;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
498 max_off_from = off_from + screen_Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
499 max_off_to = LineOffset[row] + screen_Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
500
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
501 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
502 if (flags & SLF_RIGHTLEFT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
503 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
504 // Clear rest first, because it's left of the text.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
505 if (clear_width > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
506 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
507 while (col <= endcol && ScreenLines[off_to] == ' '
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
508 && ScreenAttrs[off_to] == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
509 && (!enc_utf8 || ScreenLinesUC[off_to] == 0))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
510 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
511 ++off_to;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
512 ++col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
513 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
514 if (col <= endcol)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
515 screen_fill(row, row + 1, col + coloff,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
516 endcol + coloff + 1, ' ', ' ', 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
517 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
518 col = endcol + 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
519 off_to = LineOffset[row] + col + coloff;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
520 off_from += col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
521 endcol = (clear_width > 0 ? clear_width : -clear_width);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
522 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
523 #endif // FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
524
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
525 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
526 // First char of a popup window may go on top of the right half of a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
527 // double-wide character. Clear the left half to avoid it getting the popup
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
528 // window background color.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
529 if (coloff > 0 && enc_utf8
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
530 && ScreenLines[off_to] == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
531 && ScreenLinesUC[off_to - 1] != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
532 && (*mb_char2cells)(ScreenLinesUC[off_to - 1]) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
533 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
534 ScreenLines[off_to - 1] = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
535 ScreenLinesUC[off_to - 1] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
536 screen_char(off_to - 1, row, col + coloff - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
537 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
538 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
539
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
540 redraw_next = char_needs_redraw(off_from, off_to, endcol - col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
541 #ifdef FEAT_GUI_MSWIN
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
542 changed_next = redraw_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
543 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
544
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
545 while (col < endcol)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
546 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
547 if (has_mbyte && (col + 1 < endcol))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
548 char_cells = (*mb_off2cells)(off_from, max_off_from);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
549 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
550 char_cells = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
551
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
552 redraw_this = redraw_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
553 redraw_next = force || char_needs_redraw(off_from + char_cells,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
554 off_to + char_cells, endcol - col - char_cells);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
555
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
556 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
557 # ifdef FEAT_GUI_MSWIN
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
558 changed_this = changed_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
559 changed_next = redraw_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
560 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
561 // If the next character was bold, then redraw the current character to
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
562 // remove any pixels that might have spilt over into us. This only
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
563 // happens in the GUI.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
564 // With MS-Windows antialiasing may also cause pixels to spill over
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
565 // from a previous character, no matter attributes, always redraw if a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
566 // character changed.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
567 if (redraw_next && gui.in_use)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
568 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
569 # ifndef FEAT_GUI_MSWIN
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
570 hl = ScreenAttrs[off_to + char_cells];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
571 if (hl > HL_ALL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
572 hl = syn_attr2attr(hl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
573 if (hl & HL_BOLD)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
574 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
575 redraw_this = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
576 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
577 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
578 // Do not redraw if under the popup menu.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
579 if (redraw_this && skip_for_popup(row, col + coloff))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
580 redraw_this = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
581
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
582 if (redraw_this)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
583 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
584 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
585 * Special handling when 'xs' termcap flag set (hpterm):
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
586 * Attributes for characters are stored at the position where the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
587 * cursor is when writing the highlighting code. The
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
588 * start-highlighting code must be written with the cursor on the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
589 * first highlighted character. The stop-highlighting code must
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
590 * be written with the cursor just after the last highlighted
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
591 * character.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
592 * Overwriting a character doesn't remove its highlighting. Need
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
593 * to clear the rest of the line, and force redrawing it
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
594 * completely.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
595 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
596 if ( p_wiv
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
597 && !force
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
598 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
599 && !gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
600 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
601 && ScreenAttrs[off_to] != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
602 && ScreenAttrs[off_from] != ScreenAttrs[off_to])
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
603 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
604 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
605 * Need to remove highlighting attributes here.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
606 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
607 windgoto(row, col + coloff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
608 out_str(T_CE); // clear rest of this screen line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
609 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
610 force = TRUE; // force redraw of rest of the line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
611 redraw_next = TRUE; // or else next char would miss out
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
612
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
613 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
614 * If the previous character was highlighted, need to stop
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
615 * highlighting at this character.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
616 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
617 if (col + coloff > 0 && ScreenAttrs[off_to - 1] != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
618 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
619 screen_attr = ScreenAttrs[off_to - 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
620 term_windgoto(row, col + coloff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
621 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
622 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
623 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
624 screen_attr = 0; // highlighting has stopped
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
625 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
626 if (enc_dbcs != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
627 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
628 // Check if overwriting a double-byte with a single-byte or
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
629 // the other way around requires another character to be
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
630 // redrawn. For UTF-8 this isn't needed, because comparing
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
631 // ScreenLinesUC[] is sufficient.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
632 if (char_cells == 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
633 && col + 1 < endcol
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
634 && (*mb_off2cells)(off_to, max_off_to) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
635 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
636 // Writing a single-cell character over a double-cell
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
637 // character: need to redraw the next cell.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
638 ScreenLines[off_to + 1] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
639 redraw_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
640 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
641 else if (char_cells == 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
642 && col + 2 < endcol
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
643 && (*mb_off2cells)(off_to, max_off_to) == 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
644 && (*mb_off2cells)(off_to + 1, max_off_to) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
645 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
646 // Writing the second half of a double-cell character over
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
647 // a double-cell character: need to redraw the second
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
648 // cell.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
649 ScreenLines[off_to + 2] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
650 redraw_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
651 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
652
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
653 if (enc_dbcs == DBCS_JPNU)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
654 ScreenLines2[off_to] = ScreenLines2[off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
655 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
656 // When writing a single-width character over a double-width
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
657 // character and at the end of the redrawn text, need to clear out
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
658 // the right half of the old character.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
659 // Also required when writing the right half of a double-width
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
660 // char over the left half of an existing one.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
661 if (has_mbyte && col + char_cells == endcol
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
662 && ((char_cells == 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
663 && (*mb_off2cells)(off_to, max_off_to) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
664 || (char_cells == 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
665 && (*mb_off2cells)(off_to, max_off_to) == 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
666 && (*mb_off2cells)(off_to + 1, max_off_to) > 1)))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
667 clear_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
668
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
669 ScreenLines[off_to] = ScreenLines[off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
670 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
671 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
672 ScreenLinesUC[off_to] = ScreenLinesUC[off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
673 if (ScreenLinesUC[off_from] != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
674 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
675 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
676
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
677 for (i = 0; i < Screen_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
678 ScreenLinesC[i][off_to] = ScreenLinesC[i][off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
679 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
680 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
681 if (char_cells == 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
682 ScreenLines[off_to + 1] = ScreenLines[off_from + 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
683
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
684 #if defined(FEAT_GUI) || defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
685 // The bold trick makes a single column of pixels appear in the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
686 // next character. When a bold character is removed, the next
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
687 // character should be redrawn too. This happens for our own GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
688 // and for some xterms.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
689 if (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
690 # ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
691 gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
692 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
693 # if defined(FEAT_GUI) && defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
694 ||
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
695 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
696 # ifdef UNIX
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
697 term_is_xterm
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
698 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
699 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
700 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
701 hl = ScreenAttrs[off_to];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
702 if (hl > HL_ALL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
703 hl = syn_attr2attr(hl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
704 if (hl & HL_BOLD)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
705 redraw_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
706 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
707 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
708 #ifdef FEAT_GUI_MSWIN
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
709 // MS-Windows antialiasing may spill over to the next character,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
710 // redraw that one if this one changed, no matter attributes.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
711 if (gui.in_use && changed_this)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
712 redraw_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
713 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
714 ScreenAttrs[off_to] = ScreenAttrs[off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
715
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
716 // For simplicity set the attributes of second half of a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
717 // double-wide character equal to the first half.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
718 if (char_cells == 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
719 ScreenAttrs[off_to + 1] = ScreenAttrs[off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
720
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
721 if (enc_dbcs != 0 && char_cells == 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
722 screen_char_2(off_to, row, col + coloff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
723 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
724 screen_char(off_to, row, col + coloff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
725 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
726 else if ( p_wiv
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
727 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
728 && !gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
729 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
730 && col + coloff > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
731 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
732 if (ScreenAttrs[off_to] == ScreenAttrs[off_to - 1])
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
733 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
734 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
735 * Don't output stop-highlight when moving the cursor, it will
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
736 * stop the highlighting when it should continue.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
737 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
738 screen_attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
739 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
740 else if (screen_attr != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
741 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
742 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
743
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
744 ScreenCols[off_to] = ScreenCols[off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
745 if (char_cells == 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
746 ScreenCols[off_to + 1] = ScreenCols[off_from];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
747
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
748 off_to += char_cells;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
749 off_from += char_cells;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
750 col += char_cells;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
751 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
752
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
753 if (clear_next && !skip_for_popup(row, col + coloff))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
754 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
755 // Clear the second half of a double-wide character of which the left
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
756 // half was overwritten with a single-wide character.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
757 ScreenLines[off_to] = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
758 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
759 ScreenLinesUC[off_to] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
760 screen_char(off_to, row, col + coloff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
761 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
762
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
763 if (clear_width > 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
764 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
765 && !(flags & SLF_RIGHTLEFT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
766 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
767 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
768 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
769 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
770 int startCol = col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
771 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
772
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
773 // blank out the rest of the line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
774 while (col < clear_width && ScreenLines[off_to] == ' '
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
775 && ScreenAttrs[off_to] == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
776 && (!enc_utf8 || ScreenLinesUC[off_to] == 0))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
777 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
778 ScreenCols[off_to] = MAXCOL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
779 ++off_to;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
780 ++col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
781 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
782 if (col < clear_width)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
783 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
784 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
785 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
786 * In the GUI, clearing the rest of the line may leave pixels
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
787 * behind if the first character cleared was bold. Some bold
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
788 * fonts spill over the left. In this case we redraw the previous
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
789 * character too. If we didn't skip any blanks above, then we
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
790 * only redraw if the character wasn't already redrawn anyway.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
791 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
792 if (gui.in_use && (col > startCol || !redraw_this))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
793 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
794 hl = ScreenAttrs[off_to];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
795 if (hl > HL_ALL || (hl & HL_BOLD))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
796 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
797 int prev_cells = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
798
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
799 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
800 // for utf-8, ScreenLines[char_offset + 1] == 0 means
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
801 // that its width is 2.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
802 prev_cells = ScreenLines[off_to - 1] == 0 ? 2 : 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
803 else if (enc_dbcs != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
804 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
805 // find previous character by counting from first
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
806 // column and get its width.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
807 unsigned off = LineOffset[row];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
808 unsigned max_off = LineOffset[row] + screen_Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
809
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
810 while (off < off_to)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
811 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
812 prev_cells = (*mb_off2cells)(off, max_off);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
813 off += prev_cells;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
814 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
815 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
816
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
817 if (!skip_for_popup(row, col + coloff - prev_cells))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
818 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
819 if (enc_dbcs != 0 && prev_cells > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
820 screen_char_2(off_to - prev_cells, row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
821 col + coloff - prev_cells);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
822 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
823 screen_char(off_to - prev_cells, row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
824 col + coloff - prev_cells);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
825 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
826 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
827 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
828 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
829 screen_fill(row, row + 1, col + coloff, clear_width + coloff,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
830 ' ', ' ', 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
831 while (col < clear_width)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
832 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
833 ScreenCols[off_to++] = MAXCOL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
834 ++col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
835 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
836 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
837 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
838
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
839 if (clear_width > 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
840 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
841 && !(flags & SLF_POPUP) // no separator for popup window
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
842 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
843 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
844 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
845 // For a window that has a right neighbor, draw the separator char
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
846 // right of the window contents. But not on top of a popup window.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
847 if (coloff + col < Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
848 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
849 if (!skip_for_popup(row, col + coloff))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
850 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
851 int c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
852
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
853 c = fillchar_vsep(&hl, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
854 if (ScreenLines[off_to] != (schar_T)c
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
855 || (enc_utf8 && (int)ScreenLinesUC[off_to]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
856 != (c >= 0x80 ? c : 0))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
857 || ScreenAttrs[off_to] != hl)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
858 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
859 ScreenLines[off_to] = c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
860 ScreenAttrs[off_to] = hl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
861 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
862 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
863 if (c >= 0x80)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
864 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
865 ScreenLinesUC[off_to] = c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
866 ScreenLinesC[0][off_to] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
867 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
868 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
869 ScreenLinesUC[off_to] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
870 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
871 screen_char(off_to, row, col + coloff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
872 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
873 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
874 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
875 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
876 LineWraps[row] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
877 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
878 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
879
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
880 #if defined(FEAT_RIGHTLEFT) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
881 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
882 * Mirror text "str" for right-left displaying.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
883 * Only works for single-byte characters (e.g., numbers).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
884 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
885 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
886 rl_mirror(char_u *str)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
887 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
888 char_u *p1, *p2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
889 int t;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
890
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
891 for (p1 = str, p2 = str + STRLEN(str) - 1; p1 < p2; ++p1, --p2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
892 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
893 t = *p1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
894 *p1 = *p2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
895 *p2 = t;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
896 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
897 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
898 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
899
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
900 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
901 * Draw the verticap separator right of window "wp" starting with line "row".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
902 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
903 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
904 draw_vsep_win(win_T *wp, int row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
905 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
906 int hl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
907 int c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
908
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
909 if (!wp->w_vsep_width)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
910 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
911
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
912 // draw the vertical separator right of this window
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
913 c = fillchar_vsep(&hl, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
914 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
915 W_ENDCOL(wp), W_ENDCOL(wp) + 1,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
916 c, ' ', hl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
917 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
918
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
919 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
920 * Return TRUE if the status line of window "wp" is connected to the status
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
921 * line of the window right of it. If not, then it's a vertical separator.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
922 * Only call if (wp->w_vsep_width != 0).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
923 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
924 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
925 stl_connected(win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
926 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
927 frame_T *fr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
928
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
929 fr = wp->w_frame;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
930 while (fr->fr_parent != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
931 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
932 if (fr->fr_parent->fr_layout == FR_COL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
933 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
934 if (fr->fr_next != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
935 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
936 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
937 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
938 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
939 if (fr->fr_next != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
940 return TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
941 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
942 fr = fr->fr_parent;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
943 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
944 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
945 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
946
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
947
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
948 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
949 * Get the value to show for the language mappings, active 'keymap'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
950 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
951 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
952 get_keymap_str(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
953 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
954 char_u *fmt, // format string containing one %s item
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
955 char_u *buf, // buffer for the result
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
956 int len) // length of buffer
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
957 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
958 char_u *p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
959
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
960 if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
961 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
962
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
963 #ifdef FEAT_EVAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
964 buf_T *old_curbuf = curbuf;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
965 win_T *old_curwin = curwin;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
966 char_u *s;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
967
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
968 curbuf = wp->w_buffer;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
969 curwin = wp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
970 STRCPY(buf, "b:keymap_name"); // must be writable
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
971 ++emsg_skip;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
972 s = p = eval_to_string(buf, FALSE, FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
973 --emsg_skip;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
974 curbuf = old_curbuf;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
975 curwin = old_curwin;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
976 if (p == NULL || *p == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
977 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
978 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
979 #ifdef FEAT_KEYMAP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
980 if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
981 p = wp->w_buffer->b_p_keymap;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
982 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
983 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
984 p = (char_u *)"lang";
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
985 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
986 if (vim_snprintf((char *)buf, len, (char *)fmt, p) > len - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
987 buf[0] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
988 #ifdef FEAT_EVAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
989 vim_free(s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
990 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
991 return buf[0] != NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
992 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
993
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
994 #if defined(FEAT_STL_OPT) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
995 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
996 * Redraw the status line or ruler of window "wp".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
997 * When "wp" is NULL redraw the tab pages line from 'tabline'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
998 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
999 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1000 win_redr_custom(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1001 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1002 int draw_ruler) // TRUE or FALSE
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1003 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1004 static int entered = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1005 int attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1006 int curattr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1007 int row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1008 int col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1009 int maxwidth;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1010 int width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1011 int n;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1012 int len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1013 int fillchar;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1014 char_u buf[MAXPATHL];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1015 char_u *stl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1016 char_u *p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1017 char_u *opt_name;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1018 int opt_scope = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1019 stl_hlrec_T *hltab;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1020 stl_hlrec_T *tabtab;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1021 win_T *ewp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1022 int p_crb_save;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1023
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1024 // There is a tiny chance that this gets called recursively: When
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1025 // redrawing a status line triggers redrawing the ruler or tabline.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1026 // Avoid trouble by not allowing recursion.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1027 if (entered)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1028 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1029 entered = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1030
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1031 // setup environment for the task at hand
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1032 if (wp == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1033 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1034 // Use 'tabline'. Always at the first line of the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1035 stl = p_tal;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1036 row = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1037 fillchar = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1038 attr = HL_ATTR(HLF_TPF);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1039 maxwidth = Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1040 opt_name = (char_u *)"tabline";
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1041 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1042 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1043 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1044 row = statusline_row(wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1045 fillchar = fillchar_status(&attr, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1046 int in_status_line = wp->w_status_height != 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1047 maxwidth = in_status_line ? wp->w_width : Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1048
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1049 if (draw_ruler)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1050 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1051 stl = p_ruf;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1052 opt_name = (char_u *)"rulerformat";
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1053 // advance past any leading group spec - implicit in ru_col
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1054 if (*stl == '%')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1055 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1056 if (*++stl == '-')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1057 stl++;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1058 if (atoi((char *)stl))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1059 while (VIM_ISDIGIT(*stl))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1060 stl++;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1061 if (*stl++ != '(')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1062 stl = p_ruf;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1063 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1064 col = ru_col - (Columns - maxwidth);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1065 if (col < (maxwidth + 1) / 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1066 col = (maxwidth + 1) / 2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1067 maxwidth -= col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1068 if (!in_status_line)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1069 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1070 row = Rows - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1071 --maxwidth; // writing in last column may cause scrolling
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1072 fillchar = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1073 attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1074 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1075 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1076 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1077 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1078 opt_name = (char_u *)"statusline";
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1079 if (*wp->w_p_stl != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1080 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1081 stl = wp->w_p_stl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1082 opt_scope = OPT_LOCAL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1083 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1084 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1085 stl = p_stl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1086 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1087
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1088 if (in_status_line)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1089 col += wp->w_wincol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1090 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1091
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1092 if (maxwidth <= 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1093 goto theend;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1094
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1095 // Temporarily reset 'cursorbind', we don't want a side effect from moving
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1096 // the cursor away and back.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1097 ewp = wp == NULL ? curwin : wp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1098 p_crb_save = ewp->w_p_crb;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1099 ewp->w_p_crb = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1100
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1101 // Make a copy, because the statusline may include a function call that
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1102 // might change the option value and free the memory.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1103 stl = vim_strsave(stl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1104 width = build_stl_str_hl(ewp, buf, sizeof(buf),
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1105 stl, opt_name, opt_scope,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1106 fillchar, maxwidth, &hltab, &tabtab);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1107 vim_free(stl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1108 ewp->w_p_crb = p_crb_save;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1109
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1110 // Make all characters printable.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1111 p = transstr(buf);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1112 if (p != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1113 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1114 vim_strncpy(buf, p, sizeof(buf) - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1115 vim_free(p);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1116 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1117
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1118 // fill up with "fillchar"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1119 len = (int)STRLEN(buf);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1120 while (width < maxwidth && len < (int)sizeof(buf) - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1121 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1122 len += (*mb_char2bytes)(fillchar, buf + len);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1123 ++width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1124 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1125 buf[len] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1126
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1127 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1128 * Draw each snippet with the specified highlighting.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1129 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1130 curattr = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1131 p = buf;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1132 for (n = 0; hltab[n].start != NULL; n++)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1133 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1134 len = (int)(hltab[n].start - p);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1135 screen_puts_len(p, len, row, col, curattr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1136 col += vim_strnsize(p, len);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1137 p = hltab[n].start;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1138
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1139 if (hltab[n].userhl == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1140 curattr = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1141 else if (hltab[n].userhl < 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1142 curattr = syn_id2attr(-hltab[n].userhl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1143 #ifdef FEAT_TERMINAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1144 else if (wp != NULL && wp != curwin && bt_terminal(wp->w_buffer)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1145 && wp->w_status_height != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1146 curattr = highlight_stltermnc[hltab[n].userhl - 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1147 else if (wp != NULL && bt_terminal(wp->w_buffer)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1148 && wp->w_status_height != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1149 curattr = highlight_stlterm[hltab[n].userhl - 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1150 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1151 else if (wp != NULL && wp != curwin && wp->w_status_height != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1152 curattr = highlight_stlnc[hltab[n].userhl - 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1153 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1154 curattr = highlight_user[hltab[n].userhl - 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1155 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1156 screen_puts(p, row, col, curattr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1157
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1158 if (wp == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1159 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1160 // Fill the TabPageIdxs[] array for clicking in the tab pagesline.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1161 col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1162 len = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1163 p = buf;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1164 fillchar = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1165 for (n = 0; tabtab[n].start != NULL; n++)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1166 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1167 len += vim_strnsize(p, (int)(tabtab[n].start - p));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1168 while (col < len)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1169 TabPageIdxs[col++] = fillchar;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1170 p = tabtab[n].start;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1171 fillchar = tabtab[n].userhl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1172 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1173 while (col < Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1174 TabPageIdxs[col++] = fillchar;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1175 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1176
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1177 theend:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1178 entered = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1179 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1180
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1181 #endif // FEAT_STL_OPT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1182
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1183 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1184 * Output a single character directly to the screen and update ScreenLines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1185 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1186 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1187 screen_putchar(int c, int row, int col, int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1188 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1189 char_u buf[MB_MAXBYTES + 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1190
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1191 if (has_mbyte)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1192 buf[(*mb_char2bytes)(c, buf)] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1193 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1194 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1195 buf[0] = c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1196 buf[1] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1197 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1198 screen_puts(buf, row, col, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1199 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1200
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1201 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1202 * Get a single character directly from ScreenLines into "bytes", which must
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1203 * have a size of "MB_MAXBYTES + 1".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1204 * If "attrp" is not NULL, return the character's attribute in "*attrp".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1205 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1206 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1207 screen_getbytes(int row, int col, char_u *bytes, int *attrp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1208 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1209 unsigned off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1210
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1211 // safety check
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1212 if (ScreenLines == NULL || row >= screen_Rows || col >= screen_Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1213 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1214
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1215 off = LineOffset[row] + col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1216 if (attrp != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1217 *attrp = ScreenAttrs[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1218 bytes[0] = ScreenLines[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1219 bytes[1] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1220
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1221 if (enc_utf8 && ScreenLinesUC[off] != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1222 bytes[utfc_char2bytes(off, bytes)] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1223 else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1224 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1225 bytes[0] = ScreenLines[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1226 bytes[1] = ScreenLines2[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1227 bytes[2] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1228 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1229 else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1230 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1231 bytes[1] = ScreenLines[off + 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1232 bytes[2] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1233 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1234 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1235
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1236 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1237 * Return TRUE if composing characters for screen posn "off" differs from
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1238 * composing characters in "u8cc".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1239 * Only to be used when ScreenLinesUC[off] != 0.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1240 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1241 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1242 screen_comp_differs(int off, int *u8cc)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1243 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1244 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1245
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1246 for (i = 0; i < Screen_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1247 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1248 if (ScreenLinesC[i][off] != (u8char_T)u8cc[i])
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1249 return TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1250 if (u8cc[i] == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1251 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1252 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1253 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1254 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1255
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1256 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1257 * Put string '*text' on the screen at position 'row' and 'col', with
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1258 * attributes 'attr', and update ScreenLines[] and ScreenAttrs[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1259 * Note: only outputs within one row, message is truncated at screen boundary!
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1260 * Note: if ScreenLines[], row and/or col is invalid, nothing is done.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1261 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1262 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1263 screen_puts(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1264 char_u *text,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1265 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1266 int col,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1267 int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1268 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1269 screen_puts_len(text, -1, row, col, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1270 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1271
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1272 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1273 * Like screen_puts(), but output "text[len]". When "len" is -1 output up to
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1274 * a NUL.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1275 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1276 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1277 screen_puts_len(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1278 char_u *text,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1279 int textlen,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1280 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1281 int col,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1282 int attr_arg)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1283 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1284 int attr = attr_arg;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1285 unsigned off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1286 char_u *ptr = text;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1287 int len = textlen;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1288 int c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1289 unsigned max_off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1290 int mbyte_blen = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1291 int mbyte_cells = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1292 int u8c = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1293 int u8cc[MAX_MCO];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1294 int clear_next_cell = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1295 #ifdef FEAT_ARABIC
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1296 int prev_c = 0; // previous Arabic character
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1297 int pc, nc, nc1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1298 int pcc[MAX_MCO];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1299 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1300 int force_redraw_this;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1301 int force_redraw_next = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1302 int need_redraw;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1303
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1304 // Safety check. The check for negative row and column is to fix issue
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1305 // #4102. TODO: find out why row/col could be negative.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1306 if (ScreenLines == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1307 || row >= screen_Rows || row < 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1308 || col >= screen_Columns || col < 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1309 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1310 off = LineOffset[row] + col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1311
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1312 // When drawing over the right half of a double-wide char clear out the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1313 // left half. Only needed in a terminal.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1314 if (has_mbyte && col > 0 && col < screen_Columns
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1315 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1316 && !gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1317 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1318 && mb_fix_col(col, row) != col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1319 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1320 if (!skip_for_popup(row, col - 1))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1321 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1322 ScreenLines[off - 1] = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1323 ScreenAttrs[off - 1] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1324 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1325 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1326 ScreenLinesUC[off - 1] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1327 ScreenLinesC[0][off - 1] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1328 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1329 // redraw the previous cell, make it empty
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1330 screen_char(off - 1, row, col - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1331 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1332 // force the cell at "col" to be redrawn
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1333 force_redraw_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1334 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1335
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1336 max_off = LineOffset[row] + screen_Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1337 while (col < screen_Columns
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1338 && (len < 0 || (int)(ptr - text) < len)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1339 && *ptr != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1340 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1341 c = *ptr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1342 // check if this is the first byte of a multibyte
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1343 if (has_mbyte)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1344 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1345 mbyte_blen = enc_utf8 && len > 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1346 ? utfc_ptr2len_len(ptr, (int)((text + len) - ptr))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1347 : (*mb_ptr2len)(ptr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1348 if (enc_dbcs == DBCS_JPNU && c == 0x8e)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1349 mbyte_cells = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1350 else if (enc_dbcs != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1351 mbyte_cells = mbyte_blen;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1352 else // enc_utf8
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1353 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1354 u8c = len >= 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1355 ? utfc_ptr2char_len(ptr, u8cc, (int)((text + len) - ptr))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1356 : utfc_ptr2char(ptr, u8cc);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1357 mbyte_cells = utf_char2cells(u8c);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1358 #ifdef FEAT_ARABIC
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1359 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1360 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1361 // Do Arabic shaping.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1362 if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1363 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1364 // Past end of string to be displayed.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1365 nc = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1366 nc1 = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1367 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1368 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1369 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1370 nc = len >= 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1371 ? utfc_ptr2char_len(ptr + mbyte_blen, pcc,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1372 (int)((text + len) - ptr - mbyte_blen))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1373 : utfc_ptr2char(ptr + mbyte_blen, pcc);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1374 nc1 = pcc[0];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1375 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1376 pc = prev_c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1377 prev_c = u8c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1378 u8c = arabic_shape(u8c, &c, &u8cc[0], nc, nc1, pc);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1379 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1380 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1381 prev_c = u8c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1382 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1383 if (col + mbyte_cells > screen_Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1384 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1385 // Only 1 cell left, but character requires 2 cells:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1386 // display a '>' in the last column to avoid wrapping.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1387 c = '>';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1388 mbyte_cells = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1389 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1390 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1391 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1392
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1393 force_redraw_this = force_redraw_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1394 force_redraw_next = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1395
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1396 need_redraw = ScreenLines[off] != c
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1397 || (mbyte_cells == 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1398 && ScreenLines[off + 1] != (enc_dbcs ? ptr[1] : 0))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1399 || (enc_dbcs == DBCS_JPNU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1400 && c == 0x8e
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1401 && ScreenLines2[off] != ptr[1])
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1402 || (enc_utf8
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1403 && (ScreenLinesUC[off] !=
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1404 (u8char_T)(c < 0x80 && u8cc[0] == 0 ? 0 : u8c)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1405 || (ScreenLinesUC[off] != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1406 && screen_comp_differs(off, u8cc))))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1407 || ScreenAttrs[off] != attr
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1408 || exmode_active;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1409
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1410 if ((need_redraw || force_redraw_this) && !skip_for_popup(row, col))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1411 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1412 #if defined(FEAT_GUI) || defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1413 // The bold trick makes a single row of pixels appear in the next
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1414 // character. When a bold character is removed, the next
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1415 // character should be redrawn too. This happens for our own GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1416 // and for some xterms.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1417 if (need_redraw && ScreenLines[off] != ' ' && (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1418 # ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1419 gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1420 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1421 # if defined(FEAT_GUI) && defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1422 ||
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1423 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1424 # ifdef UNIX
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1425 term_is_xterm
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1426 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1427 ))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1428 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1429 int n = ScreenAttrs[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1430
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1431 if (n > HL_ALL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1432 n = syn_attr2attr(n);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1433 if (n & HL_BOLD)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1434 force_redraw_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1435 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1436 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1437 // When at the end of the text and overwriting a two-cell
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1438 // character with a one-cell character, need to clear the next
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1439 // cell. Also when overwriting the left half of a two-cell char
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1440 // with the right half of a two-cell char. Do this only once
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1441 // (mb_off2cells() may return 2 on the right half).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1442 if (clear_next_cell)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1443 clear_next_cell = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1444 else if (has_mbyte
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1445 && (len < 0 ? ptr[mbyte_blen] == NUL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1446 : ptr + mbyte_blen >= text + len)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1447 && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1448 || (mbyte_cells == 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1449 && (*mb_off2cells)(off, max_off) == 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1450 && (*mb_off2cells)(off + 1, max_off) > 1)))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1451 clear_next_cell = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1452
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1453 // Make sure we never leave a second byte of a double-byte behind,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1454 // it confuses mb_off2cells().
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1455 if (enc_dbcs
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1456 && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1457 || (mbyte_cells == 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1458 && (*mb_off2cells)(off, max_off) == 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1459 && (*mb_off2cells)(off + 1, max_off) > 1)))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1460 ScreenLines[off + mbyte_blen] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1461 ScreenLines[off] = c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1462 ScreenAttrs[off] = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1463 ScreenCols[off] = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1464 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1465 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1466 if (c < 0x80 && u8cc[0] == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1467 ScreenLinesUC[off] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1468 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1469 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1470 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1471
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1472 ScreenLinesUC[off] = u8c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1473 for (i = 0; i < Screen_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1474 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1475 ScreenLinesC[i][off] = u8cc[i];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1476 if (u8cc[i] == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1477 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1478 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1479 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1480 if (mbyte_cells == 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1481 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1482 ScreenLines[off + 1] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1483 ScreenAttrs[off + 1] = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1484 ScreenCols[off + 1] = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1485 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1486 screen_char(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1487 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1488 else if (mbyte_cells == 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1489 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1490 ScreenLines[off + 1] = ptr[1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1491 ScreenAttrs[off + 1] = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1492 ScreenCols[off + 1] = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1493 screen_char_2(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1494 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1495 else if (enc_dbcs == DBCS_JPNU && c == 0x8e)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1496 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1497 ScreenLines2[off] = ptr[1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1498 screen_char(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1499 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1500 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1501 screen_char(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1502 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1503 if (has_mbyte)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1504 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1505 off += mbyte_cells;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1506 col += mbyte_cells;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1507 ptr += mbyte_blen;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1508 if (clear_next_cell)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1509 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1510 // This only happens at the end, display one space next.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1511 // Keep the attribute from before.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1512 ptr = (char_u *)" ";
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1513 len = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1514 attr = ScreenAttrs[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1515 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1516 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1517 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1518 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1519 ++off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1520 ++col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1521 ++ptr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1522 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1523 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1524
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1525 // If we detected the next character needs to be redrawn, but the text
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1526 // doesn't extend up to there, update the character here.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1527 if (force_redraw_next && col < screen_Columns && !skip_for_popup(row, col))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1528 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1529 if (enc_dbcs != 0 && dbcs_off2cells(off, max_off) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1530 screen_char_2(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1531 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1532 screen_char(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1533 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1534 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1535
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1536 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1537 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1538 * Prepare for 'hlsearch' highlighting.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1539 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1540 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1541 start_search_hl(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1542 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1543 if (!p_hls || no_hlsearch)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1544 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1545
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1546 end_search_hl(); // just in case it wasn't called before
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1547 last_pat_prog(&screen_search_hl.rm);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1548 screen_search_hl.attr = HL_ATTR(HLF_L);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1549 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1550
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1551 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1552 * Clean up for 'hlsearch' highlighting.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1553 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1554 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1555 end_search_hl(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1556 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1557 if (screen_search_hl.rm.regprog == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1558 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1559
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1560 vim_regfree(screen_search_hl.rm.regprog);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1561 screen_search_hl.rm.regprog = NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1562 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1563 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1564
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1565 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1566 screen_start_highlight(int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1567 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1568 attrentry_T *aep = NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1569
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1570 screen_attr = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1571 if (!full_screen
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1572 #ifdef MSWIN
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1573 || !termcap_active
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1574 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1575 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1576 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1577
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1578 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1579 if (gui.in_use)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1580 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1581 char buf[20];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1582
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1583 // The GUI handles this internally.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1584 sprintf(buf, "\033|%dh", attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1585 OUT_STR(buf);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1586 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1587 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1588 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1589
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1590 if (attr > HL_ALL) // special HL attr.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1591 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1592 if (IS_CTERM)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1593 aep = syn_cterm_attr2entry(attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1594 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1595 aep = syn_term_attr2entry(attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1596 if (aep == NULL) // did ":syntax clear"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1597 attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1598 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1599 attr = aep->ae_attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1600 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1601 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1602 if (use_vtp())
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1603 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1604 guicolor_T defguifg, defguibg;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1605 int defctermfg, defctermbg;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1606
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1607 // If FG and BG are unset, the color is undefined when
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1608 // BOLD+INVERSE. Use Normal as the default value.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1609 get_default_console_color(&defctermfg, &defctermbg, &defguifg,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1610 &defguibg);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1611
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1612 if (p_tgc)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1613 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1614 if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.fg_rgb))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1615 term_fg_rgb_color(defguifg);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1616 if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.bg_rgb))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1617 term_bg_rgb_color(defguibg);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1618 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1619 else if (t_colors >= 256)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1620 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1621 if (aep == NULL || aep->ae_u.cterm.fg_color == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1622 term_fg_color(defctermfg);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1623 if (aep == NULL || aep->ae_u.cterm.bg_color == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1624 term_bg_color(defctermbg);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1625 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1626 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1627 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1628 if ((attr & HL_BOLD) && *T_MD != NUL) // bold
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1629 out_str(T_MD);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1630 else if (aep != NULL && cterm_normal_fg_bold && (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1631 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1632 p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1633 ? aep->ae_u.cterm.fg_rgb != INVALCOLOR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1634 :
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1635 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1636 t_colors > 1 && aep->ae_u.cterm.fg_color))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1637 // If the Normal FG color has BOLD attribute and the new HL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1638 // has a FG color defined, clear BOLD.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1639 out_str(T_ME);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1640 if ((attr & HL_STANDOUT) && *T_SO != NUL) // standout
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1641 out_str(T_SO);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1642 if ((attr & HL_UNDERCURL) && *T_UCS != NUL) // undercurl
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1643 out_str(T_UCS);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1644 if ((attr & HL_UNDERDOUBLE) && *T_USS != NUL) // double underline
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1645 out_str(T_USS);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1646 if ((attr & HL_UNDERDOTTED) && *T_DS != NUL) // dotted underline
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1647 out_str(T_DS);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1648 if ((attr & HL_UNDERDASHED) && *T_CDS != NUL) // dashed underline
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1649 out_str(T_CDS);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1650 if (((attr & HL_UNDERLINE) // underline or undercurl, etc.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1651 || ((attr & HL_UNDERCURL) && *T_UCS == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1652 || ((attr & HL_UNDERDOUBLE) && *T_USS == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1653 || ((attr & HL_UNDERDOTTED) && *T_DS == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1654 || ((attr & HL_UNDERDASHED) && *T_CDS == NUL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1655 && *T_US != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1656 out_str(T_US);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1657 if ((attr & HL_ITALIC) && *T_CZH != NUL) // italic
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1658 out_str(T_CZH);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1659 if ((attr & HL_INVERSE) && *T_MR != NUL) // inverse (reverse)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1660 out_str(T_MR);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1661 if ((attr & HL_STRIKETHROUGH) && *T_STS != NUL) // strike
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1662 out_str(T_STS);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1663
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1664 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1665 * Output the color or start string after bold etc., in case the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1666 * bold etc. override the color setting.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1667 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1668 if (aep != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1669 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1670 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1671 // When 'termguicolors' is set but fg or bg is unset,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1672 // fall back to the cterm colors. This helps for SpellBad,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1673 // where the GUI uses a red undercurl.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1674 if (p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1675 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1676 if (aep->ae_u.cterm.fg_rgb != INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1677 term_fg_rgb_color(aep->ae_u.cterm.fg_rgb);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1678 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1679 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1680 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1681 if (t_colors > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1682 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1683 if (aep->ae_u.cterm.fg_color)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1684 term_fg_color(aep->ae_u.cterm.fg_color - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1685 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1686 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1687 if (p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1688 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1689 if (aep->ae_u.cterm.bg_rgb != INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1690 term_bg_rgb_color(aep->ae_u.cterm.bg_rgb);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1691 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1692 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1693 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1694 if (t_colors > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1695 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1696 if (aep->ae_u.cterm.bg_color)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1697 term_bg_color(aep->ae_u.cterm.bg_color - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1698 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1699 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1700 if (p_tgc && aep->ae_u.cterm.ul_rgb != CTERMCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1701 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1702 if (aep->ae_u.cterm.ul_rgb != INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1703 term_ul_rgb_color(aep->ae_u.cterm.ul_rgb);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1704 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1705 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1706 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1707 if (t_colors > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1708 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1709 if (aep->ae_u.cterm.ul_color)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1710 term_ul_color(aep->ae_u.cterm.ul_color - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1711 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1712
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1713 if (!IS_CTERM)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1714 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1715 if (aep->ae_u.term.start != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1716 out_str(aep->ae_u.term.start);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1717 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1718 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1719 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1720
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1721 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1722 screen_stop_highlight(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1723 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1724 int do_ME = FALSE; // output T_ME code
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1725 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1726 int do_ME_fg = FALSE, do_ME_bg = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1727 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1728
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1729 if (screen_attr != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1730 #ifdef MSWIN
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1731 && termcap_active
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1732 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1733 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1734 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1735 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1736 if (gui.in_use)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1737 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1738 char buf[20];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1739
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1740 // use internal GUI code
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1741 sprintf(buf, "\033|%dH", screen_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1742 OUT_STR(buf);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1743 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1744 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1745 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1746 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1747 int is_under;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1748
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1749 if (screen_attr > HL_ALL) // special HL attr.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1750 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1751 attrentry_T *aep;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1752
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1753 if (IS_CTERM)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1754 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1755 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1756 * Assume that t_me restores the original colors!
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1757 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1758 aep = syn_cterm_attr2entry(screen_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1759 if (aep != NULL && ((
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1760 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1761 p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1762 ? aep->ae_u.cterm.fg_rgb != INVALCOLOR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1763 # ifdef FEAT_VTP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1764 ? !(do_ME_fg = TRUE) : (do_ME_fg = FALSE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1765 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1766 :
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1767 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1768 aep->ae_u.cterm.fg_color) || (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1769 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1770 p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1771 ? aep->ae_u.cterm.bg_rgb != INVALCOLOR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1772 # ifdef FEAT_VTP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1773 ? !(do_ME_bg = TRUE) : (do_ME_bg = FALSE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1774 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1775 :
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1776 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1777 aep->ae_u.cterm.bg_color)))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1778 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1779 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1780 if (use_vtp())
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1781 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1782 if (do_ME_fg && do_ME_bg)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1783 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1784
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1785 // FG and BG cannot be separated in T_ME, which is not
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1786 // efficient.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1787 if (!do_ME && do_ME_fg)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1788 out_str((char_u *)"\033|39m"); // restore FG
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1789 if (!do_ME && do_ME_bg)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1790 out_str((char_u *)"\033|49m"); // restore BG
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1791 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1792 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1793 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1794 // Process FG and BG at once.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1795 if (!do_ME)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1796 do_ME = do_ME_fg | do_ME_bg;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1797 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1798 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1799 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1800 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1801 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1802 aep = syn_term_attr2entry(screen_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1803 if (aep != NULL && aep->ae_u.term.stop != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1804 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1805 if (STRCMP(aep->ae_u.term.stop, T_ME) == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1806 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1807 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1808 out_str(aep->ae_u.term.stop);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1809 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1810 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1811 if (aep == NULL) // did ":syntax clear"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1812 screen_attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1813 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1814 screen_attr = aep->ae_attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1815 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1816
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1817 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1818 * Often all ending-codes are equal to T_ME. Avoid outputting the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1819 * same sequence several times.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1820 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1821 if (screen_attr & HL_STANDOUT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1822 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1823 if (STRCMP(T_SE, T_ME) == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1824 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1825 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1826 out_str(T_SE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1827 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1828 is_under = (screen_attr & (HL_UNDERCURL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1829 | HL_UNDERDOUBLE | HL_UNDERDOTTED | HL_UNDERDASHED));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1830 if (is_under && *T_UCE != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1831 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1832 if (STRCMP(T_UCE, T_ME) == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1833 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1834 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1835 out_str(T_UCE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1836 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1837 if ((screen_attr & HL_UNDERLINE) || (is_under && *T_UCE == NUL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1838 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1839 if (STRCMP(T_UE, T_ME) == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1840 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1841 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1842 out_str(T_UE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1843 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1844 if (screen_attr & HL_ITALIC)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1845 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1846 if (STRCMP(T_CZR, T_ME) == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1847 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1848 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1849 out_str(T_CZR);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1850 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1851 if (screen_attr & HL_STRIKETHROUGH)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1852 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1853 if (STRCMP(T_STE, T_ME) == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1854 do_ME = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1855 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1856 out_str(T_STE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1857 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1858 if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE)))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1859 out_str(T_ME);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1860
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1861 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1862 if (p_tgc)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1863 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1864 if (cterm_normal_fg_gui_color != INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1865 term_fg_rgb_color(cterm_normal_fg_gui_color);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1866 if (cterm_normal_bg_gui_color != INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1867 term_bg_rgb_color(cterm_normal_bg_gui_color);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1868 if (cterm_normal_ul_gui_color != INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1869 term_ul_rgb_color(cterm_normal_ul_gui_color);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1870 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1871 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1872 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1873 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1874 if (t_colors > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1875 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1876 // set Normal cterm colors
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1877 if (cterm_normal_fg_color != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1878 term_fg_color(cterm_normal_fg_color - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1879 if (cterm_normal_bg_color != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1880 term_bg_color(cterm_normal_bg_color - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1881 if (cterm_normal_ul_color != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1882 term_ul_color(cterm_normal_ul_color - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1883 if (cterm_normal_fg_bold)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1884 out_str(T_MD);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1885 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1886 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1887 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1888 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1889 screen_attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1890 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1891
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1892 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1893 * Reset the colors for a cterm. Used when leaving Vim.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1894 * The machine specific code may override this again.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1895 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1896 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1897 reset_cterm_colors(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1898 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1899 if (!IS_CTERM)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1900 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1901
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1902 // set Normal cterm colors
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1903 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1904 if (p_tgc ? (cterm_normal_fg_gui_color != INVALCOLOR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1905 || cterm_normal_bg_gui_color != INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1906 : (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1907 #else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1908 if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1909 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1910 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1911 out_str(T_OP);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1912 screen_attr = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1913 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1914 if (cterm_normal_fg_bold)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1915 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1916 out_str(T_ME);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1917 screen_attr = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1918 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1919 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1920
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1921 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1922 * Put character ScreenLines["off"] on the screen at position "row" and "col",
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1923 * using the attributes from ScreenAttrs["off"].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1924 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1925 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1926 screen_char(unsigned off, int row, int col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1927 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1928 int attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1929
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1930 // Check for illegal values, just in case (could happen just after
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1931 // resizing).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1932 if (row >= screen_Rows || col >= screen_Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1933 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1934
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1935 // Outputting a character in the last cell on the screen may scroll the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1936 // screen up. Only do it when the "xn" termcap property is set, otherwise
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1937 // mark the character invalid (update it when scrolled up).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1938 if (*T_XN == NUL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1939 && row == screen_Rows - 1 && col == screen_Columns - 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1940 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1941 // account for first command-line character in rightleft mode
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1942 && !cmdmsg_rl
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1943 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1944 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1945 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1946 ScreenAttrs[off] = (sattr_T)-1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1947 ScreenCols[off] = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1948 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1949 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1950
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1951 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1952 * Stop highlighting first, so it's easier to move the cursor.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1953 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1954 if (screen_char_attr != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1955 attr = screen_char_attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1956 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1957 attr = ScreenAttrs[off];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1958 if (screen_attr != attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1959 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1960
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1961 windgoto(row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1962
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1963 if (screen_attr != attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1964 screen_start_highlight(attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1965
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1966 if (enc_utf8 && ScreenLinesUC[off] != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1967 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1968 char_u buf[MB_MAXBYTES + 1];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1969
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1970 if (utf_ambiguous_width(ScreenLinesUC[off]))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1971 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1972 if (*p_ambw == 'd'
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1973 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1974 && !gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1975 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1976 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1977 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1978 // Clear the two screen cells. If the character is actually
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1979 // single width it won't change the second cell.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1980 out_str((char_u *)" ");
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1981 term_windgoto(row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1982 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1983 // not sure where the cursor is after drawing the ambiguous width
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1984 // character
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1985 screen_cur_col = 9999;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1986 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1987 else if (utf_char2cells(ScreenLinesUC[off]) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1988 ++screen_cur_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1989
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1990 // Convert the UTF-8 character to bytes and write it.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1991 buf[utfc_char2bytes(off, buf)] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1992 out_str(buf);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1993 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1994 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1995 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1996 out_flush_check();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1997 out_char(ScreenLines[off]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1998 // double-byte character in single-width cell
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
1999 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2000 out_char(ScreenLines2[off]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2001 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2002
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2003 screen_cur_col++;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2004 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2005
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2006 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2007 * Used for enc_dbcs only: Put one double-wide character at ScreenLines["off"]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2008 * on the screen at position 'row' and 'col'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2009 * The attributes of the first byte is used for all. This is required to
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2010 * output the two bytes of a double-byte character with nothing in between.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2011 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2012 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2013 screen_char_2(unsigned off, int row, int col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2014 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2015 // Check for illegal values (could be wrong when screen was resized).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2016 if (off + 1 >= (unsigned)(screen_Rows * screen_Columns))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2017 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2018
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2019 // Outputting the last character on the screen may scroll the screen up.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2020 // Don't to it! Mark the character invalid (update it when scrolled up)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2021 if (row == screen_Rows - 1 && col >= screen_Columns - 2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2022 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2023 ScreenAttrs[off] = (sattr_T)-1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2024 ScreenCols[off] = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2025 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2026 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2027
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2028 // Output the first byte normally (positions the cursor), then write the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2029 // second byte directly.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2030 screen_char(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2031 out_char(ScreenLines[off + 1]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2032 ++screen_cur_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2033 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2034
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2035 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2036 * Draw a rectangle of the screen, inverted when "invert" is TRUE.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2037 * This uses the contents of ScreenLines[] and doesn't change it.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2038 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2039 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2040 screen_draw_rectangle(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2041 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2042 int col,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2043 int height,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2044 int width,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2045 int invert)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2046 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2047 int r, c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2048 int off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2049 int max_off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2050
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2051 // Can't use ScreenLines unless initialized
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2052 if (ScreenLines == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2053 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2054
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2055 if (invert)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2056 screen_char_attr = HL_INVERSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2057 for (r = row; r < row + height; ++r)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2058 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2059 off = LineOffset[r];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2060 max_off = off + screen_Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2061 for (c = col; c < col + width; ++c)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2062 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2063 if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2064 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2065 if (!skip_for_popup(r, c))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2066 screen_char_2(off + c, r, c);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2067 ++c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2068 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2069 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2070 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2071 if (!skip_for_popup(r, c))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2072 screen_char(off + c, r, c);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2073 if (utf_off2cells(off + c, max_off) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2074 ++c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2075 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2076 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2077 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2078 screen_char_attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2079 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2080
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2081 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2082 * Redraw the characters for a vertically split window.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2083 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2084 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2085 redraw_block(int row, int end, win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2086 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2087 int col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2088 int width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2089
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2090 # ifdef FEAT_CLIPBOARD
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2091 clip_may_clear_selection(row, end - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2092 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2093
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2094 if (wp == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2095 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2096 col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2097 width = Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2098 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2099 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2100 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2101 col = wp->w_wincol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2102 width = wp->w_width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2103 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2104 screen_draw_rectangle(row, col, end - row, width, FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2105 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2106
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2107 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2108 space_to_screenline(int off, int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2109 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2110 ScreenLines[off] = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2111 ScreenAttrs[off] = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2112 ScreenCols[off] = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2113 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2114 ScreenLinesUC[off] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2115 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2116
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2117 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2118 * Fill the screen from "start_row" to "end_row" (exclusive), from "start_col"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2119 * to "end_col" (exclusive) with character "c1" in first column followed by
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2120 * "c2" in the other columns. Use attributes "attr".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2121 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2122 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2123 screen_fill(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2124 int start_row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2125 int end_row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2126 int start_col,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2127 int end_col,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2128 int c1,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2129 int c2,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2130 int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2131 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2132 int row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2133 int col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2134 int off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2135 int end_off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2136 int did_delete;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2137 int c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2138 int norm_term;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2139 #if defined(FEAT_GUI) || defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2140 int force_next = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2141 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2142
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2143 if (end_row > screen_Rows) // safety check
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2144 end_row = screen_Rows;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2145 if (end_col > screen_Columns) // safety check
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2146 end_col = screen_Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2147 if (ScreenLines == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2148 || start_row >= end_row
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2149 || start_col >= end_col) // nothing to do
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2150 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2151
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2152 // it's a "normal" terminal when not in a GUI or cterm
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2153 norm_term = (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2154 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2155 !gui.in_use &&
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2156 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2157 !IS_CTERM);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2158 for (row = start_row; row < end_row; ++row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2159 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2160 if (has_mbyte
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2161 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2162 && !gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2163 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2164 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2165 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2166 // When drawing over the right half of a double-wide char clear
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2167 // out the left half. When drawing over the left half of a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2168 // double wide-char clear out the right half. Only needed in a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2169 // terminal.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2170 if (start_col > 0 && mb_fix_col(start_col, row) != start_col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2171 screen_puts_len((char_u *)" ", 1, row, start_col - 1, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2172 if (end_col < screen_Columns && mb_fix_col(end_col, row) != end_col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2173 screen_puts_len((char_u *)" ", 1, row, end_col, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2174 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2175 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2176 * Try to use delete-line termcap code, when no attributes or in a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2177 * "normal" terminal, where a bold/italic space is just a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2178 * space.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2179 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2180 did_delete = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2181 if (c2 == ' '
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2182 && end_col == Columns
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2183 && can_clear(T_CE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2184 && (attr == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2185 || (norm_term
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2186 && attr <= HL_ALL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2187 && ((attr & ~(HL_BOLD | HL_ITALIC)) == 0))))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2188 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2189 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2190 * check if we really need to clear something
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2191 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2192 col = start_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2193 if (c1 != ' ') // don't clear first char
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2194 ++col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2195
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2196 off = LineOffset[row] + col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2197 end_off = LineOffset[row] + end_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2198
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2199 // skip blanks (used often, keep it fast!)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2200 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2201 while (off < end_off && ScreenLines[off] == ' '
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2202 && ScreenAttrs[off] == 0 && ScreenLinesUC[off] == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2203 ++off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2204 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2205 while (off < end_off && ScreenLines[off] == ' '
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2206 && ScreenAttrs[off] == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2207 ++off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2208 if (off < end_off) // something to be cleared
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2209 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2210 col = off - LineOffset[row];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2211 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2212 term_windgoto(row, col);// clear rest of this screen line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2213 out_str(T_CE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2214 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2215 col = end_col - col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2216 while (col--) // clear chars in ScreenLines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2217 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2218 space_to_screenline(off, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2219 ++off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2220 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2221 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2222 did_delete = TRUE; // the chars are cleared now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2223 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2224
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2225 off = LineOffset[row] + start_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2226 c = c1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2227 for (col = start_col; col < end_col; ++col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2228 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2229 if ((ScreenLines[off] != c
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2230 || (enc_utf8 && (int)ScreenLinesUC[off]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2231 != (c >= 0x80 ? c : 0))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2232 || ScreenAttrs[off] != attr
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2233 || must_redraw == UPD_CLEAR // screen clear pending
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2234 #if defined(FEAT_GUI) || defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2235 || force_next
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2236 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2237 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2238 // Skip if under a(nother) popup.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2239 && !skip_for_popup(row, col))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2240 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2241 #if defined(FEAT_GUI) || defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2242 // The bold trick may make a single row of pixels appear in
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2243 // the next character. When a bold character is removed, the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2244 // next character should be redrawn too. This happens for our
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2245 // own GUI and for some xterms.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2246 if (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2247 # ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2248 gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2249 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2250 # if defined(FEAT_GUI) && defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2251 ||
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2252 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2253 # ifdef UNIX
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2254 term_is_xterm
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2255 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2256 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2257 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2258 if (ScreenLines[off] != ' '
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2259 && (ScreenAttrs[off] > HL_ALL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2260 || ScreenAttrs[off] & HL_BOLD))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2261 force_next = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2262 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2263 force_next = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2264 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2265 #endif // FEAT_GUI || defined(UNIX)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2266 ScreenLines[off] = c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2267 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2268 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2269 if (c >= 0x80)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2270 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2271 ScreenLinesUC[off] = c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2272 ScreenLinesC[0][off] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2273 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2274 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2275 ScreenLinesUC[off] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2276 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2277 ScreenAttrs[off] = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2278 if (!did_delete || c != ' ')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2279 screen_char(off, row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2280 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2281 ScreenCols[off] = -1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2282 ++off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2283 if (col == start_col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2284 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2285 if (did_delete)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2286 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2287 c = c2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2288 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2289 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2290 if (end_col == Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2291 LineWraps[row] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2292 if (row == Rows - 1) // overwritten the command line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2293 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2294 redraw_cmdline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2295 if (start_col == 0 && end_col == Columns
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2296 && c1 == ' ' && c2 == ' ' && attr == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2297 clear_cmdline = FALSE; // command line has been cleared
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2298 if (start_col == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2299 mode_displayed = FALSE; // mode cleared or overwritten
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2300 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2301 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2302 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2303
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2304 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2305 * Check if there should be a delay. Used before clearing or redrawing the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2306 * screen or the command line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2307 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2308 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2309 check_for_delay(int check_msg_scroll)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2310 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2311 if ((emsg_on_display || (check_msg_scroll && msg_scroll))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2312 && !did_wait_return
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2313 && emsg_silent == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2314 && !in_assert_fails)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2315 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2316 out_flush();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2317 ui_delay(1006L, TRUE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2318 emsg_on_display = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2319 if (check_msg_scroll)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2320 msg_scroll = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2321 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2322 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2323
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2324 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2325 * Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2326 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2327 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2328 clear_TabPageIdxs(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2329 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2330 int scol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2331
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2332 for (scol = 0; scol < Columns; ++scol)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2333 TabPageIdxs[scol] = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2334 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2335
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2336 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2337 * screen_valid - allocate screen buffers if size changed
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2338 * If "doclear" is TRUE: clear screen if it has been resized.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2339 * Returns TRUE if there is a valid screen to write to.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2340 * Returns FALSE when starting up and screen not initialized yet.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2341 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2342 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2343 screen_valid(int doclear)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2344 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2345 screenalloc(doclear); // allocate screen buffers if size changed
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2346 return (ScreenLines != NULL);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2347 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2348
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2349 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2350 * Resize the shell to Rows and Columns.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2351 * Allocate ScreenLines[] and associated items.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2352 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2353 * There may be some time between setting Rows and Columns and (re)allocating
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2354 * ScreenLines[]. This happens when starting up and when (manually) changing
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2355 * the shell size. Always use screen_Rows and screen_Columns to access items
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2356 * in ScreenLines[]. Use Rows and Columns for positioning text etc. where the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2357 * final size of the shell is needed.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2358 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2359 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2360 screenalloc(int doclear)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2361 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2362 int new_row, old_row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2363 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2364 int old_Rows;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2365 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2366 win_T *wp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2367 int outofmem = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2368 int len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2369 schar_T *new_ScreenLines;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2370 u8char_T *new_ScreenLinesUC = NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2371 u8char_T *new_ScreenLinesC[MAX_MCO];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2372 schar_T *new_ScreenLines2 = NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2373 sattr_T *new_ScreenAttrs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2374 colnr_T *new_ScreenCols;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2375 unsigned *new_LineOffset;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2376 char_u *new_LineWraps;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2377 short *new_TabPageIdxs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2378 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2379 short *new_popup_mask;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2380 short *new_popup_mask_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2381 char *new_popup_transparent;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2382 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2383 tabpage_T *tp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2384 static int entered = FALSE; // avoid recursiveness
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2385 static int done_outofmem_msg = FALSE; // did outofmem message
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2386 int retry_count = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2387 int found_null;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2388
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2389 retry:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2390 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2391 * Allocation of the screen buffers is done only when the size changes and
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2392 * when Rows and Columns have been set and we have started doing full
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2393 * screen stuff.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2394 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2395 if ((ScreenLines != NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2396 && Rows == screen_Rows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2397 && Columns == screen_Columns
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2398 && enc_utf8 == (ScreenLinesUC != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2399 && (enc_dbcs == DBCS_JPNU) == (ScreenLines2 != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2400 && p_mco == Screen_mco)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2401 || Rows == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2402 || Columns == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2403 || (!full_screen && ScreenLines == NULL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2404 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2405
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2406 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2407 * It's possible that we produce an out-of-memory message below, which
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2408 * will cause this function to be called again. To break the loop, just
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2409 * return here.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2410 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2411 if (entered)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2412 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2413 entered = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2414
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2415 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2416 * Note that the window sizes are updated before reallocating the arrays,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2417 * thus we must not redraw here!
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2418 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2419 ++RedrawingDisabled;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2420
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2421 win_new_shellsize(); // fit the windows in the new sized shell
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2422
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2423 #ifdef FEAT_GUI_HAIKU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2424 vim_lock_screen(); // be safe, put it here
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2425 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2426
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2427 comp_col(); // recompute columns for shown command and ruler
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2428
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2429 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2430 * We're changing the size of the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2431 * - Allocate new arrays for ScreenLines and ScreenAttrs.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2432 * - Move lines from the old arrays into the new arrays, clear extra
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2433 * lines (unless the screen is going to be cleared).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2434 * - Free the old arrays.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2435 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2436 * If anything fails, make ScreenLines NULL, so we don't do anything!
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2437 * Continuing with the old ScreenLines may result in a crash, because the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2438 * size is wrong.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2439 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2440 FOR_ALL_TAB_WINDOWS(tp, wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2441 win_free_lsize(wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2442 for (int i = 0; i < AUCMD_WIN_COUNT; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2443 if (aucmd_win[i].auc_win != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2444 win_free_lsize(aucmd_win[i].auc_win);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2445 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2446 // global popup windows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2447 FOR_ALL_POPUPWINS(wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2448 win_free_lsize(wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2449 // tab-local popup windows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2450 FOR_ALL_TABPAGES(tp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2451 FOR_ALL_POPUPWINS_IN_TAB(tp, wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2452 win_free_lsize(wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2453 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2454
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2455 new_ScreenLines = LALLOC_MULT(schar_T, (Rows + 1) * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2456 vim_memset(new_ScreenLinesC, 0, sizeof(u8char_T *) * MAX_MCO);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2457 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2458 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2459 new_ScreenLinesUC = LALLOC_MULT(u8char_T, (Rows + 1) * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2460 for (int i = 0; i < p_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2461 new_ScreenLinesC[i] = LALLOC_CLEAR_MULT(u8char_T,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2462 (Rows + 1) * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2463 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2464 if (enc_dbcs == DBCS_JPNU)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2465 new_ScreenLines2 = LALLOC_MULT(schar_T, (Rows + 1) * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2466 new_ScreenAttrs = LALLOC_MULT(sattr_T, (Rows + 1) * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2467 // Clear ScreenCols to avoid a warning for uninitialized memory in
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2468 // jump_to_mouse().
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2469 new_ScreenCols = LALLOC_CLEAR_MULT(colnr_T, (Rows + 1) * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2470 new_LineOffset = LALLOC_MULT(unsigned, Rows);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2471 new_LineWraps = LALLOC_MULT(char_u, Rows);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2472 new_TabPageIdxs = LALLOC_MULT(short, Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2473 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2474 new_popup_mask = LALLOC_MULT(short, Rows * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2475 new_popup_mask_next = LALLOC_MULT(short, Rows * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2476 new_popup_transparent = LALLOC_MULT(char, Rows * Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2477 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2478
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2479 FOR_ALL_TAB_WINDOWS(tp, wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2480 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2481 if (win_alloc_lines(wp) == FAIL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2482 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2483 outofmem = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2484 goto give_up;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2485 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2486 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2487 for (int i = 0; i < AUCMD_WIN_COUNT; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2488 if (aucmd_win[i].auc_win != NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2489 && aucmd_win[i].auc_win->w_lines == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2490 && win_alloc_lines(aucmd_win[i].auc_win) == FAIL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2491 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2492 outofmem = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2493 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2494 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2495 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2496 // global popup windows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2497 FOR_ALL_POPUPWINS(wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2498 if (win_alloc_lines(wp) == FAIL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2499 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2500 outofmem = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2501 goto give_up;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2502 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2503 // tab-local popup windows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2504 FOR_ALL_TABPAGES(tp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2505 FOR_ALL_POPUPWINS_IN_TAB(tp, wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2506 if (win_alloc_lines(wp) == FAIL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2507 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2508 outofmem = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2509 goto give_up;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2510 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2511 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2512
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2513 give_up:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2514 found_null = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2515 for (int i = 0; i < p_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2516 if (new_ScreenLinesC[i] == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2517 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2518 found_null = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2519 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2520 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2521 if (new_ScreenLines == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2522 || (enc_utf8 && (new_ScreenLinesUC == NULL || found_null))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2523 || (enc_dbcs == DBCS_JPNU && new_ScreenLines2 == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2524 || new_ScreenAttrs == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2525 || new_ScreenCols == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2526 || new_LineOffset == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2527 || new_LineWraps == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2528 || new_TabPageIdxs == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2529 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2530 || new_popup_mask == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2531 || new_popup_mask_next == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2532 || new_popup_transparent == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2533 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2534 || outofmem)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2535 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2536 if (ScreenLines != NULL || !done_outofmem_msg)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2537 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2538 // guess the size
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2539 do_outofmem_msg((long_u)((Rows + 1) * Columns));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2540
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2541 // Remember we did this to avoid getting outofmem messages over
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2542 // and over again.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2543 done_outofmem_msg = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2544 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2545 VIM_CLEAR(new_ScreenLines);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2546 VIM_CLEAR(new_ScreenLinesUC);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2547 for (int i = 0; i < p_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2548 VIM_CLEAR(new_ScreenLinesC[i]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2549 VIM_CLEAR(new_ScreenLines2);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2550 VIM_CLEAR(new_ScreenAttrs);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2551 VIM_CLEAR(new_ScreenCols);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2552 VIM_CLEAR(new_LineOffset);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2553 VIM_CLEAR(new_LineWraps);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2554 VIM_CLEAR(new_TabPageIdxs);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2555 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2556 VIM_CLEAR(new_popup_mask);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2557 VIM_CLEAR(new_popup_mask_next);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2558 VIM_CLEAR(new_popup_transparent);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2559 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2560 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2561 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2562 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2563 done_outofmem_msg = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2564
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2565 for (new_row = 0; new_row < Rows; ++new_row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2566 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2567 new_LineOffset[new_row] = new_row * Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2568 new_LineWraps[new_row] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2569
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2570 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2571 * If the screen is not going to be cleared, copy as much as
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2572 * possible from the old screen to the new one and clear the rest
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2573 * (used when resizing the window at the "--more--" prompt or when
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2574 * executing an external command, for the GUI).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2575 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2576 if (!doclear)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2577 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2578 (void)vim_memset(new_ScreenLines + new_row * Columns,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2579 ' ', (size_t)Columns * sizeof(schar_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2580 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2581 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2582 (void)vim_memset(new_ScreenLinesUC + new_row * Columns,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2583 0, (size_t)Columns * sizeof(u8char_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2584 for (int i = 0; i < p_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2585 (void)vim_memset(new_ScreenLinesC[i]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2586 + new_row * Columns,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2587 0, (size_t)Columns * sizeof(u8char_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2588 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2589 if (enc_dbcs == DBCS_JPNU)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2590 (void)vim_memset(new_ScreenLines2 + new_row * Columns,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2591 0, (size_t)Columns * sizeof(schar_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2592 (void)vim_memset(new_ScreenAttrs + new_row * Columns,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2593 0, (size_t)Columns * sizeof(sattr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2594 (void)vim_memset(new_ScreenCols + new_row * Columns,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2595 0, (size_t)Columns * sizeof(colnr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2596 old_row = new_row + (screen_Rows - Rows);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2597 if (old_row >= 0 && ScreenLines != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2598 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2599 if (screen_Columns < Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2600 len = screen_Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2601 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2602 len = Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2603 // When switching to utf-8 don't copy characters, they
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2604 // may be invalid now. Also when p_mco changes.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2605 if (!(enc_utf8 && ScreenLinesUC == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2606 && p_mco == Screen_mco)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2607 mch_memmove(new_ScreenLines + new_LineOffset[new_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2608 ScreenLines + LineOffset[old_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2609 (size_t)len * sizeof(schar_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2610 if (enc_utf8 && ScreenLinesUC != NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2611 && p_mco == Screen_mco)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2612 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2613 mch_memmove(new_ScreenLinesUC + new_LineOffset[new_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2614 ScreenLinesUC + LineOffset[old_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2615 (size_t)len * sizeof(u8char_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2616 for (int i = 0; i < p_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2617 mch_memmove(new_ScreenLinesC[i]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2618 + new_LineOffset[new_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2619 ScreenLinesC[i] + LineOffset[old_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2620 (size_t)len * sizeof(u8char_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2621 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2622 if (enc_dbcs == DBCS_JPNU && ScreenLines2 != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2623 mch_memmove(new_ScreenLines2 + new_LineOffset[new_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2624 ScreenLines2 + LineOffset[old_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2625 (size_t)len * sizeof(schar_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2626 mch_memmove(new_ScreenAttrs + new_LineOffset[new_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2627 ScreenAttrs + LineOffset[old_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2628 (size_t)len * sizeof(sattr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2629 mch_memmove(new_ScreenCols + new_LineOffset[new_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2630 ScreenAttrs + LineOffset[old_row],
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2631 (size_t)len * sizeof(colnr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2632 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2633 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2634 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2635 // Use the last line of the screen for the current line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2636 current_ScreenLine = new_ScreenLines + Rows * Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2637
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2638 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2639 vim_memset(new_popup_mask, 0, Rows * Columns * sizeof(short));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2640 vim_memset(new_popup_transparent, 0, Rows * Columns * sizeof(char));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2641 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2642 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2643
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2644 free_screenlines();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2645
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2646 // NOTE: this may result in all pointers to become NULL.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2647 ScreenLines = new_ScreenLines;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2648 ScreenLinesUC = new_ScreenLinesUC;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2649 for (int i = 0; i < p_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2650 ScreenLinesC[i] = new_ScreenLinesC[i];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2651 Screen_mco = p_mco;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2652 ScreenLines2 = new_ScreenLines2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2653 ScreenAttrs = new_ScreenAttrs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2654 ScreenCols = new_ScreenCols;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2655 LineOffset = new_LineOffset;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2656 LineWraps = new_LineWraps;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2657 TabPageIdxs = new_TabPageIdxs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2658 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2659 popup_mask = new_popup_mask;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2660 popup_mask_next = new_popup_mask_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2661 popup_transparent = new_popup_transparent;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2662 popup_mask_refresh = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2663 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2664
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2665 // It's important that screen_Rows and screen_Columns reflect the actual
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2666 // size of ScreenLines[]. Set them before calling anything.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2667 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2668 old_Rows = screen_Rows;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2669 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2670 screen_Rows = Rows;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2671 screen_Columns = Columns;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2672
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2673 set_must_redraw(UPD_CLEAR); // need to clear the screen later
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2674 if (doclear)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2675 screenclear2(TRUE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2676 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2677 else if (gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2678 && !gui.starting
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2679 && ScreenLines != NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2680 && old_Rows != Rows)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2681 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2682 gui_redraw_block(0, 0, (int)Rows - 1, (int)Columns - 1, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2683
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2684 // Adjust the position of the cursor, for when executing an external
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2685 // command.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2686 if (msg_row >= Rows) // Rows got smaller
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2687 msg_row = Rows - 1; // put cursor at last row
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2688 else if (Rows > old_Rows) // Rows got bigger
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2689 msg_row += Rows - old_Rows; // put cursor in same place
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2690 if (msg_col >= Columns) // Columns got smaller
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2691 msg_col = Columns - 1; // put cursor at last column
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2692 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2693 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2694 clear_TabPageIdxs();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2695
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2696 #ifdef FEAT_GUI_HAIKU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2697 vim_unlock_screen();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2698 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2699
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2700 entered = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2701 if (RedrawingDisabled > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2702 --RedrawingDisabled;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2703
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2704 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2705 * Do not apply autocommands more than 3 times to avoid an endless loop
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2706 * in case applying autocommands always changes Rows or Columns.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2707 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2708 if (starting == 0 && ++retry_count <= 3)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2709 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2710 apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2711 // In rare cases, autocommands may have altered Rows or Columns,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2712 // jump back to check if we need to allocate the screen again.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2713 goto retry;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2714 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2715 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2716
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2717 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2718 free_screenlines(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2719 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2720 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2721
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2722 VIM_CLEAR(ScreenLinesUC);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2723 for (i = 0; i < Screen_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2724 VIM_CLEAR(ScreenLinesC[i]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2725 VIM_CLEAR(ScreenLines2);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2726 VIM_CLEAR(ScreenLines);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2727 VIM_CLEAR(ScreenAttrs);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2728 VIM_CLEAR(ScreenCols);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2729 VIM_CLEAR(LineOffset);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2730 VIM_CLEAR(LineWraps);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2731 VIM_CLEAR(TabPageIdxs);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2732 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2733 VIM_CLEAR(popup_mask);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2734 VIM_CLEAR(popup_mask_next);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2735 VIM_CLEAR(popup_transparent);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2736 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2737 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2738
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2739 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2740 * Clear the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2741 * May delay if there is something the user should read.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2742 * Allocated the screen for resizing if needed.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2743 * Returns TRUE when the screen was actually cleared, FALSE if all display
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2744 * cells were marked for updating.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2745 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2746 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2747 screenclear(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2748 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2749 check_for_delay(FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2750 screenalloc(FALSE); // allocate screen buffers if size changed
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2751 return screenclear2(TRUE); // clear the screen
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2752 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2753
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2754 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2755 * Do not clear the screen but mark everything for redraw.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2756 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2757 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2758 redraw_as_cleared(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2759 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2760 screenclear2(FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2761 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2762
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2763 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2764 screenclear2(int doclear)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2765 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2766 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2767 int did_clear = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2768
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2769 if (starting == NO_SCREEN || ScreenLines == NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2770 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2771 || (gui.in_use && gui.starting)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2772 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2773 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2774 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2775
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2776 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2777 if (!gui.in_use)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2778 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2779 screen_attr = -1; // force setting the Normal colors
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2780 screen_stop_highlight(); // don't want highlighting here
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2781
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2782 #ifdef FEAT_CLIPBOARD
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2783 // disable selection without redrawing it
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2784 clip_scroll_selection(9999);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2785 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2786
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2787 // blank out ScreenLines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2788 for (i = 0; i < Rows; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2789 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2790 lineclear(LineOffset[i], (int)Columns, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2791 LineWraps[i] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2792 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2793
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2794 if (doclear && can_clear(T_CL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2795 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2796 out_str(T_CL); // clear the display
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2797 did_clear = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2798 clear_cmdline = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2799 mode_displayed = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2800 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2801 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2802 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2803 // can't clear the screen, mark all chars with invalid attributes
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2804 for (i = 0; i < Rows; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2805 lineinvalid(LineOffset[i], (int)Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2806 clear_cmdline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2807 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2808
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2809 screen_cleared = TRUE; // can use contents of ScreenLines now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2810
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2811 win_rest_invalid(firstwin); // redraw all regular windows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2812 redraw_cmdline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2813 redraw_tabline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2814 if (must_redraw == UPD_CLEAR) // no need to clear again
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2815 must_redraw = UPD_NOT_VALID;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2816 msg_scrolled = 0; // compute_cmdrow() uses this
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2817 compute_cmdrow();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2818 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2819 popup_redraw_all(); // redraw all popup windows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2820 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2821 msg_row = cmdline_row; // put cursor on last line for messages
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2822 msg_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2823 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2824 msg_didany = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2825 msg_didout = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2826
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2827 return did_clear;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2828 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2829
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2830 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2831 * Clear one line in ScreenLines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2832 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2833 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2834 lineclear(unsigned off, int width, int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2835 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2836 (void)vim_memset(ScreenLines + off, ' ', (size_t)width * sizeof(schar_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2837 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2838 (void)vim_memset(ScreenLinesUC + off, 0,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2839 (size_t)width * sizeof(u8char_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2840 (void)vim_memset(ScreenAttrs + off, attr, (size_t)width * sizeof(sattr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2841 (void)vim_memset(ScreenCols + off, -1, (size_t)width * sizeof(colnr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2842 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2843
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2844 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2845 * Mark one line in ScreenLines invalid by setting the attributes to an
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2846 * invalid value.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2847 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2848 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2849 lineinvalid(unsigned off, int width)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2850 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2851 (void)vim_memset(ScreenAttrs + off, -1, (size_t)width * sizeof(sattr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2852 (void)vim_memset(ScreenCols + off, -1, (size_t)width * sizeof(colnr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2853 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2854
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2855 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2856 * To be called when characters were sent to the terminal directly, outputting
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2857 * test on "screen_lnum".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2858 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2859 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2860 line_was_clobbered(int screen_lnum)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2861 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2862 lineinvalid(LineOffset[screen_lnum], (int)Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2863 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2864
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2865 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2866 * Copy part of a Screenline for vertically split window "wp".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2867 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2868 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2869 linecopy(int to, int from, win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2870 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2871 unsigned off_to = LineOffset[to] + wp->w_wincol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2872 unsigned off_from = LineOffset[from] + wp->w_wincol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2873
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2874 mch_memmove(ScreenLines + off_to, ScreenLines + off_from,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2875 wp->w_width * sizeof(schar_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2876 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2877 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2878 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2879
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2880 mch_memmove(ScreenLinesUC + off_to, ScreenLinesUC + off_from,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2881 wp->w_width * sizeof(u8char_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2882 for (i = 0; i < p_mco; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2883 mch_memmove(ScreenLinesC[i] + off_to, ScreenLinesC[i] + off_from,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2884 wp->w_width * sizeof(u8char_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2885 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2886 if (enc_dbcs == DBCS_JPNU)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2887 mch_memmove(ScreenLines2 + off_to, ScreenLines2 + off_from,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2888 wp->w_width * sizeof(schar_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2889 mch_memmove(ScreenAttrs + off_to, ScreenAttrs + off_from,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2890 wp->w_width * sizeof(sattr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2891 mch_memmove(ScreenCols + off_to, ScreenCols + off_from,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2892 wp->w_width * sizeof(colnr_T));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2893 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2894
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2895 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2896 * Return TRUE if clearing with term string "p" would work.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2897 * It can't work when the string is empty or it won't set the right background.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2898 * Don't clear to end-of-line when there are popups, it may cause flicker.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2899 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2900 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2901 can_clear(char_u *p)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2902 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2903 return (*p != NUL && (t_colors <= 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2904 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2905 || gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2906 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2907 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2908 || (p_tgc && cterm_normal_bg_gui_color == INVALCOLOR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2909 || (!p_tgc && cterm_normal_bg_color == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2910 #else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2911 || cterm_normal_bg_color == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2912 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2913 || *T_UT != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2914 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2915 && !(p == T_CE && popup_visible)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2916 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2917 );
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2918 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2919
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2920 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2921 * Reset cursor position. Use whenever cursor was moved because of outputting
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2922 * something directly to the screen (shell commands) or a terminal control
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2923 * code.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2924 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2925 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2926 screen_start(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2927 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2928 screen_cur_row = screen_cur_col = 9999;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2929 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2930
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2931 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2932 * Move the cursor to position "row","col" in the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2933 * This tries to find the most efficient way to move, minimizing the number of
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2934 * characters sent to the terminal.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2935 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2936 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2937 windgoto(int row, int col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2938 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2939 sattr_T *p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2940 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2941 int plan;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2942 int cost;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2943 int wouldbe_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2944 int noinvcurs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2945 char_u *bs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2946 int goto_cost;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2947 int attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2948
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2949 #define GOTO_COST 7 // assume a term_windgoto() takes about 7 chars
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2950 #define HIGHL_COST 5 // assume unhighlight takes 5 chars
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2951
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2952 #define PLAN_LE 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2953 #define PLAN_CR 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2954 #define PLAN_NL 3
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2955 #define PLAN_WRITE 4
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2956 // Can't use ScreenLines unless initialized
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2957 if (ScreenLines == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2958 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2959 if (col == screen_cur_col && row == screen_cur_row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2960 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2961
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2962 // Check for valid position.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2963 if (row < 0) // window without text lines?
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2964 row = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2965 if (row >= screen_Rows)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2966 row = screen_Rows - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2967 if (col >= screen_Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2968 col = screen_Columns - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2969
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2970 // check if no cursor movement is allowed in highlight mode
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2971 if (screen_attr && *T_MS == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2972 noinvcurs = HIGHL_COST;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2973 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2974 noinvcurs = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2975 goto_cost = GOTO_COST + noinvcurs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2976
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2977 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2978 * Plan how to do the positioning:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2979 * 1. Use CR to move it to column 0, same row.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2980 * 2. Use T_LE to move it a few columns to the left.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2981 * 3. Use NL to move a few lines down, column 0.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2982 * 4. Move a few columns to the right with T_ND or by writing chars.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2983 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2984 * Don't do this if the cursor went beyond the last column, the cursor
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2985 * position is unknown then (some terminals wrap, some don't )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2986 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2987 * First check if the highlighting attributes allow us to write
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2988 * characters to move the cursor to the right.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2989 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2990 if (row >= screen_cur_row && screen_cur_col < Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2991 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2992 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2993 * If the cursor is in the same row, bigger col, we can use CR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2994 * or T_LE.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2995 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2996 bs = NULL; // init for GCC
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2997 attr = screen_attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2998 if (row == screen_cur_row && col < screen_cur_col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
2999 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3000 // "le" is preferred over "bc", because "bc" is obsolete
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3001 if (*T_LE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3002 bs = T_LE; // "cursor left"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3003 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3004 bs = T_BC; // "backspace character (old)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3005 if (*bs)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3006 cost = (screen_cur_col - col) * (int)STRLEN(bs);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3007 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3008 cost = 999;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3009 if (col + 1 < cost) // using CR is less characters
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3010 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3011 plan = PLAN_CR;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3012 wouldbe_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3013 cost = 1; // CR is just one character
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3014 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3015 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3016 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3017 plan = PLAN_LE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3018 wouldbe_col = col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3019 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3020 if (noinvcurs) // will stop highlighting
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3021 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3022 cost += noinvcurs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3023 attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3024 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3025 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3026
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3027 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3028 * If the cursor is above where we want to be, we can use CR LF.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3029 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3030 else if (row > screen_cur_row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3031 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3032 plan = PLAN_NL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3033 wouldbe_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3034 cost = (row - screen_cur_row) * 2; // CR LF
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3035 if (noinvcurs) // will stop highlighting
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3036 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3037 cost += noinvcurs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3038 attr = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3039 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3040 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3041
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3042 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3043 * If the cursor is in the same row, smaller col, just use write.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3044 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3045 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3046 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3047 plan = PLAN_WRITE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3048 wouldbe_col = screen_cur_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3049 cost = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3050 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3051
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3052 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3053 * Check if any characters that need to be written have the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3054 * correct attributes. Also avoid UTF-8 characters.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3055 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3056 i = col - wouldbe_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3057 if (i > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3058 cost += i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3059 if (cost < goto_cost && i > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3060 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3061 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3062 * Check if the attributes are correct without additionally
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3063 * stopping highlighting.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3064 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3065 p = ScreenAttrs + LineOffset[row] + wouldbe_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3066 while (i && *p++ == attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3067 --i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3068 if (i != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3069 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3070 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3071 * Try if it works when highlighting is stopped here.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3072 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3073 if (*--p == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3074 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3075 cost += noinvcurs;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3076 while (i && *p++ == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3077 --i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3078 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3079 if (i != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3080 cost = 999; // different attributes, don't do it
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3081 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3082 if (enc_utf8)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3083 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3084 // Don't use an UTF-8 char for positioning, it's slow.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3085 for (i = wouldbe_col; i < col; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3086 if (ScreenLinesUC[LineOffset[row] + i] != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3087 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3088 cost = 999;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3089 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3090 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3091 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3092 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3093
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3094 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3095 * We can do it without term_windgoto()!
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3096 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3097 if (cost < goto_cost)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3098 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3099 if (plan == PLAN_LE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3100 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3101 if (noinvcurs)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3102 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3103 while (screen_cur_col > col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3104 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3105 out_str(bs);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3106 --screen_cur_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3107 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3108 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3109 else if (plan == PLAN_CR)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3110 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3111 if (noinvcurs)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3112 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3113 out_char('\r');
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3114 screen_cur_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3115 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3116 else if (plan == PLAN_NL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3117 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3118 if (noinvcurs)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3119 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3120 while (screen_cur_row < row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3121 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3122 out_char('\n');
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3123 ++screen_cur_row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3124 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3125 screen_cur_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3126 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3127
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3128 i = col - screen_cur_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3129 if (i > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3130 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3131 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3132 * Use cursor-right if it's one character only. Avoids
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3133 * removing a line of pixels from the last bold char, when
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3134 * using the bold trick in the GUI.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3135 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3136 if (T_ND[0] != NUL && T_ND[1] == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3137 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3138 while (i-- > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3139 out_char(*T_ND);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3140 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3141 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3142 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3143 int off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3144
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3145 off = LineOffset[row] + screen_cur_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3146 while (i-- > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3147 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3148 if (ScreenAttrs[off] != screen_attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3149 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3150 out_flush_check();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3151 out_char(ScreenLines[off]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3152 if (enc_dbcs == DBCS_JPNU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3153 && ScreenLines[off] == 0x8e)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3154 out_char(ScreenLines2[off]);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3155 ++off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3156 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3157 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3158 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3159 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3160 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3161 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3162 cost = 999;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3163
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3164 if (cost >= goto_cost)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3165 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3166 if (noinvcurs)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3167 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3168 if (row == screen_cur_row && (col > screen_cur_col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3169 && *T_CRI != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3170 term_cursor_right(col - screen_cur_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3171 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3172 term_windgoto(row, col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3173 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3174 screen_cur_row = row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3175 screen_cur_col = col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3176 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3177
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3178 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3179 * Set cursor to its position in the current window.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3180 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3181 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3182 setcursor(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3183 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3184 setcursor_mayforce(FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3185 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3186
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3187 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3188 * Set cursor to its position in the current window.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3189 * When "force" is TRUE also when not redrawing.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3190 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3191 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3192 setcursor_mayforce(int force)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3193 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3194 if (force || redrawing())
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3195 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3196 validate_cursor();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3197 windgoto(W_WINROW(curwin) + curwin->w_wrow,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3198 curwin->w_wincol + (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3199 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3200 // With 'rightleft' set and the cursor on a double-wide
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3201 // character, position it on the leftmost column.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3202 curwin->w_p_rl ? ((int)curwin->w_width - curwin->w_wcol
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3203 - ((has_mbyte
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3204 && (*mb_ptr2cells)(ml_get_cursor()) == 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3205 && vim_isprintc(gchar_cursor())) ? 2 : 1)) :
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3206 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3207 curwin->w_wcol));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3208 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3209 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3210
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3211
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3212 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3213 * Insert 'line_count' lines at 'row' in window 'wp'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3214 * If 'invalid' is TRUE the wp->w_lines[].wl_lnum is invalidated.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3215 * If 'mayclear' is TRUE the screen will be cleared if it is faster than
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3216 * scrolling.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3217 * Returns FAIL if the lines are not inserted, OK for success.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3218 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3219 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3220 win_ins_lines(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3221 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3222 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3223 int line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3224 int invalid,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3225 int mayclear)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3226 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3227 int did_delete;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3228 int nextrow;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3229 int lastrow;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3230 int retval;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3231
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3232 if (invalid)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3233 wp->w_lines_valid = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3234
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3235 // with only a few lines it's not worth the effort
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3236 if (wp->w_height < 5)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3237 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3238
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3239 // with the popup menu visible this might not work correctly
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3240 if (pum_visible())
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3241 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3242
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3243 if (line_count > wp->w_height - row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3244 line_count = wp->w_height - row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3245
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3246 retval = win_do_lines(wp, row, line_count, mayclear, FALSE, 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3247 if (retval != MAYBE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3248 return retval;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3249
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3250 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3251 * If there is a next window or a status line, we first try to delete the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3252 * lines at the bottom to avoid messing what is after the window.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3253 * If this fails and there are following windows, don't do anything to
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3254 * avoid messing up those windows, better just redraw.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3255 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3256 did_delete = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3257 if (wp->w_next != NULL || wp->w_status_height)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3258 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3259 if (screen_del_lines(0, W_WINROW(wp) + wp->w_height - line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3260 line_count, (int)Rows, FALSE, 0, NULL) == OK)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3261 did_delete = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3262 else if (wp->w_next)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3263 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3264 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3265 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3266 * if no lines deleted, blank the lines that will end up below the window
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3267 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3268 if (!did_delete)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3269 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3270 wp->w_redr_status = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3271 redraw_cmdline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3272 nextrow = W_WINROW(wp) + wp->w_height + wp->w_status_height;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3273 lastrow = nextrow + line_count;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3274 if (lastrow > Rows)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3275 lastrow = Rows;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3276 screen_fill(nextrow - line_count, lastrow - line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3277 wp->w_wincol, (int)W_ENDCOL(wp),
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3278 ' ', ' ', 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3279 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3280
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3281 if (screen_ins_lines(0, W_WINROW(wp) + row, line_count, (int)Rows, 0, NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3282 == FAIL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3283 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3284 // deletion will have messed up other windows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3285 if (did_delete)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3286 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3287 wp->w_redr_status = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3288 win_rest_invalid(W_NEXT(wp));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3289 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3290 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3291 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3292
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3293 return OK;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3294 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3295
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3296 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3297 * Delete "line_count" window lines at "row" in window "wp".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3298 * If "invalid" is TRUE curwin->w_lines[] is invalidated.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3299 * If "mayclear" is TRUE the screen will be cleared if it is faster than
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3300 * scrolling
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3301 * Return OK for success, FAIL if the lines are not deleted.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3302 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3303 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3304 win_del_lines(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3305 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3306 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3307 int line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3308 int invalid,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3309 int mayclear,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3310 int clear_attr) // for clearing lines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3311 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3312 int retval;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3313
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3314 if (invalid)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3315 wp->w_lines_valid = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3316
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3317 if (line_count > wp->w_height - row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3318 line_count = wp->w_height - row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3319
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3320 retval = win_do_lines(wp, row, line_count, mayclear, TRUE, clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3321 if (retval != MAYBE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3322 return retval;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3323
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3324 if (screen_del_lines(0, W_WINROW(wp) + row, line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3325 (int)Rows, FALSE, clear_attr, NULL) == FAIL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3326 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3327
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3328 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3329 * If there are windows or status lines below, try to put them at the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3330 * correct place. If we can't do that, they have to be redrawn.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3331 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3332 if (wp->w_next || wp->w_status_height || cmdline_row < Rows - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3333 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3334 if (screen_ins_lines(0, W_WINROW(wp) + wp->w_height - line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3335 line_count, (int)Rows, clear_attr, NULL) == FAIL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3336 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3337 wp->w_redr_status = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3338 win_rest_invalid(wp->w_next);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3339 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3340 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3341 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3342 * If this is the last window and there is no status line, redraw the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3343 * command line later.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3344 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3345 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3346 redraw_cmdline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3347 return OK;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3348 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3349
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3350 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3351 * Common code for win_ins_lines() and win_del_lines().
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3352 * Returns OK or FAIL when the work has been done.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3353 * Returns MAYBE when not finished yet.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3354 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3355 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3356 win_do_lines(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3357 win_T *wp,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3358 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3359 int line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3360 int mayclear,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3361 int del,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3362 int clear_attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3363 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3364 int retval;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3365
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3366 if (!redrawing() || line_count <= 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3367 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3368
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3369 // When inserting lines would result in loss of command output, just redraw
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3370 // the lines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3371 if (no_win_do_lines_ins && !del)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3372 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3373
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3374 // only a few lines left: redraw is faster
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3375 if (mayclear && Rows - line_count < 5 && wp->w_width == Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3376 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3377 if (!no_win_do_lines_ins)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3378 screenclear(); // will set wp->w_lines_valid to 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3379 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3380 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3381
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3382 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3383 // this doesn't work when there are popups visible
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3384 if (popup_visible)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3385 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3386 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3387
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3388 // Delete all remaining lines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3389 if (row + line_count >= wp->w_height)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3390 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3391 screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3392 wp->w_wincol, (int)W_ENDCOL(wp),
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3393 ' ', ' ', 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3394 return OK;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3395 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3396
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3397 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3398 * When scrolling, the message on the command line should be cleared,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3399 * otherwise it will stay there forever.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3400 * Don't do this when avoiding to insert lines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3401 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3402 if (!no_win_do_lines_ins)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3403 clear_cmdline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3404
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3405 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3406 * If the terminal can set a scroll region, use that.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3407 * Always do this in a vertically split window. This will redraw from
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3408 * ScreenLines[] when t_CV isn't defined. That's faster than using
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3409 * win_line().
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3410 * Don't use a scroll region when we are going to redraw the text, writing
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3411 * a character in the lower right corner of the scroll region may cause a
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3412 * scroll-up .
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3413 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3414 if (scroll_region || wp->w_width != Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3415 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3416 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3417 scroll_region_set(wp, row);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3418 if (del)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3419 retval = screen_del_lines(W_WINROW(wp) + row, 0, line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3420 wp->w_height - row, FALSE, clear_attr, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3421 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3422 retval = screen_ins_lines(W_WINROW(wp) + row, 0, line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3423 wp->w_height - row, clear_attr, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3424 if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3425 scroll_region_reset();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3426 return retval;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3427 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3428
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3429 if (wp->w_next != NULL && p_tf) // don't delete/insert on fast terminal
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3430 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3431
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3432 return MAYBE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3433 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3434
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3435 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3436 * window 'wp' and everything after it is messed up, mark it for redraw
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3437 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3438 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3439 win_rest_invalid(win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3440 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3441 while (wp != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3442 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3443 redraw_win_later(wp, UPD_NOT_VALID);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3444 wp->w_redr_status = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3445 wp = wp->w_next;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3446 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3447 redraw_cmdline = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3448 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3449
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3450 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3451 * The rest of the routines in this file perform screen manipulations. The
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3452 * given operation is performed physically on the screen. The corresponding
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3453 * change is also made to the internal screen image. In this way, the editor
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3454 * anticipates the effect of editing changes on the appearance of the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3455 * That way, when we call screenupdate a complete redraw isn't usually
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3456 * necessary. Another advantage is that we can keep adding code to anticipate
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3457 * screen changes, and in the meantime, everything still works.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3458 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3459
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3460 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3461 * types for inserting or deleting lines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3462 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3463 #define USE_T_CAL 1
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3464 #define USE_T_CDL 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3465 #define USE_T_AL 3
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3466 #define USE_T_CE 4
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3467 #define USE_T_DL 5
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3468 #define USE_T_SR 6
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3469 #define USE_NL 7
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3470 #define USE_T_CD 8
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3471 #define USE_REDRAW 9
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3472
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3473 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3474 * insert lines on the screen and update ScreenLines[]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3475 * "end" is the line after the scrolled part. Normally it is Rows.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3476 * When scrolling region used "off" is the offset from the top for the region.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3477 * "row" and "end" are relative to the start of the region.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3478 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3479 * return FAIL for failure, OK for success.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3480 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3481 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3482 screen_ins_lines(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3483 int off,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3484 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3485 int line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3486 int end,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3487 int clear_attr,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3488 win_T *wp) // NULL or window to use width from
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3489 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3490 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3491 int j;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3492 unsigned temp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3493 int cursor_row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3494 int cursor_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3495 int type;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3496 int result_empty;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3497 int can_ce = can_clear(T_CE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3498
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3499 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3500 * FAIL if
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3501 * - there is no valid screen
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3502 * - the line count is less than one
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3503 * - the line count is more than 'ttyscroll'
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3504 * - "end" is more than "Rows" (safety check, should not happen)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3505 * - redrawing for a callback and there is a modeless selection
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3506 * - there is a popup window
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3507 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3508 if (!screen_valid(TRUE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3509 || line_count <= 0 || line_count > p_ttyscroll
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3510 || end > Rows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3511 #ifdef FEAT_CLIPBOARD
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3512 || (clip_star.state != SELECT_CLEARED
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3513 && redrawing_for_callback > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3514 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3515 #ifdef FEAT_PROP_POPUP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3516 || popup_visible
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3517 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3518 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3519 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3520
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3521 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3522 * There are seven ways to insert lines:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3523 * 0. When in a vertically split window and t_CV isn't set, redraw the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3524 * characters from ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3525 * 1. Use T_CD (clear to end of display) if it exists and the result of
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3526 * the insert is just empty lines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3527 * 2. Use T_CAL (insert multiple lines) if it exists and T_AL is not
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3528 * present or line_count > 1. It looks better if we do all the inserts
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3529 * at once.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3530 * 3. Use T_CDL (delete multiple lines) if it exists and the result of the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3531 * insert is just empty lines and T_CE is not present or line_count >
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3532 * 1.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3533 * 4. Use T_AL (insert line) if it exists.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3534 * 5. Use T_CE (erase line) if it exists and the result of the insert is
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3535 * just empty lines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3536 * 6. Use T_DL (delete line) if it exists and the result of the insert is
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3537 * just empty lines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3538 * 7. Use T_SR (scroll reverse) if it exists and inserting at row 0 and
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3539 * the 'da' flag is not set or we have clear line capability.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3540 * 8. redraw the characters from ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3541 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3542 * Careful: In a hpterm scroll reverse doesn't work as expected, it moves
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3543 * the scrollbar for the window. It does have insert line, use that if it
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3544 * exists.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3545 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3546 result_empty = (row + line_count >= end);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3547 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3548 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3549 // Avoid that lines are first cleared here and then redrawn, which
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3550 // results in many characters updated twice. This happens with CTRL-F
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3551 // in a vertically split window. With line-by-line scrolling
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3552 // USE_REDRAW should be faster.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3553 if (line_count > 3)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3554 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3555 type = USE_REDRAW;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3556 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3557 else if (can_clear(T_CD) && result_empty)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3558 type = USE_T_CD;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3559 else if (*T_CAL != NUL && (line_count > 1 || *T_AL == NUL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3560 type = USE_T_CAL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3561 else if (*T_CDL != NUL && result_empty && (line_count > 1 || !can_ce))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3562 type = USE_T_CDL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3563 else if (*T_AL != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3564 type = USE_T_AL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3565 else if (can_ce && result_empty)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3566 type = USE_T_CE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3567 else if (*T_DL != NUL && result_empty)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3568 type = USE_T_DL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3569 else if (*T_SR != NUL && row == 0 && (*T_DA == NUL || can_ce))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3570 type = USE_T_SR;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3571 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3572 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3573
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3574 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3575 * For clearing the lines screen_del_lines() is used. This will also take
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3576 * care of t_db if necessary.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3577 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3578 if (type == USE_T_CD || type == USE_T_CDL ||
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3579 type == USE_T_CE || type == USE_T_DL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3580 return screen_del_lines(off, row, line_count, end, FALSE, 0, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3581
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3582 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3583 * If text is retained below the screen, first clear or delete as many
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3584 * lines at the bottom of the window as are about to be inserted so that
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3585 * the deleted lines won't later surface during a screen_del_lines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3586 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3587 if (*T_DB)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3588 screen_del_lines(off, end - line_count, line_count, end, FALSE, 0, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3589
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3590 #ifdef FEAT_CLIPBOARD
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3591 // Remove a modeless selection when inserting lines halfway the screen
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3592 // or not the full width of the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3593 if (off + row > 0 || (wp != NULL && wp->w_width != Columns))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3594 clip_clear_selection(&clip_star);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3595 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3596 clip_scroll_selection(-line_count);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3597 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3598
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3599 #ifdef FEAT_GUI_HAIKU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3600 vim_lock_screen();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3601 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3602
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3603 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3604 // Don't update the GUI cursor here, ScreenLines[] is invalid until the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3605 // scrolling is actually carried out.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3606 gui_dont_update_cursor(row + off <= gui.cursor_row);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3607 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3608
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3609 if (wp != NULL && wp->w_wincol != 0 && *T_CSV != NUL && *T_CCS == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3610 cursor_col = wp->w_wincol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3611
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3612 if (*T_CCS != NUL) // cursor relative to region
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3613 cursor_row = row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3614 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3615 cursor_row = row + off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3616
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3617 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3618 * Shift LineOffset[] line_count down to reflect the inserted lines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3619 * Clear the inserted lines in ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3620 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3621 row += off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3622 end += off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3623 for (i = 0; i < line_count; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3624 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3625 if (wp != NULL && wp->w_width != Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3626 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3627 // need to copy part of a line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3628 j = end - 1 - i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3629 while ((j -= line_count) >= row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3630 linecopy(j + line_count, j, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3631 j += line_count;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3632 if (can_clear((char_u *)" "))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3633 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3634 clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3635 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3636 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3637 LineWraps[j] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3638 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3639 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3640 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3641 j = end - 1 - i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3642 temp = LineOffset[j];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3643 while ((j -= line_count) >= row)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3644 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3645 LineOffset[j + line_count] = LineOffset[j];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3646 LineWraps[j + line_count] = LineWraps[j];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3647 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3648 LineOffset[j + line_count] = temp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3649 LineWraps[j + line_count] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3650 if (can_clear((char_u *)" "))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3651 lineclear(temp, (int)Columns, clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3652 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3653 lineinvalid(temp, (int)Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3654 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3655 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3656
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3657 #ifdef FEAT_GUI_HAIKU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3658 vim_unlock_screen();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3659 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3660
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3661 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3662 windgoto(cursor_row, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3663 if (clear_attr != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3664 screen_start_highlight(clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3665
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3666 // redraw the characters
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3667 if (type == USE_REDRAW)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3668 redraw_block(row, end, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3669 else if (type == USE_T_CAL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3670 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3671 term_append_lines(line_count);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3672 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3673 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3674 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3675 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3676 for (i = 0; i < line_count; i++)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3677 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3678 if (type == USE_T_AL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3679 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3680 if (i && cursor_row != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3681 windgoto(cursor_row, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3682 out_str(T_AL);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3683 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3684 else // type == USE_T_SR
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3685 out_str(T_SR);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3686 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3687 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3688 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3689
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3690 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3691 * With scroll-reverse and 'da' flag set we need to clear the lines that
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3692 * have been scrolled down into the region.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3693 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3694 if (type == USE_T_SR && *T_DA)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3695 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3696 for (i = 0; i < line_count; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3697 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3698 windgoto(off + i, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3699 out_str(T_CE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3700 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3701 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3702 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3703
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3704 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3705 gui_can_update_cursor();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3706 if (gui.in_use)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3707 out_flush(); // always flush after a scroll
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3708 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3709 return OK;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3710 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3711
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3712 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3713 * Delete lines on the screen and update ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3714 * "end" is the line after the scrolled part. Normally it is Rows.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3715 * When scrolling region used "off" is the offset from the top for the region.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3716 * "row" and "end" are relative to the start of the region.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3717 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3718 * Return OK for success, FAIL if the lines are not deleted.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3719 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3720 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3721 screen_del_lines(
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3722 int off,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3723 int row,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3724 int line_count,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3725 int end,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3726 int force, // even when line_count > p_ttyscroll
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3727 int clear_attr, // used for clearing lines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3728 win_T *wp) // NULL or window to use width from
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3729 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3730 int j;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3731 int i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3732 unsigned temp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3733 int cursor_row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3734 int cursor_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3735 int cursor_end;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3736 int result_empty; // result is empty until end of region
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3737 int can_delete; // deleting line codes can be used
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3738 int type;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3739
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3740 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3741 * FAIL if
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3742 * - there is no valid screen
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3743 * - the screen has to be redrawn completely
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3744 * - the line count is less than one
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3745 * - the line count is more than 'ttyscroll'
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3746 * - "end" is more than "Rows" (safety check, should not happen)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3747 * - redrawing for a callback and there is a modeless selection
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3748 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3749 if (!screen_valid(TRUE)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3750 || line_count <= 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3751 || (!force && line_count > p_ttyscroll)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3752 || end > Rows
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3753 #ifdef FEAT_CLIPBOARD
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3754 || (clip_star.state != SELECT_CLEARED && redrawing_for_callback > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3755 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3756 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3757 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3758
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3759 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3760 * Check if the rest of the current region will become empty.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3761 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3762 result_empty = row + line_count >= end;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3763
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3764 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3765 * We can delete lines only when 'db' flag not set or when 'ce' option
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3766 * available.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3767 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3768 can_delete = (*T_DB == NUL || can_clear(T_CE));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3769
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3770 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3771 * There are six ways to delete lines:
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3772 * 0. When in a vertically split window and t_CV isn't set, redraw the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3773 * characters from ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3774 * 1. Use T_CD if it exists and the result is empty.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3775 * 2. Use newlines if row == 0 and count == 1 or T_CDL does not exist.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3776 * 3. Use T_CDL (delete multiple lines) if it exists and line_count > 1 or
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3777 * none of the other ways work.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3778 * 4. Use T_CE (erase line) if the result is empty.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3779 * 5. Use T_DL (delete line) if it exists.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3780 * 6. redraw the characters from ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3781 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3782 if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3783 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3784 // Avoid that lines are first cleared here and then redrawn, which
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3785 // results in many characters updated twice. This happens with CTRL-F
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3786 // in a vertically split window. With line-by-line scrolling
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3787 // USE_REDRAW should be faster.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3788 if (line_count > 3)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3789 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3790 type = USE_REDRAW;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3791 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3792 else if (can_clear(T_CD) && result_empty)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3793 type = USE_T_CD;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3794 else if (row == 0 && (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3795 #ifndef AMIGA
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3796 // On the Amiga, somehow '\n' on the last line doesn't always scroll
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3797 // up, so use delete-line command
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3798 line_count == 1 ||
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3799 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3800 *T_CDL == NUL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3801 type = USE_NL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3802 else if (*T_CDL != NUL && line_count > 1 && can_delete)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3803 type = USE_T_CDL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3804 else if (can_clear(T_CE) && result_empty
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3805 && (wp == NULL || wp->w_width == Columns))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3806 type = USE_T_CE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3807 else if (*T_DL != NUL && can_delete)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3808 type = USE_T_DL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3809 else if (*T_CDL != NUL && can_delete)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3810 type = USE_T_CDL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3811 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3812 return FAIL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3813
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3814 #ifdef FEAT_CLIPBOARD
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3815 // Remove a modeless selection when deleting lines halfway the screen or
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3816 // not the full width of the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3817 if (off + row > 0 || (wp != NULL && wp->w_width != Columns))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3818 clip_clear_selection(&clip_star);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3819 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3820 clip_scroll_selection(line_count);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3821 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3822
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3823 #ifdef FEAT_GUI_HAIKU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3824 vim_lock_screen();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3825 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3826
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3827 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3828 // Don't update the GUI cursor here, ScreenLines[] is invalid until the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3829 // scrolling is actually carried out.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3830 gui_dont_update_cursor(gui.cursor_row >= row + off
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3831 && gui.cursor_row < end + off);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3832 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3833
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3834 if (wp != NULL && wp->w_wincol != 0 && *T_CSV != NUL && *T_CCS == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3835 cursor_col = wp->w_wincol;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3836
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3837 if (*T_CCS != NUL) // cursor relative to region
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3838 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3839 cursor_row = row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3840 cursor_end = end;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3841 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3842 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3843 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3844 cursor_row = row + off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3845 cursor_end = end + off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3846 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3847
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3848 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3849 * Now shift LineOffset[] line_count up to reflect the deleted lines.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3850 * Clear the inserted lines in ScreenLines[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3851 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3852 row += off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3853 end += off;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3854 for (i = 0; i < line_count; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3855 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3856 if (wp != NULL && wp->w_width != Columns)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3857 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3858 // need to copy part of a line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3859 j = row + i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3860 while ((j += line_count) <= end - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3861 linecopy(j - line_count, j, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3862 j -= line_count;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3863 if (can_clear((char_u *)" "))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3864 lineclear(LineOffset[j] + wp->w_wincol, wp->w_width,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3865 clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3866 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3867 lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3868 LineWraps[j] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3869 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3870 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3871 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3872 // whole width, moving the line pointers is faster
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3873 j = row + i;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3874 temp = LineOffset[j];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3875 while ((j += line_count) <= end - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3876 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3877 LineOffset[j - line_count] = LineOffset[j];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3878 LineWraps[j - line_count] = LineWraps[j];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3879 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3880 LineOffset[j - line_count] = temp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3881 LineWraps[j - line_count] = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3882 if (can_clear((char_u *)" "))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3883 lineclear(temp, (int)Columns, clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3884 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3885 lineinvalid(temp, (int)Columns);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3886 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3887 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3888
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3889 #ifdef FEAT_GUI_HAIKU
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3890 vim_unlock_screen();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3891 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3892
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3893 if (screen_attr != clear_attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3894 screen_stop_highlight();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3895 if (clear_attr != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3896 screen_start_highlight(clear_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3897
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3898 // redraw the characters
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3899 if (type == USE_REDRAW)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3900 redraw_block(row, end, wp);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3901 else if (type == USE_T_CD) // delete the lines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3902 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3903 windgoto(cursor_row, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3904 out_str(T_CD);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3905 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3906 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3907 else if (type == USE_T_CDL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3908 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3909 windgoto(cursor_row, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3910 term_delete_lines(line_count);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3911 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3912 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3913 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3914 * Deleting lines at top of the screen or scroll region: Just scroll
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3915 * the whole screen (scroll region) up by outputting newlines on the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3916 * last line.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3917 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3918 else if (type == USE_NL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3919 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3920 windgoto(cursor_end - 1, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3921 for (i = line_count; --i >= 0; )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3922 out_char('\n'); // cursor will remain on same line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3923 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3924 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3925 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3926 for (i = line_count; --i >= 0; )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3927 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3928 if (type == USE_T_DL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3929 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3930 windgoto(cursor_row, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3931 out_str(T_DL); // delete a line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3932 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3933 else // type == USE_T_CE
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3934 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3935 windgoto(cursor_row + i, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3936 out_str(T_CE); // erase a line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3937 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3938 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3939 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3940 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3941
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3942 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3943 * If the 'db' flag is set, we need to clear the lines that have been
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3944 * scrolled up at the bottom of the region.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3945 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3946 if (*T_DB && (type == USE_T_DL || type == USE_T_CDL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3947 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3948 for (i = line_count; i > 0; --i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3949 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3950 windgoto(cursor_end - i, cursor_col);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3951 out_str(T_CE); // erase a line
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3952 screen_start(); // don't know where cursor is now
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3953 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3954 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3955
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3956 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3957 gui_can_update_cursor();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3958 if (gui.in_use)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3959 out_flush(); // always flush after a scroll
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3960 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3961
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3962 return OK;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3963 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3964
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3965 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3966 * Return TRUE when postponing displaying the mode message: when not redrawing
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3967 * or inside a mapping.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3968 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3969 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3970 skip_showmode(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3971 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3972 // Call char_avail() only when we are going to show something, because it
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3973 // takes a bit of time. redrawing() may also call char_avail().
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3974 if (global_busy
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3975 || msg_silent != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3976 || !redrawing()
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3977 || (char_avail() && !KeyTyped))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3978 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3979 redraw_mode = TRUE; // show mode later
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3980 return TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3981 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3982 return FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3983 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3984
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3985 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3986 * Show the current mode and ruler.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3987 *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3988 * If clear_cmdline is TRUE, clear the rest of the cmdline.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3989 * If clear_cmdline is FALSE there may be a message there that needs to be
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3990 * cleared only if a mode is shown.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3991 * If redraw_mode is TRUE show or clear the mode.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3992 * Return the length of the message (0 if no message).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3993 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3994 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3995 showmode(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3996 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3997 int need_clear;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3998 int length = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
3999 int do_mode;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4000 int attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4001 int nwr_save;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4002 int sub_attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4003
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4004 do_mode = p_smd && msg_silent == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4005 && ((State & MODE_INSERT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4006 || restart_edit != NUL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4007 || VIsual_active);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4008 if (do_mode || reg_recording != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4009 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4010 if (skip_showmode())
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4011 return 0; // show mode later
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4012
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4013 nwr_save = need_wait_return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4014
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4015 // wait a bit before overwriting an important message
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4016 check_for_delay(FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4017
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4018 // if the cmdline is more than one line high, erase top lines
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4019 need_clear = clear_cmdline;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4020 if (clear_cmdline && cmdline_row < Rows - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4021 msg_clr_cmdline(); // will reset clear_cmdline
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4022
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4023 // Position on the last line in the window, column 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4024 msg_pos_mode();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4025 cursor_off();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4026 attr = HL_ATTR(HLF_CM); // Highlight mode
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4027 if (do_mode)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4028 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4029 msg_puts_attr("--", attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4030 #if defined(FEAT_XIM)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4031 if (
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4032 # ifdef FEAT_GUI_GTK
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4033 preedit_get_status()
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4034 # else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4035 im_get_status()
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4036 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4037 )
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4038 # ifdef FEAT_GUI_GTK // most of the time, it's not XIM being used
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4039 msg_puts_attr(" IM", attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4040 # else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4041 msg_puts_attr(" XIM", attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4042 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4043 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4044 // CTRL-X in Insert mode
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4045 if (edit_submode != NULL && !shortmess(SHM_COMPLETIONMENU))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4046 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4047 // These messages can get long, avoid a wrap in a narrow
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4048 // window. Prefer showing edit_submode_extra.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4049 length = (Rows - msg_row) * Columns - 3;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4050 if (edit_submode_extra != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4051 length -= vim_strsize(edit_submode_extra);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4052 if (length > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4053 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4054 if (edit_submode_pre != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4055 length -= vim_strsize(edit_submode_pre);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4056 if (length - vim_strsize(edit_submode) > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4057 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4058 if (edit_submode_pre != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4059 msg_puts_attr((char *)edit_submode_pre, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4060 msg_puts_attr((char *)edit_submode, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4061 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4062 if (edit_submode_extra != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4063 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4064 msg_puts_attr(" ", attr); // add a space in between
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4065 if ((int)edit_submode_highl < (int)HLF_COUNT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4066 sub_attr = HL_ATTR(edit_submode_highl);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4067 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4068 sub_attr = attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4069 msg_puts_attr((char *)edit_submode_extra, sub_attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4070 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4071 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4072 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4073 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4074 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4075 if (State & VREPLACE_FLAG)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4076 msg_puts_attr(_(" VREPLACE"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4077 else if (State & REPLACE_FLAG)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4078 msg_puts_attr(_(" REPLACE"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4079 else if (State & MODE_INSERT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4080 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4081 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4082 if (p_ri)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4083 msg_puts_attr(_(" REVERSE"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4084 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4085 msg_puts_attr(_(" INSERT"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4086 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4087 else if (restart_edit == 'I' || restart_edit == 'i' ||
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4088 restart_edit == 'a' || restart_edit == 'A')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4089 msg_puts_attr(_(" (insert)"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4090 else if (restart_edit == 'R')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4091 msg_puts_attr(_(" (replace)"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4092 else if (restart_edit == 'V')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4093 msg_puts_attr(_(" (vreplace)"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4094 #ifdef FEAT_RIGHTLEFT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4095 if (p_hkmap)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4096 msg_puts_attr(_(" Hebrew"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4097 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4098 #ifdef FEAT_KEYMAP
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4099 if (State & MODE_LANGMAP)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4100 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4101 # ifdef FEAT_ARABIC
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4102 if (curwin->w_p_arab)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4103 msg_puts_attr(_(" Arabic"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4104 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4105 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4106 if (get_keymap_str(curwin, (char_u *)" (%s)",
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4107 NameBuff, MAXPATHL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4108 msg_puts_attr((char *)NameBuff, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4109 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4110 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4111 if ((State & MODE_INSERT) && p_paste)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4112 msg_puts_attr(_(" (paste)"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4113
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4114 if (VIsual_active)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4115 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4116 char *p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4117
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4118 // Don't concatenate separate words to avoid translation
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4119 // problems.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4120 switch ((VIsual_select ? 4 : 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4121 + (VIsual_mode == Ctrl_V) * 2
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4122 + (VIsual_mode == 'V'))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4123 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4124 case 0: p = N_(" VISUAL"); break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4125 case 1: p = N_(" VISUAL LINE"); break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4126 case 2: p = N_(" VISUAL BLOCK"); break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4127 case 4: p = N_(" SELECT"); break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4128 case 5: p = N_(" SELECT LINE"); break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4129 default: p = N_(" SELECT BLOCK"); break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4130 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4131 msg_puts_attr(_(p), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4132 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4133 msg_puts_attr(" --", attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4134 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4135
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4136 need_clear = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4137 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4138 if (reg_recording != 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4139 && edit_submode == NULL) // otherwise it gets too long
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4140 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4141 recording_mode(attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4142 need_clear = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4143 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4144
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4145 mode_displayed = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4146 if (need_clear || clear_cmdline || redraw_mode)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4147 msg_clr_eos();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4148 msg_didout = FALSE; // overwrite this message
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4149 length = msg_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4150 msg_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4151 need_wait_return = nwr_save; // never ask for hit-return for this
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4152 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4153 else if (clear_cmdline && msg_silent == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4154 // Clear the whole command line. Will reset "clear_cmdline".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4155 msg_clr_cmdline();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4156 else if (redraw_mode)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4157 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4158 msg_pos_mode();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4159 msg_clr_eos();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4160 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4161
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4162 // In Visual mode the size of the selected area must be redrawn.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4163 if (VIsual_active)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4164 clear_showcmd();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4165
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4166 // If the last window has no status line, the ruler is after the mode
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4167 // message and must be redrawn
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4168 if (redrawing() && lastwin->w_status_height == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4169 win_redr_ruler(lastwin, TRUE, FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4170
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4171 redraw_cmdline = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4172 redraw_mode = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4173 clear_cmdline = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4174
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4175 return length;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4176 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4177
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4178 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4179 * Position for a mode message.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4180 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4181 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4182 msg_pos_mode(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4183 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4184 msg_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4185 msg_row = Rows - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4186 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4187
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4188 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4189 * Delete mode message. Used when ESC is typed which is expected to end
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4190 * Insert mode (but Insert mode didn't end yet!).
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4191 * Caller should check "mode_displayed".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4192 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4193 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4194 unshowmode(int force)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4195 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4196 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4197 * Don't delete it right now, when not redrawing or inside a mapping.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4198 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4199 if (!redrawing() || (!force && char_avail() && !KeyTyped))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4200 redraw_cmdline = TRUE; // delete mode later
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4201 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4202 clearmode();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4203 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4204
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4205 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4206 * Clear the mode message.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4207 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4208 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4209 clearmode(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4210 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4211 int save_msg_row = msg_row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4212 int save_msg_col = msg_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4213
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4214 msg_pos_mode();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4215 if (reg_recording != 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4216 recording_mode(HL_ATTR(HLF_CM));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4217 msg_clr_eos();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4218
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4219 msg_col = save_msg_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4220 msg_row = save_msg_row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4221 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4222
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4223 static void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4224 recording_mode(int attr)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4225 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4226 msg_puts_attr(_("recording"), attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4227 if (shortmess(SHM_RECORDING))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4228 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4229
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4230 char s[4];
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4231
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4232 sprintf(s, " @%c", reg_recording);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4233 msg_puts_attr(s, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4234 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4235
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4236 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4237 * Draw the tab pages line at the top of the Vim window.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4238 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4239 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4240 draw_tabline(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4241 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4242 int tabcount = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4243 tabpage_T *tp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4244 int tabwidth;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4245 int col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4246 int scol = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4247 int attr;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4248 win_T *wp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4249 win_T *cwp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4250 int wincount;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4251 int modified;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4252 int c;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4253 int len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4254 int attr_sel = HL_ATTR(HLF_TPS);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4255 int attr_nosel = HL_ATTR(HLF_TP);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4256 int attr_fill = HL_ATTR(HLF_TPF);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4257 char_u *p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4258 int room;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4259 int use_sep_chars = (t_colors < 8
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4260 #ifdef FEAT_GUI
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4261 && !gui.in_use
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4262 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4263 #ifdef FEAT_TERMGUICOLORS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4264 && !p_tgc
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4265 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4266 );
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4267
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4268 if (ScreenLines == NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4269 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4270 redraw_tabline = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4271
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4272 #ifdef FEAT_GUI_TABLINE
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4273 // Take care of a GUI tabline.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4274 if (gui_use_tabline())
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4275 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4276 gui_update_tabline();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4277 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4278 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4279 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4280
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4281 if (tabline_height() < 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4282 return;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4283
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4284 #if defined(FEAT_STL_OPT)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4285 clear_TabPageIdxs();
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4286
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4287 // Use the 'tabline' option if it's set.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4288 if (*p_tal != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4289 win_redr_custom(NULL, FALSE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4290 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4291 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4292 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4293 FOR_ALL_TABPAGES(tp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4294 ++tabcount;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4295
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4296 tabwidth = (Columns - 1 + tabcount / 2) / tabcount;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4297 if (tabwidth < 6)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4298 tabwidth = 6;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4299
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4300 attr = attr_nosel;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4301 tabcount = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4302 for (tp = first_tabpage; tp != NULL && col < Columns - 4;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4303 tp = tp->tp_next)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4304 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4305 scol = col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4306
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4307 if (tp->tp_topframe == topframe)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4308 attr = attr_sel;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4309 if (use_sep_chars && col > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4310 screen_putchar('|', 0, col++, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4311
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4312 if (tp->tp_topframe != topframe)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4313 attr = attr_nosel;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4314
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4315 screen_putchar(' ', 0, col++, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4316
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4317 if (tp == curtab)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4318 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4319 cwp = curwin;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4320 wp = firstwin;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4321 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4322 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4323 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4324 cwp = tp->tp_curwin;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4325 wp = tp->tp_firstwin;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4326 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4327
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4328 modified = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4329 for (wincount = 0; wp != NULL; wp = wp->w_next, ++wincount)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4330 if (bufIsChanged(wp->w_buffer))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4331 modified = TRUE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4332 if (modified || wincount > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4333 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4334 if (wincount > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4335 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4336 vim_snprintf((char *)NameBuff, MAXPATHL, "%d", wincount);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4337 len = (int)STRLEN(NameBuff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4338 if (col + len >= Columns - 3)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4339 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4340 screen_puts_len(NameBuff, len, 0, col,
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4341 #if defined(FEAT_SYN_HL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4342 hl_combine_attr(attr, HL_ATTR(HLF_T))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4343 #else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4344 attr
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4345 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4346 );
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4347 col += len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4348 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4349 if (modified)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4350 screen_puts_len((char_u *)"+", 1, 0, col++, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4351 screen_putchar(' ', 0, col++, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4352 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4353
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4354 room = scol - col + tabwidth - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4355 if (room > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4356 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4357 // Get buffer name in NameBuff[]
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4358 get_trans_bufname(cwp->w_buffer);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4359 shorten_dir(NameBuff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4360 len = vim_strsize(NameBuff);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4361 p = NameBuff;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4362 if (has_mbyte)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4363 while (len > room)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4364 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4365 len -= ptr2cells(p);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4366 MB_PTR_ADV(p);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4367 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4368 else if (len > room)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4369 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4370 p += len - room;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4371 len = room;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4372 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4373 if (len > Columns - col - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4374 len = Columns - col - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4375
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4376 screen_puts_len(p, (int)STRLEN(p), 0, col, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4377 col += len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4378 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4379 screen_putchar(' ', 0, col++, attr);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4380
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4381 // Store the tab page number in TabPageIdxs[], so that
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4382 // jump_to_mouse() knows where each one is.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4383 ++tabcount;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4384 while (scol < col)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4385 TabPageIdxs[scol++] = tabcount;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4386 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4387
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4388 if (use_sep_chars)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4389 c = '_';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4390 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4391 c = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4392 screen_fill(0, 1, col, (int)Columns, c, c, attr_fill);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4393
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4394 // Draw the 'showcmd' information if 'showcmdloc' == "tabline".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4395 if (p_sc && *p_sloc == 't')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4396 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4397 int width = MIN(10, (int)Columns - col - (tabcount > 1) * 3);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4398
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4399 if (width > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4400 screen_puts_len(showcmd_buf, width, 0, (int)Columns
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4401 - width - (tabcount > 1) * 2, attr_nosel);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4402 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4403
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4404 // Put an "X" for closing the current tab if there are several.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4405 if (tabcount > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4406 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4407 screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4408 TabPageIdxs[Columns - 1] = -999;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4409 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4410 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4411
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4412 // Reset the flag here again, in case evaluating 'tabline' causes it to be
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4413 // set.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4414 redraw_tabline = FALSE;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4415 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4416
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4417 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4418 * Get buffer name for "buf" into NameBuff[].
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4419 * Takes care of special buffer names and translates special characters.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4420 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4421 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4422 get_trans_bufname(buf_T *buf)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4423 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4424 if (buf_spname(buf) != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4425 vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4426 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4427 home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4428 trans_characters(NameBuff, MAXPATHL);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4429 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4430
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4431 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4432 * Get the character to use in a status line. Get its attributes in "*attr".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4433 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4434 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4435 fillchar_status(int *attr, win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4436 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4437 int fill;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4438
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4439 #ifdef FEAT_TERMINAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4440 if (bt_terminal(wp->w_buffer))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4441 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4442 if (wp == curwin)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4443 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4444 *attr = HL_ATTR(HLF_ST);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4445 fill = wp->w_fill_chars.stl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4446 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4447 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4448 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4449 *attr = HL_ATTR(HLF_STNC);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4450 fill = wp->w_fill_chars.stlnc;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4451 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4452 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4453 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4454 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4455 if (wp == curwin)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4456 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4457 *attr = HL_ATTR(HLF_S);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4458 fill = wp->w_fill_chars.stl;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4459 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4460 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4461 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4462 *attr = HL_ATTR(HLF_SNC);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4463 fill = wp->w_fill_chars.stlnc;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4464 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4465 // Use fill when there is highlighting, and highlighting of current
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4466 // window differs, or the fillchars differ, or this is not the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4467 // current window
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4468 if (*attr != 0 && ((HL_ATTR(HLF_S) != HL_ATTR(HLF_SNC)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4469 || wp != curwin || ONE_WINDOW)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4470 || (wp->w_fill_chars.stl != wp->w_fill_chars.stlnc)))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4471 return fill;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4472 if (wp == curwin)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4473 return '^';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4474 return '=';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4475 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4476
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4477 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4478 * Get the character to use in a separator between vertically split windows.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4479 * Get its attributes in "*attr".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4480 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4481 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4482 fillchar_vsep(int *attr, win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4483 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4484 *attr = HL_ATTR(HLF_C);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4485 if (*attr == 0 && wp->w_fill_chars.vert == ' ')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4486 return '|';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4487 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4488 return wp->w_fill_chars.vert;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4489 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4490
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4491 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4492 * Return TRUE if redrawing should currently be done.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4493 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4494 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4495 redrawing(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4496 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4497 #ifdef FEAT_EVAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4498 if (disable_redraw_for_testing)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4499 return 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4500 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4501 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4502 return ((RedrawingDisabled == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4503 #ifdef FEAT_EVAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4504 || ignore_redraw_flag_for_testing
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4505 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4506 ) && !(p_lz && char_avail() && !KeyTyped && !do_redraw));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4507 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4508
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4509 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4510 * Return TRUE if printing messages should currently be done.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4511 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4512 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4513 messaging(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4514 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4515 return (!(p_lz && char_avail() && !KeyTyped));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4516 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4517
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4518 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4519 * Compute columns for ruler and shown command. 'sc_col' is also used to
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4520 * decide what the maximum length of a message on the status line can be.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4521 * If there is a status line for the last window, 'sc_col' is independent
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4522 * of 'ru_col'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4523 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4524
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4525 #define COL_RULER 17 // columns needed by standard ruler
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4526
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4527 void
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4528 comp_col(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4529 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4530 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4531
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4532 sc_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4533 ru_col = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4534 if (p_ru)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4535 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4536 #ifdef FEAT_STL_OPT
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4537 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4538 #else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4539 ru_col = COL_RULER + 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4540 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4541 // no last status line, adjust sc_col
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4542 if (!last_has_status)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4543 sc_col = ru_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4544 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4545 if (p_sc)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4546 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4547 sc_col += SHOWCMD_COLS;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4548 if (!p_ru || last_has_status) // no need for separating space
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4549 ++sc_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4550 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4551 sc_col = Columns - sc_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4552 ru_col = Columns - ru_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4553 if (sc_col <= 0) // screen too narrow, will become a mess
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4554 sc_col = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4555 if (ru_col <= 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4556 ru_col = 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4557 #ifdef FEAT_EVAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4558 set_vim_var_nr(VV_ECHOSPACE, sc_col - 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4559 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4560 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4561
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4562 #if defined(FEAT_LINEBREAK) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4563 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4564 * Return the width of the 'number' and 'relativenumber' column.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4565 * Caller may need to check if 'number' or 'relativenumber' is set.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4566 * Otherwise it depends on 'numberwidth' and the line count.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4567 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4568 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4569 number_width(win_T *wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4570 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4571 int n;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4572 linenr_T lnum;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4573
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4574 if (wp->w_p_rnu && !wp->w_p_nu)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4575 // cursor line shows "0"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4576 lnum = wp->w_height;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4577 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4578 // cursor line shows absolute line number
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4579 lnum = wp->w_buffer->b_ml.ml_line_count;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4580
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4581 if (lnum == wp->w_nrwidth_line_count && wp->w_nuw_cached == wp->w_p_nuw)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4582 return wp->w_nrwidth_width;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4583 wp->w_nrwidth_line_count = lnum;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4584
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4585 n = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4586 do
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4587 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4588 lnum /= 10;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4589 ++n;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4590 } while (lnum > 0);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4591
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4592 // 'numberwidth' gives the minimal width plus one
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4593 if (n < wp->w_p_nuw - 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4594 n = wp->w_p_nuw - 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4595
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4596 # ifdef FEAT_SIGNS
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4597 // If 'signcolumn' is set to 'number' and there is a sign to display, then
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4598 // the minimal width for the number column is 2.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4599 if (n < 2 && get_first_valid_sign(wp) != NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4600 && (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4601 n = 2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4602 # endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4603
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4604 wp->w_nrwidth_width = n;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4605 wp->w_nuw_cached = wp->w_p_nuw;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4606 return n;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4607 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4608 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4609
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4610 #if defined(FEAT_EVAL) || defined(PROTO)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4611 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4612 * Return the current cursor column. This is the actual position on the
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4613 * screen. First column is 0.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4614 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4615 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4616 screen_screencol(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4617 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4618 return screen_cur_col;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4619 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4620
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4621 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4622 * Return the current cursor row. This is the actual position on the screen.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4623 * First row is 0.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4624 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4625 int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4626 screen_screenrow(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4627 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4628 return screen_cur_row;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4629 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4630 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4631
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4632 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4633 * Calls mb_ptr2char_adv(p) and returns the character.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4634 * If "p" starts with "\x", "\u" or "\U" the hex or unicode value is used.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4635 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4636 static int
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4637 get_encoded_char_adv(char_u **p)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4638 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4639 char_u *s = *p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4640
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4641 if (s[0] == '\\' && (s[1] == 'x' || s[1] == 'u' || s[1] == 'U'))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4642 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4643 varnumber_T num = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4644 int bytes;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4645 int n;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4646
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4647 for (bytes = s[1] == 'x' ? 1 : s[1] == 'u' ? 2 : 4; bytes > 0; --bytes)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4648 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4649 *p += 2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4650 n = hexhex2nr(*p);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4651 if (n < 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4652 return 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4653 num = num * 256 + n;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4654 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4655 *p += 2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4656 return num;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4657 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4658 return mb_ptr2char_adv(p);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4659 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4660
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4661 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4662 * Handle setting 'listchars' or 'fillchars'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4663 * "value" points to either the global or the window-local value.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4664 * "is_listchars" is TRUE for "listchars" and FALSE for "fillchars".
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4665 * When "apply" is FALSE do not store the flags, only check for errors.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4666 * Assume monocell characters.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4667 * Returns error message, NULL if it's OK.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4668 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4669 static char *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4670 set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4671 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4672 int round, i, len, len2, entries;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4673 char_u *p, *s;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4674 int c1 = 0, c2 = 0, c3 = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4675 char_u *last_multispace = NULL; // Last occurrence of "multispace:"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4676 char_u *last_lmultispace = NULL; // Last occurrence of "leadmultispace:"
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4677 int multispace_len = 0; // Length of lcs-multispace string
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4678 int lead_multispace_len = 0; // Length of lcs-leadmultispace string
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4679
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4680 struct charstab
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4681 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4682 int *cp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4683 char *name;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4684 };
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4685 struct charstab *tab;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4686
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4687 static fill_chars_T fill_chars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4688 static struct charstab filltab[] =
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4689 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4690 {&fill_chars.stl, "stl"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4691 {&fill_chars.stlnc, "stlnc"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4692 {&fill_chars.vert, "vert"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4693 {&fill_chars.fold, "fold"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4694 {&fill_chars.foldopen, "foldopen"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4695 {&fill_chars.foldclosed, "foldclose"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4696 {&fill_chars.foldsep, "foldsep"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4697 {&fill_chars.diff, "diff"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4698 {&fill_chars.eob, "eob"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4699 {&fill_chars.lastline, "lastline"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4700 };
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4701
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4702 static lcs_chars_T lcs_chars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4703 struct charstab lcstab[] =
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4704 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4705 {&lcs_chars.eol, "eol"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4706 {&lcs_chars.ext, "extends"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4707 {&lcs_chars.nbsp, "nbsp"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4708 {&lcs_chars.prec, "precedes"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4709 {&lcs_chars.space, "space"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4710 {&lcs_chars.tab2, "tab"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4711 {&lcs_chars.trail, "trail"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4712 {&lcs_chars.lead, "lead"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4713 #ifdef FEAT_CONCEAL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4714 {&lcs_chars.conceal, "conceal"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4715 #else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4716 {NULL, "conceal"},
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4717 #endif
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4718 };
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4719
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4720 if (is_listchars)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4721 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4722 tab = lcstab;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4723 CLEAR_FIELD(lcs_chars);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4724 entries = ARRAY_LENGTH(lcstab);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4725 if (wp->w_p_lcs[0] == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4726 value = p_lcs; // local value is empty, use the global value
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4727 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4728 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4729 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4730 tab = filltab;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4731 entries = ARRAY_LENGTH(filltab);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4732 if (wp->w_p_fcs[0] == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4733 value = p_fcs; // local value is empty, us the global value
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4734 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4735
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4736 // first round: check for valid value, second round: assign values
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4737 for (round = 0; round <= 1; ++round)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4738 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4739 if (round > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4740 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4741 // After checking that the value is valid: set defaults.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4742 if (is_listchars)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4743 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4744 for (i = 0; i < entries; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4745 if (tab[i].cp != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4746 *(tab[i].cp) = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4747 lcs_chars.tab1 = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4748 lcs_chars.tab3 = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4749
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4750 if (multispace_len > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4751 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4752 lcs_chars.multispace = ALLOC_MULT(int, multispace_len + 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4753 if (lcs_chars.multispace != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4754 lcs_chars.multispace[multispace_len] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4755 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4756 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4757 lcs_chars.multispace = NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4758
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4759 if (lead_multispace_len > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4760 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4761 lcs_chars.leadmultispace =
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4762 ALLOC_MULT(int, lead_multispace_len + 1);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4763 lcs_chars.leadmultispace[lead_multispace_len] = NUL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4764 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4765 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4766 lcs_chars.leadmultispace = NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4767 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4768 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4769 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4770 fill_chars.stl = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4771 fill_chars.stlnc = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4772 fill_chars.vert = ' ';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4773 fill_chars.fold = '-';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4774 fill_chars.foldopen = '-';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4775 fill_chars.foldclosed = '+';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4776 fill_chars.foldsep = '|';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4777 fill_chars.diff = '-';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4778 fill_chars.eob = '~';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4779 fill_chars.lastline = '@';
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4780 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4781 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4782 p = value;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4783 while (*p)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4784 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4785 for (i = 0; i < entries; ++i)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4786 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4787 len = (int)STRLEN(tab[i].name);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4788 if (STRNCMP(p, tab[i].name, len) == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4789 && p[len] == ':'
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4790 && p[len + 1] != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4791 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4792 c2 = c3 = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4793 s = p + len + 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4794 c1 = get_encoded_char_adv(&s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4795 if (char2cells(c1) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4796 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4797 if (tab[i].cp == &lcs_chars.tab2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4798 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4799 if (*s == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4800 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4801 c2 = get_encoded_char_adv(&s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4802 if (char2cells(c2) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4803 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4804 if (!(*s == ',' || *s == NUL))
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4805 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4806 c3 = get_encoded_char_adv(&s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4807 if (char2cells(c3) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4808 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4809 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4810 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4811
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4812 if (*s == ',' || *s == NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4813 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4814 if (round > 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4815 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4816 if (tab[i].cp == &lcs_chars.tab2)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4817 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4818 lcs_chars.tab1 = c1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4819 lcs_chars.tab2 = c2;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4820 lcs_chars.tab3 = c3;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4821 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4822 else if (tab[i].cp != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4823 *(tab[i].cp) = c1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4824
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4825 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4826 p = s;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4827 break;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4828 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4829 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4830 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4831
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4832 if (i == entries)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4833 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4834 len = (int)STRLEN("multispace");
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4835 len2 = (int)STRLEN("leadmultispace");
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4836 if (is_listchars
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4837 && STRNCMP(p, "multispace", len) == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4838 && p[len] == ':'
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4839 && p[len + 1] != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4840 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4841 s = p + len + 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4842 if (round == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4843 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4844 // Get length of lcs-multispace string in first round
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4845 last_multispace = p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4846 multispace_len = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4847 while (*s != NUL && *s != ',')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4848 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4849 c1 = get_encoded_char_adv(&s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4850 if (char2cells(c1) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4851 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4852 ++multispace_len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4853 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4854 if (multispace_len == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4855 // lcs-multispace cannot be an empty string
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4856 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4857 p = s;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4858 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4859 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4860 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4861 int multispace_pos = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4862
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4863 while (*s != NUL && *s != ',')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4864 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4865 c1 = get_encoded_char_adv(&s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4866 if (p == last_multispace)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4867 lcs_chars.multispace[multispace_pos++] = c1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4868 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4869 p = s;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4870 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4871 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4872
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4873 else if (is_listchars
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4874 && STRNCMP(p, "leadmultispace", len2) == 0
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4875 && p[len2] == ':'
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4876 && p[len2 + 1] != NUL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4877 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4878 s = p + len2 + 1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4879 if (round == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4880 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4881 // get length of lcs-leadmultispace string in first
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4882 // round
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4883 last_lmultispace = p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4884 lead_multispace_len = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4885 while (*s != NUL && *s != ',')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4886 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4887 c1 = get_encoded_char_adv(&s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4888 if (char2cells(c1) > 1)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4889 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4890 ++lead_multispace_len;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4891 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4892 if (lead_multispace_len == 0)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4893 // lcs-leadmultispace cannot be an empty string
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4894 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4895 p = s;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4896 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4897 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4898 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4899 int multispace_pos = 0;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4900
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4901 while (*s != NUL && *s != ',')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4902 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4903 c1 = get_encoded_char_adv(&s);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4904 if (p == last_lmultispace)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4905 lcs_chars.leadmultispace[multispace_pos++] = c1;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4906 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4907 p = s;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4908 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4909 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4910 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4911 return e_invalid_argument;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4912 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4913
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4914 if (*p == ',')
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4915 ++p;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4916 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4917 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4918
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4919 if (apply)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4920 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4921 if (is_listchars)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4922 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4923 vim_free(wp->w_lcs_chars.multispace);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4924 vim_free(wp->w_lcs_chars.leadmultispace);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4925 wp->w_lcs_chars = lcs_chars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4926 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4927 else
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4928 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4929 wp->w_fill_chars = fill_chars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4930 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4931 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4932 else if (is_listchars)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4933 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4934 vim_free(lcs_chars.multispace);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4935 vim_free(lcs_chars.leadmultispace);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4936 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4937
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4938 return NULL; // no error
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4939 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4940
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4941 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4942 * Handle the new value of 'fillchars'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4943 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4944 char *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4945 set_fillchars_option(win_T *wp, char_u *val, int apply)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4946 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4947 return set_chars_option(wp, val, FALSE, apply);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4948 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4949
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4950 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4951 * Handle the new value of 'listchars'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4952 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4953 char *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4954 set_listchars_option(win_T *wp, char_u *val, int apply)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4955 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4956 return set_chars_option(wp, val, TRUE, apply);
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4957 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4958
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4959 /*
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4960 * Check all global and local values of 'listchars' and 'fillchars'.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4961 * Return an untranslated error messages if any of them is invalid, NULL
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4962 * otherwise.
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4963 */
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4964 char *
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4965 check_chars_options(void)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4966 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4967 tabpage_T *tp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4968 win_T *wp;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4969
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4970 if (set_listchars_option(curwin, p_lcs, FALSE) != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4971 return e_conflicts_with_value_of_listchars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4972 if (set_fillchars_option(curwin, p_fcs, FALSE) != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4973 return e_conflicts_with_value_of_fillchars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4974 FOR_ALL_TAB_WINDOWS(tp, wp)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4975 {
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4976 if (set_listchars_option(wp, wp->w_p_lcs, FALSE) != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4977 return e_conflicts_with_value_of_listchars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4978 if (set_fillchars_option(wp, wp->w_p_fcs, FALSE) != NULL)
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4979 return e_conflicts_with_value_of_fillchars;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4980 }
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4981 return NULL;
448aef880252 normalize line endings
Christian Brabandt <cb@256bit.org>
parents: 32533
diff changeset
4982 }