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:
|
- nano.h:
|
||||||
- Since we only use vsnprintf() now, remove the #ifdef block for
|
- Since we only use vsnprintf() now, remove the #ifdef block for
|
||||||
HAVE_SNPRINTF. (DLR)
|
HAVE_SNPRINTF. (DLR)
|
||||||
|
- Remove TOP from the topmidnone enum, and rename it centernone.
|
||||||
|
(DLR)
|
||||||
- rcfile.c:
|
- rcfile.c:
|
||||||
nregcomp()
|
nregcomp()
|
||||||
- Return TRUE when the compilation succeeds and FALSE otherwise,
|
- Return TRUE when the compilation succeeds and FALSE otherwise,
|
||||||
|
@ -109,7 +111,8 @@ CVS code -
|
||||||
- Remove unnecessary renumber(). (DLR)
|
- Remove unnecessary renumber(). (DLR)
|
||||||
do_gotolinecolumn()
|
do_gotolinecolumn()
|
||||||
- Add parameter allow_update to control whether the screen is
|
- 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()
|
do_gotopos()
|
||||||
- Only include this function when DISABLE_SPELLER isn't defined,
|
- Only include this function when DISABLE_SPELLER isn't defined,
|
||||||
as the alternate spell checking code is now the only place
|
as the alternate spell checking code is now the only place
|
||||||
|
@ -117,6 +120,9 @@ CVS code -
|
||||||
- winio.c:
|
- winio.c:
|
||||||
edit_scroll(), edit_redraw(), edit_refresh()
|
edit_scroll(), edit_redraw(), edit_refresh()
|
||||||
- Clean up and simplify. (DLR)
|
- 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()
|
do_statusbar_next_word()
|
||||||
- Rework to be more like do_statusbar_prev_word(), to avoid a
|
- Rework to be more like do_statusbar_prev_word(), to avoid a
|
||||||
potential problem if we start at the end of a line. (DLR)
|
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));
|
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
color_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ENABLE_COLOR */
|
#endif /* ENABLE_COLOR */
|
||||||
|
|
|
@ -1586,8 +1586,10 @@ int write_file(const char *name, FILE *f_open, bool tmp, int append,
|
||||||
realname);
|
realname);
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
/* We might have changed the filename, so update the colors
|
/* 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_update();
|
||||||
|
color_init();
|
||||||
|
|
||||||
/* If color syntaxes are available and turned on, we need to
|
/* If color syntaxes are available and turned on, we need to
|
||||||
* call edit_refresh(). */
|
* call edit_refresh(). */
|
||||||
|
|
|
@ -40,7 +40,7 @@ void do_first_line(void)
|
||||||
|
|
||||||
if (openfile->edittop != openfile->fileage ||
|
if (openfile->edittop != openfile->fileage ||
|
||||||
need_vertical_update(pww_save))
|
need_vertical_update(pww_save))
|
||||||
edit_update(TOP);
|
edit_update(CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_last_line(void)
|
void do_last_line(void)
|
||||||
|
|
|
@ -149,8 +149,8 @@ typedef enum {
|
||||||
} updown;
|
} updown;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TOP, CENTER, NONE
|
CENTER, NONE
|
||||||
} topmidnone;
|
} centernone;
|
||||||
|
|
||||||
/* Structure types. */
|
/* Structure types. */
|
||||||
typedef struct filestruct {
|
typedef struct filestruct {
|
||||||
|
|
|
@ -671,7 +671,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(topmidnone location);
|
void edit_update(centernone location);
|
||||||
int do_yesno(bool all, const char *msg);
|
int do_yesno(bool all, const char *msg);
|
||||||
void total_redraw(void);
|
void total_redraw(void);
|
||||||
void total_refresh(void);
|
void total_refresh(void);
|
||||||
|
|
10
src/search.c
10
src/search.c
|
@ -1026,10 +1026,14 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||||
openfile->current_x = actual_x(openfile->current->data, column - 1);
|
openfile->current_x = actual_x(openfile->current->data, column - 1);
|
||||||
openfile->placewewant = column - 1;
|
openfile->placewewant = column - 1;
|
||||||
|
|
||||||
/* If allow_update is TRUE, update the edit window. If save_pos is
|
/* Put the top line of the edit window in range of the current line.
|
||||||
* TRUE, don't change the cursor position when doing it. */
|
* 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)
|
if (allow_update)
|
||||||
edit_update(save_pos ? NONE : CENTER);
|
edit_refresh();
|
||||||
|
|
||||||
display_main_list();
|
display_main_list();
|
||||||
}
|
}
|
||||||
|
|
86
src/winio.c
86
src/winio.c
|
@ -3607,73 +3607,71 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
|
||||||
/* Refresh the screen without changing the position of lines. */
|
/* Refresh the screen without changing the position of lines. */
|
||||||
void edit_refresh(void)
|
void edit_refresh(void)
|
||||||
{
|
{
|
||||||
|
int nlines = 0;
|
||||||
|
const filestruct *foo = openfile->edittop;
|
||||||
|
|
||||||
if (openfile->current->lineno < openfile->edittop->lineno ||
|
if (openfile->current->lineno < openfile->edittop->lineno ||
|
||||||
openfile->current->lineno >= openfile->edittop->lineno +
|
openfile->current->lineno >= openfile->edittop->lineno +
|
||||||
editwinrows)
|
editwinrows)
|
||||||
/* Note that edit_update() changes edittop so that it's in range
|
/* Put the top line of the edit window in the range of the
|
||||||
* of current. Thus, when it then calls edit_refresh(), there
|
* current line. */
|
||||||
* is no danger of getting an infinite loop. */
|
|
||||||
edit_update(
|
edit_update(
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||||
#endif
|
#endif
|
||||||
CENTER);
|
CENTER);
|
||||||
else {
|
|
||||||
int nlines = 0;
|
|
||||||
const filestruct *foo = openfile->edittop;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)openfile->edittop->lineno);
|
fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)openfile->edittop->lineno);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (nlines < editwinrows && foo != NULL) {
|
while (nlines < editwinrows && foo != NULL) {
|
||||||
update_line(foo, (foo == openfile->current) ?
|
update_line(foo, (foo == openfile->current) ?
|
||||||
openfile->current_x : 0);
|
openfile->current_x : 0);
|
||||||
foo = foo->next;
|
foo = foo->next;
|
||||||
nlines++;
|
nlines++;
|
||||||
}
|
|
||||||
while (nlines < editwinrows) {
|
|
||||||
blank_line(edit, nlines, 0, COLS);
|
|
||||||
nlines++;
|
|
||||||
}
|
|
||||||
reset_cursor();
|
|
||||||
wrefresh(edit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
/* Move edittop to put it in range of current, keeping current in the
|
||||||
* the same place and move edittop to put it in range of current. */
|
* same place. location determines how we move it: if it's CENTER, we
|
||||||
void edit_update(topmidnone location)
|
* center current, and if it's NONE, we put current current_y lines
|
||||||
|
* below edittop. */
|
||||||
|
void edit_update(centernone location)
|
||||||
{
|
{
|
||||||
filestruct *foo = openfile->current;
|
filestruct *foo = openfile->current;
|
||||||
|
int goal;
|
||||||
|
|
||||||
if (location != TOP) {
|
/* If location is CENTER, we move edittop up (editwinrows / 2)
|
||||||
/* If location is CENTER, we move edittop up (editwinrows / 2)
|
* lines. This puts current at the center of the screen. If
|
||||||
* lines. This puts current at the center of the screen. If
|
* location is NONE, we move edittop up current_y lines if current_y
|
||||||
* location is NONE, we move edittop up current_y lines if
|
* is in range of the screen, 0 lines if current_y is less than 0,
|
||||||
* current_y is in range of the screen, 0 lines if current_y is
|
* or (editwinrows - 1) lines if current_y is greater than
|
||||||
* less than 0, or (editwinrows - 1) lines if current_y is
|
* (editwinrows - 1). This puts current at the same place on the
|
||||||
* greater than (editwinrows - 1). This puts current at the
|
* screen as before, or at the top or bottom of the screen if
|
||||||
* same place on the screen as before, or at the top or bottom
|
* edittop is beyond either. */
|
||||||
* of the screen if edittop is beyond either. */
|
if (location == CENTER)
|
||||||
int goal;
|
goal = editwinrows / 2;
|
||||||
|
else {
|
||||||
|
goal = openfile->current_y;
|
||||||
|
|
||||||
if (location == CENTER)
|
/* Limit goal to (editwinrows - 1) lines maximum. */
|
||||||
goal = editwinrows / 2;
|
if (goal > editwinrows - 1)
|
||||||
else {
|
goal = editwinrows - 1;
|
||||||
goal = openfile->current_y;
|
|
||||||
|
|
||||||
/* Limit goal to (editwinrows - 1) lines maximum. */
|
|
||||||
if (goal > editwinrows - 1)
|
|
||||||
goal = editwinrows - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; goal > 0 && foo->prev != NULL; goal--)
|
|
||||||
foo = foo->prev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (; goal > 0 && foo->prev != NULL; goal--)
|
||||||
|
foo = foo->prev;
|
||||||
|
|
||||||
openfile->edittop = foo;
|
openfile->edittop = foo;
|
||||||
edit_refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ask a simple yes/no question, specified in msg, on the statusbar.
|
/* Ask a simple yes/no question, specified in msg, on the statusbar.
|
||||||
|
|
Loading…
Reference in New Issue