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 2851242..d19f097 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 @@
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 4509d66..f3a8499 100644
--- a/cut.c
+++ b/cut.c
@@ -123,7 +123,7 @@
}
}
if (top->lineno < edittop->lineno)
- edit_update(top);
+ edit_update(top, CENTER);
}
#endif
@@ -207,7 +207,7 @@
if (cuttingtoend)
edit_refresh();
else
- edit_update(current);
+ edit_update(current, CENTER);
return 1;
#else
@@ -223,7 +223,7 @@
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 @@
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 @@
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 3912c86..92b2da2 100644
--- a/files.c
+++ b/files.c
@@ -261,7 +261,7 @@
/* 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 f7790d0..12dcde4 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 @@
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 @@
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 @@
int page_up(void)
{
+ filestruct *fileptr = edittop;
wrap_reset();
current_x = 0;
placewewant = 0;
@@ -142,7 +148,13 @@
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 b074715..af2bef7 100644
--- a/nano.c
+++ b/nano.c
@@ -545,7 +545,7 @@
* 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 @@
current_x = i;
placewewant = xplustabs();
if (current->lineno >= editbot->lineno)
- edit_update(current);
+ edit_update(current, CENTER);
}
@@ -859,7 +859,7 @@
/* totsize++; */
renumber(inptr);
- edit_update_top(edittop);
+ edit_update(edittop, TOP);
/* Move the cursor to the new line if appropriate. */
@@ -872,7 +872,7 @@
do_right();
}
- edit_update_top(edittop);
+ edit_update(edittop, TOP);
reset_cursor();
edit_refresh();
}
@@ -1113,7 +1113,7 @@
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 @@
fix_editbot();
if (current_y > editwinrows - 1) {
- edit_update(editbot);
+ edit_update(editbot, CENTER);
}
erase();
@@ -1471,7 +1471,7 @@
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 @@
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 7fe2060..3e21cc4 100644
--- a/nano.h
+++ b/nano.h
@@ -233,4 +233,7 @@
#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 ebd44d6..3343a27 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -344,7 +344,7 @@
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 @@
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 fdaedcf..203dddf 100644
--- a/proto.h
+++ b/proto.h
@@ -80,9 +80,7 @@
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 adad320..f3f1273 100644
--- a/search.c
+++ b/search.c
@@ -157,7 +157,7 @@
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 @@
for (tmp = fileptr->data; tmp != found; tmp++)
current_x++;
- edit_update(current);
+ edit_update(current, CENTER);
reset_cursor();
if (!quiet)
@@ -487,7 +487,7 @@
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 @@
if (!strcmp(answer, "$")) {
current = filebot;
current_x = 0;
- edit_update(current);
+ edit_update(current, CENTER);
goto_abort();
return 1;
}
@@ -539,14 +539,14 @@
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 d02fdbc..1270733 100644
--- a/winio.c
+++ b/winio.c
@@ -48,7 +48,7 @@
current = fileage;
placewewant = 0;
current_x = 0;
- edit_update(current);
+ edit_update(current, CENTER);
return 1;
}
@@ -57,7 +57,7 @@
current = filebot;
placewewant = 0;
current_x = 0;
- edit_update(current);
+ edit_update(current, CENTER);
return 1;
}
@@ -839,8 +839,8 @@
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 @@
* 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 @@
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 @@
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)