Commit 20b83508 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

simplify edit_update() so as not to require the fileptr parameter

anymore, since it's set to current in all calls


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1915 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 17 additions and 12 deletions
+17 -12
...@@ -29,6 +29,9 @@ CVS code - ...@@ -29,6 +29,9 @@ CVS code -
- If there are more than MAIN_VISIBLE shortcuts available, only - If there are more than MAIN_VISIBLE shortcuts available, only
register clicks on the first MAIN_VISIBLE shortcuts, since register clicks on the first MAIN_VISIBLE shortcuts, since
bottombars() only shows that many shortcuts. (DLR) bottombars() only shows that many shortcuts. (DLR)
edit_update()
- Simplify so as not to require the fileptr parameter anymore,
since it's set to current in all calls. (DLR)
do_yesno() do_yesno()
- Don't bother assigning the value of get_mouseinput() to - Don't bother assigning the value of get_mouseinput() to
anything. Since allow_shortcuts is FALSE, its return value anything. Since allow_shortcuts is FALSE, its return value
......
...@@ -35,7 +35,7 @@ void do_first_line(void) ...@@ -35,7 +35,7 @@ void do_first_line(void)
placewewant = 0; placewewant = 0;
current_x = 0; current_x = 0;
if (edittop != fileage || need_vertical_update(old_pww)) if (edittop != fileage || need_vertical_update(old_pww))
edit_update(current, TOP); edit_update(TOP);
} }
void do_last_line(void) void do_last_line(void)
...@@ -46,7 +46,7 @@ void do_last_line(void) ...@@ -46,7 +46,7 @@ void do_last_line(void)
current_x = 0; current_x = 0;
if (edittop->lineno + (editwinrows / 2) != filebot->lineno || if (edittop->lineno + (editwinrows / 2) != filebot->lineno ||
need_vertical_update(old_pww)) need_vertical_update(old_pww))
edit_update(current, CENTER); edit_update(CENTER);
} }
void do_home(void) void do_home(void)
......
...@@ -565,7 +565,7 @@ int need_vertical_update(size_t old_pww); ...@@ -565,7 +565,7 @@ int need_vertical_update(size_t old_pww);
void edit_scroll(updown direction, int nlines); void edit_scroll(updown direction, int nlines);
void edit_redraw(const filestruct *old_current, size_t old_pww); void edit_redraw(const filestruct *old_current, size_t old_pww);
void edit_refresh(void); void edit_refresh(void);
void edit_update(filestruct *fileptr, topmidnone location); void edit_update(topmidnone location);
int statusq(int allowtabs, const shortcut *s, const char *def, int statusq(int allowtabs, const shortcut *s, const char *def,
#ifndef NANO_SMALL #ifndef NANO_SMALL
historyheadtype *history_list, historyheadtype *history_list,
......
...@@ -877,7 +877,7 @@ void do_gotoline(int line, bool save_pos) ...@@ -877,7 +877,7 @@ void do_gotoline(int line, bool save_pos)
/* If save_pos is TRUE, don't change the cursor position when /* If save_pos is TRUE, don't change the cursor position when
* updating the edit window. */ * updating the edit window. */
edit_update(current, save_pos ? NONE : CENTER); edit_update(save_pos ? NONE : CENTER);
placewewant = 0; placewewant = 0;
display_main_list(); display_main_list();
......
...@@ -2897,7 +2897,7 @@ void edit_refresh(void) ...@@ -2897,7 +2897,7 @@ void edit_refresh(void)
* current->lineno = edittop->lineno + editwinrows / 2. Thus * current->lineno = edittop->lineno + editwinrows / 2. Thus
* when it then calls edit_refresh(), there is no danger of * when it then calls edit_refresh(), there is no danger of
* getting an infinite loop. */ * getting an infinite loop. */
edit_update(current, CENTER); edit_update(CENTER);
else { else {
int nlines = 0; int nlines = 0;
const filestruct *foo = edittop; const filestruct *foo = edittop;
...@@ -2922,20 +2922,22 @@ void edit_refresh(void) ...@@ -2922,20 +2922,22 @@ void edit_refresh(void)
} }
} }
/* Nice generic routine to update the edit buffer, given a pointer to the /* A nice generic routine to update the edit buffer. */
* file struct =) */ void edit_update(topmidnone location)
void edit_update(filestruct *fileptr, topmidnone location)
{ {
if (fileptr == NULL) filestruct *foo = current;
/* We shouldn't need this check. Yuck. */
if (current == NULL)
return; return;
if (location != TOP) { if (location != TOP) {
int goal = (location == NONE) ? current_y : editwinrows / 2; int goal = (location == NONE) ? current_y : editwinrows / 2;
for (; goal > 0 && fileptr->prev != NULL; goal--) for (; goal > 0 && foo->prev != NULL; goal--)
fileptr = fileptr->prev; foo = foo->prev;
} }
edittop = fileptr; edittop = foo;
edit_refresh(); edit_refresh();
} }
......
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