tweaks: make a function do a check so its calls don't need to
parent
557ad827f9
commit
785efc2087
|
@ -1212,9 +1212,7 @@ void do_insertfile(void)
|
|||
/* If the current mode of operation allows it, go insert a file. */
|
||||
void do_insertfile_void(void)
|
||||
{
|
||||
if (ISSET(RESTRICTED))
|
||||
show_restricted_warning();
|
||||
else
|
||||
if (!in_restricted_mode())
|
||||
do_insertfile();
|
||||
}
|
||||
|
||||
|
|
16
src/nano.c
16
src/nano.c
|
@ -463,11 +463,15 @@ void print_view_warning(void)
|
|||
statusbar(_("Key is invalid in view mode"));
|
||||
}
|
||||
|
||||
/* Indicate that something is disabled in restricted mode. */
|
||||
void show_restricted_warning(void)
|
||||
/* When in restricted mode, show a warning and return TRUE. */
|
||||
bool in_restricted_mode(void)
|
||||
{
|
||||
statusbar(_("This function is disabled in restricted mode"));
|
||||
beep();
|
||||
if (ISSET(RESTRICTED)) {
|
||||
statusbar(_("This function is disabled in restricted mode"));
|
||||
beep();
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HELP
|
||||
|
@ -1340,10 +1344,8 @@ void do_toggle(int flag)
|
|||
{
|
||||
bool enabled;
|
||||
|
||||
if (flag == SUSPEND && ISSET(RESTRICTED)) {
|
||||
show_restricted_warning();
|
||||
if (flag == SUSPEND && in_restricted_mode())
|
||||
return;
|
||||
}
|
||||
|
||||
TOGGLE(flag);
|
||||
focusing = FALSE;
|
||||
|
|
|
@ -408,7 +408,7 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
|
|||
void ingraft_buffer(linestruct *somebuffer);
|
||||
void copy_from_buffer(linestruct *somebuffer);
|
||||
void print_view_warning(void);
|
||||
void show_restricted_warning(void);
|
||||
bool in_restricted_mode(void);
|
||||
#ifndef ENABLE_HELP
|
||||
void say_there_is_no_help(void);
|
||||
#endif
|
||||
|
|
|
@ -2640,10 +2640,8 @@ void do_spell(void)
|
|||
/* A storage place for the current flag settings. */
|
||||
const char *result_msg;
|
||||
|
||||
if (ISSET(RESTRICTED)) {
|
||||
show_restricted_warning();
|
||||
if (in_restricted_mode())
|
||||
return;
|
||||
}
|
||||
|
||||
temp = safe_tempfile(&temp_file);
|
||||
|
||||
|
@ -2712,10 +2710,8 @@ void do_linter(void)
|
|||
lintstruct *lints = NULL, *tmplint = NULL, *curlint = NULL;
|
||||
time_t last_wait = 0;
|
||||
|
||||
if (ISSET(RESTRICTED)) {
|
||||
show_restricted_warning();
|
||||
if (in_restricted_mode())
|
||||
return;
|
||||
}
|
||||
|
||||
if (!openfile->syntax || !openfile->syntax->linter) {
|
||||
statusbar(_("No linter defined for this type of file!"));
|
||||
|
|
Loading…
Reference in New Issue