Commit dab017e7 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

- More cleanups with DISABLE flags, better free_shortcutage and free_toggle,...

- More cleanups with DISABLE flags, better free_shortcutage and free_toggle, and get rid of unnecessary variable decls with NANO_SMALL in shortcut_init() by David Benbennick


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1194 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 269 additions and 200 deletions
+269 -200
......@@ -15,6 +15,9 @@ CVS code -
- Change from read() and write() to file streams by Jay Carlson.
Allows OS to implement read and write ahead rather than making
us do it. Hopefully merged properly.
- More cleanups with DISABLE flags, better free_shortcutage and
free_toggle, and get rid of unnecessary variable decls with
NANO_SMALL in shortcut_init() by David Benbennick.
- configure.ac:
- Define NDEBUG to silence asserts (David Benbennick).
- files.c:
......
This diff is collapsed.
......@@ -696,7 +696,8 @@ int no_help(void)
return 0;
}
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP)
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || \
defined(DISABLE_HELP) || defined(NANO_SMALL)
void nano_disabled_msg(void)
{
statusbar("Sorry, support for this function has been disabled");
......@@ -746,33 +747,36 @@ int do_enter(filestruct * inptr)
{
filestruct *newnode;
char *tmp;
#ifndef NANO_SMALL
char *spc;
int extra = 0;
#endif
newnode = make_new_node(inptr);
assert(current->data != NULL);
tmp = &current->data[current_x];
current_x = 0;
#ifndef NANO_SMALL
/* Do auto-indenting, like the neolithic Turbo Pascal editor */
if (ISSET(AUTOINDENT)) {
spc = current->data;
if (spc) {
while ((*spc == ' ') || (*spc == '\t')) {
extra++;
spc++;
current_x++;
totsize++;
}
newnode->data = charalloc(strlen(tmp) + extra + 1);
strncpy(newnode->data, current->data, extra);
strcpy(&newnode->data[extra], tmp);
int extra = 0;
char *spc = current->data;
while ((*spc == ' ') || (*spc == '\t')) {
extra++;
spc++;
}
/* If the cursor is in the indentation, only indent to the cursor.
* Ex, if cursor is at col 0, don't indent at all.
*/
if (current_x < extra)
extra = current_x;
else
current_x = extra;
totsize += extra;
newnode->data = charalloc(strlen(tmp) + extra + 1);
strncpy(newnode->data, current->data, extra);
strcpy(&newnode->data[extra], tmp);
} else
#endif
{
current_x = 0;
newnode->data = charalloc(strlen(tmp) + 1);
strcpy(newnode->data, tmp);
}
......@@ -2477,7 +2481,9 @@ void help_init(void)
int i, sofar = 0, meta_shortcut = 0, helplen;
long allocsize = 1; /* How much space we're gonna need for the help text */
char buf[BUFSIZ] = "", *ptr = NULL;
#ifndef NANO_SMALL
toggle *t;
#endif
shortcut *s;
helplen = length_of_list(currshortcut);
......@@ -2579,12 +2585,14 @@ void help_init(void)
s = s->next;
}
#ifndef NANO_SMALL
/* If we're on the main list, we also allocate space for toggle help text. */
if (currshortcut == main_list) {
for (t = toggles; t != NULL; t = t->next)
if (t->desc != NULL)
allocsize += strlen(t->desc) + 30;
}
#endif /* !NANO_SMALL */
allocsize += strlen(ptr);
......@@ -2658,6 +2666,7 @@ void help_init(void)
s = s->next;
}
#ifndef NANO_SMALL
/* And the toggles... */
if (currshortcut == main_list)
for (t = toggles; t != NULL; t = t->next) {
......@@ -2670,15 +2679,13 @@ void help_init(void)
strcat(help_text, buf);
strcat(help_text, "\n");
}
#endif /* !NANO_SMALL */
}
#endif
#ifndef NANO_SMALL
void do_toggle(toggle *which)
{
#ifdef NANO_SMALL
nano_disabled_msg();
#else
char *enabled = _("enabled");
char *disabled = _("disabled");
......@@ -2733,9 +2740,8 @@ void do_toggle(toggle *which)
else
statusbar("%s %s", which->desc, enabled);
}
#endif
}
#endif /* !NANO_SMALL */
/* If the NumLock key has made the keypad go awry, print an error
message; hopefully we can address it later. */
......
......@@ -99,14 +99,16 @@ typedef struct shortcut {
int misc2;
int viewok; /* is this function legal in view mode? */
int (*func) (void); /* Function to call when we catch this key */
char *desc; /* Description, e.g. "Page Up" */
char *help; /* Help file entry text */
const char *desc; /* Description, e.g. "Page Up" */
#ifndef DISABLE_HELP
const char *help; /* Help file entry text */
#endif
struct shortcut *next;
} shortcut;
typedef struct toggle {
int val; /* Sequence to toggle the key. Should only need 1 */
char *desc; /* Description for when toggle is, uh, toggled,
const char *desc; /* Description for when toggle is, uh, toggled,
e.g. "Pico Messages"; we'll append Enabled or
Disabled */
int flag; /* What flag actually gets toggled */
......
......@@ -97,6 +97,13 @@ extern toggle *toggles;
/* Programs we want available */
/* public functions in global.c */
int length_of_list(const shortcut *s);
void shortcut_init(int unjustify);
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);
......@@ -122,7 +129,6 @@ int no_help(void);
int renumber_all(void);
int open_file(char *filename, int insert, int quiet);
int do_insertfile(int loading_file);
int length_of_list(shortcut *s);
int num_of_digits(int n);
int open_pipe(char *command);
int read_file(FILE *f, char *filename, int quiet);
......@@ -156,7 +162,6 @@ int check_wildcard_match(const char *text, const char *pattern);
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace, int *list);
char *real_dir_from_tilde(char *buf);
void shortcut_init(int unjustify);
void signal_init(void);
void lowercase(char *src);
void blank_bottombars(void);
......@@ -223,8 +228,6 @@ void unlink_opennode(openfilestruct * fileptr);
void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
int bot_x, int destructive);
void free_shortcutage(shortcut **src);
void thanks_for_all_the_fish(void);
#ifdef ENABLE_NANORC
void do_rcfile(void);
......
......@@ -579,7 +579,7 @@ void titlebar(char *path)
reset_cursor();
}
void onekey(char *keystroke, char *desc, int len)
void onekey(char *keystroke, const char *desc, int len)
{
int i;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment