]> git.wh0rd.org Git - nano.git/commitdiff
move the paragraph-searching functions to move.c, as they're movement
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 20 Jul 2005 19:24:11 +0000 (19:24 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 20 Jul 2005 19:24:11 +0000 (19:24 +0000)
functions, and make them call check_statusblank() too; also reorder some
other movement functions

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2902 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/move.c
src/nano.c
src/proto.h

index a2b8ad623b440ff5034a00418da2819a433edf5d..0c1377b2595f037ec555a900fc0067757501ea74 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -94,6 +94,10 @@ CVS code -
   do_first_line(), do_last_line()
        - Simplify by only using edit_redraw(), and also make them call
          check_statusblank(). (DLR)
+  do_para_begin(), do_para_begin_void(), do_para_end(),
+  do_para_end_void()
+       - Move here from nano.c, as they're movement functions, and also
+         make them call check_statusblank().
   do_page_up(), do_page_down()
        - If there's less than a page of text onscreen, just call
          do_(first|last)_line(). (DLR)
index c99377592419e97d0d23d68f3e1f267e60454565..d6c6ce321035c5e9ab1fa35cb4c71a2d882ff7f0 100644 (file)
@@ -59,48 +59,6 @@ void do_last_line(void)
     edit_redraw(current_save, pww_save);
 }
 
-void do_home(void)
-{
-    size_t pww_save = openfile->placewewant;
-
-    check_statusblank();
-
-#ifndef NANO_SMALL
-    if (ISSET(SMART_HOME)) {
-       size_t current_x_save = openfile->current_x;
-
-       openfile->current_x = indent_length(openfile->current->data);
-
-       if (openfile->current_x == current_x_save ||
-               openfile->current->data[openfile->current_x] == '\0')
-           openfile->current_x = 0;
-
-       openfile->placewewant = xplustabs();
-    } else {
-#endif
-       openfile->current_x = 0;
-       openfile->placewewant = 0;
-#ifndef NANO_SMALL
-    }
-#endif
-
-    if (need_horizontal_update(pww_save))
-       update_line(openfile->current, openfile->current_x);
-}
-
-void do_end(void)
-{
-    size_t pww_save = openfile->placewewant;
-
-    check_statusblank();
-
-    openfile->current_x = strlen(openfile->current->data);
-    openfile->placewewant = xplustabs();
-
-    if (need_horizontal_update(pww_save))
-       update_line(openfile->current, openfile->current_x);
-}
-
 void do_page_up(void)
 {
     int i;
@@ -182,6 +140,114 @@ void do_page_down(void)
     edit_scroll(DOWN, editwinrows - 2);
 }
 
+#ifndef DISABLE_JUSTIFY
+/* Move up to the last beginning-of-paragraph line before the current
+ * line. */
+void do_para_begin(bool allow_update)
+{
+    const filestruct *current_save = openfile->current;
+    const size_t pww_save = openfile->placewewant;
+
+    check_statusblank();
+
+    openfile->current_x = 0;
+    openfile->placewewant = 0;
+
+    if (openfile->current->prev != NULL) {
+       do {
+           openfile->current = openfile->current->prev;
+           openfile->current_y--;
+       } while (!begpar(openfile->current));
+    }
+
+    if (allow_update)
+       edit_redraw(current_save, pww_save);
+}
+
+void do_para_begin_void(void)
+{
+    do_para_begin(TRUE);
+}
+
+/* Move down to the end of a paragraph, then one line farther.  A line
+ * is the last line of a paragraph if it is in a paragraph, and the next
+ * line either is a beginning-of-paragraph line or isn't in a
+ * paragraph. */
+void do_para_end(bool allow_update)
+{
+    const filestruct *const current_save = openfile->current;
+    const size_t pww_save = openfile->placewewant;
+
+    check_statusblank();
+
+    openfile->current_x = 0;
+    openfile->placewewant = 0;
+
+    while (openfile->current->next != NULL && !inpar(openfile->current))
+       openfile->current = openfile->current->next;
+
+    while (openfile->current->next != NULL &&
+       inpar(openfile->current->next) &&
+       !begpar(openfile->current->next)) {
+       openfile->current = openfile->current->next;
+       openfile->current_y++;
+    }
+
+    if (openfile->current->next != NULL)
+       openfile->current = openfile->current->next;
+
+    if (allow_update)
+       edit_redraw(current_save, pww_save);
+}
+
+void do_para_end_void(void)
+{
+    do_para_end(TRUE);
+}
+#endif /* !DISABLE_JUSTIFY */
+
+void do_home(void)
+{
+    size_t pww_save = openfile->placewewant;
+
+    check_statusblank();
+
+#ifndef NANO_SMALL
+    if (ISSET(SMART_HOME)) {
+       size_t current_x_save = openfile->current_x;
+
+       openfile->current_x = indent_length(openfile->current->data);
+
+       if (openfile->current_x == current_x_save ||
+               openfile->current->data[openfile->current_x] == '\0')
+           openfile->current_x = 0;
+
+       openfile->placewewant = xplustabs();
+    } else {
+#endif
+       openfile->current_x = 0;
+       openfile->placewewant = 0;
+#ifndef NANO_SMALL
+    }
+#endif
+
+    if (need_horizontal_update(pww_save))
+       update_line(openfile->current, openfile->current_x);
+}
+
+void do_end(void)
+{
+    size_t pww_save = openfile->placewewant;
+
+    check_statusblank();
+
+    openfile->current_x = strlen(openfile->current->data);
+    openfile->placewewant = xplustabs();
+
+    if (need_horizontal_update(pww_save))
+       update_line(openfile->current, openfile->current_x);
+}
+
 void do_up(void)
 {
     check_statusblank();
index 78bacb134f2808858eae187b0b3f2bcde30c9283..1f9bf20db937033fc2ec2af53feb0999a3efa221 100644 (file)
@@ -2948,32 +2948,6 @@ bool begpar(const filestruct *const foo)
     return FALSE;
 }
 
-/* We find the last beginning-of-paragraph line before the current
- * line. */
-void do_para_begin(bool allow_update)
-{
-    const filestruct *current_save = openfile->current;
-    const size_t pww_save = openfile->placewewant;
-
-    openfile->current_x = 0;
-    openfile->placewewant = 0;
-
-    if (openfile->current->prev != NULL) {
-       do {
-           openfile->current = openfile->current->prev;
-           openfile->current_y--;
-       } while (!begpar(openfile->current));
-    }
-
-    if (allow_update)
-       edit_redraw(current_save, pww_save);
-}
-
-void do_para_begin_void(void)
-{
-    do_para_begin(TRUE);
-}
-
 /* Is foo inside a paragraph? */
 bool inpar(const filestruct *const foo)
 {
@@ -2988,39 +2962,6 @@ bool inpar(const filestruct *const foo)
        quote_len)] != '\0';
 }
 
-/* A line is the last line of a paragraph if it is in a paragraph, and
- * the next line isn't, or is the beginning of a paragraph.  We move
- * down to the end of a paragraph, then one line farther. */
-void do_para_end(bool allow_update)
-{
-    const filestruct *const current_save = openfile->current;
-    const size_t pww_save = openfile->placewewant;
-
-    openfile->current_x = 0;
-    openfile->placewewant = 0;
-
-    while (openfile->current->next != NULL && !inpar(openfile->current))
-       openfile->current = openfile->current->next;
-
-    while (openfile->current->next != NULL &&
-       inpar(openfile->current->next) &&
-       !begpar(openfile->current->next)) {
-       openfile->current = openfile->current->next;
-       openfile->current_y++;
-    }
-
-    if (openfile->current->next != NULL)
-       openfile->current = openfile->current->next;
-
-    if (allow_update)
-       edit_redraw(current_save, pww_save);
-}
-
-void do_para_end_void(void)
-{
-    do_para_end(TRUE);
-}
-
 /* Put the next par_len lines, starting with first_line, into the
  * justify buffer, leaving copies of those lines in place.  Assume there
  * are enough lines after first_line.  Return the new copy of
index dd643a94aab14a389519c34412a68dec0e4053bc..f798a0e1ff246fc5ad7d84e4562e33d6f00a5571 100644 (file)
@@ -329,10 +329,16 @@ void thanks_for_all_the_fish(void);
 /* Public functions in move.c. */
 void do_first_line(void);
 void do_last_line(void);
-void do_home(void);
-void do_end(void);
 void do_page_up(void);
 void do_page_down(void);
+#ifndef DISABLE_JUSTIFY
+void do_para_begin(bool allow_update);
+void do_para_begin_void(void);
+void do_para_end(bool allow_update);
+void do_para_end_void(void);
+#endif
+void do_home(void);
+void do_end(void);
 void do_up(void);
 void do_down(void);
 void do_left(bool allow_update);
@@ -420,11 +426,7 @@ bool quotes_match(const char *a_line, size_t a_quote, const char
 bool indents_match(const char *a_line, size_t a_indent, const char
        *b_line, size_t b_indent);
 bool begpar(const filestruct *const foo);
-void do_para_begin(bool allow_update);
-void do_para_begin_void(void);
 bool inpar(const filestruct *const foo);
-void do_para_end(bool allow_update);
-void do_para_end_void(void);
 filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
        quote_len);
 bool find_paragraph(size_t *const quote, size_t *const par);