in help_init(), avoid a warning when compiling with -pedantic by

breaking overly long help text up into separate chunks, and add a few
wording fixes to the help text as well


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2442 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-03-30 18:11:59 +00:00
parent 050469c595
commit aa683853d4
2 changed files with 131 additions and 83 deletions

View File

@ -31,6 +31,10 @@ CVS code -
help_init() help_init()
- When calculating allocsize, take multibyte characters into - When calculating allocsize, take multibyte characters into
account, and keep the column number limits consistent. (DLR) account, and keep the column number limits consistent. (DLR)
- Break htx up into three chunks, in case the string is too long
for the compiler to handle (e.g. an ISO C89 compiler that can
only handle up to 509 characters). (DLR)
- Minor wording fixes. (DLR)
print1opt() print1opt()
- Don't include longflag if HAVE_GETOPT_LONG isn't defined. - Don't include longflag if HAVE_GETOPT_LONG isn't defined.
Rename this function to print1opt_full(), leave out the Rename this function to print1opt_full(), leave out the

View File

@ -265,7 +265,10 @@ void mouse_init(void)
void help_init(void) void help_init(void)
{ {
size_t allocsize = 0; /* Space needed for help_text. */ size_t allocsize = 0; /* Space needed for help_text. */
const char *htx; /* Untranslated help message. */ const char *htx[3]; /* Untranslated help message. We break
* it up into three chunks in case the
* full string is too long for the
* compiler to handle. */
char *ptr; char *ptr;
const shortcut *s; const shortcut *s;
#ifndef NANO_SMALL #ifndef NANO_SMALL
@ -279,115 +282,151 @@ void help_init(void)
/* First, set up the initial help text for the current function. */ /* First, set up the initial help text for the current function. */
if (currshortcut == whereis_list || currshortcut == replace_list if (currshortcut == whereis_list || currshortcut == replace_list
|| currshortcut == replace_list_2) || currshortcut == replace_list_2) {
htx = N_("Search Command Help Text\n\n " htx[0] = N_("Search Command Help Text\n\n "
"Enter the words or characters you would like to search " "Enter the words or characters you would like to "
"for, then hit Enter. If there is a match for the text you " "search for, and then press Enter. If there is a "
"entered, the screen will be updated to the location of the " "match for the text you entered, the screen will be "
"nearest match for the search string.\n\n The previous " "updated to the location of the nearest match for the "
"search string will be shown in brackets after the search " "search string.\n\n The previous search string will be "
"prompt. Hitting Enter without entering any text will " "shown in brackets after the search prompt. Hitting "
"perform the previous search. If you have selected text " "Enter without entering any text will perform the "
"with the mark and then search to replace, only matches in " "previous search. ");
"the selected text will be replaced.\n\n The following " htx[1] = N_("If you have selected text with the mark and then "
"function keys are available in Search mode:\n\n"); "search to replace, only matches in the selected text "
else if (currshortcut == gotoline_list) "will be replaced.\n\n The following function keys are "
htx = N_("Go To Line Help Text\n\n " "available in Search mode:\n\n");
htx[2] = NULL;
} else if (currshortcut == gotoline_list) {
htx[0] = N_("Go To Line Help Text\n\n "
"Enter the line number that you wish to go to and hit " "Enter the line number that you wish to go to and hit "
"Enter. If there are fewer lines of text than the " "Enter. If there are fewer lines of text than the "
"number you entered, you will be brought to the last line " "number you entered, you will be brought to the last "
"of the file.\n\n The following function keys are " "line of the file.\n\n The following function keys are "
"available in Go To Line mode:\n\n"); "available in Go To Line mode:\n\n");
else if (currshortcut == insertfile_list) htx[1] = NULL;
htx = N_("Insert File Help Text\n\n " htx[2] = NULL;
"Type in the name of a file to be inserted into the current " } else if (currshortcut == insertfile_list) {
"file buffer at the current cursor location.\n\n " htx[0] = N_("Insert File Help Text\n\n "
"If you have compiled nano with multiple file buffer " "Type in the name of a file to be inserted into the "
"support, and enable multiple buffers with the -F " "current file buffer at the current cursor "
"or --multibuffer command line flags, the Meta-F toggle, or " "location.\n\n If you have compiled nano with multiple "
"a nanorc file, inserting a file will cause it to be " "file buffer support, and enable multiple file buffers "
"loaded into a separate buffer (use Meta-< and > to switch " "with the -F or --multibuffer command line flags, the "
"between file buffers). If you need another blank buffer, " "Meta-F toggle, or a nanorc file, inserting a file "
"do not enter any filename, or type in a nonexistent " "will cause it to be loaded into a separate buffer "
"filename at the prompt and press Enter.\n\n The following " "(use Meta-< and > to switch between file buffers). ");
htx[1] = N_("If you need another blank buffer, do not enter "
"any filename, or type in a nonexistent filename at "
"the prompt and press Enter.\n\n The following "
"function keys are available in Insert File mode:\n\n"); "function keys are available in Insert File mode:\n\n");
else if (currshortcut == writefile_list) htx[2] = NULL;
htx = N_("Write File Help Text\n\n " } else if (currshortcut == writefile_list) {
htx[0] = N_("Write File Help Text\n\n "
"Type the name that you wish to save the current file " "Type the name that you wish to save the current file "
"as and hit Enter to save the file.\n\n If you have " "as and press Enter to save the file.\n\n If you have "
"selected text with the mark, you will be prompted to " "selected text with the mark, you will be prompted to "
"save only the selected portion to a separate file. To " "save only the selected portion to a separate file. To "
"reduce the chance of overwriting the current file with " "reduce the chance of overwriting the current file with "
"just a portion of it, the current filename is not the " "just a portion of it, the current filename is not the "
"default in this mode.\n\n The following function keys " "default in this mode.\n\n The following function keys "
"are available in Write File mode:\n\n"); "are available in Write File mode:\n\n");
htx[1] = NULL;
htx[2] = NULL;
}
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
else if (currshortcut == browser_list) else if (currshortcut == browser_list) {
htx = N_("File Browser Help Text\n\n " htx[0] = N_("File Browser Help Text\n\n "
"The file browser is used to visually browse the " "The file browser is used to visually browse the "
"directory structure to select a file for reading " "directory structure to select a file for reading "
"or writing. You may use the arrow keys or Page Up/" "or writing. You may use the arrow keys or Page Up/"
"Down to browse through the files, and S or Enter to " "Down to browse through the files, and S or Enter to "
"choose the selected file or enter the selected " "choose the selected file or enter the selected "
"directory. To move up one level, select the directory " "directory. To move up one level, select the "
"called \"..\" at the top of the file list.\n\n The " "directory called \"..\" at the top of the file "
"following function keys are available in the file " "list.\n\n The following function keys are available "
"browser:\n\n"); "in the file browser:\n\n");
else if (currshortcut == gotodir_list) htx[1] = NULL;
htx = N_("Browser Go To Directory Help Text\n\n " htx[2] = NULL;
} else if (currshortcut == gotodir_list) {
htx[0] = N_("Browser Go To Directory Help Text\n\n "
"Enter the name of the directory you would like to " "Enter the name of the directory you would like to "
"browse to.\n\n If tab completion has not been disabled, " "browse to.\n\n If tab completion has not been "
"you can use the Tab key to (attempt to) automatically " "disabled, you can use the Tab key to (attempt to) "
"complete the directory name.\n\n The following function " "automatically complete the directory name.\n\n The "
"keys are available in Browser Go To Directory mode:\n\n"); "following function keys are available in Browser Go "
"To Directory mode:\n\n");
htx[1] = NULL;
htx[2] = NULL;
}
#endif #endif
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
else if (currshortcut == spell_list) else if (currshortcut == spell_list) {
htx = N_("Spell Check Help Text\n\n " htx[0] = N_("Spell Check Help Text\n\n "
"The spell checker checks the spelling of all text " "The spell checker checks the spelling of all text in "
"in the current file. When an unknown word is " "the current file. When an unknown word is "
"encountered, it is highlighted and a replacement can " "encountered, it is highlighted and a replacement can "
"be edited. It will then prompt to replace every " "be edited. It will then prompt to replace every "
"instance of the given misspelled word in the " "instance of the given misspelled word in the current "
"current file, or, if you have selected text with the " "file, or, if you have selected text with the mark, in "
"mark, in the selected text.\n\n The following other " "the selected text.\n\n The following other functions "
"functions are available in Spell Check mode:\n\n"); "are available in Spell Check mode:\n\n");
htx[1] = NULL;
htx[2] = NULL;
}
#endif #endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
else if (currshortcut == extcmd_list) else if (currshortcut == extcmd_list) {
htx = N_("External Command Help Text\n\n " htx[0] = N_("Execute Command Help Text\n\n "
"This menu allows you to insert the output of a command " "This menu allows you to insert the output of a "
"run by the shell into the current buffer (or a new " "command run by the shell into the current buffer (or "
"buffer in multibuffer mode). If you need another blank " "a new buffer in multiple file buffer mode). If you "
"buffer, do not enter any command.\n\n The following keys " "need another blank buffer, do not enter any "
"are available in this mode:\n\n"); "command.\n\n The following keys are available in "
"Execute Command mode:\n\n");
htx[1] = NULL;
htx[2] = NULL;
}
#endif #endif
else else {
/* Default to the main help list. */ /* Default to the main help list. */
htx = N_(" nano help text\n\n " htx[0] = N_(" nano help text\n\n "
"The nano editor is designed to emulate the functionality and " "The nano editor is designed to emulate the "
"ease-of-use of the UW Pico text editor. There are four main " "functionality and ease-of-use of the UW Pico text "
"sections of the editor. The top line shows the program " "editor. There are four main sections of the editor. "
"version, the current filename being edited, and whether " "The top line shows the program version, the current "
"or not the file has been modified. Next is the main editor " "filename being edited, and whether or not the file "
"window showing the file being edited. The status line is " "has been modified. Next is the main editor window "
"the third line from the bottom and shows important messages. " "showing the file being edited. The status line is "
"The bottom two lines show the most commonly used shortcuts " "the third line from the bottom and shows important "
"in the editor.\n\n " "messages. The bottom two lines show the most "
"The notation for shortcuts is as follows: Control-key " "commonly used shortcuts in the editor.\n\n ");
"sequences are notated with a caret (^) symbol and can be " htx[1] = N_("The notation for shortcuts is as follows: "
"entered either by using the Control (Ctrl) key or pressing the " "Control-key sequences are notated with a caret (^) "
"Esc key twice. Escape-key sequences are notated with the Meta " "symbol and can be entered either by using the Control "
"(M) symbol and can be entered using either the Esc, Alt or " "(Ctrl) key or pressing the Escape (Esc) key twice. "
"Meta key depending on your keyboard setup. Also, pressing Esc " "Escape-key sequences are notated with the Meta (M) "
"twice and then typing a three-digit decimal number from 000 to " "symbol and can be entered using either the Esc, Alt, "
"255 will enter the character with the corresponding value. " "or Meta key depending on your keyboard setup. ");
"The following keystrokes are available in the main editor " htx[2] = N_("Also, pressing Esc twice and then typing a "
"window. Alternative keys are shown in parentheses:\n\n"); "three-digit decimal number from 000 to 255 will enter "
"the character with the corresponding value. The "
"following keystrokes are available in the main editor "
"window. Alternative keys are shown in "
"parentheses:\n\n");
}
htx = _(htx); htx[0] = _(htx[0]);
if (htx[1] != NULL)
htx[1] = _(htx[1]);
if (htx[2] != NULL)
htx[2] = _(htx[2]);
allocsize += strlen(htx); allocsize += strlen(htx[0]);
if (htx[1] != NULL)
allocsize += strlen(htx[1]);
if (htx[2] != NULL)
allocsize += strlen(htx[2]);
/* The space needed for the shortcut lists, at most COLS characters, /* The space needed for the shortcut lists, at most COLS characters,
* plus '\n'. */ * plus '\n'. */
@ -414,7 +453,12 @@ void help_init(void)
help_text = charalloc(allocsize + 1); help_text = charalloc(allocsize + 1);
/* Now add the text we want. */ /* Now add the text we want. */
strcpy(help_text, htx); strcpy(help_text, htx[0]);
if (htx[1] != NULL)
strcat(help_text, htx[1]);
if (htx[2] != NULL)
strcat(help_text, htx[2]);
ptr = help_text + strlen(help_text); ptr = help_text + strlen(help_text);
/* Now add our shortcut info. Assume that each shortcut has, at the /* Now add our shortcut info. Assume that each shortcut has, at the