mirror of git://git.sv.gnu.org/nano.git
Carl Drinkwater's titlebar spacing fixes, David Benbennick's help browser
fixes, and my regexp searching bug fix git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1223 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
834913c8b1
commit
c5967551f6
23
ChangeLog
23
ChangeLog
|
@ -5,12 +5,17 @@ CVS Code -
|
|||
Removed intl/ entirely, and a few more tweaks by gettextize.
|
||||
- i18nized a few strings used in DEBUG mode. (DLR)
|
||||
- Some chars being assigned 0 are now assigned '\0'. (DLR)
|
||||
- Put header files in a more consistent order. (DLR)
|
||||
- Put header file #includes in a more consistent order. (DLR)
|
||||
- Remove some unneeded blank lines and spaces, and make some
|
||||
spacing more consistent. (DLR)
|
||||
- When possible, use iscntrl() to determine whether a character
|
||||
is a control character or not. (DLR)
|
||||
- Miscellaneous typo fixes. (DLR)
|
||||
- Many fixes to the help browser and shortcut lists: efficiency
|
||||
updates, consistency fixes, help text fixes and improvements,
|
||||
and spacing improvements. (David Benbennick)
|
||||
- Make more functions use const variables when possible. (David
|
||||
Benbennick)
|
||||
- files.c:
|
||||
read_file(), read_line():
|
||||
- Rework to properly handle nulls in the input file, fix
|
||||
|
@ -52,10 +57,17 @@ CVS Code -
|
|||
with it, instead of calling clear_filename() in two places.
|
||||
Make startline an int instead of a long, since it's supposed to
|
||||
hold a line number. (DLR)
|
||||
- Properly handle multiple -r settings on the command line. (Carl
|
||||
Drinkwater)
|
||||
- search.c:
|
||||
findnextstr():
|
||||
- Update the current line at current_x if we don't find a match.
|
||||
(DLR)
|
||||
Also, pass current_x_find to strstrwrapper() so we know whether
|
||||
we're at the beginning of a string or not (see changes to
|
||||
strstrwrapper() below), and reset it between lines. (DLR)
|
||||
do_gotoline():
|
||||
- Make sure placewewant is zero after we go to a line. (David
|
||||
Benbennick)
|
||||
do_gotopos():
|
||||
- Simplify the sanity check to only put x within the range of the
|
||||
current line; don't call actual_x() anymore. (DLR)
|
||||
|
@ -64,6 +76,10 @@ CVS Code -
|
|||
other than the terminating null in strings to newlines and
|
||||
back; they're used to handle null characters in files properly.
|
||||
(DLR)
|
||||
strstrwrapper(): Set REG_NOTBOL when we're not at the beginning of a
|
||||
string, to avoid false positives when searching for regular
|
||||
expressions prefixed with ^. Make it take a new parameter,
|
||||
line_pos, to determine where we are in the string. (DLR)
|
||||
- winio.c:
|
||||
actual_x_from_start():
|
||||
- Overhaul to make cursor placement more like that of Pico: add
|
||||
|
@ -74,6 +90,9 @@ CVS Code -
|
|||
- After the user presses Enter at the prompt, refresh the edit
|
||||
window in case there's a list of possible filename matches
|
||||
(left over from attempted tab completion) on it. (DLR)
|
||||
titlebar():
|
||||
- Tweak text spacing and printing so that the titlebar text looks
|
||||
better on smaller terminals. (Carl Drinkwater)
|
||||
update_line():
|
||||
- When marking control characters, make sure the mark moves
|
||||
forward by two characters inctead of one. Rework control
|
||||
|
|
33
global.c
33
global.c
|
@ -369,7 +369,7 @@ void shortcut_init(int unjustify)
|
|||
_("Make the current search or replace case (in)sensitive");
|
||||
nano_tofiles_msg = _("Go to file browser");
|
||||
nano_execute_msg = _("Execute external command");
|
||||
nano_gotodir_msg = _("Goto Directory");
|
||||
nano_gotodir_msg = _("Go to directory");
|
||||
nano_cancel_msg = _("Cancel the current function");
|
||||
nano_append_msg = _("Append to the current file");
|
||||
nano_prepend_msg = _("Prepend to the current file");
|
||||
|
@ -541,10 +541,20 @@ void shortcut_init(int unjustify)
|
|||
IFHELP(nano_enter_msg, 0),
|
||||
KEY_ENTER, NANO_CONTROL_M, NOVIEW, do_enter_void);
|
||||
|
||||
sc_init_one(&main_list, NANO_GOTO_KEY, _("Goto Line"),
|
||||
sc_init_one(&main_list, NANO_GOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, NANO_ALT_GOTO_KEY),
|
||||
NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&main_list, NANO_NEXTWORD_KEY, _("Next Word"),
|
||||
IFHELP(_("Move forward one word"), 0),
|
||||
0, 0, VIEW, do_next_word_void);
|
||||
|
||||
sc_init_one(&main_list, -9, _("Prev Word"),
|
||||
IFHELP(_("Move backward one word"), NANO_PREVWORD_KEY), 0, 0,
|
||||
VIEW, do_prev_word_void);
|
||||
#endif
|
||||
|
||||
#if (!defined NANO_SMALL) && (defined HAVE_REGEX_H)
|
||||
sc_init_one(&main_list, -9, _("Find Other Bracket"),
|
||||
IFHELP(nano_bracket_msg, NANO_BRACKET_KEY),
|
||||
|
@ -560,15 +570,6 @@ void shortcut_init(int unjustify)
|
|||
0, 0, VIEW, open_nextfile_void);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&main_list, NANO_NEXTWORD_KEY, _("Next Word"),
|
||||
IFHELP(_("Move forward one word"), 0),
|
||||
0, 0, VIEW, do_next_word_void);
|
||||
sc_init_one(&main_list, -9, _("Prev Word"),
|
||||
IFHELP(_("Move backward one word"), NANO_PREVWORD_KEY), 0, 0,
|
||||
VIEW, do_prev_word_void);
|
||||
#endif
|
||||
|
||||
free_shortcutage(&whereis_list);
|
||||
|
||||
sc_init_one(&whereis_list, NANO_HELP_KEY, _("Get Help"),
|
||||
|
@ -587,7 +588,7 @@ void shortcut_init(int unjustify)
|
|||
sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("Replace"),
|
||||
IFHELP(nano_replace_msg, 0), 0, 0, VIEW, do_replace);
|
||||
|
||||
sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, _("Goto Line"),
|
||||
sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, 0), 0, 0, VIEW, do_gotoline_void);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
|
@ -620,7 +621,7 @@ void shortcut_init(int unjustify)
|
|||
sc_init_one(&replace_list, NANO_OTHERSEARCH_KEY, _("No Replace"),
|
||||
IFHELP(nano_whereis_msg, 0), 0, 0, VIEW, do_search);
|
||||
|
||||
sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY, _("Goto Line"),
|
||||
sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, 0), 0, 0, VIEW, do_gotoline_void);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
|
@ -747,8 +748,8 @@ void shortcut_init(int unjustify)
|
|||
sc_init_one(&browser_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&browser_list, NANO_EXIT_KEY, _("Exit"),
|
||||
IFHELP(nano_exit_msg, 0), NANO_EXIT_FKEY, 0, VIEW, 0);
|
||||
sc_init_one(&browser_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), NANO_EXIT_FKEY, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
IFHELP(nano_prevpage_msg, 0), NANO_PREVPAGE_FKEY,
|
||||
|
@ -758,7 +759,7 @@ void shortcut_init(int unjustify)
|
|||
IFHELP(nano_nextpage_msg, 0), NANO_NEXTPAGE_FKEY,
|
||||
KEY_NPAGE, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list, NANO_GOTO_KEY, _("Goto"),
|
||||
sc_init_one(&browser_list, NANO_GOTO_KEY, _("Go To Dir"),
|
||||
IFHELP(nano_gotodir_msg, NANO_ALT_GOTO_KEY),
|
||||
NANO_GOTO_FKEY, 0, VIEW, 0);
|
||||
|
||||
|
|
226
nano.c
226
nano.c
|
@ -70,10 +70,6 @@ int wrap_at = 0;/* Right justified fill value, allows resize */
|
|||
struct termios oldterm; /* The user's original term settings */
|
||||
static struct sigaction act; /* For all our fun signal handlers */
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
static char *help_text_init = ""; /* Initial message, not including shortcuts */
|
||||
#endif
|
||||
|
||||
char *last_search = NULL; /* Last string we searched for */
|
||||
char *last_replace = NULL; /* Last replacement string */
|
||||
int search_last_line; /* Is this the last search line? */
|
||||
|
@ -248,33 +244,7 @@ void global_init(int save_cutbuffer)
|
|||
|
||||
}
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
void init_help_msg(void)
|
||||
{
|
||||
|
||||
help_text_init =
|
||||
_(" nano help text\n\n "
|
||||
"The nano editor is designed to emulate the functionality and "
|
||||
"ease-of-use of the UW Pico text editor. There are four main "
|
||||
"sections of the editor: The top line shows the program "
|
||||
"version, the current filename being edited, and whether "
|
||||
"or not the file has been modified. Next is the main editor "
|
||||
"window showing the file being edited. The status line is "
|
||||
"the third line from the bottom and shows important messages. "
|
||||
"The bottom two lines show the most commonly used shortcuts "
|
||||
"in the editor.\n\n "
|
||||
"The notation for shortcuts is as follows: Control-key "
|
||||
"sequences are notated with a caret (^) symbol and are entered "
|
||||
"with the Control (Ctrl) key. Escape-key sequences are notated "
|
||||
"with the Meta (M) symbol and can be entered using either the "
|
||||
"Esc, Alt or Meta key depending on your keyboard setup. The "
|
||||
"following keystrokes are available in the main editor window. "
|
||||
"Optional keys are shown in parentheses:\n\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make a copy of a node to a pointer (space will be malloc()ed). This
|
||||
does NOT copy the data members used only by open_files. */
|
||||
/* Make a copy of a node to a pointer (space will be malloc()ed). */
|
||||
filestruct *copy_node(filestruct * src)
|
||||
{
|
||||
filestruct *dst;
|
||||
|
@ -2514,17 +2484,16 @@ int do_justify(void)
|
|||
}
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
/* This function allocates help_text, and stores the help string in it.
|
||||
* help_text should be NULL initially. */
|
||||
void help_init(void)
|
||||
{
|
||||
int i, sofar = 0, helplen;
|
||||
long allocsize = 1; /* How much space we're gonna need for the help text */
|
||||
size_t allocsize = 1; /* space needed for help_text */
|
||||
char *ptr = NULL;
|
||||
#ifndef NANO_SMALL
|
||||
toggle *t;
|
||||
const toggle *t;
|
||||
#endif
|
||||
shortcut *s;
|
||||
|
||||
helplen = length_of_list(currshortcut);
|
||||
const shortcut *s;
|
||||
|
||||
/* First set up the initial help text for the current function */
|
||||
if (currshortcut == whereis_list || currshortcut == replace_list
|
||||
|
@ -2534,29 +2503,29 @@ void help_init(void)
|
|||
"for, then hit enter. If there is a match for the text you "
|
||||
"entered, the screen will be updated to the location of the "
|
||||
"nearest match for the search string.\n\n "
|
||||
"If using Pico Mode via the -p or --pico flags, using the "
|
||||
"Meta-P toggle or using a nanorc file, the previous search "
|
||||
"If using Pico Mode via the -p or --pico flags, the "
|
||||
"Meta-P toggle, or a nanorc file, the previous search "
|
||||
"string will be shown in brackets after the Search: prompt. "
|
||||
"Hitting enter without entering any text will perform the "
|
||||
"Hitting Enter without entering any text will perform the "
|
||||
"previous search. Otherwise, the previous string will be "
|
||||
"placed in front of the cursor, and can be edited or deleted "
|
||||
"before hitting enter.\n\n The following functions keys are "
|
||||
"placed before the cursor, and can be edited or deleted "
|
||||
"before hitting enter.\n\n The following function keys are "
|
||||
"available in Search mode:\n\n");
|
||||
else if (currshortcut == goto_list)
|
||||
ptr = _("Goto Line Help Text\n\n "
|
||||
ptr = _("Go To Line Help Text\n\n "
|
||||
"Enter the line number that you wish to go to and hit "
|
||||
"Enter. If there are fewer lines of text than the "
|
||||
"number you entered, you will be brought to the last line "
|
||||
"of the file.\n\n The following functions keys are "
|
||||
"available in Goto Line mode:\n\n");
|
||||
"of the file.\n\n The following function keys are "
|
||||
"available in Go To Line mode:\n\n");
|
||||
else if (currshortcut == insertfile_list)
|
||||
ptr = _("Insert File Help Text\n\n "
|
||||
"Type in the name of a file to be inserted into the current "
|
||||
"file buffer at the current cursor location.\n\n "
|
||||
"If you have compiled nano with multiple file buffer "
|
||||
"support, and enable multiple buffers with the -F "
|
||||
"or --multibuffer command line flags, the Meta-F toggle or "
|
||||
"using a nanorc file, inserting a file will cause it to be "
|
||||
"or --multibuffer command line flags, the Meta-F toggle, or "
|
||||
"a nanorc file, inserting a file will cause it to be "
|
||||
"loaded into a separate buffer (use Meta-< and > to switch "
|
||||
"between file buffers).\n\n If you need another blank "
|
||||
"buffer, do not enter any filename, or type in a "
|
||||
|
@ -2566,14 +2535,13 @@ void help_init(void)
|
|||
else if (currshortcut == writefile_list)
|
||||
ptr = _("Write File Help Text\n\n "
|
||||
"Type the name that you wish to save the current file "
|
||||
"as and hit enter to save the file.\n\n "
|
||||
"If you are using the marker code with Ctrl-^ and have "
|
||||
"selected text, you will be prompted to save only the "
|
||||
"selected portion to a separate file. To reduce the "
|
||||
"chance of overwriting the current file with just a portion "
|
||||
"of it, the current filename is not the default in this "
|
||||
"mode.\n\n The following function keys are available in "
|
||||
"Write File mode:\n\n");
|
||||
"as and hit Enter to save the file.\n\n If you have "
|
||||
"selected text with Ctrl-^, you will be prompted to "
|
||||
"save only the selected portion to a separate file. To "
|
||||
"reduce the chance of overwriting the current file with "
|
||||
"just a portion of it, the current filename is not the "
|
||||
"default in this mode.\n\n The following function keys "
|
||||
"are available in Write File mode:\n\n");
|
||||
#ifndef DISABLE_BROWSER
|
||||
else if (currshortcut == browser_list)
|
||||
ptr = _("File Browser Help Text\n\n "
|
||||
|
@ -2584,15 +2552,15 @@ void help_init(void)
|
|||
"choose the selected file or enter the selected "
|
||||
"directory. To move up one level, select the directory "
|
||||
"called \"..\" at the top of the file list.\n\n The "
|
||||
"following functions keys are available in the file "
|
||||
"following function keys are available in the file "
|
||||
"browser:\n\n");
|
||||
else if (currshortcut == gotodir_list)
|
||||
ptr = _("Browser Goto Directory Help Text\n\n "
|
||||
ptr = _("Browser Go To Directory Help Text\n\n "
|
||||
"Enter the name of the directory you would like to "
|
||||
"browse to.\n\n If tab completion has not been disabled, "
|
||||
"you can use the TAB key to (attempt to) automatically "
|
||||
"complete the directory name.\n\n The following function "
|
||||
"keys are available in Browser GotoDir mode:\n\n");
|
||||
"keys are available in Browser Go To Directory mode:\n\n");
|
||||
#endif
|
||||
else if (currshortcut == spell_list)
|
||||
ptr = _("Spell Check Help Text\n\n "
|
||||
|
@ -2612,107 +2580,117 @@ void help_init(void)
|
|||
"available in this mode:\n\n");
|
||||
#endif
|
||||
else /* Default to the main help list */
|
||||
ptr = help_text_init;
|
||||
ptr = _(" nano help text\n\n "
|
||||
"The nano editor is designed to emulate the functionality and "
|
||||
"ease-of-use of the UW Pico text editor. There are four main "
|
||||
"sections of the editor: The top line shows the program "
|
||||
"version, the current filename being edited, and whether "
|
||||
"or not the file has been modified. Next is the main editor "
|
||||
"window showing the file being edited. The status line is "
|
||||
"the third line from the bottom and shows important messages. "
|
||||
"The bottom two lines show the most commonly used shortcuts "
|
||||
"in the editor.\n\n "
|
||||
"The notation for shortcuts is as follows: Control-key "
|
||||
"sequences are notated with a caret (^) symbol and are entered "
|
||||
"with the Control (Ctrl) key. Escape-key sequences are notated "
|
||||
"with the Meta (M) symbol and can be entered using either the "
|
||||
"Esc, Alt or Meta key depending on your keyboard setup. The "
|
||||
"following keystrokes are available in the main editor window. "
|
||||
"Alternative keys are shown in parentheses:\n\n");
|
||||
|
||||
/* Compute the space needed for the shortcut lists - we add 15 to
|
||||
have room for the shortcut abbrev and its possible alternate keys */
|
||||
s = currshortcut;
|
||||
for (i = 0; i <= helplen - 1; i++) {
|
||||
if (s->help != NULL)
|
||||
allocsize += strlen(s->help) + 15;
|
||||
s = s->next;
|
||||
assert(currshortcut != NULL);
|
||||
/* Compute the space needed for the shortcut lists */
|
||||
for (s = currshortcut; s != NULL; s = s->next) {
|
||||
assert(s->help != NULL);
|
||||
/* Each shortcut has at most 24 chars for the shortcut keys, plus
|
||||
* the help description, plus 1 for \n. */
|
||||
allocsize += strlen(s->help) + 25;
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* If we're on the main list, we also allocate space for toggle help text. */
|
||||
/* If we're on the main list, we also count the toggle help text. */
|
||||
if (currshortcut == main_list) {
|
||||
for (t = toggles; t != NULL; t = t->next)
|
||||
if (t->desc != NULL)
|
||||
allocsize += strlen(t->desc) + 30;
|
||||
for (t = toggles; t != NULL; t = t->next) {
|
||||
size_t len;
|
||||
|
||||
assert(t->desc != NULL);
|
||||
len = strlen(t->desc);
|
||||
|
||||
/* 6 for "M-%c\t\t\t", which fills 24 columns. */
|
||||
allocsize += 6 + (len < COLS-24 ? len : COLS-24);
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
allocsize += strlen(ptr);
|
||||
|
||||
if (help_text != NULL)
|
||||
free(help_text);
|
||||
/* Other routines should have set help_text to NULL before */
|
||||
assert(help_text == NULL);
|
||||
|
||||
/* Allocate space for the help text */
|
||||
help_text = charalloc(allocsize);
|
||||
|
||||
/* Now add the text we want */
|
||||
strcpy(help_text, ptr);
|
||||
sofar = strlen(help_text);
|
||||
ptr = help_text + strlen(help_text);
|
||||
|
||||
/* Now add our shortcut info */
|
||||
s = currshortcut;
|
||||
for (i = 0; i <= helplen - 1; i++) {
|
||||
for (s = currshortcut; s != NULL; s = s->next) {
|
||||
/* true if the character in s->altval is shown in first column */
|
||||
int meta_shortcut = 0;
|
||||
|
||||
if (s->val > 0 && s->val < 32)
|
||||
sofar += sprintf(help_text + sofar, "^%c\t", s->val + 64);
|
||||
ptr += sprintf(ptr, "^%c", s->val + 64);
|
||||
#ifndef NANO_SMALL
|
||||
else if (s->val == NANO_CONTROL_SPACE)
|
||||
sofar += sprintf(help_text + sofar, "^%s\t", _("Space"));
|
||||
#endif
|
||||
else if (s->altval > 0)
|
||||
ptr += snprintf(ptr, 8, "^%s", _("Space"));
|
||||
else if (s->altval == NANO_ALT_SPACE) {
|
||||
meta_shortcut = 1;
|
||||
else
|
||||
help_text[sofar++] = '\t';
|
||||
|
||||
if (!meta_shortcut) {
|
||||
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
|
||||
sofar += sprintf(help_text + sofar, "(F%d)",
|
||||
s->misc1 - KEY_F0);
|
||||
help_text[sofar++] = '\t';
|
||||
ptr += snprintf(ptr, 8, "M-%s", _("Space"));
|
||||
}
|
||||
#endif
|
||||
else if (s->altval > 0) {
|
||||
meta_shortcut = 1;
|
||||
ptr += sprintf(ptr, "M-%c", s->altval -
|
||||
(('A' <= s->altval && s->altval <= 'Z') ||
|
||||
'a' <= s->altval ? 32 : 0));
|
||||
}
|
||||
/* Hack */
|
||||
else if (s->val >= 'a') {
|
||||
meta_shortcut = 1;
|
||||
ptr += sprintf(ptr, "M-%c", s->val - 32);
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (s->altval == NANO_ALT_SPACE)
|
||||
sofar += sprintf(help_text + sofar, "M-%s", _("Space"));
|
||||
else
|
||||
#endif
|
||||
if (s->altval > 0)
|
||||
sofar += sprintf(help_text + sofar,
|
||||
(meta_shortcut ? "M-%c" : "(M-%c)"), s->altval -
|
||||
*(ptr++) = '\t';
|
||||
|
||||
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
|
||||
ptr += sprintf(ptr, "(F%d)", s->misc1 - KEY_F0);
|
||||
|
||||
*(ptr++) = '\t';
|
||||
|
||||
if (!meta_shortcut && s->altval > 0)
|
||||
ptr += sprintf(ptr, "(M-%c)", s->altval -
|
||||
(('A' <= s->altval && s->altval <= 'Z') || 'a' <= s->altval
|
||||
? 32 : 0));
|
||||
/* Hack */
|
||||
else if (s->val >= 'a')
|
||||
sofar += sprintf(help_text + sofar,
|
||||
(meta_shortcut ? "(M-%c)\t" : "M-%c\t"), s->val - 32);
|
||||
|
||||
help_text[sofar++] = '\t';
|
||||
*(ptr++) = '\t';
|
||||
|
||||
if (meta_shortcut) {
|
||||
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
|
||||
sofar += sprintf(help_text + sofar,
|
||||
"(F%d)", s->misc1 - KEY_F0);
|
||||
help_text[sofar++] = '\t';
|
||||
help_text[sofar++] = '\t';
|
||||
}
|
||||
|
||||
if (s->help != NULL)
|
||||
sofar += sprintf(help_text + sofar, "%s", s->help);
|
||||
|
||||
help_text[sofar++] = '\n';
|
||||
|
||||
s = s->next;
|
||||
ptr += sprintf(ptr, "%s\n", s->help);
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* And the toggles... */
|
||||
if (currshortcut == main_list)
|
||||
for (t = toggles; t != NULL; t = t->next) {
|
||||
sofar += sprintf(help_text + sofar, "M-%c\t\t\t",
|
||||
t->val - 32);
|
||||
if (t->desc != NULL) {
|
||||
sofar += sprintf(help_text + sofar,
|
||||
_("%s enable/disable"), t->desc);
|
||||
}
|
||||
help_text[sofar++] = '\n';
|
||||
ptr += sprintf(ptr, "M-%c\t\t\t", t->val - 32);
|
||||
ptr += snprintf(ptr, COLS-24, _("%s enable/disable\n"),
|
||||
t->desc);
|
||||
}
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
/* If all went well, we didn't overwrite the allocated space for
|
||||
help_text. */
|
||||
assert(strlen(help_text) < allocsize);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3007,6 +2985,8 @@ int main(int argc, char *argv[])
|
|||
fill = atoi(optarg);
|
||||
if (fill < 0)
|
||||
wrap_at = fill;
|
||||
else if (fill > 0)
|
||||
wrap_at = 0;
|
||||
else if (fill == 0) {
|
||||
usage(); /* To stop bogus data (like a string) */
|
||||
finish(1);
|
||||
|
@ -3093,10 +3073,6 @@ int main(int argc, char *argv[])
|
|||
/* Set up some global variables */
|
||||
global_init(0);
|
||||
shortcut_init(0);
|
||||
#ifndef DISABLE_HELP
|
||||
init_help_msg();
|
||||
help_init();
|
||||
#endif
|
||||
signal_init();
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
2
proto.h
2
proto.h
|
@ -114,7 +114,7 @@ void thanks_for_all_the_fish(void);
|
|||
char *revstrstr(char *haystack, char *needle, char *rev_start);
|
||||
char *stristr(char *haystack, char *needle);
|
||||
char *revstristr(char *haystack, char *needle, char *rev_start);
|
||||
char *strstrwrapper(char *haystack, char *needle, char *rev_start);
|
||||
char *strstrwrapper(char *haystack, char *needle, char *rev_start, int line_pos);
|
||||
int search_init(int replacing);
|
||||
int renumber(filestruct * fileptr);
|
||||
int free_filestruct(filestruct * src);
|
||||
|
|
27
search.c
27
search.c
|
@ -268,7 +268,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
|||
searchstr = &fileptr->data[current_x_find];
|
||||
|
||||
/* Look for needle in searchstr */
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start)) == NULL) {
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start, current_x_find)) == NULL) {
|
||||
|
||||
/* finished processing file, get out */
|
||||
if (search_last_line) {
|
||||
|
@ -279,6 +279,10 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
|||
}
|
||||
|
||||
update_line(fileptr, 0);
|
||||
|
||||
/* reset current_x_find between lines */
|
||||
current_x_find = 0;
|
||||
|
||||
fileptr = fileptr->next;
|
||||
|
||||
if (fileptr == editbot)
|
||||
|
@ -286,7 +290,8 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
|||
|
||||
/* EOF reached ?, wrap around once */
|
||||
if (fileptr == NULL) {
|
||||
if (bracket_mode) /* don't wrap if looking for bracket match */
|
||||
/* don't wrap if looking for bracket match */
|
||||
if (bracket_mode)
|
||||
return NULL;
|
||||
fileptr = fileage;
|
||||
past_editbuff = 1;
|
||||
|
@ -332,7 +337,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
|||
searchstr = fileptr->data;
|
||||
|
||||
/* Look for needle in searchstr */
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start)) == NULL) {
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start, current_x_find)) == NULL) {
|
||||
|
||||
/* finished processing file, get out */
|
||||
if (search_last_line) {
|
||||
|
@ -342,6 +347,10 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
|||
}
|
||||
|
||||
update_line(fileptr, 0);
|
||||
|
||||
/* reset current_x_find between lines */
|
||||
current_x_find = 0;
|
||||
|
||||
fileptr = fileptr->prev;
|
||||
|
||||
if (fileptr == edittop->prev)
|
||||
|
@ -811,14 +820,8 @@ void goto_abort(void)
|
|||
|
||||
int do_gotoline(int line, int save_pos)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (line <= 0) { /* Ask for it */
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = statusq(0, goto_list, "", _("Enter line number"));
|
||||
if (j != 0) {
|
||||
if (statusq(0, goto_list, "", _("Enter line number"))) {
|
||||
statusbar(_("Aborted"));
|
||||
goto_abort();
|
||||
return 0;
|
||||
|
@ -834,7 +837,7 @@ int do_gotoline(int line, int save_pos)
|
|||
}
|
||||
}
|
||||
|
||||
for (current = fileage; ((current->next != NULL) && (i < line)); i++)
|
||||
for (current = fileage; current->next != NULL && line > 1; line--)
|
||||
current = current->next;
|
||||
|
||||
current_x = 0;
|
||||
|
@ -846,7 +849,7 @@ int do_gotoline(int line, int save_pos)
|
|||
else
|
||||
edit_update(current, CENTER);
|
||||
|
||||
placewewant = xplustabs();
|
||||
placewewant = 0;
|
||||
goto_abort();
|
||||
return 1;
|
||||
}
|
||||
|
|
9
utils.c
9
utils.c
|
@ -137,7 +137,7 @@ char *stristr(char *haystack, char *needle)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *strstrwrapper(char *haystack, char *needle, char *rev_start)
|
||||
char *strstrwrapper(char *haystack, char *needle, char *rev_start, int line_pos)
|
||||
{
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
|
@ -145,7 +145,7 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start)
|
|||
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
if (!ISSET(REVERSE_SEARCH)) {
|
||||
result = regexec(&search_regexp, haystack, 10, regmatches, 0);
|
||||
result = regexec(&search_regexp, haystack, 10, regmatches, (line_pos > 0) ? REG_NOTBOL : 0);
|
||||
if (!result)
|
||||
return haystack + regmatches[0].rm_so;
|
||||
#ifndef NANO_SMALL
|
||||
|
@ -155,13 +155,14 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start)
|
|||
/* do a quick search forward first */
|
||||
if (!(regexec(&search_regexp, haystack, 10, regmatches, 0))) {
|
||||
/* there's a match somewhere in the line - now search for it backwards, much slower */
|
||||
for(i = rev_start ; i >= haystack ; --i)
|
||||
if (!(result = regexec(&search_regexp, i, 10, regmatches, 0))) {
|
||||
for (i = rev_start; i >= haystack; --i) {
|
||||
if (!(result = regexec(&search_regexp, i, 10, regmatches, (i > haystack) ? REG_NOTBOL : 0))) {
|
||||
j = i + regmatches[0].rm_so;
|
||||
if (j <= rev_start)
|
||||
return j;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
|
33
winio.c
33
winio.c
|
@ -68,7 +68,7 @@ int do_last_line(void)
|
|||
}
|
||||
|
||||
/* Like xplustabs, but for a specific index of a specific filestruct */
|
||||
int xpt(filestruct * fileptr, int index)
|
||||
int xpt(const filestruct *fileptr, int index)
|
||||
{
|
||||
int i, tabs = 0;
|
||||
|
||||
|
@ -558,13 +558,13 @@ void titlebar(char *path)
|
|||
wattron(topwin, A_REVERSE);
|
||||
#endif
|
||||
|
||||
|
||||
mvwaddstr(topwin, 0, 3, VERMSG);
|
||||
mvwaddnstr(topwin, 0, 2, VERMSG, COLS - 3);
|
||||
|
||||
space = COLS - strlen(VERMSG) - strlen(VERSION) - 21;
|
||||
|
||||
namelen = strlen(what);
|
||||
|
||||
if (space > 0) {
|
||||
if (what[0] == '\0')
|
||||
mvwaddstr(topwin, 0, COLS / 2 - 6, _("New Buffer"));
|
||||
else {
|
||||
|
@ -584,10 +584,11 @@ void titlebar(char *path)
|
|||
waddstr(topwin, what);
|
||||
}
|
||||
}
|
||||
} /* If we don't have space, we shouldn't bother */
|
||||
if (ISSET(MODIFIED))
|
||||
mvwaddstr(topwin, 0, COLS - 10, _("Modified"));
|
||||
mvwaddstr(topwin, 0, COLS - 11, _(" Modified "));
|
||||
else if (ISSET(VIEW_MODE))
|
||||
mvwaddstr(topwin, 0, COLS - 10, _("View"));
|
||||
mvwaddstr(topwin, 0, COLS - 11, _(" View "));
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
color_off(topwin, COLOR_TITLEBAR);
|
||||
|
@ -1733,12 +1734,11 @@ int do_cursorpos_void(void)
|
|||
return do_cursorpos(0);
|
||||
}
|
||||
|
||||
/* Our broken, non-shortcut list compliant help function.
|
||||
But, hey, it's better than nothing, and it's dynamic! */
|
||||
/* Our shortcut-list-compliant help function, which is
|
||||
* better than nothing, and dynamic! */
|
||||
int do_help(void)
|
||||
{
|
||||
#ifndef DISABLE_HELP
|
||||
char *ptr, *end;
|
||||
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp, kp2;
|
||||
int no_help_flag = 0;
|
||||
shortcut *oldshortcut;
|
||||
|
@ -1748,8 +1748,9 @@ int do_help(void)
|
|||
wattroff(bottomwin, A_REVERSE);
|
||||
blank_statusbar();
|
||||
|
||||
/* set help_text as the string to display */
|
||||
help_init();
|
||||
ptr = help_text;
|
||||
assert(help_text != NULL);
|
||||
|
||||
oldshortcut = currshortcut;
|
||||
|
||||
|
@ -1771,7 +1772,8 @@ int do_help(void)
|
|||
bottombars(help_list);
|
||||
|
||||
do {
|
||||
ptr = help_text;
|
||||
const char *ptr = help_text;
|
||||
|
||||
switch (kbinput) {
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
|
@ -1842,14 +1844,10 @@ int do_help(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (i > 1) {
|
||||
|
||||
}
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (i < editwinrows && *ptr != '\0') {
|
||||
end = ptr;
|
||||
const char *end = ptr;
|
||||
while (*end != '\n' && *end != '\0' && j != COLS - 5) {
|
||||
end++;
|
||||
j++;
|
||||
|
@ -1895,6 +1893,11 @@ int do_help(void)
|
|||
nano_disabled_msg();
|
||||
#endif
|
||||
|
||||
/* The help_init() at the beginning allocated help_text, which has
|
||||
now been written to screen. */
|
||||
free(help_text);
|
||||
help_text = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue