annotate src/message.c @ 41:f529edb9bab3 v7.0025

updated for version 7.0025
author vimboss
date Mon, 27 Dec 2004 21:59:20 +0000
parents 410fa1a31baf
children 8800a9c402b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * message.c: functions for displaying messages on the command line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #define MESSAGE_FILE /* don't include prototype for smsg() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #ifdef HAVE_STDARG_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # include <stdarg.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 static void reset_last_sourcing __ARGS((void));
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
23 static int other_sourcing_name __ARGS((void));
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
24 static char_u *get_emsg_source __ARGS((void));
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
25 static char_u *get_emsg_lnum __ARGS((void));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 static void add_msg_hist __ARGS((char_u *s, int len, int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 static void hit_return_msg __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 static void msg_home_replace_attr __ARGS((char_u *fname, int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 static char_u *screen_puts_mbyte __ARGS((char_u *s, int l, int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 static void msg_puts_attr_len __ARGS((char_u *str, int maxlen, int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 static void t_puts __ARGS((int t_col, char_u *t_s, char_u *s, int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 static void msg_screen_putchar __ARGS((int c, int attr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 static int msg_check_screen __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 static void redir_write __ARGS((char_u *s, int maxlen));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #ifdef FEAT_CON_DIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 static char_u *msg_show_console_dialog __ARGS((char_u *message, char_u *buttons, int dfltbutton));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 static int confirm_msg_used = FALSE; /* displaying confirm_msg */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 static char_u *confirm_msg = NULL; /* ":confirm" message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 static char_u *confirm_msg_tail; /* tail of confirm_msg */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 struct msg_hist
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 struct msg_hist *next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 char_u *msg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 static struct msg_hist *first_msg_hist = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 static struct msg_hist *last_msg_hist = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 static int msg_hist_len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 static int msg_hist_off = FALSE; /* don't add messages to history */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 * When writing messages to the screen, there are many different situations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 * A number of variables is used to remember the current state:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 * msg_didany TRUE when messages were written since the last time the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 * user reacted to a prompt.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 * Reset: After hitting a key for the hit-return prompt,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 * hitting <CR> for the command line or input().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 * Set: When any message is written to the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 * msg_didout TRUE when something was written to the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 * Reset: When advancing to the next line, when the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 * text can be overwritten.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 * Set: When any message is written to the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 * msg_nowait No extra delay for the last drawn message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 * Used in normal_cmd() before the mode message is drawn.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 * emsg_on_display There was an error message recently. Indicates that there
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 * should be a delay before redrawing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 * msg_scroll The next message should not overwrite the current one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 * msg_scrolled How many lines the screen has been scrolled (because of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 * messages). Used in update_screen() to scroll the screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 * back. Incremented each time the screen scrolls a line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 * msg_scrolled_ign TRUE when msg_scrolled is non-zero and msg_puts_attr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 * writes something without scrolling should not make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 * need_wait_return to be set. This is a hack to make ":ts"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 * work without an extra prompt.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 * lines_left Number of lines available for messages before the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 * more-prompt is to be given.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 * need_wait_return TRUE when the hit-return prompt is needed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 * Reset: After giving the hit-return prompt, when the user
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 * has answered some other prompt.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 * Set: When the ruler or typeahead display is overwritten,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 * scrolling the screen for some message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 * keep_msg Message to be displayed after redrawing the screen, in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 * main_loop().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 * This is an allocated string or NULL when not used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 * msg(s) - displays the string 's' on the status line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 * When terminal not initialized (yet) mch_errmsg(..) is used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 * return TRUE if wait_return not called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 msg(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 return msg_attr_keep(s, 0, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 msg_attr(s, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 return msg_attr_keep(s, attr, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 msg_attr_keep(s, attr, keep)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 int keep; /* TRUE: set keep_msg if it doesn't scroll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 static int entered = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 char_u *buf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 if (attr == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 set_vim_var_string(VV_STATUSMSG, s, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 * It is possible that displaying a messages causes a problem (e.g.,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 * when redrawing the window), which causes another message, etc.. To
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 * break this loop, limit the recursiveness to 3 levels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 if (entered >= 3)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 ++entered;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 /* Add message to history (unless it's a repeated kept message or a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 * truncated message) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 if (s != keep_msg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 || (*s != '<'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 && last_msg_hist != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 && last_msg_hist->msg != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 && STRCMP(s, last_msg_hist->msg)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 add_msg_hist(s, -1, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 /* When displaying keep_msg, don't let msg_start() free it, caller must do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 * that. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 if (s == keep_msg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 keep_msg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 /* Truncate the message if needed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 buf = msg_strtrunc(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 s = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 msg_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 msg_outtrans_attr(s, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 msg_clr_eos();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 retval = msg_end();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 if (keep && retval && vim_strsize(s) < (int)(Rows - cmdline_row - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 * Columns + sc_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 set_keep_msg(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 keep_msg_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 --entered;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 * Truncate a string such that it can be printed without causing a scroll.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 * Returns an allocated string or NULL when no truncating is done.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 msg_strtrunc(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 char_u *buf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 int room;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 /* May truncate message to avoid a hit-return prompt */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 if (!msg_scroll && !need_wait_return && shortmess(SHM_TRUNCALL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 && !exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 len = vim_strsize(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 if (len > room && room > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 /* may have up to 18 bytes per cell (6 per char, up to two
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 * composing chars) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 buf = alloc((room + 2) * 18);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 else if (enc_dbcs == DBCS_JPNU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 /* may have up to 2 bytes per cell for euc-jp */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 buf = alloc((room + 2) * 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 buf = alloc(room + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 trunc_string(s, buf, room);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 * Truncate a string "s" to "buf" with cell width "room".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 * "s" and "buf" may be equal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 trunc_string(s, buf, room)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 int room;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 int half;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 int e;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 room -= 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 half = room / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 /* First part: Start of the string. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 for (e = 0; len < half; ++e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 if (s[e] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 /* text fits without truncating! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 buf[e] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 n = ptr2cells(s + e);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 if (len + n >= half)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 len += n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 buf[e] = s[e];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 for (n = (*mb_ptr2len_check)(s + e); --n > 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 ++e;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 buf[e] = s[e];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 /* Last part: End of the string. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 i = e;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 if (enc_dbcs != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 /* For DBCS going backwards in a string is slow, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 * computing the cell width isn't too slow: go forward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 * until the rest fits. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 n = vim_strsize(s + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 while (len + n > room)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 n -= ptr2cells(s + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 i += (*mb_ptr2len_check)(s + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 else if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 /* For UTF-8 we can go backwards easily. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 i = (int)STRLEN(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 half = i - (*mb_head_off)(s, s + i - 1) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 n = ptr2cells(s + half);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 if (len + n > room)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 len += n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 i = half;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 for (i = (int)STRLEN(s); len + (n = ptr2cells(s + i - 1)) <= room; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 len += n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 /* Set the middle and copy the last part. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 mch_memmove(buf + e, "...", (size_t)3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 mch_memmove(buf + e + 3, s + i, STRLEN(s + i) + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 * Automatic prototype generation does not understand this function.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 * Note: Caller of smgs() and smsg_attr() must check the resulting string is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 * shorter than IOSIZE!!!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 #ifndef PROTO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 # ifndef HAVE_STDARG_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 _RTLENTRYF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 smsg __ARGS((char_u *, long, long, long,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 long, long, long, long, long, long, long));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 _RTLENTRYF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 smsg_attr __ARGS((int, char_u *, long, long, long,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 long, long, long, long, long, long, long));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 /* VARARGS */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 _RTLENTRYF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 smsg(s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 return smsg_attr(0, s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 /* VARARGS */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 _RTLENTRYF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 smsg_attr(attr, s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 sprintf((char *)IObuff, (char *)s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 return msg_attr(IObuff, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 # else /* HAVE_STDARG_H */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 _RTLENTRYF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 smsg(char_u *s, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 va_list arglist;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 va_start(arglist, s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 # ifdef HAVE_VSNPRINTF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 vsnprintf((char *)IObuff, IOSIZE, (char *)s, arglist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 vsprintf((char *)IObuff, (char *)s, arglist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 va_end(arglist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 return msg(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 _RTLENTRYF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 smsg_attr(int attr, char_u *s, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 va_list arglist;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 va_start(arglist, s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 # ifdef HAVE_VSNPRINTF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 vsnprintf((char *)IObuff, IOSIZE, (char *)s, arglist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 vsprintf((char *)IObuff, (char *)s, arglist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 va_end(arglist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 return msg_attr(IObuff, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 # endif /* HAVE_STDARG_H */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 * Remember the last sourcing name/lnum used in an error message, so that it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 * isn't printed each time when it didn't change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 static int last_sourcing_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 static char_u *last_sourcing_name = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 * Reset the last used sourcing name/lnum. Makes sure it is displayed again
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 * for the next error message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 reset_last_sourcing()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 vim_free(last_sourcing_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 last_sourcing_name = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 last_sourcing_lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 /*
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
403 * Return TRUE if "sourcing_name" differs from "last_sourcing_name".
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
404 */
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
405 static int
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
406 other_sourcing_name()
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
407 {
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
408 if (sourcing_name != NULL)
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
409 {
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
410 if (last_sourcing_name != NULL)
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
411 return STRCMP(sourcing_name, last_sourcing_name) != 0;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
412 return TRUE;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
413 }
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
414 return FALSE;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
415 }
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
416
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
417 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 * Get the message about the source, as used for an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 * Returns an allocated string with room for one more character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 * Returns NULL when no message is to be given.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 static char_u *
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
423 get_emsg_source()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 char_u *Buf, *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
427 if (sourcing_name != NULL && other_sourcing_name())
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 p = (char_u *)_("Error detected while processing %s:");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 Buf = alloc((unsigned)(STRLEN(sourcing_name) + STRLEN(p)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 if (Buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 sprintf((char *)Buf, (char *)p, sourcing_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 return Buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 * Get the message about the source lnum, as used for an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 * Returns an allocated string with room for one more character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 * Returns NULL when no message is to be given.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 static char_u *
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
444 get_emsg_lnum()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 char_u *Buf, *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 /* lnum is 0 when executing a command from the command line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 * argument, we don't want a line number then */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 if (sourcing_name != NULL
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
451 && (other_sourcing_name() || sourcing_lnum != last_sourcing_lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 && sourcing_lnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 p = (char_u *)_("line %4ld:");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 Buf = alloc((unsigned)(STRLEN(p) + 20));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 if (Buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 sprintf((char *)Buf, (char *)p, (long)sourcing_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 return Buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 /*
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
464 * Display name and line number for the source of an error.
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
465 * Remember the file name and line number, so that for the next error the info
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
466 * is only displayed if it changed.
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
467 */
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
468 void
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
469 msg_source(attr)
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
470 int attr;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
471 {
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
472 char_u *p;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
473
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
474 ++no_wait_return;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
475 p = get_emsg_source();
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
476 if (p != NULL)
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
477 {
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
478 msg_attr(p, attr);
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
479 vim_free(p);
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
480 }
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
481 p = get_emsg_lnum();
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
482 if (p != NULL)
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
483 {
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
484 msg_attr(p, hl_attr(HLF_N));
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
485 vim_free(p);
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
486 last_sourcing_lnum = sourcing_lnum; /* only once for each line */
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
487 }
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
488
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
489 /* remember the last sourcing name printed, also when it's empty */
36
125e80798a85 updated for version 7.0021
vimboss
parents: 28
diff changeset
490 if (sourcing_name == NULL || other_sourcing_name())
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
491 {
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
492 vim_free(last_sourcing_name);
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
493 if (sourcing_name == NULL)
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
494 last_sourcing_name = NULL;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
495 else
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
496 last_sourcing_name = vim_strsave(sourcing_name);
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
497 }
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
498 --no_wait_return;
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
499 }
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
500
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
501 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 * emsg() - display an error message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 * Rings the bell, if appropriate, and calls message() to do the real work
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 * When terminal not initialized (yet) mch_errmsg(..) is used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 * return TRUE if wait_return not called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 emsg(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 int ignore = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 int severe;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 called_emsg = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 * If "emsg_severe" is TRUE: When an error exception is to be thrown, prefer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 * this message over previous messages for the same command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 severe = emsg_severe;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 emsg_severe = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 * If "emsg_off" is set: no error messages at the moment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 * If 'debug' is set: do error message anyway, but without side effects.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 * If "emsg_skip" is set: never do error messages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 if ((emsg_off > 0 && *p_debug == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 || emsg_skip > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 if (!emsg_off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 * Cause a throw of an error exception if appropriate. Don't display
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 * the error message in this case. (If no matching catch clause will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 * be found, the message will be displayed later on.) "ignore" is set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 * when the message should be ignored completely (used for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 * interrupt message).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 if (cause_errthrow(s, severe, &ignore) == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 if (!ignore)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 did_emsg = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 /* set "v:errmsg", also when using ":silent! cmd" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 set_vim_var_string(VV_ERRMSG, s, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 * When using ":silent! cmd" ignore error messsages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 * But do write it to the redirection file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 if (emsg_silent != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 msg_start();
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
571 p = get_emsg_source();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 STRCAT(p, "\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 redir_write(p, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 }
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
578 p = get_emsg_lnum();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 STRCAT(p, "\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 redir_write(p, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 redir_write(s, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 /* Reset msg_silent, an error causes messages to be switched back on. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 msg_silent = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 cmd_silent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 if (global_busy) /* break :global command */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 ++global_busy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 if (p_eb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 beep_flush(); /* also includes flush_buffers() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 flush_buffers(FALSE); /* flush internal buffers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 did_emsg = TRUE; /* flag for DoOneCmd() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 emsg_on_display = TRUE; /* remember there is an error message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 ++msg_scroll; /* don't overwrite a previous message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 attr = hl_attr(HLF_E); /* set highlight mode for error messages */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 if (msg_scrolled)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 need_wait_return = TRUE; /* needed in case emsg() is called after
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 * wait_return has reset need_wait_return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 * and a redraw is expected because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 * msg_scrolled is non-zero */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 * Display name and line number for the source of the error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 */
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
615 msg_source(attr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 * Display the error message itself.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 */
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 8
diff changeset
620 msg_nowait = FALSE; /* wait for this msg */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 return msg_attr(s, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 * Print an error message with one "%s" and one string argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 emsg2(s, a1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 char_u *s, *a1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 return emsg3(s, a1, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 * Print an error message with one or two "%s" and one or two string arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 emsg3(s, a1, a2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 char_u *s, *a1, *a2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 if ((emsg_off > 0 && *p_debug == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 || emsg_skip > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 return TRUE; /* no error messages at the moment */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 /* Check for NULL strings (just in case) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 if (a1 == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 a1 = (char_u *)"[NULL]";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 if (a2 == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 a2 = (char_u *)"[NULL]";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 /* Check for very long strings (can happen with ":help ^A<CR>"). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 if (STRLEN(s) + STRLEN(a1) + STRLEN(a2) >= (size_t)IOSIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 a1 = a2 = (char_u *)_("[string too long]");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 sprintf((char *)IObuff, (char *)s, (char *)a1, (char *)a2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 return emsg(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 * Print an error message with one "%ld" and one long int argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 emsgn(s, n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 if ((emsg_off > 0 && *p_debug == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 || emsg_skip > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 return TRUE; /* no error messages at the moment */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 sprintf((char *)IObuff, (char *)s, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 return emsg(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 * Like msg(), but truncate to a single line if p_shm contains 't', or when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 * "force" is TRUE. This truncates in another way as for normal messages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 * Careful: The string may be changed by msg_may_trunc()!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 * Returns a pointer to the printed message, if wait_return() not called.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 msg_trunc_attr(s, force, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 int force;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 /* Add message to history before truncating */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 add_msg_hist(s, -1, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 s = msg_may_trunc(force, s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 msg_hist_off = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 n = msg_attr(s, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 msg_hist_off = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 if (n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 return s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 * Check if message "s" should be truncated at the start (for filenames).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 * Return a pointer to where the truncated message starts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 * Note: May change the message by replacing a character with '<'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 msg_may_trunc(force, s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 int force;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 int room;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 && (n = (int)STRLEN(s) - room) > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 int size = vim_strsize(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 for (n = 0; size >= room; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 size -= (*mb_ptr2cells)(s + n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 n += (*mb_ptr2len_check)(s + n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 --n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 s += n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 *s = '<';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 return s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 add_msg_hist(s, len, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 int len; /* -1 for undetermined length */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 struct msg_hist *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 if (msg_hist_off || msg_silent != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 /* Don't let the message history get too big */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 while (msg_hist_len > 20)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 p = first_msg_hist;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 first_msg_hist = p->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 vim_free(p->msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 --msg_hist_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 /* allocate an entry and add the message at the end of the history */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 p = (struct msg_hist *)alloc((int)sizeof(struct msg_hist));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 if (len < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 len = (int)STRLEN(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 /* remove leading and trailing newlines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 while (len > 0 && *s == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 ++s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 --len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 while (len > 0 && s[len - 1] == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 --len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 p->msg = vim_strnsave(s, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 p->next = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 p->attr = attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 if (last_msg_hist != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 last_msg_hist->next = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 last_msg_hist = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 if (first_msg_hist == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 first_msg_hist = last_msg_hist;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 ++msg_hist_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 * ":messages" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 ex_messages(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 struct msg_hist *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 msg_hist_off = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 s = mch_getenv((char_u *)"LANG");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 if (s != NULL && *s != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 msg_attr((char_u *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 hl_attr(HLF_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 for (p = first_msg_hist; p != NULL; p = p->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 if (p->msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 msg_attr(p->msg, p->attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 msg_hist_off = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
816 #if defined(FEAT_CON_DIALOG) || defined(FIND_REPLACE_DIALOG) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 * Call this after prompting the user. This will avoid a hit-return message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 * and a delay.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 */
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
821 void
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 msg_end_prompt()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 emsg_on_display = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 cmdline_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 msg_clr_eos();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 * wait for the user to hit a key (normally a return)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 * if 'redraw' is TRUE, clear and redraw the screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 * if 'redraw' is FALSE, just redraw the screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 * if 'redraw' is -1, don't redraw at all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 wait_return(redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 int redraw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 int oldState;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 int tmpState;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 #ifndef ORG_HITRETURN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 int had_got_int;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 if (redraw == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 must_redraw = CLEAR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 /* If using ":silent cmd", don't wait for a return. Also don't set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 * need_wait_return to do it later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 if (msg_silent != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 * With the global command (and some others) we only need one return at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 * end. Adjust cmdline_row to avoid the next message overwriting the last one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 * When inside vgetc(), we can't wait for a typed character at all.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 if (vgetc_busy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 if (no_wait_return)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 need_wait_return = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 if (!exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 cmdline_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 redir_off = TRUE; /* don't redirect this message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 oldState = State;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 if (quit_more)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 c = CAR; /* just pretend CR was hit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 quit_more = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 else if (exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 MSG_PUTS(" "); /* make sure the cursor is on the right line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 c = CAR; /* no need for a return in ex mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 /* Make sure the hit-return prompt is on screen when 'guioptions' was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 * just changed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 screenalloc(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 State = HITRETURN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 setmouse();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 #ifdef USE_ON_FLY_SCROLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 dont_scroll = TRUE; /* disallow scrolling here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 hit_return_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 #ifdef ORG_HITRETURN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 c = safe_vgetc();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 } while (vim_strchr((char_u *)"\r\n: ", c) == NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 if (c == ':') /* this can vi too (but not always!) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 stuffcharReadbuff(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 /* Remember "got_int", if it is set vgetc() probably returns a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 * CTRL-C, but we need to loop then. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 had_got_int = got_int;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 c = safe_vgetc();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 if (!global_busy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 #ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 /* Strange way to allow copying (yanking) a modeless selection at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 * the hit-enter prompt. Use CTRL-Y, because the same is used in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 * Cmdline-mode and it's harmless when there is no selection. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 if (c == Ctrl_Y && clip_star.state == SELECT_DONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 clip_copy_modeless_selection(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 c = K_IGNORE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 } while ((had_got_int && c == Ctrl_C)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 || c == K_IGNORE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 || c == K_LEFTDRAG || c == K_LEFTRELEASE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 || c == K_MIDDLEDRAG || c == K_MIDDLERELEASE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 || c == K_RIGHTDRAG || c == K_RIGHTRELEASE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 || c == K_MOUSEDOWN || c == K_MOUSEUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 || (!mouse_has(MOUSE_RETURN)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 && mouse_row < msg_row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 && (c == K_LEFTMOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 || c == K_MIDDLEMOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 || c == K_RIGHTMOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 || c == K_X1MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 || c == K_X2MOUSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 * Avoid that the mouse-up event causes visual mode to start.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 || c == K_X1MOUSE || c == K_X2MOUSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 stuffcharReadbuff(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 do_redraw = TRUE; /* need a redraw even though there is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 something in the stuff buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 redir_off = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 * If the user hits ':', '?' or '/' we get a command line from the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 * line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 if (c == ':' || c == '?' || c == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 if (!exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 cmdline_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 skip_redraw = TRUE; /* skip redraw once */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 do_redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 * If the window size changed set_shellsize() will redraw the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 * Otherwise the screen is only redrawn if 'redraw' is set and no ':'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 * typed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 tmpState = State;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 State = oldState; /* restore State before set_shellsize */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 setmouse();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 msg_check();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 #if defined(UNIX) || defined(VMS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 * When switching screens, we need to output an extra newline on exit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 if (swapping_screen() && !termcap_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 newline_on_exit = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 did_wait_return = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 emsg_on_display = FALSE; /* can delete error message now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 lines_left = -1; /* reset lines_left at next msg_start() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 reset_last_sourcing();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 if (keep_msg != NULL && vim_strsize(keep_msg) >=
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 (Rows - cmdline_row - 1) * Columns + sc_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 vim_free(keep_msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 keep_msg = NULL; /* don't redisplay message, it's too long */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 if (tmpState == SETWSIZE) /* got resize event while in vgetc() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 starttermcap(); /* start termcap before redrawing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 shell_resized();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 else if (!skip_redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 && (redraw == TRUE || (msg_scrolled != 0 && redraw != -1)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 starttermcap(); /* start termcap before redrawing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 * Write the hit-return prompt.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 hit_return_msg()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 if (msg_didout) /* start on a new line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 if (got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 MSG_PUTS(_("Interrupt: "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 #ifdef ORG_HITRETURN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 MSG_PUTS_ATTR(_("Hit ENTER to continue"), hl_attr(HLF_R));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 MSG_PUTS_ATTR(_("Hit ENTER or type command to continue"), hl_attr(HLF_R));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 if (!msg_use_printf())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 msg_clr_eos();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 * Set "keep_msg" to "s". Free the old value and check for NULL pointer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 set_keep_msg(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 vim_free(keep_msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 if (s != NULL && msg_silent == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 keep_msg = vim_strsave(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 keep_msg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 * Prepare for outputting characters in the command line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 msg_start()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 int did_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 vim_free(keep_msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 keep_msg = NULL; /* don't display old message now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 if (!msg_scroll && full_screen) /* overwrite last message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 msg_row = cmdline_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 msg_col =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 cmdmsg_rl ? Columns - 1 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 else if (msg_didout) /* start message on next line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 did_return = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 if (exmode_active != EXMODE_NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 cmdline_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 if (!msg_didany || lines_left < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 msg_starthere();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 if (msg_silent == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 msg_didout = FALSE; /* no output on current line yet */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 cursor_off();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 /* when redirecting, may need to start a new line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 if (!did_return)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 redir_write((char_u *)"\n", -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 * Note that the current msg position is where messages start.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 msg_starthere()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 lines_left = cmdline_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 msg_didany = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 msg_putchar(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 msg_putchar_attr(c, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 msg_putchar_attr(c, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 char_u buf[MB_MAXBYTES + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 char_u buf[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 if (IS_SPECIAL(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 buf[0] = K_SPECIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 buf[1] = K_SECOND(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 buf[2] = K_THIRD(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 buf[3] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 buf[(*mb_char2bytes)(c, buf)] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 buf[0] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 buf[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 msg_puts_attr(buf, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 msg_outnum(n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 char_u buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 sprintf((char *)buf, "%ld", n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 msg_puts(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 msg_home_replace(fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 msg_home_replace_attr(fname, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 #if defined(FEAT_FIND_ID) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 msg_home_replace_hl(fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 msg_home_replace_attr(fname, hl_attr(HLF_D));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 msg_home_replace_attr(fname, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 name = home_replace_save(NULL, fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 if (name != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 msg_outtrans_attr(name, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 * Output 'len' characters in 'str' (including NULs) with translation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 * if 'len' is -1, output upto a NUL character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 * Use attributes 'attr'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 * Return the number of characters it takes on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 msg_outtrans(str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 return msg_outtrans_attr(str, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 msg_outtrans_attr(str, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 return msg_outtrans_len_attr(str, (int)STRLEN(str), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 msg_outtrans_len(str, len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 return msg_outtrans_len_attr(str, len, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 * Output one character at "p". Return pointer to the next character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 * Handles multi-byte characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 msg_outtrans_one(p, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 msg_outtrans_len_attr(p, l, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 return p + l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 msg_puts_attr(transchar_byte(*p), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 return p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 msg_outtrans_len_attr(msgstr, len, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 char_u *msgstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 int retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 char_u *str = msgstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 char_u *plain_start = msgstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 int mb_l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 /* if MSG_HIST flag set, add message to history */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 if (attr & MSG_HIST)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 add_msg_hist(str, len, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 attr &= ~MSG_HIST;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 /* If the string starts with a composing character first draw a space on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 * which the composing char can be drawn. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 if (enc_utf8 && utf_iscomposing(utf_ptr2char(msgstr)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 msg_puts_attr((char_u *)" ", attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 * Go over the string. Special characters are translated and printed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 * Normal characters are printed several at a time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 while (--len >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 /* Don't include composing chars after the end. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 mb_l = utfc_ptr2len_check_len(str, len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 else if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 mb_l = (*mb_ptr2len_check)(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 mb_l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 if (has_mbyte && mb_l > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 c = (*mb_ptr2char)(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 if (vim_isprintc(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 /* printable multi-byte char: count the cells. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 retval += (*mb_ptr2cells)(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 /* unprintable multi-byte char: print the printable chars so
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 * far and the translation of the unprintable char. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 if (str > plain_start)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 msg_puts_attr_len(plain_start, (int)(str - plain_start),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 plain_start = str + mb_l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 msg_puts_attr(transchar(c), attr == 0 ? hl_attr(HLF_8) : attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 retval += char2cells(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 len -= mb_l - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 str += mb_l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 s = transchar_byte(*str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 if (s[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 /* unprintable char: print the printable chars so far and the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 * translation of the unprintable char. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 if (str > plain_start)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 msg_puts_attr_len(plain_start, (int)(str - plain_start),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 plain_start = str + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 msg_puts_attr(s, attr == 0 ? hl_attr(HLF_8) : attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 retval += ptr2cells(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 ++str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 if (str > plain_start)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 /* print the printable chars at the end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 msg_puts_attr_len(plain_start, (int)(str - plain_start), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 #if defined(FEAT_QUICKFIX) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 msg_make(arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 char_u *arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 static char_u *str = (char_u *)"eeffoc", *rs = (char_u *)"Plon#dqg#vxjduB";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 for (i = 5; *arg && i >= 0; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 if (*arg++ != str[i])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 if (i < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 for (i = 0; rs[i]; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 msg_putchar(rs[i] - 3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 * Output the string 'str' upto a NUL character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 * Return the number of characters it takes on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 * If K_SPECIAL is encountered, then it is taken in conjunction with the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 * following character and shown as <F1>, <S-Up> etc. Any other character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 * which is not printable shown in <> form.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 * If 'from' is TRUE (lhs of a mapping), a space is shown as <Space>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 * If a character is displayed in one of these special ways, is also
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 * highlighted (its highlight name is '8' in the p_hl variable).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 * Otherwise characters are not highlighted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 * This function is used to show mappings, where we want to see how to type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 * the character/string -- webb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 msg_outtrans_special(strstart, from)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 char_u *strstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 int from; /* TRUE for lhs of a mapping */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 char_u *str = strstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 int retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 char_u *string;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 while (*str != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 /* Leading and trailing spaces need to be displayed in <> form. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 if ((str == strstart || str[1] == NUL) && *str == ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 string = (char_u *)"<Space>";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 ++str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 string = str2special(&str, from);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 len = vim_strsize(string);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 /* Highlight special keys */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 msg_puts_attr(string, len > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 && (*mb_ptr2len_check)(string) <= 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 ? attr : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 retval += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 * Return the printable string for the key codes at "*sp".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 * Used for translating the lhs or rhs of a mapping to printable chars.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 * Advances "sp" to the next code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 str2special(sp, from)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 char_u **sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 int from; /* TRUE for lhs of mapping */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 static char_u buf[7];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 char_u *str = *sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 int modifiers = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 int special = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 /* Try to un-escape a multi-byte character. Return the un-escaped
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 * string if it is a multi-byte character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 p = mb_unescape(sp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 c = *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 if (str[1] == KS_MODIFIER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 modifiers = str[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 str += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 c = *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 c = TO_SPECIAL(str[1], str[2]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 str += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 if (c == K_ZERO) /* display <Nul> as ^@ */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 c = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 if (IS_SPECIAL(c) || modifiers) /* special key */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 special = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 *sp = str + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 /* For multi-byte characters check for an illegal byte. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len_check)(str))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 transchar_nonprint(buf, c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 /* Make unprintable characters in <> form, also <M-Space> and <Tab>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 * Use <Space> only for lhs of a mapping. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 if (special || char2cells(c) > 1 || (from && c == ' '))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 return get_special_key_name(c, modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 buf[0] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 buf[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 * Translate a key sequence into special key names.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 str2specialbuf(sp, buf, len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 char_u *sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 *buf = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 while (*sp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 s = str2special(&sp, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 if ((int)(STRLEN(s) + STRLEN(buf)) < len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 STRCAT(buf, s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 * print line for :print or :list command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 msg_prt_line(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 int col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 int n_extra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 int c_extra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 char_u *p_extra = NULL; /* init to make SASC shut up */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 int attr= 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 char_u *trail = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 char_u buf[MB_MAXBYTES + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 /* find start of trailing whitespace */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 if (curwin->w_p_list && lcs_trail)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 trail = s + STRLEN(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 while (trail > s && vim_iswhite(trail[-1]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 --trail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 /* output a space for an empty line, otherwise the line will be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 * overwritten */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 if (*s == NUL && !(curwin->w_p_list && lcs_eol != NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 if (n_extra)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 --n_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 if (c_extra)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 c = c_extra;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 c = *p_extra++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 else if (has_mbyte && (l = (*mb_ptr2len_check)(s)) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 col += (*mb_ptr2cells)(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 mch_memmove(buf, s, (size_t)l);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 buf[l] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 msg_puts_attr(buf, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 s += l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 c = *s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 if (c == TAB && (!curwin->w_p_list || lcs_tab1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 /* tab amount depends on current column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 n_extra = curbuf->b_p_ts - col % curbuf->b_p_ts - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 if (!curwin->w_p_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 c = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 c_extra = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 c = lcs_tab1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 c_extra = lcs_tab2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 else if (c == NUL && curwin->w_p_list && lcs_eol != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 p_extra = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 n_extra = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 c = lcs_eol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 attr = hl_attr(HLF_AT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 --s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 else if (c != NUL && (n = byte2cells(c)) > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 n_extra = n - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 p_extra = transchar_byte(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 c_extra = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 c = *p_extra++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 else if (c == ' ' && trail != NULL && s > trail)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 c = lcs_trail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 attr = hl_attr(HLF_8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 if (c == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 msg_putchar_attr(c, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 col++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 msg_clr_eos();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 * Use screen_puts() to output one multi-byte character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 * Return the pointer "s" advanced to the next character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 screen_puts_mbyte(s, l, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 int cw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 msg_didout = TRUE; /* remember that line is not empty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 cw = (*mb_ptr2cells)(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 if (cw > 1 && (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 cmdmsg_rl ? msg_col <= 1 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 msg_col == Columns - 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 /* Doesn't fit, print a highlighted '>' to fill it up. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 msg_screen_putchar('>', hl_attr(HLF_AT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 return s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 screen_puts_len(s, l, msg_row, msg_col, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 if (cmdmsg_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 msg_col -= cw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 if (msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 msg_col = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 ++msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 msg_col += cw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 if (msg_col >= Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 ++msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 return s + l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 * Output a string to the screen at position msg_row, msg_col.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 * Update msg_row and msg_col for the next message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 msg_puts(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 msg_puts_attr(s, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 msg_puts_title(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 msg_puts_attr(s, hl_attr(HLF_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 #if defined(FEAT_CSCOPE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 * if printing a string will exceed the screen width, print "..." in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 * middle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660 msg_puts_long(longstr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 char_u *longstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 msg_puts_long_len_attr(longstr, (int)strlen((char *)longstr), 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 * Show a message in such a way that it always fits in the line. Cut out a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 * part in the middle and replace it with "..." when necessary.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 * Does not handle multi-byte characters!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 msg_puts_long_attr(longstr, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 char_u *longstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 msg_puts_long_len_attr(longstr, (int)strlen((char *)longstr), attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 msg_puts_long_len_attr(longstr, len, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 char_u *longstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 int slen = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 int room;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 room = Columns - msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 if (len > room && room >= 20)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 slen = (room - 3) / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 msg_outtrans_len_attr(longstr, slen, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 msg_puts_attr((char_u *)"...", hl_attr(HLF_8));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 msg_outtrans_len_attr(longstr + len - slen, slen, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 * Basic function for writing a message with highlight attributes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 msg_puts_attr(s, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 msg_puts_attr_len(s, -1, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 * Like msg_puts_attr(), but with a maximum length "maxlen" (in bytes).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 * When "maxlen" is -1 there is no maximum length.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 * When "maxlen" is >= 0 the message is not put in the history.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 msg_puts_attr_len(str, maxlen, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 int maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 int oldState;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 char_u *s = str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 char_u buf[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 char_u *t_s = str; /* string from "t_s" to "s" is still todo */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 int t_col = 0; /* screen cells todo, 0 when "t_s" not used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 int cw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734 * If redirection is on, also write to the redirection file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 redir_write(s, maxlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 * Don't print anything when using ":silent cmd".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 if (msg_silent != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 /* if MSG_HIST flag set, add message to history */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 if ((attr & MSG_HIST) && maxlen < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 add_msg_hist(s, -1, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 attr &= ~MSG_HIST;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 * When writing something to the screen after it has scrolled, requires a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 * wait-return prompt later. Needed when scrolling, resetting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 * need_wait_return after some prompt, and then outputting something
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 * without scrolling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 if (msg_scrolled && !msg_scrolled_ign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 need_wait_return = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 msg_didany = TRUE; /* remember that something was outputted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 * If there is no valid screen, use fprintf so we can see error messages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 * If termcap is not active, we may be writing in an alternate console
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 * window, cursor positioning may not work correctly (window size may be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 * different, e.g. for Win32 console) or we just don't know where the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 * cursor is.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 if (msg_use_printf())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 #ifdef WIN3264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 if (!(silent_mode && p_verbose == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 if (!(silent_mode && p_verbose == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 p = &buf[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 /* NL --> CR NL translation (for Unix, not for "--version") */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 /* NL --> CR translation (for Mac) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 if (*s == '\n' && !info_message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 *p++ = '\r';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 #if defined(USE_CR) && !defined(MACOS_X_UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 *p++ = *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 *p = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 if (info_message) /* informative message, not an error */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 mch_msg((char *)buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 mch_errmsg((char *)buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 /* primitive way to compute the current column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 if (cmdmsg_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 if (*s == '\r' || *s == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 msg_col = Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 --msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 if (*s == '\r' || *s == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 ++msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 ++s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 msg_didout = TRUE; /* assume that line is not empty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 #ifdef WIN3264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 if (!(silent_mode && p_verbose == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 mch_settmode(TMODE_RAW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 did_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 * The screen is scrolled up when:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 * - When outputting a newline in the last row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 * - when outputting a character in the last column of the last row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 * (some terminals scroll automatically, some don't. To avoid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 * problems we scroll ourselves)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 if (msg_row >= Rows - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 && (*s == '\n'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 || (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 cmdmsg_rl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 ? (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 msg_col <= 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 || (*s == TAB && msg_col <= 7)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 || (has_mbyte && (*mb_ptr2cells)(s) > 1 && msg_col <= 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 (msg_col + t_col >= Columns - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 || (*s == TAB && msg_col + t_col >= ((Columns - 1) & ~7))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 || (has_mbyte && (*mb_ptr2cells)(s) > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 && msg_col + t_col >= Columns - 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 ))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 if (t_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 /* output postponed text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 t_puts(t_col, t_s, s, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 t_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 /* When no more prompt an no more room, truncate here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 if (msg_no_more && lines_left == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 /* Remove the cursor before scrolling, ScreenLines[] is going to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 * become invalid. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 gui_undraw_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 /* scrolling up always works */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 if (!can_clear((char_u *)" "))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 /* Scrolling up doesn't result in the right background. Set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 * the background here. It's not efficient, but avoids that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 * we have to do it all over the code. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 screen_fill((int)Rows - 1, (int)Rows, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 (int)Columns, ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 /* Also clear the last char of the last but one line if it was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 * not cleared before to avoid a scroll-up. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883 if (ScreenAttrs[LineOffset[Rows - 2] + Columns - 1]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 == (sattr_T)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 screen_fill((int)Rows - 2, (int)Rows - 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 (int)Columns - 1, (int)Columns, ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 msg_row = Rows - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 if (msg_col >= Columns) /* can happen after screen resize */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 msg_col = Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 ++msg_scrolled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894 need_wait_return = TRUE; /* may need wait_return in main() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 if (must_redraw < VALID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 must_redraw = VALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 if (cmdline_row > 0 && !exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 --cmdline_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 * if screen is completely filled wait for a character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 if (p_more && --lines_left == 0 && State != HITRETURN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 && !msg_no_more && !exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 oldState = State;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 State = ASKMORE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 setmouse();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 msg_moremsg(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 * Get a typed character directly from the user.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 c = get_keystroke();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 #if defined(FEAT_MENU) && defined(FEAT_GUI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 if (c == K_MENU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 int idx = get_menu_index(current_menu, ASKMORE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 /* Used a menu. If it starts with CTRL-Y, it must
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 * be a "Copy" for the clipboard. Otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 * assume that we end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 if (idx == MENU_INDEX_INVALID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 c = *current_menu->strings[idx];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 if (c != NUL && current_menu->strings[idx][1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 ins_typebuf(current_menu->strings[idx] + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 current_menu->noremap[idx], 0, TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 current_menu->silent[idx]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 switch (c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 case BS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 case 'k':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 case K_UP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 if (!more_back_used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 msg_moremsg(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 more_back = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 lines_left = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 case CAR: /* one extra line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 case NL:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 case 'j':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 case K_DOWN:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 lines_left = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 case ':': /* start new command line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 #ifdef FEAT_CON_DIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 if (!confirm_msg_used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 /* Since got_int is set all typeahead will be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 * flushed, but we want to keep this ':', remember
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 * that in a special way. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 typeahead_noflush(':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 cmdline_row = Rows - 1; /* put ':' on this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 skip_redraw = TRUE; /* skip redraw once */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 need_wait_return = FALSE; /* don't wait in main() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 /*FALLTHROUGH*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 case 'q': /* quit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 case Ctrl_C:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 case ESC:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 #ifdef FEAT_CON_DIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 if (confirm_msg_used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 /* Jump to the choices of the dialog. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 s = confirm_msg_tail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 lines_left = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 quit_more = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 case 'u': /* Up half a page */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 case K_PAGEUP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 if (!more_back_used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 msg_moremsg(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 more_back = Rows / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 /*FALLTHROUGH*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 case 'd': /* Down half a page */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 lines_left = Rows / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 case 'b': /* one page back */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 if (!more_back_used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 msg_moremsg(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 more_back = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 /*FALLTHROUGH*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 case ' ': /* one extra page */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 case K_PAGEDOWN:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 case K_LEFTMOUSE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 lines_left = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 #ifdef FEAT_CLIPBOARD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 case Ctrl_Y:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 /* Strange way to allow copying (yanking) a modeless
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 * selection at the more prompt. Use CTRL-Y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 * because the same is used in Cmdline-mode and at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 * hit-enter prompt. However, scrolling one line up
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 * might be expected... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 if (clip_star.state == SELECT_DONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 clip_copy_modeless_selection(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 default: /* no valid response */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 msg_moremsg(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 /* clear the --more-- message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 screen_fill((int)Rows - 1, (int)Rows,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 0, (int)Columns, ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 State = oldState;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 setmouse();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 if (quit_more)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 msg_row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 return; /* the string is not displayed! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 if (cmdmsg_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 msg_col = Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 if (t_col > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 && (vim_strchr((char_u *)"\n\r\b\t", *s) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 || *s == BELL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 || msg_col + t_col >= Columns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 || (has_mbyte && (*mb_ptr2cells)(s) > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 && msg_col + t_col >= Columns - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 ))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 /* output any postponed text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 t_puts(t_col, t_s, s, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 t_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 if (*s == '\n') /* go to next line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 msg_didout = FALSE; /* remember that line is empty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 if (++msg_row >= Rows) /* safety check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 msg_row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 else if (*s == '\r') /* go to column 0 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 else if (*s == '\b') /* go to previous char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 if (msg_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 --msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 else if (*s == TAB) /* translate into spaces */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 msg_screen_putchar(' ', attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087 while (msg_col & 7);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 else if (*s == BELL) /* beep (from ":sh") */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 vim_beep();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 cw = (*mb_ptr2cells)(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 if (enc_utf8 && maxlen >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 /* avoid including composing chars after the end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 l = utfc_ptr2len_check_len(s, (int)((str + maxlen) - s));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101 l = (*mb_ptr2len_check)(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105 cw = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 /* When drawing from right to left or when a double-wide character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 * doesn't fit, draw a single character here. Otherwise collect
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 * characters and draw them all at once later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 #if defined(FEAT_RIGHTLEFT) || defined(FEAT_MBYTE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 # ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 cmdmsg_rl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 (cw > 1 && msg_col + t_col >= Columns - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 # ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 if (l > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 s = screen_puts_mbyte(s, l, attr) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130 msg_screen_putchar(*s, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 /* postpone this character until later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 if (t_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 t_s = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 t_col += cw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 s += l - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 ++t_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 ++s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149 /* output any postponed text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 if (t_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151 t_puts(t_col, t_s, s, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 msg_check();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 * Output any postponed text for msg_puts_attr_len().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 t_puts(t_col, t_s, s, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161 int t_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2162 char_u *t_s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166 /* output postponed text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167 msg_didout = TRUE; /* remember that line is not empty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2168 screen_puts_len(t_s, (int)(s - t_s), msg_row, msg_col, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169 msg_col += t_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 /* If the string starts with a composing character don't increment the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 * column position for it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 if (enc_utf8 && utf_iscomposing(utf_ptr2char(t_s)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174 --msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 if (msg_col >= Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179 ++msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 * Returns TRUE when messages should be printed with mch_errmsg().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 * This is used when there is no valid screen, so we can see error messages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 * If termcap is not active, we may be writing in an alternate console
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 * window, cursor positioning may not work correctly (window size may be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189 * different, e.g. for Win32 console) or we just don't know where the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2190 * cursor is.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2191 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 msg_use_printf()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2195 return (!msg_check_screen()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2196 #if defined(WIN3264) && !defined(FEAT_GUI_MSWIN)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2197 || !termcap_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2199 || (swapping_screen() && !termcap_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 #if defined(USE_MCH_ERRMSG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205 #ifdef mch_errmsg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2206 # undef mch_errmsg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 #ifdef mch_msg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 # undef mch_msg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2212 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 * Give an error message. To be used when the screen hasn't been initialized
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 * yet. When stderr can't be used, collect error messages until the GUI has
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 * started and they can be displayed in a message box.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218 mch_errmsg(str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 char *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 /* On Unix use stderr if it's a tty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 * When not going to start the GUI also use stderr.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226 * On Mac, when started from Finder, stderr is the console. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 # ifdef UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 # ifdef MACOS_X_UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 isatty(2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2235 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2239 !(gui.in_use || gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2240 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2242 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243 fprintf(stderr, "%s", str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 /* avoid a delay for a message that isn't there */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 emsg_on_display = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 len = (int)STRLEN(str) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 if (error_ga.ga_growsize == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 error_ga.ga_growsize = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 error_ga.ga_itemsize = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 if (ga_grow(&error_ga, len) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 mch_memmove((char_u *)error_ga.ga_data + error_ga.ga_len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 (char_u *)str, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 #ifdef UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 /* remove CR characters, they are displayed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 p = (char_u *)error_ga.ga_data + error_ga.ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 p = vim_strchr(p, '\r');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 *p = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 --len; /* don't count the NUL at the end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 error_ga.ga_len += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 * Give a message. To be used when the screen hasn't been initialized yet.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 * When there is no tty, collect messages until the GUI has started and they
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 * can be displayed in a message box.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 mch_msg(str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 char *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290 #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 /* On Unix use stdout if we have a tty. This allows "vim -h | more" and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 * uses mch_errmsg() when started from the desktop.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 * When not going to start the GUI also use stdout.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 * On Mac, when started from Finder, stderr is the console. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 # ifdef UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 # ifdef MACOS_X_UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 isatty(2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 !(gui.in_use || gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 printf("%s", str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 mch_errmsg(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 #endif /* USE_MCH_ERRMSG */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 * Put a character on the screen at the current message position and advance
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 * to the next position. Only for printable ASCII!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 msg_screen_putchar(c, attr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 msg_didout = TRUE; /* remember that line is not empty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329 screen_putchar(c, msg_row, msg_col, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 if (cmdmsg_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 if (--msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335 msg_col = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336 ++msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 if (++msg_col >= Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 ++msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 msg_moremsg(full)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 int full;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 int attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 attr = hl_attr(HLF_M);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 screen_puts((char_u *)_("-- More --"), (int)Rows - 1, 0, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358 if (full)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359 screen_puts(more_back_used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 ? (char_u *)_(" (RET/BS: line, SPACE/b: page, d/u: half page, q: quit)")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 : (char_u *)_(" (RET: line, SPACE: page, d: half page, q: quit)"),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2362 (int)Rows - 1, 10, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 * Repeat the message for the current mode: ASKMORE, EXTERNCMD, CONFIRM or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 * exmode_active.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 repeat_message()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 if (State == ASKMORE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2374 msg_moremsg(TRUE); /* display --more-- message again */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 msg_row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2377 #ifdef FEAT_CON_DIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 else if (State == CONFIRM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 display_confirm_msg(); /* display ":confirm" message again */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381 msg_row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 else if (State == EXTERNCMD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 windgoto(msg_row, msg_col); /* put cursor back */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 else if (State == HITRETURN || State == SETWSIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 hit_return_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 msg_row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 * msg_check_screen - check if the screen is initialized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 * Also check msg_row and msg_col, if they are too big it may cause a crash.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 * While starting the GUI the terminal codes will be set for the GUI, but the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 * output goes to the terminal. Don't use the terminal codes then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 msg_check_screen()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 if (!full_screen || !screen_valid(FALSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 if (msg_row >= Rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408 msg_row = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 if (msg_col >= Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 msg_col = Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 * Clear from current message position to end of screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 * Skip this when ":silent" was used, no need to clear for redirection.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 msg_clr_eos()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 if (msg_silent == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 msg_clr_eos_force();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 * Clear from current message position to end of screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 * Note: msg_col is not updated, so we remember the end of the message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 * for msg_check().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 msg_clr_eos_force()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 if (msg_use_printf())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 if (full_screen) /* only when termcap codes are valid */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 if (*T_CD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 out_str(T_CD); /* clear to end of display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 else if (*T_CE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 out_str(T_CE); /* clear to end of line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 if (cmdmsg_rl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 screen_fill(msg_row, msg_row + 1, 0, msg_col + 1, ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 screen_fill(msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2451 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 screen_fill(msg_row, msg_row + 1, msg_col, (int)Columns,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 screen_fill(msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 * Clear the command line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 msg_clr_cmdline()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 msg_row = cmdline_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 msg_clr_eos_force();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2472 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 * end putting a message on the screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 * call wait_return if the message does not fit in the available space
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 * return TRUE if wait_return not called.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 msg_end()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 * if the string is larger than the window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 * or the ruler option is set and we run into it,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 * we have to redraw the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 * Do not do this if we are abandoning the file or editing the command line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 if (!exiting && need_wait_return && !(State & CMDLINE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 wait_return(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 * If the written message runs into the shown command or ruler, we have to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 * wait for hit-return and redraw the window later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 msg_check()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 if (msg_row == Rows - 1 && msg_col >= sc_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 need_wait_return = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 redraw_cmdline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 * May write a string to the redirection file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 * When "maxlen" is -1 write the whole string, otherwise up to "maxlen" bytes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514 redir_write(str, maxlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 int maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 char_u *s = str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 static int cur_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 if ((redir_fd != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 || redir_reg
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 ) && !redir_off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 /* If the string doesn't start with CR or NL, go to msg_col */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 if (*s != '\n' && *s != '\r')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 while (cur_col < msg_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 if (redir_reg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 else if (redir_fd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 fputs(" ", redir_fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 ++cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 if (redir_reg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 write_reg_contents(redir_reg, s, maxlen, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 /* Adjust the current column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 if (!redir_reg && redir_fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 putc(*s, redir_fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 if (*s == '\r' || *s == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 cur_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 else if (*s == '\t')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 cur_col += (8 - cur_col % 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 ++cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 ++s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 if (msg_silent != 0) /* should update msg_col */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 msg_col = cur_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 * Give a warning message (for searching).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 * Use 'w' highlighting and may repeat the message after redrawing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 give_warning(message, hl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 char_u *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 int hl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 /* Don't do this for ":silent". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 if (msg_silent != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 /* Don't want a hit-enter prompt here. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 ++no_wait_return;
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
2583
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 set_vim_var_string(VV_WARNINGMSG, message, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 vim_free(keep_msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 keep_msg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 if (hl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 keep_msg_attr = hl_attr(HLF_W);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 keep_msg_attr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 if (msg_attr(message, keep_msg_attr) && msg_scrolled == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 set_keep_msg(message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 msg_didout = FALSE; /* overwrite this message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2596 msg_nowait = TRUE; /* don't wait for this message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 msg_col = 0;
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
2598
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 --no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 * Advance msg cursor to column "col".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 msg_advance(col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 if (msg_silent != 0) /* nothing to advance to */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 msg_col = col; /* for redirection, may fill it up later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 if (col >= Columns) /* not enough room */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 col = Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 while (msg_col < col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 #if defined(FEAT_CON_DIALOG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 * Used for "confirm()" function, and the :confirm command prefix.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 * Versions which haven't got flexible dialogs yet, and console
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624 * versions, get this generic handler which uses the command line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 * type = one of:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 * VIM_QUESTION, VIM_INFO, VIM_WARNING, VIM_ERROR or VIM_GENERIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 * title = title string (can be NULL for default)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 * (neither used in console dialogs at the moment)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 * Format of the "buttons" string:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 * "Button1Name\nButton2Name\nButton3Name"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 * The first button should normally be the default/accept
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634 * The second button should be the 'Cancel' button
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 * Other buttons- use your imagination!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 * A '&' in a button name becomes a shortcut, so each '&' should be before a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2637 * different letter.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 do_dialog(type, title, message, buttons, dfltbutton, textfield)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 char_u *title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 char_u *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 char_u *buttons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 int dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 char_u *textfield; /* IObuff for inputdialog(), NULL otherwise */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649 int oldState;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 int retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 char_u *hotkeys;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 /* Don't output anything in silent mode ("ex -s") */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 if (silent_mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658 return dfltbutton; /* return default option */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 #ifdef FEAT_GUI_DIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 /* When GUI is running and 'c' not in 'guioptions', use the GUI dialog */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 c = gui_mch_dialog(type, title, message, buttons, dfltbutton,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 textfield);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 msg_end_prompt();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 /* Flush output to avoid that further messages and redrawing is done
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 * in the wrong order. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 return c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678 oldState = State;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 State = CONFIRM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 setmouse();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 * Since we wait for a keypress, don't make the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 * user press RETURN as well afterwards.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 ++no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 hotkeys = msg_show_console_dialog(message, buttons, dfltbutton);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 if (hotkeys != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695 /* Get a typed character directly from the user. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696 c = get_keystroke();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 switch (c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699 case CAR: /* User accepts default option */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 case NL:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701 retval = dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703 case Ctrl_C: /* User aborts/cancels */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 case ESC:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705 retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 default: /* Could be a hotkey? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 if (c < 0) /* special keys are ignored here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 /* Make the character lowercase, as chars in "hotkeys" are. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 c = MB_TOLOWER(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 retval = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 for (i = 0; hotkeys[i]; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 if ((*mb_ptr2char)(hotkeys + i) == c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 i += (*mb_ptr2len_check)(hotkeys + i) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 if (hotkeys[i] == c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 ++retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728 if (hotkeys[i])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 /* No hotkey match, so keep waiting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 vim_free(hotkeys);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 State = oldState;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 setmouse();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743 --no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744 msg_end_prompt();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 static int copy_char __ARGS((char_u *from, char_u *to, int lowercase));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2752 * Copy one character from "*from" to "*to", taking care of multi-byte
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 * characters. Return the length of the character in bytes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 copy_char(from, to, lowercase)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 char_u *from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 char_u *to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 int lowercase; /* make character lower case */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2764
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 if (lowercase)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 c = MB_TOLOWER((*mb_ptr2char)(from));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770 return (*mb_char2bytes)(c, to);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774 len = (*mb_ptr2len_check)(from);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 mch_memmove(to, from, (size_t)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 return len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2782 if (lowercase)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 *to = (char_u)TOLOWER_LOC(*from);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 *to = *from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 * Format the dialog string, and display it at the bottom of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 * the screen. Return a string of hotkey chars (if defined) for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 * each 'button'. If a button has no hotkey defined, the first character of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 * the button is used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 * The hotkeys can be multi-byte characters, but without combining chars.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 * Returns an allocated string with hotkeys, or NULL for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 msg_show_console_dialog(message, buttons, dfltbutton)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 char_u *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 char_u *buttons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 int dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 int len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 # define HOTK_LEN (has_mbyte ? MB_MAXBYTES : 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2808 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 # define HOTK_LEN 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 int lenhotkey = HOTK_LEN; /* count first button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2812 char_u *hotk = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 char_u *msgp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814 char_u *hotkp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2815 char_u *r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 int copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2817 #define HAS_HOTKEY_LEN 30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 char_u has_hotkey[HAS_HOTKEY_LEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2819 int first_hotkey = FALSE; /* first char of button is hotkey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822 has_hotkey[0] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 * First loop: compute the size of memory to allocate.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 * Second loop: copy to the allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 for (copy = 0; copy <= 1; ++copy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 r = buttons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 while (*r)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 if (*r == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 if (copy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 *msgp++ = ',';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 *msgp++ = ' '; /* '\n' -> ', ' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 /* advance to next hotkey and set default hotkey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2844 hotkp += (*mb_ptr2len_check)(hotkp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 ++hotkp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 (void)copy_char(r + 1, hotkp, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 if (dfltbutton)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 --dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852 /* If no hotkey is specified first char is used. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853 if (idx < HAS_HOTKEY_LEN - 1 && !has_hotkey[++idx])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2854 first_hotkey = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2855 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 len += 3; /* '\n' -> ', '; 'x' -> '(x)' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 lenhotkey += HOTK_LEN; /* each button needs a hotkey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 if (idx < HAS_HOTKEY_LEN - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 has_hotkey[++idx] = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 else if (*r == DLG_HOTKEY_CHAR || first_hotkey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 if (*r == DLG_HOTKEY_CHAR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 ++r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868 first_hotkey = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 if (copy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 if (*r == DLG_HOTKEY_CHAR) /* '&&a' -> '&a' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 *msgp++ = *r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2873 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2875 /* '&a' -> '[a]' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 *msgp++ = (dfltbutton == 1) ? '[' : '(';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 msgp += copy_char(r, msgp, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 *msgp++ = (dfltbutton == 1) ? ']' : ')';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 /* redefine hotkey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 (void)copy_char(r, hotkp, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 ++len; /* '&a' -> '[a]' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 if (idx < HAS_HOTKEY_LEN - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2888 has_hotkey[idx] = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2889 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 /* everything else copy literally */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2894 if (copy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895 msgp += copy_char(r, msgp, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898 /* advance to the next character */
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2899 mb_ptr_adv(r);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2900 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2901
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902 if (copy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 *msgp++ = ':';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 *msgp++ = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 *msgp = NUL;
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
2907 mb_ptr_adv(hotkp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908 *hotkp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2909 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 len += STRLEN(message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 + 2 /* for the NL's */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914 + STRLEN(buttons)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2915 + 3; /* for the ": " and NUL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916 lenhotkey++; /* for the NUL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 /* If no hotkey is specified first char is used. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2919 if (!has_hotkey[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2920 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 first_hotkey = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 len += 2; /* "x" -> "[x]" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2923 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2925 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2926 * Now allocate and load the strings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2928 vim_free(confirm_msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929 confirm_msg = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 if (confirm_msg == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 *confirm_msg = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2933 hotk = alloc(lenhotkey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934 if (hotk == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2937 *confirm_msg = '\n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938 STRCPY(confirm_msg + 1, message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 msgp = confirm_msg + 1 + STRLEN(message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941 hotkp = hotk;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2942
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 /* define first default hotkey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2944 (void)copy_char(buttons, hotkp, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2945
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2946 /* Remember where the choices start, displaying starts here when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2947 * "hotkp" typed at the more prompt. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948 confirm_msg_tail = msgp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2949 *msgp++ = '\n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2950 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2953 display_confirm_msg();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 return hotk;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2955 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958 * Display the ":confirm" message. Also called when screen resized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 display_confirm_msg()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 /* avoid that 'q' at the more prompt truncates the message here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 ++confirm_msg_used;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965 if (confirm_msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 msg_puts_attr(confirm_msg, hl_attr(HLF_M));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 --confirm_msg_used;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2968 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970 #endif /* FEAT_CON_DIALOG */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972 #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2974 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2975 vim_dialog_yesno(type, title, message, dflt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2977 char_u *title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2978 char_u *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2979 int dflt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2980 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2981 if (do_dialog(type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2982 title == NULL ? (char_u *)_("Question") : title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2984 (char_u *)_("&Yes\n&No"), dflt, NULL) == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2985 return VIM_YES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2986 return VIM_NO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2987 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2989 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2990 vim_dialog_yesnocancel(type, title, message, dflt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2991 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 char_u *title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993 char_u *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994 int dflt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2995 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2996 switch (do_dialog(type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2997 title == NULL ? (char_u *)_("Question") : title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2998 message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2999 (char_u *)_("&Yes\n&No\n&Cancel"), dflt, NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3000 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3001 case 1: return VIM_YES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3002 case 2: return VIM_NO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3004 return VIM_CANCEL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3006
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3007 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3008 vim_dialog_yesnoallcancel(type, title, message, dflt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3009 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3010 char_u *title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 char_u *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 int dflt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3013 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3014 switch (do_dialog(type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3015 title == NULL ? (char_u *)"Question" : title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3016 message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 (char_u *)_("&Yes\n&No\nSave &All\n&Discard All\n&Cancel"),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3018 dflt, NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3019 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3020 case 1: return VIM_YES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3021 case 2: return VIM_NO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3022 case 3: return VIM_ALL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3023 case 4: return VIM_DISCARDALL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3024 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3025 return VIM_CANCEL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3026 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3027
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3028 #endif /* FEAT_GUI_DIALOG || FEAT_CON_DIALOG */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3029
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3030 #if defined(FEAT_BROWSE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3031 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3032 * Generic browse function. Calls gui_mch_browse() when possible.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3033 * Later this may pop-up a non-GUI file selector (external command?).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3034 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3035 char_u *
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3036 do_browse(flags, title, dflt, ext, initdir, filter, buf)
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3037 int flags; /* BROWSE_SAVE and BROWSE_DIR */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3038 char_u *title; /* title for the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3039 char_u *dflt; /* default file name (may include directory) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3040 char_u *ext; /* extension added */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3041 char_u *initdir; /* initial directory, NULL for current dir or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3042 when using path from "dflt" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3043 char_u *filter; /* file name filter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3044 buf_T *buf; /* buffer to read/write for */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3045 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3046 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047 static char_u *last_dir = NULL; /* last used directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3048 char_u *tofree = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3049 int save_browse = cmdmod.browse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3051 /* Must turn off browse to avoid that autocommands will get the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3052 * flag too! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3053 cmdmod.browse = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3054
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3055 if (title == NULL || *title == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3056 {
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3057 if (flags & BROWSE_DIR)
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3058 title = (char_u *)_("Select Directory dialog");
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3059 else if (flags & BROWSE_SAVE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3060 title = (char_u *)_("Save File dialog");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3061 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3062 title = (char_u *)_("Open File dialog");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3063 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3065 /* When no directory specified, use default file name, default dir, buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3066 * dir, last dir or current dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3067 if ((initdir == NULL || *initdir == NUL) && dflt != NULL && *dflt != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3069 if (mch_isdir(dflt)) /* default file name is a directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3071 initdir = dflt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3072 dflt = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074 else if (gettail(dflt) != dflt) /* default file name includes a path */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 tofree = vim_strsave(dflt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3077 if (tofree != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3078 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079 initdir = tofree;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3080 *gettail(initdir) = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3081 dflt = gettail(dflt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3083 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3086 if (initdir == NULL || *initdir == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3087 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3088 /* When 'browsedir' is a directory, use it */
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3089 if (STRCMP(p_bsdir, "last") != 0
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3090 && STRCMP(p_bsdir, "buffer") != 0
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3091 && STRCMP(p_bsdir, "current") != 0
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3092 && mch_isdir(p_bsdir))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3093 initdir = p_bsdir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3094 /* When saving or 'browsedir' is "buffer", use buffer fname */
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3095 else if (((flags & BROWSE_SAVE) || *p_bsdir == 'b')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096 && buf != NULL && buf->b_ffname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 if (dflt == NULL || *dflt == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 dflt = gettail(curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100 tofree = vim_strsave(curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3101 if (tofree != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3103 initdir = tofree;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3104 *gettail(initdir) = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3105 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3107 /* When 'browsedir' is "last", use dir from last browse */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3108 else if (*p_bsdir == 'l')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109 initdir = last_dir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110 /* When 'browsedir is "current", use current directory. This is the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 * default already, leave initdir empty. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3114 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3115 if (gui.in_use) /* when this changes, also adjust f_has()! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3116 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3117 if (filter == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3118 # ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3119 && (filter = get_var_value((char_u *)"b:browsefilter")) == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3120 && (filter = get_var_value((char_u *)"g:browsefilter")) == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3121 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3122 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3123 filter = BROWSE_FILTER_DEFAULT;
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3124 if (flags & BROWSE_DIR)
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3125 {
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3126 # if defined(HAVE_GTK2) || defined(WIN3264)
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3127 /* For systems that have a directory dialog. */
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3128 fname = gui_mch_browsedir(title, initdir);
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3129 # else
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3130 /* Generic solution for selecting a directory: select a file and
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3131 * remove the file name. */
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3132 fname = gui_mch_browse(0, title, dflt, ext, initdir, (char_u *)"");
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3133 # endif
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3134 # if !defined(HAVE_GTK2)
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3135 /* Win32 adds a dummy file name, others return an arbitrary file
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3136 * name. GTK+ 2 returns only the directory, */
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3137 if (fname != NULL && *fname != NUL && !mch_isdir(fname))
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3138 {
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3139 /* Remove the file name. */
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
3140 char_u *tail = gettail_sep(fname);
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3141
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3142 if (tail == fname)
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3143 *tail++ = '.'; /* use current dir */
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3144 *tail = NUL;
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3145 }
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3146 # endif
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3147 }
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3148 else
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3149 fname = gui_mch_browse(flags & BROWSE_SAVE,
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3150 title, dflt, ext, initdir, filter);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3152 /* We hang around in the dialog for a while, the user might do some
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3153 * things to our files. The Win32 dialog allows deleting or renaming
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3154 * a file, check timestamps. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3155 need_check_timestamps = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 did_check_timestamps = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3161 /* TODO: non-GUI file selector here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3162 EMSG(_("E338: Sorry, no file browser in console mode"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3163 fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3164 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3166 /* keep the directory for next time */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3167 if (fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3168 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3169 vim_free(last_dir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3170 last_dir = vim_strsave(fname);
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 16
diff changeset
3171 if (last_dir != NULL && !(flags & BROWSE_DIR))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3172 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3173 *gettail(last_dir) = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3174 if (*last_dir == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3175 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3176 /* filename only returned, must be in current dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3177 vim_free(last_dir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3178 last_dir = alloc(MAXPATHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3179 if (last_dir != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3180 mch_dirname(last_dir, MAXPATHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3181 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3183 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3185 vim_free(tofree);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3186 cmdmod.browse = save_browse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3188 return fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3189 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3190 #endif