From 1dd0bc98a2942bb18d3cfe0afe9c44357be2b5bf Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Sun, 13 Oct 2002 18:43:45 +0000 Subject: [PATCH] Remove malloc.h completely and add color synatx highlighting toggle git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1300 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ configure.ac | 2 +- global.c | 10 ++++++++++ nano.c | 3 +++ nano.h | 7 ++----- rcfile.c | 1 + winio.c | 2 +- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 249533fb..e4752e44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ CVS code - - General: - Translation updates (see po/ChangeLog for details). + - Remove malloc.h, as it's unneeded and just causes annoyances on + *BSD systems. Added stdlib.h to global.c + - Added Meta-Y toggle to disable/enable color syntax highlighting + completely. This may eventually be per-buffer, but that's too + complicated for a feature freeze. GNU nano 1.1.11 - 10/01/2002 - General: diff --git a/configure.ac b/configure.ac index 34f9b9c9..b0d3dd7c 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ AC_SYS_LARGEFILE dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h regex.h) +AC_CHECK_HEADERS(fcntl.h unistd.h termios.h termio.h limits.h getopt.h regex.h) dnl options AC_ARG_ENABLE(debug, diff --git a/global.c b/global.c index 0e978606..5fc946b5 100644 --- a/global.c +++ b/global.c @@ -21,6 +21,7 @@ #include "config.h" +#include #include #include #include "proto.h" @@ -222,6 +223,9 @@ void toggle_init(void) #ifdef ENABLE_MULTIBUFFER char *toggle_load_msg; #endif +#ifdef ENABLE_COLOR + char *toggle_syntax_msg; +#endif /* There is no need to reinitialize the toggles. They can't change. In fact, reinitializing them causes a segfault in @@ -242,6 +246,9 @@ void toggle_init(void) toggle_mac_msg = _("Writing file in Mac format"); toggle_backup_msg = _("Backing up file"); toggle_smooth_msg = _("Smooth scrolling"); +#ifdef ENABLE_COLOR + toggle_syntax_msg = _("Color syntax highlighting"); +#endif #ifndef DISABLE_WRAPPING toggle_wrap_msg = _("Auto wrap"); #endif @@ -267,6 +274,9 @@ void toggle_init(void) toggle_init_one(TOGGLE_MAC_KEY, toggle_mac_msg, MAC_FILE); toggle_init_one(TOGGLE_BACKUP_KEY, toggle_backup_msg, BACKUP_FILE); toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL); +#ifdef ENABLE_COLOR + toggle_init_one(TOGGLE_SYNTAX_KEY, toggle_syntax_msg, COLOR_SYNTAX); +#endif } #ifdef DEBUG diff --git a/nano.c b/nano.c index c68ae8aa..538099dd 100644 --- a/nano.c +++ b/nano.c @@ -2838,6 +2838,9 @@ void do_toggle(const toggle *which) case TOGGLE_MAC_KEY: UNSET(DOS_FILE); break; + case TOGGLE_SYNTAX_KEY: + edit_refresh(); + break; } /* We are assuming here that shortcut_init() above didn't free and diff --git a/nano.h b/nano.h index e16a941c..3e38bc00 100644 --- a/nano.h +++ b/nano.h @@ -19,10 +19,6 @@ * * **************************************************************************/ -#ifdef HAVE_MALLOC_H -#include -#endif - #ifdef HAVE_LIMITS_H #include #endif @@ -174,7 +170,6 @@ typedef struct syntaxtype { exttype *extensions; /* List of extensions that this applies to */ colortype *color; /* color struct for this syntax */ struct syntaxtype *next; - } syntaxtype; #endif /* ENABLE_COLOR */ @@ -211,6 +206,7 @@ typedef struct syntaxtype { #define NO_CONVERT (1<<26) #define BACKUP_FILE (1<<27) #define NO_RCFILE (1<<28) +#define COLOR_SYNTAX (1<<28) /* Control key sequences, changing these would be very very bad */ @@ -364,6 +360,7 @@ know what you're doing */ #define TOGGLE_SMOOTH_KEY NANO_ALT_S #define TOGGLE_NOCONVERT_KEY NANO_ALT_N #define TOGGLE_BACKUP_KEY NANO_ALT_B +#define TOGGLE_SYNTAX_KEY NANO_ALT_Y #endif /* !NANO_SMALL */ #define MAIN_VISIBLE 12 diff --git a/rcfile.c b/rcfile.c index 0f55f116..43594413 100644 --- a/rcfile.c +++ b/rcfile.c @@ -275,6 +275,7 @@ void parse_syntax(char *ptr) if (syntaxes == NULL) { syntaxes = (syntaxtype *)nmalloc(sizeof(syntaxtype)); tmpsyntax = syntaxes; + SET(COLOR_SYNTAX); } else { for (tmpsyntax = syntaxes; tmpsyntax->next != NULL; tmpsyntax = tmpsyntax->next) diff --git a/winio.c b/winio.c index fb79153b..e09cdcd1 100644 --- a/winio.c +++ b/winio.c @@ -614,7 +614,7 @@ void edit_add(const filestruct *fileptr, int yval, int start mvwaddnstr(edit, yval, 0, &fileptr->data[start], COLS); #ifdef ENABLE_COLOR - if (colorstrings != NULL) { + if (colorstrings != NULL && ISSET(COLOR_SYNTAX)) { const colortype *tmpcolor = colorstrings; for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) { -- 2.39.5