mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
move change_warning
This commit is contained in:
@@ -11,50 +11,41 @@
|
|||||||
* If the file is readonly, give a warning message with the first change.
|
* If the file is readonly, give a warning message with the first change.
|
||||||
* Don't do this for autocommands.
|
* Don't do this for autocommands.
|
||||||
* Doesn't use emsg(), because it flushes the macro buffer.
|
* Doesn't use emsg(), because it flushes the macro buffer.
|
||||||
* If we have undone all changes b_changed will be FALSE, but "b_did_warn"
|
* If we have undone all changes b_changed will be false, but "b_did_warn"
|
||||||
* will be TRUE.
|
* will be true.
|
||||||
* "col" is the column for the message; non-zero when in insert mode and
|
* "col" is the column for the message; non-zero when in insert mode and
|
||||||
* 'showmode' is on.
|
* 'showmode' is on.
|
||||||
* Careful: may trigger autocommands that reload the buffer.
|
* Careful: may trigger autocommands that reload the buffer.
|
||||||
*/
|
*/
|
||||||
void
|
void change_warning(int col)
|
||||||
change_warning(int col)
|
|
||||||
{
|
{
|
||||||
static char *w_readonly = N_("W10: Warning: Changing a readonly file");
|
static char *w_readonly = N_("W10: Warning: Changing a readonly file");
|
||||||
|
|
||||||
if (curbuf->b_did_warn == FALSE
|
if (curbuf->b_did_warn == false
|
||||||
&& curbufIsChanged() == 0
|
&& curbufIsChanged() == 0
|
||||||
&& !autocmd_busy
|
&& !autocmd_busy
|
||||||
&& curbuf->b_p_ro)
|
&& curbuf->b_p_ro) {
|
||||||
{
|
|
||||||
++curbuf_lock;
|
++curbuf_lock;
|
||||||
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
|
||||||
--curbuf_lock;
|
--curbuf_lock;
|
||||||
if (!curbuf->b_p_ro)
|
if (!curbuf->b_p_ro)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Do what msg() does, but with a column offset if the warning should
|
// Do what msg() does, but with a column offset if the warning should
|
||||||
// be after the mode message.
|
// be after the mode message.
|
||||||
msg_start();
|
msg_start();
|
||||||
if (msg_row == Rows - 1)
|
if (msg_row == Rows - 1)
|
||||||
msg_col = col;
|
msg_col = col;
|
||||||
msg_source(HL_ATTR(HLF_W));
|
msg_source(HL_ATTR(HLF_W));
|
||||||
msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
|
msg_ext_set_kind("wmsg");
|
||||||
#ifdef FEAT_EVAL
|
MSG_PUTS_ATTR(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
|
||||||
set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
|
set_vim_var_string(VV_WARNINGMSG, _(w_readonly), -1);
|
||||||
#endif
|
|
||||||
msg_clr_eos();
|
msg_clr_eos();
|
||||||
(void)msg_end();
|
(void)msg_end();
|
||||||
if (msg_silent == 0 && !silent_mode
|
if (msg_silent == 0 && !silent_mode && ui_active()) {
|
||||||
#ifdef FEAT_EVAL
|
ui_flush();
|
||||||
&& time_for_testing != 1
|
os_delay(1000L, true); // give the user time to think about it
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
out_flush();
|
|
||||||
ui_delay(1000L, TRUE); // give the user time to think about it
|
|
||||||
}
|
}
|
||||||
curbuf->b_did_warn = TRUE;
|
curbuf->b_did_warn = true;
|
||||||
redraw_cmdline = FALSE; // don't redraw and erase the message
|
redraw_cmdline = FALSE; // don't redraw and erase the message
|
||||||
if (msg_row < Rows - 1)
|
if (msg_row < Rows - 1)
|
||||||
showmode();
|
showmode();
|
||||||
|
@@ -2225,55 +2225,6 @@ void check_status(buf_T *buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If the file is readonly, give a warning message with the first change.
|
|
||||||
* Don't do this for autocommands.
|
|
||||||
* Don't use emsg(), because it flushes the macro buffer.
|
|
||||||
* If we have undone all changes b_changed will be false, but "b_did_warn"
|
|
||||||
* will be true.
|
|
||||||
* Careful: may trigger autocommands that reload the buffer.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
change_warning (
|
|
||||||
int col /* column for message; non-zero when in insert
|
|
||||||
mode and 'showmode' is on */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
static char *w_readonly = N_("W10: Warning: Changing a readonly file");
|
|
||||||
|
|
||||||
if (curbuf->b_did_warn == false
|
|
||||||
&& curbufIsChanged() == 0
|
|
||||||
&& !autocmd_busy
|
|
||||||
&& curbuf->b_p_ro) {
|
|
||||||
++curbuf_lock;
|
|
||||||
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
|
|
||||||
--curbuf_lock;
|
|
||||||
if (!curbuf->b_p_ro)
|
|
||||||
return;
|
|
||||||
/*
|
|
||||||
* Do what msg() does, but with a column offset if the warning should
|
|
||||||
* be after the mode message.
|
|
||||||
*/
|
|
||||||
msg_start();
|
|
||||||
if (msg_row == Rows - 1)
|
|
||||||
msg_col = col;
|
|
||||||
msg_source(HL_ATTR(HLF_W));
|
|
||||||
msg_ext_set_kind("wmsg");
|
|
||||||
MSG_PUTS_ATTR(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
|
|
||||||
set_vim_var_string(VV_WARNINGMSG, _(w_readonly), -1);
|
|
||||||
msg_clr_eos();
|
|
||||||
(void)msg_end();
|
|
||||||
if (msg_silent == 0 && !silent_mode && ui_active()) {
|
|
||||||
ui_flush();
|
|
||||||
os_delay(1000L, true); /* give the user time to think about it */
|
|
||||||
}
|
|
||||||
curbuf->b_did_warn = true;
|
|
||||||
redraw_cmdline = FALSE; /* don't redraw and erase the message */
|
|
||||||
if (msg_row < Rows - 1)
|
|
||||||
showmode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ask for a reply from the user, 'y' or 'n'
|
/// Ask for a reply from the user, 'y' or 'n'
|
||||||
///
|
///
|
||||||
/// No other characters are accepted, the message is repeated until a valid
|
/// No other characters are accepted, the message is repeated until a valid
|
||||||
|
Reference in New Issue
Block a user