Fixes for the nano.h #defines, shortcut_init() lists and search.c reverse search stuff when NANO_SMALL is used

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@733 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2001-07-16 00:48:53 +00:00
parent f372bd9f8c
commit 5f36c3760f
5 changed files with 85 additions and 51 deletions

View File

@ -2,13 +2,25 @@ CVS code -
- nano.c: - nano.c:
main() main()
- Change the getop option to 'F' (David Lawrence Ramsey) - Change the getop option to 'F' (David Lawrence Ramsey)
- global.c:
shortcut_init()
- Rewrote the whereis and replace lists to put CANCEL at the end
of the list, and not include the toggle functions when using
NANO_SMALL.
- nano.h: - nano.h:
- Fix type in INSERTFILE_LIST_LEN. - Fix type in INSERTFILE_LIST_LEN.
- Rewrote all the macro definitions to be a little less messy,
for the #ifdefs anyway.
- rcfile.c: - rcfile.c:
- Update for the multibuffer option (oops) (David Lawrence Ramsey). - Update for the multibuffer option (oops) (David Lawrence Ramsey).
- search.c: - search.c:
- Added #ifdef NANO_SMALLs around the REVERSE_SEARCH code.
search_init() search_init()
- add #ifdef NANO_SMALL around toggles code. - add #ifdef NANO_SMALL around toggles code.
- winio.c:
bottombars()
- Fixed an off by one that wasn't letting lines with odd #
shortcuts work in certain cases.
nano-1.1.0 - 07/15/2001 nano-1.1.0 - 07/15/2001
- General - General

View File

@ -226,14 +226,12 @@ void shortcut_init(int unjustify)
"", *nano_lastline_msg = "", *nano_refresh_msg = "", *nano_lastline_msg = "", *nano_refresh_msg =
"", *nano_mark_msg = "", *nano_delete_msg = "", *nano_mark_msg = "", *nano_delete_msg =
"", *nano_backspace_msg = "", *nano_tab_msg = "", *nano_backspace_msg = "", *nano_tab_msg =
"", *nano_enter_msg = "", *nano_case_msg = "", *nano_enter_msg = "", *nano_cancel_msg =
"", *nano_cancel_msg = "", *nano_unjustify_msg = "", *nano_unjustify_msg = "", *nano_append_msg = "";
"", *nano_append_msg = "", *nano_reverse_msg =
"", *nano_regexp_msg = "";
#ifndef NANO_SMALL #ifndef NANO_SMALL
char *nano_tofiles_msg = ""; char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg =
char *nano_gotodir_msg = ""; "", *nano_reverse_msg = "", *nano_regexp_msg = "";
nano_help_msg = _("Invoke the help menu"); nano_help_msg = _("Invoke the help menu");
nano_writeout_msg = _("Write the current file to disk"); nano_writeout_msg = _("Write the current file to disk");
@ -414,19 +412,22 @@ void shortcut_init(int unjustify)
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW, _("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
do_gotoline_void); do_gotoline_void);
sc_init_one(&whereis_list[4], NANO_CANCEL_KEY, _("Cancel"), #ifndef NANO_SMALL
nano_cancel_msg, 0, 0, 0, VIEW, 0); sc_init_one(&whereis_list[4], TOGGLE_CASE_KEY, _("Case Sens"),
sc_init_one(&whereis_list[5], TOGGLE_CASE_KEY, _("Case Sens"),
nano_case_msg, 0, 0, 0, VIEW, 0); nano_case_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&whereis_list[6], TOGGLE_BACKWARDS_KEY, _("Backward"), sc_init_one(&whereis_list[5], TOGGLE_BACKWARDS_KEY, _("Backward"),
nano_reverse_msg, 0, 0, 0, VIEW, 0); nano_reverse_msg, 0, 0, 0, VIEW, 0);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
sc_init_one(&whereis_list[7], TOGGLE_REGEXP_KEY, _("Regexp"), sc_init_one(&whereis_list[REPLACE_LIST_LEN - 2], TOGGLE_REGEXP_KEY,
nano_regexp_msg, 0, 0, 0, VIEW, 0); _("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
#endif #endif
#endif /* NANO_SMALL */
sc_init_one(&whereis_list[REPLACE_LIST_LEN - 1], NANO_CANCEL_KEY,
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&replace_list[0], NANO_FIRSTLINE_KEY, _("First Line"), sc_init_one(&replace_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line); nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
@ -441,19 +442,21 @@ void shortcut_init(int unjustify)
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW, _("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
do_gotoline_void); do_gotoline_void);
sc_init_one(&replace_list[4], NANO_CANCEL_KEY, _("Cancel"), #ifndef NANO_SMALL
nano_cancel_msg, 0, 0, 0, VIEW, 0); sc_init_one(&replace_list[4], TOGGLE_CASE_KEY, _("Case Sens"),
sc_init_one(&replace_list[5], TOGGLE_CASE_KEY, _("Case Sens"),
nano_case_msg, 0, 0, 0, VIEW, 0); nano_case_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&replace_list[6], TOGGLE_BACKWARDS_KEY, _("Backward"), sc_init_one(&replace_list[5], TOGGLE_BACKWARDS_KEY, _("Backward"),
nano_reverse_msg, 0, 0, 0, VIEW, 0); nano_reverse_msg, 0, 0, 0, VIEW, 0);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
sc_init_one(&replace_list[7], TOGGLE_REGEXP_KEY, _("Regexp"), sc_init_one(&replace_list[REPLACE_LIST_LEN - 2], TOGGLE_REGEXP_KEY,
nano_regexp_msg, 0, 0, 0, VIEW, 0); _("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
#endif #endif
#endif /* NANO_SMALL */
sc_init_one(&replace_list[REPLACE_LIST_LEN - 1], NANO_CANCEL_KEY,
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&replace_list_2[0], NANO_FIRSTLINE_KEY, _("First Line"), sc_init_one(&replace_list_2[0], NANO_FIRSTLINE_KEY, _("First Line"),

54
nano.h
View File

@ -276,28 +276,40 @@ know what you're doing */
/* Toggle stuff, these static lengths need to go away RSN */ /* Toggle stuff, these static lengths need to go away RSN */
#ifndef HAVE_REGEX_H
#define NO_REGEX 1
#else
#define NO_REGEX 0
#endif
#ifdef DISABLE_BROWSER
#define NO_BROWSER 1
#else
#define NO_BROWSER 0
#endif
#ifdef NANO_SMALL
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
#define NO_TOGGLES 3
#else
#define NO_TOGGLES 2
#endif /* HAVE_REGEX_H */
#else
#define NO_TOGGLES 0
#endif /* NANO_SMALL */
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
#define TOGGLE_LEN 14 #define MULTI_TOGGLES 3
#else #else
#define TOGGLE_LEN 11 #define MULTI_TOGGLES 0
#endif
#define WHEREIS_LIST_LEN 8
#define REPLACE_LIST_LEN 8
#else
#ifdef ENABLE_MULTIBUFFER
#define TOGGLE_LEN 13
#else
#define TOGGLE_LEN 10
#endif
#define WHEREIS_LIST_LEN 7
#define REPLACE_LIST_LEN 7
#endif #endif
#define WHEREIS_LIST_LEN (8 - NO_REGEX - NO_TOGGLES)
#define REPLACE_LIST_LEN (8 - NO_REGEX - NO_TOGGLES)
#define TOGGLE_LEN (11 - NO_REGEX + MULTI_TOGGLES)
#define WRITEFILE_LIST_LEN (3 - NO_BROWSER)
#define INSERTFILE_LIST_LEN (2 - NO_BROWSER)
#define BROWSER_LIST_LEN 4
#define MAIN_LIST_LEN 26 #define MAIN_LIST_LEN 26
#define MAIN_VISIBLE 12 #define MAIN_VISIBLE 12
#define REPLACE_LIST_2_LEN 3 #define REPLACE_LIST_2_LEN 3
@ -306,14 +318,8 @@ know what you're doing */
#define HELP_LIST_LEN 3 #define HELP_LIST_LEN 3
#define SPELL_LIST_LEN 1 #define SPELL_LIST_LEN 1
#ifndef DISABLE_BROWSER
#define WRITEFILE_LIST_LEN 3
#define INSERTFILE_LIST_LEN 2
#define BROWSER_LIST_LEN 4
#else
#define WRITEFILE_LIST_LEN 3
#define INSERTFILE_LIST_LEN 1
#endif
#define VIEW 1 #define VIEW 1
#define NOVIEW 0 #define NOVIEW 0

25
utils.c
View File

@ -47,6 +47,8 @@ void lowercase(char *src)
} }
} }
/* None of this is needed if we're using NANO_SMALL! */
#ifndef NANO_SMALL
char *revstrstr(char *haystack, char *needle, char *rev_start) char *revstrstr(char *haystack, char *needle, char *rev_start)
{ {
char *p, *q, *r; char *p, *q, *r;
@ -72,6 +74,7 @@ char *revstrcasestr(char *haystack, char *needle, char *rev_start)
} }
return 0; return 0;
} }
#endif /* NANO_SMALL */
/* This is now mutt's version (called mutt_stristr) because it doesn't /* This is now mutt's version (called mutt_stristr) because it doesn't
use memory allocation to do a simple search (yuck). */ use memory allocation to do a simple search (yuck). */
@ -103,11 +106,13 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start)
char *i, *j; char *i, *j;
if (ISSET(USE_REGEXP)) { if (ISSET(USE_REGEXP)) {
#ifndef NANO_SMALL
if (!ISSET(REVERSE_SEARCH)) { if (!ISSET(REVERSE_SEARCH)) {
result = regexec(&search_regexp, haystack, 10, regmatches, 0); result = regexec(&search_regexp, haystack, 10, regmatches, 0);
if (!result) if (!result)
return haystack + regmatches[0].rm_so; return haystack + regmatches[0].rm_so;
} else { } else {
#endif
/* do quick check first */ /* do quick check first */
if (!(regexec(&search_regexp, haystack, 10, regmatches, 0))) { if (!(regexec(&search_regexp, haystack, 10, regmatches, 0))) {
/* there is a match */ /* there is a match */
@ -117,21 +122,29 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start)
if (j <= rev_start) if (j <= rev_start)
return j; return j;
} }
} }
#ifndef NANO_SMALL
} }
#endif
return 0; return 0;
} }
#endif #endif
if (ISSET(CASE_SENSITIVE)) { if (ISSET(CASE_SENSITIVE)) {
if (!ISSET(REVERSE_SEARCH)) #ifndef NANO_SMALL
return strstr(haystack,needle); if (ISSET(REVERSE_SEARCH))
else
return revstrstr(haystack, needle, rev_start); return revstrstr(haystack, needle, rev_start);
else
#endif
return strstr(haystack,needle);
} else { } else {
if (!ISSET(REVERSE_SEARCH)) #ifndef NANO_SMALL
return strcasestr(haystack, needle); if (ISSET(REVERSE_SEARCH))
else
return revstrcasestr(haystack, needle, rev_start); return revstrcasestr(haystack, needle, rev_start);
else
#endif
return strcasestr(haystack, needle);
} }
} }

View File

@ -607,7 +607,7 @@ void bottombars(shortcut s[], int slen)
clear_bottomwin(); clear_bottomwin();
wmove(bottomwin, 1, 0); wmove(bottomwin, 1, 0);
for (i = 0; i <= slen - 2; i += 2) { for (i = 0; i <= slen - 1; i += 2) {
if (s[i].val < 97) if (s[i].val < 97)
snprintf(keystr, 10, "^%c", s[i].val + 64); snprintf(keystr, 10, "^%c", s[i].val + 64);