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. */
|
/* If the current mode of operation allows it, go insert a file. */
|
||||||
void do_insertfile_void(void)
|
void do_insertfile_void(void)
|
||||||
{
|
{
|
||||||
if (ISSET(RESTRICTED))
|
if (!in_restricted_mode())
|
||||||
show_restricted_warning();
|
|
||||||
else
|
|
||||||
do_insertfile();
|
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"));
|
statusbar(_("Key is invalid in view mode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Indicate that something is disabled in restricted mode. */
|
/* When in restricted mode, show a warning and return TRUE. */
|
||||||
void show_restricted_warning(void)
|
bool in_restricted_mode(void)
|
||||||
{
|
{
|
||||||
statusbar(_("This function is disabled in restricted mode"));
|
if (ISSET(RESTRICTED)) {
|
||||||
beep();
|
statusbar(_("This function is disabled in restricted mode"));
|
||||||
|
beep();
|
||||||
|
return TRUE;
|
||||||
|
} else
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ENABLE_HELP
|
#ifndef ENABLE_HELP
|
||||||
|
@ -1340,10 +1344,8 @@ void do_toggle(int flag)
|
||||||
{
|
{
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
if (flag == SUSPEND && ISSET(RESTRICTED)) {
|
if (flag == SUSPEND && in_restricted_mode())
|
||||||
show_restricted_warning();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
TOGGLE(flag);
|
TOGGLE(flag);
|
||||||
focusing = FALSE;
|
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 ingraft_buffer(linestruct *somebuffer);
|
||||||
void copy_from_buffer(linestruct *somebuffer);
|
void copy_from_buffer(linestruct *somebuffer);
|
||||||
void print_view_warning(void);
|
void print_view_warning(void);
|
||||||
void show_restricted_warning(void);
|
bool in_restricted_mode(void);
|
||||||
#ifndef ENABLE_HELP
|
#ifndef ENABLE_HELP
|
||||||
void say_there_is_no_help(void);
|
void say_there_is_no_help(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2640,10 +2640,8 @@ void do_spell(void)
|
||||||
/* A storage place for the current flag settings. */
|
/* A storage place for the current flag settings. */
|
||||||
const char *result_msg;
|
const char *result_msg;
|
||||||
|
|
||||||
if (ISSET(RESTRICTED)) {
|
if (in_restricted_mode())
|
||||||
show_restricted_warning();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
temp = safe_tempfile(&temp_file);
|
temp = safe_tempfile(&temp_file);
|
||||||
|
|
||||||
|
@ -2712,10 +2710,8 @@ void do_linter(void)
|
||||||
lintstruct *lints = NULL, *tmplint = NULL, *curlint = NULL;
|
lintstruct *lints = NULL, *tmplint = NULL, *curlint = NULL;
|
||||||
time_t last_wait = 0;
|
time_t last_wait = 0;
|
||||||
|
|
||||||
if (ISSET(RESTRICTED)) {
|
if (in_restricted_mode())
|
||||||
show_restricted_warning();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!openfile->syntax || !openfile->syntax->linter) {
|
if (!openfile->syntax || !openfile->syntax->linter) {
|
||||||
statusbar(_("No linter defined for this type of file!"));
|
statusbar(_("No linter defined for this type of file!"));
|
||||||
|
|
Loading…
Reference in New Issue