tweaks: rename three variables, elide another, and reshuffle some stuff
Also, avoid an unused-variable warning when configured with --enable-tiny --enable-help --enable-multibuffer.
Этот коммит содержится в:
родитель
c42d6d378a
Коммит
009cd30695
56
src/help.c
56
src/help.c
@ -32,7 +32,7 @@
|
|||||||
static char *help_text = NULL;
|
static char *help_text = NULL;
|
||||||
/* The text displayed in the help window. */
|
/* The text displayed in the help window. */
|
||||||
|
|
||||||
static const char *start_of_text = NULL;
|
static const char *start_of_body = NULL;
|
||||||
/* The point in the help text just after the title. */
|
/* The point in the help text just after the title. */
|
||||||
|
|
||||||
static char *end_of_intro = NULL;
|
static char *end_of_intro = NULL;
|
||||||
@ -50,7 +50,7 @@ char *tempfilename = NULL;
|
|||||||
void display_the_help_text(bool redisplaying)
|
void display_the_help_text(bool redisplaying)
|
||||||
{
|
{
|
||||||
int line_size, sum = 0;
|
int line_size, sum = 0;
|
||||||
const char *ptr = start_of_text;
|
const char *ptr = start_of_body;
|
||||||
FILE *fp = fopen(tempfilename, "w+b");
|
FILE *fp = fopen(tempfilename, "w+b");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
@ -97,31 +97,29 @@ void display_the_help_text(bool redisplaying)
|
|||||||
void do_help(void)
|
void do_help(void)
|
||||||
{
|
{
|
||||||
int kbinput = ERR;
|
int kbinput = ERR;
|
||||||
int oldmenu = currmenu;
|
|
||||||
/* The menu we were called from. */
|
|
||||||
const char *ptr;
|
|
||||||
/* The current line of the help text. */
|
|
||||||
functionptrtype func;
|
functionptrtype func;
|
||||||
/* The function of the key the user typed in. */
|
/* The function of the key the user typed in. */
|
||||||
FILE *fp;
|
int oldmenu = currmenu;
|
||||||
filestruct *line;
|
/* The menu we were called from. */
|
||||||
int line_size;
|
#ifdef ENABLE_LINENUMBERS
|
||||||
int saved_margin = margin;
|
int was_margin = margin;
|
||||||
/* For avoiding the line numbers on the help screen. */
|
#endif
|
||||||
ssize_t was_tabsize = tabsize;
|
ssize_t was_tabsize = tabsize;
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
char *was_syntax = syntaxstr;
|
char *was_syntax = syntaxstr;
|
||||||
#endif
|
#endif
|
||||||
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
|
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
|
||||||
/* Store current answer when user invokes help at the prompt. */
|
/* The current answer when the user invokes help at the prompt. */
|
||||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||||
/* A storage place for the current flag settings. */
|
/* A storage place for the current flag settings. */
|
||||||
|
filestruct *line;
|
||||||
|
int length;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
blank_statusbar();
|
blank_statusbar();
|
||||||
|
|
||||||
|
/* Get a temporary file for the help text. If it fails, give up. */
|
||||||
tempfilename = safe_tempfile(&fp);
|
tempfilename = safe_tempfile(&fp);
|
||||||
|
|
||||||
/* If we can't get a temporary file for the help text, give up. */
|
|
||||||
if (tempfilename == NULL) {
|
if (tempfilename == NULL) {
|
||||||
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
|
||||||
free(saved_answer);
|
free(saved_answer);
|
||||||
@ -145,37 +143,35 @@ void do_help(void)
|
|||||||
window_init();
|
window_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSET(WHITESPACE_DISPLAY);
|
|
||||||
UNSET(NOREAD_MODE);
|
|
||||||
SET(MULTIBUFFER);
|
|
||||||
|
|
||||||
/* When searching, do it forward, case insensitive, and without regexes. */
|
/* When searching, do it forward, case insensitive, and without regexes. */
|
||||||
UNSET(BACKWARDS_SEARCH);
|
UNSET(BACKWARDS_SEARCH);
|
||||||
UNSET(CASE_SENSITIVE);
|
UNSET(CASE_SENSITIVE);
|
||||||
UNSET(USE_REGEXP);
|
UNSET(USE_REGEXP);
|
||||||
|
|
||||||
bottombars(MHELP);
|
UNSET(WHITESPACE_DISPLAY);
|
||||||
wnoutrefresh(bottomwin);
|
UNSET(NOREAD_MODE);
|
||||||
|
SET(MULTIBUFFER);
|
||||||
|
|
||||||
#ifdef ENABLE_LINENUMBERS
|
#ifdef ENABLE_LINENUMBERS
|
||||||
UNSET(LINE_NUMBERS);
|
UNSET(LINE_NUMBERS);
|
||||||
margin = 0;
|
margin = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bottombars(MHELP);
|
||||||
|
wnoutrefresh(bottomwin);
|
||||||
|
|
||||||
/* Extract the title from the head of the help text. */
|
/* Extract the title from the head of the help text. */
|
||||||
ptr = help_text;
|
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
|
||||||
line_size = break_line(ptr, MAX_BUF_SIZE, TRUE);
|
title = charalloc(length * sizeof(char) + 1);
|
||||||
title = charalloc(line_size * sizeof(char) + 1);
|
strncpy(title, help_text, length);
|
||||||
strncpy(title, ptr, line_size);
|
title[length] = '\0';
|
||||||
title[line_size] = '\0';
|
|
||||||
|
|
||||||
titlebar(title);
|
titlebar(title);
|
||||||
|
|
||||||
/* Skip over the title to point at the start of the body text. */
|
/* Skip over the title to point at the start of the body text. */
|
||||||
ptr += line_size;
|
start_of_body = help_text + length;
|
||||||
while (*ptr == '\n')
|
while (*start_of_body == '\n')
|
||||||
++ptr;
|
start_of_body++;
|
||||||
start_of_text = ptr;
|
|
||||||
|
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
syntaxstr = "nanohelp";
|
syntaxstr = "nanohelp";
|
||||||
@ -252,7 +248,7 @@ void do_help(void)
|
|||||||
memcpy(flags, stash, sizeof(flags));
|
memcpy(flags, stash, sizeof(flags));
|
||||||
|
|
||||||
#ifdef ENABLE_LINENUMBERS
|
#ifdef ENABLE_LINENUMBERS
|
||||||
margin = saved_margin;
|
margin = was_margin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ISSET(NO_HELP)) {
|
if (ISSET(NO_HELP)) {
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user