really fix color breakage by decoupling edit_update() and
edit_refresh(); edit_update() is only called without edit_refresh() in do_gotolinecolumn() if allow_update is FALSE, and in edit_refresh() itself if edittop is out of range of current git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2875 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
8f4762a842
commit
5b44f373fd
|
@ -91,6 +91,8 @@ CVS code -
|
|||
- nano.h:
|
||||
- Since we only use vsnprintf() now, remove the #ifdef block for
|
||||
HAVE_SNPRINTF. (DLR)
|
||||
- Remove TOP from the topmidnone enum, and rename it centernone.
|
||||
(DLR)
|
||||
- rcfile.c:
|
||||
nregcomp()
|
||||
- Return TRUE when the compilation succeeds and FALSE otherwise,
|
||||
|
@ -109,7 +111,8 @@ CVS code -
|
|||
- Remove unnecessary renumber(). (DLR)
|
||||
do_gotolinecolumn()
|
||||
- Add parameter allow_update to control whether the screen is
|
||||
updated after moving. (DLR)
|
||||
updated after moving. If it's TRUE, call edit_refresh() after
|
||||
edit_update(). (DLR)
|
||||
do_gotopos()
|
||||
- Only include this function when DISABLE_SPELLER isn't defined,
|
||||
as the alternate spell checking code is now the only place
|
||||
|
@ -117,6 +120,9 @@ CVS code -
|
|||
- winio.c:
|
||||
edit_scroll(), edit_redraw(), edit_refresh()
|
||||
- Clean up and simplify. (DLR)
|
||||
edit_update()
|
||||
- Since we no longer use TOP, remove references to it. Also,
|
||||
don't call edit_refresh() anymore: it will call us. (DLR)
|
||||
do_statusbar_next_word()
|
||||
- Rework to be more like do_statusbar_prev_word(), to avoid a
|
||||
potential problem if we start at the end of a line. (DLR)
|
||||
|
|
|
@ -161,8 +161,6 @@ void color_update(void)
|
|||
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
|
||||
}
|
||||
}
|
||||
|
||||
color_init();
|
||||
}
|
||||
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
|
|
@ -1586,8 +1586,10 @@ int write_file(const char *name, FILE *f_open, bool tmp, int append,
|
|||
realname);
|
||||
#ifdef ENABLE_COLOR
|
||||
/* We might have changed the filename, so update the colors
|
||||
* to account for it. */
|
||||
* to account for it, and then make sure we're using
|
||||
* them. */
|
||||
color_update();
|
||||
color_init();
|
||||
|
||||
/* If color syntaxes are available and turned on, we need to
|
||||
* call edit_refresh(). */
|
||||
|
|
|
@ -40,7 +40,7 @@ void do_first_line(void)
|
|||
|
||||
if (openfile->edittop != openfile->fileage ||
|
||||
need_vertical_update(pww_save))
|
||||
edit_update(TOP);
|
||||
edit_update(CENTER);
|
||||
}
|
||||
|
||||
void do_last_line(void)
|
||||
|
|
|
@ -149,8 +149,8 @@ typedef enum {
|
|||
} updown;
|
||||
|
||||
typedef enum {
|
||||
TOP, CENTER, NONE
|
||||
} topmidnone;
|
||||
CENTER, NONE
|
||||
} centernone;
|
||||
|
||||
/* Structure types. */
|
||||
typedef struct filestruct {
|
||||
|
|
|
@ -671,7 +671,7 @@ int need_vertical_update(size_t old_pww);
|
|||
void edit_scroll(updown direction, int nlines);
|
||||
void edit_redraw(const filestruct *old_current, size_t old_pww);
|
||||
void edit_refresh(void);
|
||||
void edit_update(topmidnone location);
|
||||
void edit_update(centernone location);
|
||||
int do_yesno(bool all, const char *msg);
|
||||
void total_redraw(void);
|
||||
void total_refresh(void);
|
||||
|
|
10
src/search.c
10
src/search.c
|
@ -1026,11 +1026,15 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
|||
openfile->current_x = actual_x(openfile->current->data, column - 1);
|
||||
openfile->placewewant = column - 1;
|
||||
|
||||
/* If allow_update is TRUE, update the edit window. If save_pos is
|
||||
* TRUE, don't change the cursor position when doing it. */
|
||||
if (allow_update)
|
||||
/* Put the top line of the edit window in range of the current line.
|
||||
* If save_pos is TRUE, don't change the cursor position when doing
|
||||
* it. */
|
||||
edit_update(save_pos ? NONE : CENTER);
|
||||
|
||||
/* If allow_update is TRUE, update the screen. */
|
||||
if (allow_update)
|
||||
edit_refresh();
|
||||
|
||||
display_main_list();
|
||||
}
|
||||
|
||||
|
|
42
src/winio.c
42
src/winio.c
|
@ -3607,20 +3607,19 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
|
|||
/* Refresh the screen without changing the position of lines. */
|
||||
void edit_refresh(void)
|
||||
{
|
||||
int nlines = 0;
|
||||
const filestruct *foo = openfile->edittop;
|
||||
|
||||
if (openfile->current->lineno < openfile->edittop->lineno ||
|
||||
openfile->current->lineno >= openfile->edittop->lineno +
|
||||
editwinrows)
|
||||
/* Note that edit_update() changes edittop so that it's in range
|
||||
* of current. Thus, when it then calls edit_refresh(), there
|
||||
* is no danger of getting an infinite loop. */
|
||||
/* Put the top line of the edit window in the range of the
|
||||
* current line. */
|
||||
edit_update(
|
||||
#ifndef NANO_SMALL
|
||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||
#endif
|
||||
CENTER);
|
||||
else {
|
||||
int nlines = 0;
|
||||
const filestruct *foo = openfile->edittop;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)openfile->edittop->lineno);
|
||||
|
@ -3632,32 +3631,33 @@ void edit_refresh(void)
|
|||
foo = foo->next;
|
||||
nlines++;
|
||||
}
|
||||
|
||||
while (nlines < editwinrows) {
|
||||
blank_line(edit, nlines, 0, COLS);
|
||||
nlines++;
|
||||
}
|
||||
|
||||
reset_cursor();
|
||||
wrefresh(edit);
|
||||
}
|
||||
}
|
||||
|
||||
/* A nice generic routine to update the edit buffer. We keep current in
|
||||
* the same place and move edittop to put it in range of current. */
|
||||
void edit_update(topmidnone location)
|
||||
/* Move edittop to put it in range of current, keeping current in the
|
||||
* same place. location determines how we move it: if it's CENTER, we
|
||||
* center current, and if it's NONE, we put current current_y lines
|
||||
* below edittop. */
|
||||
void edit_update(centernone location)
|
||||
{
|
||||
filestruct *foo = openfile->current;
|
||||
|
||||
if (location != TOP) {
|
||||
/* If location is CENTER, we move edittop up (editwinrows / 2)
|
||||
* lines. This puts current at the center of the screen. If
|
||||
* location is NONE, we move edittop up current_y lines if
|
||||
* current_y is in range of the screen, 0 lines if current_y is
|
||||
* less than 0, or (editwinrows - 1) lines if current_y is
|
||||
* greater than (editwinrows - 1). This puts current at the
|
||||
* same place on the screen as before, or at the top or bottom
|
||||
* of the screen if edittop is beyond either. */
|
||||
int goal;
|
||||
|
||||
/* If location is CENTER, we move edittop up (editwinrows / 2)
|
||||
* lines. This puts current at the center of the screen. If
|
||||
* location is NONE, we move edittop up current_y lines if current_y
|
||||
* is in range of the screen, 0 lines if current_y is less than 0,
|
||||
* or (editwinrows - 1) lines if current_y is greater than
|
||||
* (editwinrows - 1). This puts current at the same place on the
|
||||
* screen as before, or at the top or bottom of the screen if
|
||||
* edittop is beyond either. */
|
||||
if (location == CENTER)
|
||||
goal = editwinrows / 2;
|
||||
else {
|
||||
|
@ -3670,10 +3670,8 @@ void edit_update(topmidnone location)
|
|||
|
||||
for (; goal > 0 && foo->prev != NULL; goal--)
|
||||
foo = foo->prev;
|
||||
}
|
||||
|
||||
openfile->edittop = foo;
|
||||
edit_refresh();
|
||||
}
|
||||
|
||||
/* Ask a simple yes/no question, specified in msg, on the statusbar.
|
||||
|
|
Loading…
Reference in New Issue