commit c97acfb2d64da0caf64cfadb642e31f632f5124a
parent 14509a3aa209dc2bcc248e962999e9e3ab8fcd9f
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Wed, 10 Sep 2003 20:08:00 +0000
since the SAMELINEWRAP flag is only used in nano.c, convert it to a
static int there and free up space for one more flag; also make a few
misc. cleanups involving #ifdefs
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1549 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
8 files changed, 61 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -33,6 +33,9 @@ CVS code -
NANO_SMALL is defined. (DLR)
- Source reorganization: move code to src/, docs to doc/. (Jordi)
- Translation updates (see po/ChangeLog for details).
+ - Since SAMELINEWRAP is only used in nano.c, make it a static
+ variable in nano.c instead of a flag, and surround all
+ wrap_reset() calls with DISABLE_WRAPPING #ifdefs. (DLR)
- files.c:
do_browser()
- Some of the Pico compatibility options in the file browser
@@ -80,6 +83,10 @@ CVS code -
page_up()
- Removed due to rewrite of movement functions. (David
Benbennick)
+- proto.h:
+ - Surround the do_prev_word() and do_next_word() prototypes with
+ NANO_SMALL #ifdefs, since the actual functions aren't included
+ in tiny mode. (DLR)
- rcfile.c:
parse_colors()
- Generate an error if we try to use a bright background color
diff --git a/src/cut.c b/src/cut.c
@@ -322,7 +322,9 @@ int do_uncut_text(void)
filestruct *hold = current;
int i;
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
check_statblank();
if (cutbuffer == NULL || fileptr == NULL)
return 0; /* AIEEEEEEEEEEEE */
diff --git a/src/files.c b/src/files.c
@@ -427,7 +427,9 @@ int do_insertfile(int loading_file)
inspath[0] = '\0';
}
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
start_again: /* Goto here when the user cancels the file browser. */
diff --git a/src/move.c b/src/move.c
@@ -49,7 +49,9 @@ int do_page_up(void)
{
int i;
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
/* If edittop is the first line of the file, move current up there
* and put the cursor at the beginning of the line. */
@@ -91,7 +93,9 @@ int do_page_down(void)
{
int i;
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
/* If the last line of the file is onscreen, move current down
* there and put the cursor at the beginning of the line. */
@@ -131,7 +135,9 @@ int do_page_down(void)
int do_up(void)
{
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
check_statblank();
if (current->prev == NULL)
@@ -159,7 +165,9 @@ int do_up(void)
* bottom. */
int do_down(void)
{
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
check_statblank();
if (current->next == NULL)
diff --git a/src/nano.c b/src/nano.c
@@ -57,6 +57,10 @@
#ifndef DISABLE_WRAPJUSTIFY
static int fill = 0; /* Fill - where to wrap lines, basically */
#endif
+#ifndef DISABLE_WRAPPING
+static int same_line_wrap = 0; /* Whether wrapped text should be
+ prepended to the next line */
+#endif
static struct termios oldterm; /* The user's original term settings */
static struct sigaction act; /* For all our fun signal handlers */
@@ -1299,10 +1303,12 @@ int do_mark(void)
return 1;
}
+#ifndef DISABLE_WRAPPING
void wrap_reset(void)
{
- UNSET(SAMELINEWRAP);
+ same_line_wrap = 0;
}
+#endif
#ifndef DISABLE_WRAPPING
/* We wrap the given line. Precondition: we assume the cursor has been
@@ -1387,7 +1393,7 @@ int do_wrap(filestruct *inptr)
/* We prepend the wrapped text to the next line, if the flag is set,
* and there is a next line, and prepending would not make the line
* too long. */
- if (ISSET(SAMELINEWRAP) && inptr->next) {
+ if (same_line_wrap && inptr->next) {
wrap_line = inptr->next->data;
wrap_line_len = strlen(wrap_line);
@@ -1465,7 +1471,7 @@ int do_wrap(filestruct *inptr)
* other sundry things. */
/* later wraps of this line will be prepended to the next line. */
- SET(SAMELINEWRAP);
+ same_line_wrap = 1;
/* Each line knows its line number. We recalculate these if we
* inserted a new line. */
diff --git a/src/nano.h b/src/nano.h
@@ -40,11 +40,12 @@
#endif
#ifndef NANO_SMALL
- /* For the backup file copy ... */
-# define COPYFILEBLOCKSIZE 1024
+/* For the backup file copy ... */
+#define COPYFILEBLOCKSIZE 1024
#endif
-#ifdef USE_SLANG /* Slang support enabled */
+#ifdef USE_SLANG
+/* Slang support enabled */
#include <slcurses.h>
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
@@ -53,7 +54,7 @@
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else /* Uh oh */
-#include <curses.h>
+#include <curses.h>
#endif /* CURSES_H */
#ifdef ENABLE_NLS
@@ -233,28 +234,27 @@ typedef struct historyheadtype {
#define SUSPEND (1<<7)
#define NO_WRAP (1<<8)
#define AUTOINDENT (1<<9)
-#define SAMELINEWRAP (1<<10)
-#define VIEW_MODE (1<<11)
-#define USE_MOUSE (1<<12)
-#define USE_REGEXP (1<<13)
-#define REGEXP_COMPILED (1<<14)
-#define TEMP_OPT (1<<15)
-#define CUT_TO_END (1<<16)
-#define REVERSE_SEARCH (1<<17)
-#define MULTIBUFFER (1<<18)
-#define DOS_FILE (1<<19)
-#define MAC_FILE (1<<20)
-#define SMOOTHSCROLL (1<<21)
-#define DISABLE_CURPOS (1<<22) /* Damn, we still need it */
-#define REBIND_DELETE (1<<23)
-#define NO_CONVERT (1<<24)
-#define BACKUP_FILE (1<<25)
-#define NO_RCFILE (1<<26)
-#define COLOR_SYNTAX (1<<27)
-#define PRESERVE (1<<28)
-#define HISTORY_CHANGED (1<<29)
-#define HISTORYLOG (1<<30)
-#define JUSTIFY_MODE (1<<31)
+#define VIEW_MODE (1<<10)
+#define USE_MOUSE (1<<11)
+#define USE_REGEXP (1<<12)
+#define REGEXP_COMPILED (1<<13)
+#define TEMP_OPT (1<<14)
+#define CUT_TO_END (1<<15)
+#define REVERSE_SEARCH (1<<16)
+#define MULTIBUFFER (1<<17)
+#define DOS_FILE (1<<18)
+#define MAC_FILE (1<<19)
+#define SMOOTHSCROLL (1<<20)
+#define DISABLE_CURPOS (1<<21) /* Damn, we still need it */
+#define REBIND_DELETE (1<<22)
+#define NO_CONVERT (1<<23)
+#define BACKUP_FILE (1<<24)
+#define NO_RCFILE (1<<25)
+#define COLOR_SYNTAX (1<<26)
+#define PRESERVE (1<<27)
+#define HISTORY_CHANGED (1<<28)
+#define HISTORYLOG (1<<29)
+#define JUSTIFY_MODE (1<<30)
/* Control key sequences, changing these would be very very bad */
diff --git a/src/proto.h b/src/proto.h
@@ -274,11 +274,13 @@ int do_backspace(void);
int do_delete(void);
int do_tab(void);
int do_enter(void);
+#ifndef NANO_SMALL
int do_next_word(void);
int do_prev_word(void);
+#endif
int do_mark(void);
-void wrap_reset(void);
#ifndef DISABLE_WRAPPING
+void wrap_reset(void);
int do_wrap(filestruct *inptr);
#endif
#ifndef DISABLE_SPELLER
diff --git a/src/search.c b/src/search.c
@@ -385,7 +385,9 @@ int do_search(void)
filestruct *fileptr = current, *didfind;
int fileptr_x = current_x;
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
i = search_init(0);
switch (i) {
case -1:
@@ -439,7 +441,9 @@ int do_research(void)
const char *regex_error = _("Invalid regex \"%s\"");
#endif /* HAVE_REGEX_H */
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
search_init_globals();
if (last_search[0] != '\0') {