2009-12-12 Chris Allegretta <chrisa@asty.org>

* text.c (do_delete), nano.c (do_output): Add check for length of current line
          before and after adding/deleting text, and do full refresh if it is now
          a different multiple of COLS.  Also get rid of superfluous do_refresh
          vars now that we have edit_refresh_needed.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4462 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2009-12-12 22:21:20 +00:00
parent f387f33083
commit a8bc492b8a
3 changed files with 31 additions and 25 deletions

View File

@ -1,4 +1,10 @@
2009-12-07 David Lawrence Ramsey <pooka109@gmail.com>
2009-12-12 Chris Allegretta <chrisa@asty.org>
* text.c (do_delete), nano.c (do_output): Add check for length of current line
before and after adding/deleting text, and do full refresh if it is now
a different multiple of COLS. Also get rid of superfluous do_refresh
vars now that we have edit_refresh_needed.
2009-12-09 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init), browser.c (do_browser): Fix M-W not being bound to
research in either main menu or browser.

View File

@ -1893,17 +1893,15 @@ precalc_cleanup:
* TRUE. */
void do_output(char *output, size_t output_len, bool allow_cntrls)
{
size_t current_len, i = 0;
bool do_refresh = FALSE;
/* Do we have to call edit_refresh(), or can we get away with
* just update_line()? */
size_t current_len, orig_lenpt, i = 0;
char *char_buf = charalloc(mb_cur_max());
int char_buf_len;
assert(openfile->current != NULL && openfile->current->data != NULL);
current_len = strlen(openfile->current->data);
if (ISSET(SOFTWRAP))
orig_lenpt = strlenpt(openfile->current->data);
while (i < output_len) {
/* If allow_cntrls is TRUE, convert nulls and newlines
@ -1967,26 +1965,25 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifndef DISABLE_WRAPPING
/* If we're wrapping text, we need to call edit_refresh(). */
if (!ISSET(NO_WRAP)) {
bool do_refresh_save = do_refresh;
do_refresh = do_wrap(openfile->current, FALSE);
/* If we needed to call edit_refresh() before this, we'll
* still need to after this. */
if (do_refresh_save)
do_refresh = TRUE;
}
if (!ISSET(NO_WRAP))
if (do_wrap(openfile->current, FALSE))
edit_refresh_needed = TRUE;
#endif
#ifdef ENABLE_COLOR
/* If color syntaxes are available and turned on, we need to
* call edit_refresh(). */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
do_refresh = TRUE;
edit_refresh_needed = TRUE;
#endif
}
/* Well we might also need a full refresh if we've changed the
line length to be a new multiple of COLS */
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
edit_refresh_needed = TRUE;
free(char_buf);
openfile->placewewant = xplustabs();
@ -1995,7 +1992,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifdef ENABLE_COLOR
reset_multis(openfile->current, FALSE);
#endif
if (do_refresh) {
if (edit_refresh_needed == TRUE) {
edit_refresh();
edit_refresh_needed = FALSE;
} else

View File

@ -66,9 +66,7 @@ void do_mark(void)
/* Delete the character under the cursor. */
void do_delete(void)
{
bool do_refresh = FALSE;
/* Do we have to call edit_refresh(), or can we get away with
* just update_line()? */
size_t orig_lenpt = 0;
#ifndef NANO_TINY
update_undo(DEL);
@ -86,6 +84,9 @@ void do_delete(void)
assert(openfile->current_x < strlen(openfile->current->data));
if (ISSET(SOFTWRAP))
orig_lenpt = strlenpt(openfile->current->data);
/* Let's get dangerous. */
charmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x +
@ -108,7 +109,7 @@ void do_delete(void)
/* If we're deleting at the end of a line, we need to call
* edit_refresh(). */
if (openfile->current->data[openfile->current_x] == '\0')
do_refresh = TRUE;
edit_refresh_needed = TRUE;
openfile->current->data = charealloc(openfile->current->data,
openfile->current_x + strlen(foo->data) + 1);
@ -138,11 +139,13 @@ void do_delete(void)
} else
return;
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
edit_refresh_needed = TRUE;
set_modified();
if (do_refresh)
edit_refresh_needed = TRUE;
else
if (edit_refresh_needed == FALSE)
update_line(openfile->current, openfile->current_x);
}