Commit 56214c6a authored by Chris Allegretta's avatar Chris Allegretta
Browse files

DLR's fixes: arg for operatingdir's getopt_long text, changes to cases 2b and...

DLR's fixes: arg for operatingdir's getopt_long text, changes to cases 2b and 2c in do_wrap for Pico compatibility, and new arg save_cutbuffer to global_init() to stop the cutbuffer from being lost with multiple buffers


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@789 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 5050d35e
Showing with 43 additions and 23 deletions
+43 -23
...@@ -34,6 +34,12 @@ CVS code - ...@@ -34,6 +34,12 @@ CVS code -
lines aren't lined up since the menu width changed though, lines aren't lined up since the menu width changed though,
this breakage depends on whether the new widths will be kept this breakage depends on whether the new widths will be kept
or not (FEEDBACK!!) or not (FEEDBACK!!)
do_wrap()
- Fixes for Pico incompatibility in cases 2b and 2c.
(David Lawrence Ramsey).
global_init()
- New arg save_cutbuffer, allows cutbuffer to not be lost when
using multibuffer.
- nano.texi: - nano.texi:
- corrected the Mouse Toggle section, noticed by Daniel Bonniot. - corrected the Mouse Toggle section, noticed by Daniel Bonniot.
- rcfile.c: - rcfile.c:
......
...@@ -202,8 +202,9 @@ void clear_filename(void) ...@@ -202,8 +202,9 @@ void clear_filename(void)
filename[0] = 0; filename[0] = 0;
} }
/* Initialize global variables - no better way for now */ /* Initialize global variables - no better way for now. If
void global_init(void) save_cutbuffer is nonzero, don't set cutbuffer to NULL. */
void global_init(int save_cutbuffer)
{ {
current_x = 0; current_x = 0;
current_y = 0; current_y = 0;
...@@ -212,11 +213,13 @@ void global_init(void) ...@@ -212,11 +213,13 @@ void global_init(void)
die_too_small(); die_too_small();
fileage = NULL; fileage = NULL;
cutbuffer = NULL; if (!save_cutbuffer)
cutbuffer = NULL;
current = NULL; current = NULL;
edittop = NULL; edittop = NULL;
editbot = NULL; editbot = NULL;
totlines = 0; totlines = 0;
totsize = 0;
placewewant = 0; placewewant = 0;
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY
...@@ -449,7 +452,7 @@ void usage(void) ...@@ -449,7 +452,7 @@ void usage(void)
#endif #endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
printf(_ printf(_
(" -o [dir] --operatingdir Set operating directory\n")); (" -o [dir] --operatingdir=[dir] Set operating directory\n"));
#endif #endif
printf(_ printf(_
(" -p --pico Emulate Pico as closely as possible\n")); (" -p --pico Emulate Pico as closely as possible\n"));
...@@ -884,13 +887,10 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -884,13 +887,10 @@ void do_wrap(filestruct * inptr, char input_char)
* it is all spaces between previous word and next word which appears after fill. * it is all spaces between previous word and next word which appears after fill.
* b) cursor is at the word at the wrap point. * b) cursor is at the word at the wrap point.
* - word at wrap point starts a new line. * - word at wrap point starts a new line.
* 1. pressed a space and at first character of wrap point word. * - white space on original line is kept to where cursor was.
* - white space on original line is kept to where cursor was.
* 2. pressed non space (or space elsewhere).
* - white space at end of original line is cleared.
* c) cursor is past the word at the wrap point. * c) cursor is past the word at the wrap point.
* - word at wrap point starts a new line. * - word at wrap point starts a new line.
* - white space at end of original line is cleared * - white space at end of original line is cleared
*/ */
temp = nmalloc(sizeof(filestruct)); temp = nmalloc(sizeof(filestruct));
...@@ -933,6 +933,10 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -933,6 +933,10 @@ void do_wrap(filestruct * inptr, char input_char)
/* Inside word, remove it from original, and move cursor to right spot. */ /* Inside word, remove it from original, and move cursor to right spot. */
if (current_x >= current_word_start) { if (current_x >= current_word_start) {
right = current_x - current_word_start; right = current_x - current_word_start;
/* Decrease totsize by the number of spaces we removed, less
one for the new line we're replacing the spaces with. */
totsize -= (current_word_start - 1);
current_x = 0; current_x = 0;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
...@@ -965,10 +969,16 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -965,10 +969,16 @@ void do_wrap(filestruct * inptr, char input_char)
if (!isspace((int) input_char)) { if (!isspace((int) input_char)) {
i = current_word_start - 1; i = current_word_start - 1;
/* Decrement totsize each time we remove a space. */
while (isspace((int) inptr->data[i])) { while (isspace((int) inptr->data[i])) {
i--; i--;
totsize--;
assert(i >= 0); assert(i >= 0);
} }
/* And increment it to account for the blank line we're
replacing the spaces with. */
totsize++;
} else if (current_x <= last_word_end) } else if (current_x <= last_word_end)
i = last_word_end - 1; i = last_word_end - 1;
else else
...@@ -1000,20 +1010,14 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -1000,20 +1010,14 @@ void do_wrap(filestruct * inptr, char input_char)
} }
#endif #endif
i = current_word_start - 1; i = current_word_start - 1;
if (isspace((int) input_char) current_x = current_word_start;
&& (current_x == current_word_start)) {
current_x = current_word_start;
null_at(inptr->data, current_word_start); null_at(inptr->data, current_word_start);
} else {
while (isspace((int) inptr->data[i])) { /* Increment totsize to account for the new line that
i--; will be added below, so that it won't end up being
assert(i >= 0); short by one. */
} totsize++;
inptr->data = nrealloc(inptr->data, i + 2);
inptr->data[i + 1] = 0;
}
} }
...@@ -1029,12 +1033,17 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -1029,12 +1033,17 @@ void do_wrap(filestruct * inptr, char input_char)
current_x = current_word_start; current_x = current_word_start;
i = current_word_start - 1; i = current_word_start - 1;
/* Decrement totsize each time we remove a space. */
while (isspace((int) inptr->data[i])) { while (isspace((int) inptr->data[i])) {
i--; i--;
totsize--;
assert(i >= 0); assert(i >= 0);
inptr->data = nrealloc(inptr->data, i + 2); inptr->data = nrealloc(inptr->data, i + 2);
inptr->data[i + 1] = 0; inptr->data[i + 1] = 0;
} }
/* And increment it to account for the blank line we're
replacing the spaces with. */
totsize++;
} }
} }
...@@ -1046,6 +1055,11 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -1046,6 +1055,11 @@ void do_wrap(filestruct * inptr, char input_char)
char *p = char *p =
charalloc((strlen(temp->data) + strlen(inptr->next->data) + 2)); charalloc((strlen(temp->data) + strlen(inptr->next->data) + 2));
/* We're adding to an existing line instead of creating a new
one; decrement totlines here so that when it gets incremented
below, it won't end up being high by one. */
totlines--;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
int non = 0; int non = 0;
...@@ -1562,7 +1576,7 @@ int do_alt_speller(char *file_name) ...@@ -1562,7 +1576,7 @@ int do_alt_speller(char *file_name)
refresh(); refresh();
free_filestruct(fileage); free_filestruct(fileage);
global_init(); global_init(1);
open_file(file_name, 0, 1); open_file(file_name, 0, 1);
/* go back to the old line while keeping the same position, mark the /* go back to the old line while keeping the same position, mark the
...@@ -2676,7 +2690,7 @@ int main(int argc, char *argv[]) ...@@ -2676,7 +2690,7 @@ int main(int argc, char *argv[])
noecho(); noecho();
/* Set up some global variables */ /* Set up some global variables */
global_init(); global_init(0);
shortcut_init(0); shortcut_init(0);
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
init_help_msg(); init_help_msg();
......
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