nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] patch: misc. fixes


From: David Lawrence Ramsey
Subject: [Nano-devel] patch: misc. fixes
Date: Tue, 14 May 2002 19:31:38 -0700 (PDT)

The attached patch attempts to fix the following bugs in
1.1.9-cvs; note that I'm still testing it, though.

* The kludge to deal with totsize's being low by one upon
reading in a file/input in general that doesn't end in a
newline doesn't work properly in all cases; reading in a
non-blank file that doesn't end in a newline results in
totsize's being high by one.  Making it so totsize is
incremented along with totlines when
non-newline-terminated data is read in in read_file()
(since a blank line counts as one character) and removing
the kludge appears to have fixed the problem.

* Marking is now apparently preserved after spell-checking,
with both the internal and alternate spell checkers.  In
the former case, I just turned off marking at the
beginning of do_int_spell_fix() and turned it back on at
its end; otherwise, the highlighting would cause cosmetic
problems during the spell checking.  The latter case was
more complex, as the file is reread after spell checking
and hence none of the pointers or variables are valid
anymore; I had to turn off marking at its beginning, save
the number of the line that mark_beginbuf pointed to
(among other things), use do_gotopos() to go back to that
line afterwards, set mark_beginbuf to it (among other
things), turn marking back on, and then let the original
do_gotopos() call occur to move the cursor back to its old
location.


_____________________________________________________________
Sluggy.Net: The Sluggy Freelance Community!

_____________________________________________________________
Promote your group and strengthen ties to your members with address@hidden by 
Everyone.net  http://www.everyone.net/?btn=tag
diff -urN nano-1.1.9-cvs/files.c nano-1.1.9-cvs-fixed/files.c
--- nano-1.1.9-cvs/files.c      Sun May 12 15:52:15 2002
+++ nano-1.1.9-cvs-fixed/files.c        Tue May 14 22:20:15 2002
@@ -232,6 +232,7 @@
     if (buf[0]) {
        fileptr = read_line(buf, fileptr, &line1ins);
        num_lines++;
+       totsize++;
        buf[0] = 0;
     }
 
@@ -449,13 +450,6 @@
 #endif
        }
 #endif
-
-       /* Here is a kludge.  If the current file is blank (including
-        * after new_file()), then totlines==1 and totsize==0.  Thus
-        * after open_pipe() or open_file() below, the totsize is short
-        * by one. */
-       if (totlines==1 && totsize==0)
-           totsize++;
 
 #ifndef NANO_SMALL
        if (i == NANO_EXTCMD_KEY) {
diff -urN nano-1.1.9-cvs/nano.c nano-1.1.9-cvs-fixed/nano.c
--- nano-1.1.9-cvs/nano.c       Sun May 12 15:52:15 2002
+++ nano-1.1.9-cvs-fixed/nano.c Tue May 14 22:21:03 2002
@@ -1367,6 +1367,9 @@
     char *prevanswer = NULL, *save_search = NULL, *save_replace = NULL;
     filestruct *begin;
     int i = 0, j = 0, beginx, beginx_top, reverse_search_set;
+#ifndef NANO_SMALL
+    int mark_set;
+#endif
 
     /* save where we are */
     begin = current;
@@ -1376,6 +1379,12 @@
     reverse_search_set = ISSET(REVERSE_SEARCH);
     UNSET(REVERSE_SEARCH);
 
+#ifndef NANO_SMALL
+    /* Make sure the marking highlight is off during Spell Check */
+    mark_set = ISSET(MARK_ISSET);
+    UNSET(MARK_ISSET);
+#endif
+
     /* save the current search/replace strings */
     search_init_globals();
     save_search = mallocstrcpy(save_search, last_search);
@@ -1438,6 +1447,12 @@
     if (reverse_search_set)
        SET(REVERSE_SEARCH);
 
+#ifndef NANO_SMALL
+    /* restore marking highlight */
+    if (mark_set)
+       SET(MARK_ISSET);
+#endif
+
     edit_update(current, CENTER);
 
     if (i == -1)
@@ -1451,8 +1466,7 @@
 {
     char *read_buff, *read_buff_ptr, *read_buff_word;
     size_t pipe_buff_size, read_buff_size, read_buff_read, bytesread;
-    int in_fd[2], tempfile_fd;
-    int spell_status;
+    int in_fd[2], tempfile_fd, spell_status;
     pid_t pid_spell;
 
     /* Create a pipe to spell program */
@@ -1583,12 +1597,25 @@
 {
     int alt_spell_status, lineno_cur = current->lineno;
     int x_cur = current_x, y_cur = current_y, pww_cur = placewewant;
+#ifndef NANO_SMALL
+    int mark_set = 0, mbb_lineno_cur, mbx_cur;
+#endif
 
     pid_t pid_spell;
     char *ptr;
     static int arglen = 3;
     static char **spellargs = (char **) NULL;
 
+#ifndef NANO_SMALL
+    mark_set = ISSET(MARK_ISSET);
+    if (mark_set) {
+       /* Save the marking position */
+       mbb_lineno_cur = mark_beginbuf->lineno;
+       mbx_cur = mark_beginx;
+       UNSET(MARK_ISSET);
+    }
+#endif
+
     endwin();
 
     /* Set up an argument list to pass the execvp function */
@@ -1634,6 +1661,15 @@
     free_filestruct(fileage);
     global_init(1);
     open_file(file_name, 0, 1);
+
+#ifndef NANO_SMALL
+    if (mark_set) {
+       /* Restore the marking position */
+       do_gotopos(mbb_lineno_cur, mbx_cur, y_cur, 0);
+       mark_beginbuf = current;
+       SET(MARK_ISSET);
+    }
+#endif
 
     /* go back to the old position, mark the file as modified, and make
        sure that the titlebar is refreshed */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]