tweaks: determine in another way whether a shortcut is okay in view mode
This addresses the other part of https://savannah.gnu.org/bugs/?62899.
Этот коммит содержится в:
родитель
10b4d0c8ad
Коммит
4b928b466a
36
src/nano.c
36
src/nano.c
@ -1368,16 +1368,30 @@ bool wanted_to_move(void (*func)(void))
|
|||||||
func == to_first_line || func == to_last_line;
|
func == to_first_line || func == to_last_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE when the given shortcut is admissible in view mode. */
|
/* Return TRUE when the given function makes a change -- no good for view mode. */
|
||||||
bool okay_for_view(const keystruct *shortcut)
|
bool changes_something(const void *f)
|
||||||
{
|
{
|
||||||
funcstruct *item = allfuncs;
|
return (f == do_savefile || f == do_writeout || f == do_enter ||
|
||||||
|
f == do_tab || f == do_delete || f == do_backspace ||
|
||||||
/* Search the function of the given shortcut in the list of functions. */
|
f == cut_text || f == paste_text || f == do_replace ||
|
||||||
while (item != NULL && item->func != shortcut->func)
|
#ifndef NANO_TINY
|
||||||
item = item->next;
|
f == chop_previous_word || f == chop_next_word ||
|
||||||
|
f == zap_text || f == cut_till_eof || f == do_execute ||
|
||||||
return (item == NULL || item->viewok);
|
f == do_indent || f == do_unindent || f == do_comment ||
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_JUSTIFY
|
||||||
|
f == do_justify || f == do_full_justify ||
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_SPELLER
|
||||||
|
f == do_spell ||
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_COLOR
|
||||||
|
f == do_linter || f == do_formatter ||
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_WORDCOMPLETION
|
||||||
|
f == complete_a_word ||
|
||||||
|
#endif
|
||||||
|
f == do_verbatim_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
@ -1585,7 +1599,7 @@ void process_a_keystroke(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ISSET(VIEW_MODE) && !okay_for_view(shortcut)) {
|
if (ISSET(VIEW_MODE) && changes_something(function)) {
|
||||||
print_view_warning();
|
print_view_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1653,7 +1667,7 @@ void process_a_keystroke(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
if (!refresh_needed && !okay_for_view(shortcut))
|
if (!refresh_needed && changes_something(function))
|
||||||
check_the_multis(openfile->current);
|
check_the_multis(openfile->current);
|
||||||
#endif
|
#endif
|
||||||
if (!refresh_needed && (function == do_delete || function == do_backspace))
|
if (!refresh_needed && (function == do_delete || function == do_backspace))
|
||||||
|
@ -523,7 +523,9 @@ void do_formatter(void);
|
|||||||
void count_lines_words_and_characters(void);
|
void count_lines_words_and_characters(void);
|
||||||
#endif
|
#endif
|
||||||
void do_verbatim_input(void);
|
void do_verbatim_input(void);
|
||||||
|
#ifdef ENABLE_WORDCOMPLETION
|
||||||
void complete_a_word(void);
|
void complete_a_word(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* All functions in utils.c. */
|
/* All functions in utils.c. */
|
||||||
void get_homedir(void);
|
void get_homedir(void);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user