From: Chris Allegretta Date: Sat, 29 Jul 2000 04:33:38 +0000 (+0000) Subject: Chris goes berzerk on no sleep X-Git-Tag: v0.9.15~13 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=234a34d27376488c48121d01b57e809397d5ab4a;p=nano.git Chris goes berzerk on no sleep git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@150 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 28512422..d19f0976 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ CVS code +- Changed edit_update call to take arguments TOP, CENTER or BOTTOM. + Affects many many functions. Removed functions edit_update_top and + edit_update_bot. - nano.c: splice_node() - New function, abstracts linking in nodes. Fixes bug #36. @@ -14,9 +17,17 @@ CVS code edit_refresh() - Added check for current line "running" off the screen. Hopefully this will not cause any recursive lockups. + (Who am I kidding, of course it will!) + edit_update() + - Rewritten, hopefully this will remove a lot of the + scrolling the cursor back and forth needlessly. - move.c: page_down() - - do an edit_update() at last case. + - do an edit_update() at last case. Made function more like + Pico's version, only move down to two lines before editbot. + page_up() + - Made function more like Pico's version, only move down to two + lines after edittop. nano-0.9.14 - 07/27/2000 - nano.h: diff --git a/cut.c b/cut.c index 4509d663..f3a84998 100644 --- a/cut.c +++ b/cut.c @@ -123,7 +123,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, } } if (top->lineno < edittop->lineno) - edit_update(top); + edit_update(top, CENTER); } #endif @@ -207,7 +207,7 @@ int do_cut_text(void) if (cuttingtoend) edit_refresh(); else - edit_update(current); + edit_update(current, CENTER); return 1; #else @@ -223,7 +223,7 @@ int do_cut_text(void) totsize--; /* get the newline */ totlines--; fileptr->prev = NULL; - edit_update(fileage); + edit_update(fileage, CENTER); current = fileptr; } else { add_to_cutbuffer(fileptr); @@ -355,7 +355,7 @@ int do_uncut_text(void) current = newend; if (i <= newend->lineno) - edit_update(current); + edit_update(current, CENTER); } /* If marked cut == 2, that means that we're doing a cut to end @@ -407,7 +407,7 @@ int do_uncut_text(void) i = editbot->lineno; renumber(newbuf); if (i < newend->lineno) - edit_update(fileptr); + edit_update(fileptr, CENTER); dump_buffer_reverse(fileptr); diff --git a/files.c b/files.c index 3912c86c..92b2da21 100644 --- a/files.c +++ b/files.c @@ -261,7 +261,7 @@ int do_insertfile(void) /* If we've gone off the bottom, recenter, otherwise just redraw */ if (current->lineno > editbot->lineno) - edit_update(current); + edit_update(current, CENTER); else edit_refresh(); diff --git a/move.c b/move.c index f7790d0e..12dcde46 100644 --- a/move.c +++ b/move.c @@ -35,12 +35,12 @@ void page_down_center(void) { if (editbot != filebot) { - edit_update(editbot->next); + edit_update(editbot->next, CENTER); center_cursor(); } else { while (current != filebot) current = current->next; - edit_update(current); + edit_update(current, CENTER); } update_cursor(); } @@ -54,17 +54,22 @@ int page_down(void) if (current == filebot) return 0; - if (editbot != filebot) { + if (editbot != filebot || edittop == fileage) { current_y = 0; - current = editbot; - edit_update_top(current); - } else + current = editbot; + + if (current->prev != NULL) + current = current->prev; + if (current->prev != NULL) + current = current->prev; + edit_update(current, TOP); + } else { while (current != filebot) { current = current->next; current_y++; - - edit_update(current); } + edit_update(edittop, TOP); + } update_cursor(); UNSET(KEEP_CUTBUFFER); @@ -123,7 +128,7 @@ int do_down(void) void page_up_center(void) { if (edittop != fileage) { - edit_update(edittop); + edit_update(edittop, CENTER); center_cursor(); } else current_y = 0; @@ -134,6 +139,7 @@ void page_up_center(void) int page_up(void) { + filestruct *fileptr = edittop; wrap_reset(); current_x = 0; placewewant = 0; @@ -142,7 +148,13 @@ int page_up(void) return 0; current_y = 0; - edit_update_bot(edittop); + if (fileptr->next != NULL) + fileptr = fileptr->next; + if (fileptr->next != NULL) + fileptr = fileptr->next; + + current = edittop; + edit_update(fileptr, BOTTOM); update_cursor(); UNSET(KEEP_CUTBUFFER); diff --git a/nano.c b/nano.c index b0747150..af2bef76 100644 --- a/nano.c +++ b/nano.c @@ -545,7 +545,7 @@ int do_enter(filestruct * inptr) * where we think the cursor is. */ if (current_y == editwinrows - 1) { - edit_update(current); + edit_update(current, CENTER); reset_cursor(); } else { current_y++; @@ -601,7 +601,7 @@ void do_next_word(void) current_x = i; placewewant = xplustabs(); if (current->lineno >= editbot->lineno) - edit_update(current); + edit_update(current, CENTER); } @@ -859,7 +859,7 @@ void do_wrap(filestruct * inptr, char input_char) /* totsize++; */ renumber(inptr); - edit_update_top(edittop); + edit_update(edittop, TOP); /* Move the cursor to the new line if appropriate. */ @@ -872,7 +872,7 @@ void do_wrap(filestruct * inptr, char input_char) do_right(); } - edit_update_top(edittop); + edit_update(edittop, TOP); reset_cursor(); edit_refresh(); } @@ -1113,7 +1113,7 @@ int do_spell(void) free_filestruct(fileage); global_init(); open_file(temp, 0, 1); - edit_update(fileage); + edit_update(fileage, CENTER); set_modified(); exit_spell(temp, foo); statusbar(_("Finished checking spelling")); @@ -1274,7 +1274,7 @@ void handle_sigwinch(int s) fix_editbot(); if (current_y > editwinrows - 1) { - edit_update(editbot); + edit_update(editbot, CENTER); } erase(); @@ -1471,7 +1471,7 @@ int do_justify(void) if ((current_y < 0) || (current_y >= editwinrows - 1) || (initial_y <= 0)) { - edit_update(current); + edit_update(current, CENTER); center_cursor(); } else { fix_editbot(); @@ -1784,7 +1784,7 @@ int main(int argc, char *argv[]) if (startline > 0) do_gotoline(startline); else - edit_update(fileage); + edit_update(fileage, CENTER); #ifdef HAVE_TABSIZE if (usrtabsize > 0) diff --git a/nano.h b/nano.h index 7fe20601..3e21cc4a 100644 --- a/nano.h +++ b/nano.h @@ -233,4 +233,7 @@ know what you're doing */ #define VIEW 1 #define NOVIEW 0 +#define TOP 2 +#define CENTER 1 +#define BOTTOM 0 #endif diff --git a/po/nano.pot b/po/nano.pot index ebd44d6c..3343a27c 100644 --- a/po/nano.pot +++ b/po/nano.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-07-28 10:15-0400\n" +"POT-Creation-Date: 2000-07-29 00:38-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -344,7 +344,7 @@ msgid "Case Sens" msgstr "" #: global.c:282 global.c:301 global.c:311 global.c:327 global.c:331 -#: global.c:337 winio.c:1002 +#: global.c:337 winio.c:975 msgid "Cancel" msgstr "" @@ -758,50 +758,50 @@ msgstr "" msgid "Modified" msgstr "" -#: winio.c:918 +#: winio.c:891 #, c-format msgid "Moved to (%d, %d) in edit buffer\n" msgstr "" -#: winio.c:929 +#: winio.c:902 #, c-format msgid "current->data = \"%s\"\n" msgstr "" -#: winio.c:972 +#: winio.c:945 #, c-format msgid "I got \"%s\"\n" msgstr "" -#: winio.c:997 +#: winio.c:970 msgid "Yes" msgstr "" -#: winio.c:999 +#: winio.c:972 msgid "All" msgstr "" -#: winio.c:1001 +#: winio.c:974 msgid "No" msgstr "" -#: winio.c:1137 +#: winio.c:1110 #, c-format msgid "do_cursorpos: linepct = %f, bytepct = %f\n" msgstr "" -#: winio.c:1141 +#: winio.c:1114 msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)" msgstr "" -#: winio.c:1265 +#: winio.c:1238 msgid "Dumping file buffer to stderr...\n" msgstr "" -#: winio.c:1267 +#: winio.c:1240 msgid "Dumping cutbuffer to stderr...\n" msgstr "" -#: winio.c:1269 +#: winio.c:1242 msgid "Dumping a buffer to stderr...\n" msgstr "" diff --git a/proto.h b/proto.h index fdaedcf7..203dddf7 100644 --- a/proto.h +++ b/proto.h @@ -80,9 +80,7 @@ void check_wrap(filestruct * inptr, char ch); void dump_buffer(filestruct * inptr); void align(char **strp); void edit_refresh(void); -void edit_update(filestruct * fileptr); -void edit_update_top(filestruct * fileptr); -void edit_update_bot(filestruct * fileptr); +void edit_update(filestruct * fileptr, int topmidbot); void update_cursor(void); void delete_node(filestruct * fileptr); void set_modified(void); diff --git a/search.c b/search.c index adad3208..f3f12730 100644 --- a/search.c +++ b/search.c @@ -157,7 +157,7 @@ filestruct *findnextstr(int quiet, filestruct * begin, char *needle) current_x++; if (past_editbot) - edit_update(current); + edit_update(current, CENTER); reset_cursor(); } else { /* We're at EOF, go back to the top, once */ @@ -179,7 +179,7 @@ filestruct *findnextstr(int quiet, filestruct * begin, char *needle) for (tmp = fileptr->data; tmp != found; tmp++) current_x++; - edit_update(current); + edit_update(current, CENTER); reset_cursor(); if (!quiet) @@ -487,7 +487,7 @@ int do_replace(void) current = begin; current_x = beginx; renumber_all(); - edit_update(current); + edit_update(current, CENTER); print_replaced(numreplaced); replace_abort(); return 1; @@ -521,7 +521,7 @@ int do_gotoline(long defline) if (!strcmp(answer, "$")) { current = filebot; current_x = 0; - edit_update(current); + edit_update(current, CENTER); goto_abort(); return 1; } @@ -539,14 +539,14 @@ int do_gotoline(long defline) filebot->lineno); current = filebot; current_x = 0; - edit_update(current); + edit_update(current, CENTER); } else { for (fileptr = fileage; fileptr != NULL && i < line; i++) fileptr = fileptr->next; current = fileptr; current_x = 0; - edit_update(current); + edit_update(current, CENTER); } goto_abort(); diff --git a/winio.c b/winio.c index d02fdbca..1270733e 100644 --- a/winio.c +++ b/winio.c @@ -48,7 +48,7 @@ int do_first_line(void) current = fileage; placewewant = 0; current_x = 0; - edit_update(current); + edit_update(current, CENTER); return 1; } @@ -57,7 +57,7 @@ int do_last_line(void) current = filebot; placewewant = 0; current_x = 0; - edit_update(current); + edit_update(current, CENTER); return 1; } @@ -839,8 +839,8 @@ void edit_refresh(void) temp = temp->next; lines++; } - if (!currentcheck) /* Then current has run off the screen... */ -/* edit_update(current) */ ; + if (!currentcheck) /* Then current has run off the screen... */ + edit_update(current, CENTER); if (lines <= editwinrows - 1) while (lines <= editwinrows - 1) { @@ -857,7 +857,7 @@ void edit_refresh(void) * Nice generic routine to update the edit buffer given a pointer to the * file struct =) */ -void edit_update(filestruct * fileptr) +void edit_update(filestruct * fileptr, int topmidbot) { int i = 0; filestruct *temp; @@ -866,10 +866,14 @@ void edit_update(filestruct * fileptr) return; temp = fileptr; - while (i <= editwinrows / 2 && temp->prev != NULL) { - i++; - temp = temp->prev; - } + if (topmidbot == 2) + ; + else if (topmidbot == 0) + for (i = 0; i <= editwinrows - 1 && temp->prev != NULL; i++) + temp = temp->prev; + else + for (i = 0; i <= editwinrows / 2 && temp->prev != NULL; i++) + temp = temp->prev; edittop = temp; fix_editbot(); @@ -877,37 +881,6 @@ void edit_update(filestruct * fileptr) edit_refresh(); } -/* Now we want to update the screen using this struct as the top of the edit buffer */ -void edit_update_top(filestruct * fileptr) -{ - int i; - filestruct *temp = fileptr; - - if (fileptr == NULL) - return; - - i = 0; - while (i <= editwinrows / 2 && temp->next != NULL) { - i++; - temp = temp->next; - } - edit_update(temp); -} - -/* And also for the bottom... */ -void edit_update_bot(filestruct * fileptr) -{ - int i; - filestruct *temp = fileptr; - - i = 0; - while (i <= editwinrows / 2 - 1 && temp->prev != NULL) { - i++; - temp = temp->prev; - } - edit_update(temp); -} - /* This function updates current based on where current_y is, reset_cursor does the opposite */ void update_cursor(void)