Commit 234a34d2 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

Chris goes berzerk on no sleep

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@150 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 84 additions and 87 deletions
+84 -87
CVS code 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: - nano.c:
splice_node() splice_node()
- New function, abstracts linking in nodes. Fixes bug #36. - New function, abstracts linking in nodes. Fixes bug #36.
...@@ -14,9 +17,17 @@ CVS code ...@@ -14,9 +17,17 @@ CVS code
edit_refresh() edit_refresh()
- Added check for current line "running" off the screen. - Added check for current line "running" off the screen.
Hopefully this will not cause any recursive lockups. 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: - move.c:
page_down() 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-0.9.14 - 07/27/2000
- nano.h: - nano.h:
......
...@@ -123,7 +123,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, ...@@ -123,7 +123,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
} }
} }
if (top->lineno < edittop->lineno) if (top->lineno < edittop->lineno)
edit_update(top); edit_update(top, CENTER);
} }
#endif #endif
...@@ -207,7 +207,7 @@ int do_cut_text(void) ...@@ -207,7 +207,7 @@ int do_cut_text(void)
if (cuttingtoend) if (cuttingtoend)
edit_refresh(); edit_refresh();
else else
edit_update(current); edit_update(current, CENTER);
return 1; return 1;
#else #else
...@@ -223,7 +223,7 @@ int do_cut_text(void) ...@@ -223,7 +223,7 @@ int do_cut_text(void)
totsize--; /* get the newline */ totsize--; /* get the newline */
totlines--; totlines--;
fileptr->prev = NULL; fileptr->prev = NULL;
edit_update(fileage); edit_update(fileage, CENTER);
current = fileptr; current = fileptr;
} else { } else {
add_to_cutbuffer(fileptr); add_to_cutbuffer(fileptr);
...@@ -355,7 +355,7 @@ int do_uncut_text(void) ...@@ -355,7 +355,7 @@ int do_uncut_text(void)
current = newend; current = newend;
if (i <= newend->lineno) 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 /* If marked cut == 2, that means that we're doing a cut to end
...@@ -407,7 +407,7 @@ int do_uncut_text(void) ...@@ -407,7 +407,7 @@ int do_uncut_text(void)
i = editbot->lineno; i = editbot->lineno;
renumber(newbuf); renumber(newbuf);
if (i < newend->lineno) if (i < newend->lineno)
edit_update(fileptr); edit_update(fileptr, CENTER);
dump_buffer_reverse(fileptr); dump_buffer_reverse(fileptr);
......
...@@ -261,7 +261,7 @@ int do_insertfile(void) ...@@ -261,7 +261,7 @@ int do_insertfile(void)
/* If we've gone off the bottom, recenter, otherwise just redraw */ /* If we've gone off the bottom, recenter, otherwise just redraw */
if (current->lineno > editbot->lineno) if (current->lineno > editbot->lineno)
edit_update(current); edit_update(current, CENTER);
else else
edit_refresh(); edit_refresh();
......
...@@ -35,12 +35,12 @@ ...@@ -35,12 +35,12 @@
void page_down_center(void) void page_down_center(void)
{ {
if (editbot != filebot) { if (editbot != filebot) {
edit_update(editbot->next); edit_update(editbot->next, CENTER);
center_cursor(); center_cursor();
} else { } else {
while (current != filebot) while (current != filebot)
current = current->next; current = current->next;
edit_update(current); edit_update(current, CENTER);
} }
update_cursor(); update_cursor();
} }
...@@ -54,17 +54,22 @@ int page_down(void) ...@@ -54,17 +54,22 @@ int page_down(void)
if (current == filebot) if (current == filebot)
return 0; return 0;
if (editbot != filebot) { if (editbot != filebot || edittop == fileage) {
current_y = 0; current_y = 0;
current = editbot; current = editbot;
edit_update_top(current);
} else if (current->prev != NULL)
current = current->prev;
if (current->prev != NULL)
current = current->prev;
edit_update(current, TOP);
} else {
while (current != filebot) { while (current != filebot) {
current = current->next; current = current->next;
current_y++; current_y++;
edit_update(current);
} }
edit_update(edittop, TOP);
}
update_cursor(); update_cursor();
UNSET(KEEP_CUTBUFFER); UNSET(KEEP_CUTBUFFER);
...@@ -123,7 +128,7 @@ int do_down(void) ...@@ -123,7 +128,7 @@ int do_down(void)
void page_up_center(void) void page_up_center(void)
{ {
if (edittop != fileage) { if (edittop != fileage) {
edit_update(edittop); edit_update(edittop, CENTER);
center_cursor(); center_cursor();
} else } else
current_y = 0; current_y = 0;
...@@ -134,6 +139,7 @@ void page_up_center(void) ...@@ -134,6 +139,7 @@ void page_up_center(void)
int page_up(void) int page_up(void)
{ {
filestruct *fileptr = edittop;
wrap_reset(); wrap_reset();
current_x = 0; current_x = 0;
placewewant = 0; placewewant = 0;
...@@ -142,7 +148,13 @@ int page_up(void) ...@@ -142,7 +148,13 @@ int page_up(void)
return 0; return 0;
current_y = 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(); update_cursor();
UNSET(KEEP_CUTBUFFER); UNSET(KEEP_CUTBUFFER);
......
...@@ -545,7 +545,7 @@ int do_enter(filestruct * inptr) ...@@ -545,7 +545,7 @@ int do_enter(filestruct * inptr)
* where we think the cursor is. * where we think the cursor is.
*/ */
if (current_y == editwinrows - 1) { if (current_y == editwinrows - 1) {
edit_update(current); edit_update(current, CENTER);
reset_cursor(); reset_cursor();
} else { } else {
current_y++; current_y++;
...@@ -601,7 +601,7 @@ void do_next_word(void) ...@@ -601,7 +601,7 @@ void do_next_word(void)
current_x = i; current_x = i;
placewewant = xplustabs(); placewewant = xplustabs();
if (current->lineno >= editbot->lineno) if (current->lineno >= editbot->lineno)
edit_update(current); edit_update(current, CENTER);
} }
...@@ -859,7 +859,7 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -859,7 +859,7 @@ void do_wrap(filestruct * inptr, char input_char)
/* totsize++; */ /* totsize++; */
renumber(inptr); renumber(inptr);
edit_update_top(edittop); edit_update(edittop, TOP);
/* Move the cursor to the new line if appropriate. */ /* Move the cursor to the new line if appropriate. */
...@@ -872,7 +872,7 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -872,7 +872,7 @@ void do_wrap(filestruct * inptr, char input_char)
do_right(); do_right();
} }
edit_update_top(edittop); edit_update(edittop, TOP);
reset_cursor(); reset_cursor();
edit_refresh(); edit_refresh();
} }
...@@ -1113,7 +1113,7 @@ int do_spell(void) ...@@ -1113,7 +1113,7 @@ int do_spell(void)
free_filestruct(fileage); free_filestruct(fileage);
global_init(); global_init();
open_file(temp, 0, 1); open_file(temp, 0, 1);
edit_update(fileage); edit_update(fileage, CENTER);
set_modified(); set_modified();
exit_spell(temp, foo); exit_spell(temp, foo);
statusbar(_("Finished checking spelling")); statusbar(_("Finished checking spelling"));
...@@ -1274,7 +1274,7 @@ void handle_sigwinch(int s) ...@@ -1274,7 +1274,7 @@ void handle_sigwinch(int s)
fix_editbot(); fix_editbot();
if (current_y > editwinrows - 1) { if (current_y > editwinrows - 1) {
edit_update(editbot); edit_update(editbot, CENTER);
} }
erase(); erase();
...@@ -1471,7 +1471,7 @@ int do_justify(void) ...@@ -1471,7 +1471,7 @@ int do_justify(void)
if ((current_y < 0) || (current_y >= editwinrows - 1) if ((current_y < 0) || (current_y >= editwinrows - 1)
|| (initial_y <= 0)) { || (initial_y <= 0)) {
edit_update(current); edit_update(current, CENTER);
center_cursor(); center_cursor();
} else { } else {
fix_editbot(); fix_editbot();
...@@ -1784,7 +1784,7 @@ int main(int argc, char *argv[]) ...@@ -1784,7 +1784,7 @@ int main(int argc, char *argv[])
if (startline > 0) if (startline > 0)
do_gotoline(startline); do_gotoline(startline);
else else
edit_update(fileage); edit_update(fileage, CENTER);
#ifdef HAVE_TABSIZE #ifdef HAVE_TABSIZE
if (usrtabsize > 0) if (usrtabsize > 0)
......
...@@ -233,4 +233,7 @@ know what you're doing */ ...@@ -233,4 +233,7 @@ know what you're doing */
#define VIEW 1 #define VIEW 1
#define NOVIEW 0 #define NOVIEW 0
#define TOP 2
#define CENTER 1
#define BOTTOM 0
#endif #endif
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -344,7 +344,7 @@ msgid "Case Sens" ...@@ -344,7 +344,7 @@ msgid "Case Sens"
msgstr "" msgstr ""
#: global.c:282 global.c:301 global.c:311 global.c:327 global.c:331 #: 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" msgid "Cancel"
msgstr "" msgstr ""
...@@ -758,50 +758,50 @@ msgstr "" ...@@ -758,50 +758,50 @@ msgstr ""
msgid "Modified" msgid "Modified"
msgstr "" msgstr ""
#: winio.c:918 #: winio.c:891
#, c-format #, c-format
msgid "Moved to (%d, %d) in edit buffer\n" msgid "Moved to (%d, %d) in edit buffer\n"
msgstr "" msgstr ""
#: winio.c:929 #: winio.c:902
#, c-format #, c-format
msgid "current->data = \"%s\"\n" msgid "current->data = \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:972 #: winio.c:945
#, c-format #, c-format
msgid "I got \"%s\"\n" msgid "I got \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:997 #: winio.c:970
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#: winio.c:999 #: winio.c:972
msgid "All" msgid "All"
msgstr "" msgstr ""
#: winio.c:1001 #: winio.c:974
msgid "No" msgid "No"
msgstr "" msgstr ""
#: winio.c:1137 #: winio.c:1110
#, c-format #, c-format
msgid "do_cursorpos: linepct = %f, bytepct = %f\n" msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
msgstr "" msgstr ""
#: winio.c:1141 #: winio.c:1114
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)" msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "" msgstr ""
#: winio.c:1265 #: winio.c:1238
msgid "Dumping file buffer to stderr...\n" msgid "Dumping file buffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1267 #: winio.c:1240
msgid "Dumping cutbuffer to stderr...\n" msgid "Dumping cutbuffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1269 #: winio.c:1242
msgid "Dumping a buffer to stderr...\n" msgid "Dumping a buffer to stderr...\n"
msgstr "" msgstr ""
...@@ -80,9 +80,7 @@ void check_wrap(filestruct * inptr, char ch); ...@@ -80,9 +80,7 @@ void check_wrap(filestruct * inptr, char ch);
void dump_buffer(filestruct * inptr); void dump_buffer(filestruct * inptr);
void align(char **strp); void align(char **strp);
void edit_refresh(void); void edit_refresh(void);
void edit_update(filestruct * fileptr); void edit_update(filestruct * fileptr, int topmidbot);
void edit_update_top(filestruct * fileptr);
void edit_update_bot(filestruct * fileptr);
void update_cursor(void); void update_cursor(void);
void delete_node(filestruct * fileptr); void delete_node(filestruct * fileptr);
void set_modified(void); void set_modified(void);
......
...@@ -157,7 +157,7 @@ filestruct *findnextstr(int quiet, filestruct * begin, char *needle) ...@@ -157,7 +157,7 @@ filestruct *findnextstr(int quiet, filestruct * begin, char *needle)
current_x++; current_x++;
if (past_editbot) if (past_editbot)
edit_update(current); edit_update(current, CENTER);
reset_cursor(); reset_cursor();
} else { /* We're at EOF, go back to the top, once */ } else { /* We're at EOF, go back to the top, once */
...@@ -179,7 +179,7 @@ filestruct *findnextstr(int quiet, filestruct * begin, char *needle) ...@@ -179,7 +179,7 @@ filestruct *findnextstr(int quiet, filestruct * begin, char *needle)
for (tmp = fileptr->data; tmp != found; tmp++) for (tmp = fileptr->data; tmp != found; tmp++)
current_x++; current_x++;
edit_update(current); edit_update(current, CENTER);
reset_cursor(); reset_cursor();
if (!quiet) if (!quiet)
...@@ -487,7 +487,7 @@ int do_replace(void) ...@@ -487,7 +487,7 @@ int do_replace(void)
current = begin; current = begin;
current_x = beginx; current_x = beginx;
renumber_all(); renumber_all();
edit_update(current); edit_update(current, CENTER);
print_replaced(numreplaced); print_replaced(numreplaced);
replace_abort(); replace_abort();
return 1; return 1;
...@@ -521,7 +521,7 @@ int do_gotoline(long defline) ...@@ -521,7 +521,7 @@ int do_gotoline(long defline)
if (!strcmp(answer, "$")) { if (!strcmp(answer, "$")) {
current = filebot; current = filebot;
current_x = 0; current_x = 0;
edit_update(current); edit_update(current, CENTER);
goto_abort(); goto_abort();
return 1; return 1;
} }
...@@ -539,14 +539,14 @@ int do_gotoline(long defline) ...@@ -539,14 +539,14 @@ int do_gotoline(long defline)
filebot->lineno); filebot->lineno);
current = filebot; current = filebot;
current_x = 0; current_x = 0;
edit_update(current); edit_update(current, CENTER);
} else { } else {
for (fileptr = fileage; fileptr != NULL && i < line; i++) for (fileptr = fileage; fileptr != NULL && i < line; i++)
fileptr = fileptr->next; fileptr = fileptr->next;
current = fileptr; current = fileptr;
current_x = 0; current_x = 0;
edit_update(current); edit_update(current, CENTER);
} }
goto_abort(); goto_abort();
......
...@@ -48,7 +48,7 @@ int do_first_line(void) ...@@ -48,7 +48,7 @@ int do_first_line(void)
current = fileage; current = fileage;
placewewant = 0; placewewant = 0;
current_x = 0; current_x = 0;
edit_update(current); edit_update(current, CENTER);
return 1; return 1;
} }
...@@ -57,7 +57,7 @@ int do_last_line(void) ...@@ -57,7 +57,7 @@ int do_last_line(void)
current = filebot; current = filebot;
placewewant = 0; placewewant = 0;
current_x = 0; current_x = 0;
edit_update(current); edit_update(current, CENTER);
return 1; return 1;
} }
...@@ -839,8 +839,8 @@ void edit_refresh(void) ...@@ -839,8 +839,8 @@ void edit_refresh(void)
temp = temp->next; temp = temp->next;
lines++; lines++;
} }
if (!currentcheck) /* Then current has run off the screen... */ if (!currentcheck) /* Then current has run off the screen... */
/* edit_update(current) */ ; edit_update(current, CENTER);
if (lines <= editwinrows - 1) if (lines <= editwinrows - 1)
while (lines <= editwinrows - 1) { while (lines <= editwinrows - 1) {
...@@ -857,7 +857,7 @@ void edit_refresh(void) ...@@ -857,7 +857,7 @@ void edit_refresh(void)
* Nice generic routine to update the edit buffer given a pointer to the * Nice generic routine to update the edit buffer given a pointer to the
* file struct =) * file struct =)
*/ */
void edit_update(filestruct * fileptr) void edit_update(filestruct * fileptr, int topmidbot)
{ {
int i = 0; int i = 0;
filestruct *temp; filestruct *temp;
...@@ -866,10 +866,14 @@ void edit_update(filestruct * fileptr) ...@@ -866,10 +866,14 @@ void edit_update(filestruct * fileptr)
return; return;
temp = fileptr; temp = fileptr;
while (i <= editwinrows / 2 && temp->prev != NULL) { if (topmidbot == 2)
i++; ;
temp = temp->prev; 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; edittop = temp;
fix_editbot(); fix_editbot();
...@@ -877,37 +881,6 @@ void edit_update(filestruct * fileptr) ...@@ -877,37 +881,6 @@ void edit_update(filestruct * fileptr)
edit_refresh(); 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 /* This function updates current based on where current_y is, reset_cursor
does the opposite */ does the opposite */
void update_cursor(void) void update_cursor(void)
......
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