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-d3aeb78583b8master
parent
f387f33083
commit
a8bc492b8a
|
@ -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
|
* global.c (shortcut_init), browser.c (do_browser): Fix M-W not being bound to
|
||||||
research in either main menu or browser.
|
research in either main menu or browser.
|
||||||
|
|
||||||
|
|
31
src/nano.c
31
src/nano.c
|
@ -1893,17 +1893,15 @@ precalc_cleanup:
|
||||||
* TRUE. */
|
* TRUE. */
|
||||||
void do_output(char *output, size_t output_len, bool allow_cntrls)
|
void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||||
{
|
{
|
||||||
size_t current_len, i = 0;
|
size_t current_len, orig_lenpt, i = 0;
|
||||||
bool do_refresh = FALSE;
|
|
||||||
/* Do we have to call edit_refresh(), or can we get away with
|
|
||||||
* just update_line()? */
|
|
||||||
|
|
||||||
char *char_buf = charalloc(mb_cur_max());
|
char *char_buf = charalloc(mb_cur_max());
|
||||||
int char_buf_len;
|
int char_buf_len;
|
||||||
|
|
||||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||||
|
|
||||||
current_len = strlen(openfile->current->data);
|
current_len = strlen(openfile->current->data);
|
||||||
|
if (ISSET(SOFTWRAP))
|
||||||
|
orig_lenpt = strlenpt(openfile->current->data);
|
||||||
|
|
||||||
while (i < output_len) {
|
while (i < output_len) {
|
||||||
/* If allow_cntrls is TRUE, convert nulls and newlines
|
/* 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
|
#ifndef DISABLE_WRAPPING
|
||||||
/* If we're wrapping text, we need to call edit_refresh(). */
|
/* If we're wrapping text, we need to call edit_refresh(). */
|
||||||
if (!ISSET(NO_WRAP)) {
|
if (!ISSET(NO_WRAP))
|
||||||
bool do_refresh_save = do_refresh;
|
if (do_wrap(openfile->current, FALSE))
|
||||||
|
edit_refresh_needed = TRUE;
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
/* 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(). */
|
||||||
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
|
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
|
||||||
do_refresh = TRUE;
|
edit_refresh_needed = TRUE;
|
||||||
#endif
|
#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);
|
free(char_buf);
|
||||||
|
|
||||||
openfile->placewewant = xplustabs();
|
openfile->placewewant = xplustabs();
|
||||||
|
@ -1995,7 +1992,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
reset_multis(openfile->current, FALSE);
|
reset_multis(openfile->current, FALSE);
|
||||||
#endif
|
#endif
|
||||||
if (do_refresh) {
|
if (edit_refresh_needed == TRUE) {
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
edit_refresh_needed = FALSE;
|
edit_refresh_needed = FALSE;
|
||||||
} else
|
} else
|
||||||
|
|
17
src/text.c
17
src/text.c
|
@ -66,9 +66,7 @@ void do_mark(void)
|
||||||
/* Delete the character under the cursor. */
|
/* Delete the character under the cursor. */
|
||||||
void do_delete(void)
|
void do_delete(void)
|
||||||
{
|
{
|
||||||
bool do_refresh = FALSE;
|
size_t orig_lenpt = 0;
|
||||||
/* Do we have to call edit_refresh(), or can we get away with
|
|
||||||
* just update_line()? */
|
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
update_undo(DEL);
|
update_undo(DEL);
|
||||||
|
@ -86,6 +84,9 @@ void do_delete(void)
|
||||||
|
|
||||||
assert(openfile->current_x < strlen(openfile->current->data));
|
assert(openfile->current_x < strlen(openfile->current->data));
|
||||||
|
|
||||||
|
if (ISSET(SOFTWRAP))
|
||||||
|
orig_lenpt = strlenpt(openfile->current->data);
|
||||||
|
|
||||||
/* Let's get dangerous. */
|
/* Let's get dangerous. */
|
||||||
charmove(&openfile->current->data[openfile->current_x],
|
charmove(&openfile->current->data[openfile->current_x],
|
||||||
&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
|
/* If we're deleting at the end of a line, we need to call
|
||||||
* edit_refresh(). */
|
* edit_refresh(). */
|
||||||
if (openfile->current->data[openfile->current_x] == '\0')
|
if (openfile->current->data[openfile->current_x] == '\0')
|
||||||
do_refresh = TRUE;
|
edit_refresh_needed = TRUE;
|
||||||
|
|
||||||
openfile->current->data = charealloc(openfile->current->data,
|
openfile->current->data = charealloc(openfile->current->data,
|
||||||
openfile->current_x + strlen(foo->data) + 1);
|
openfile->current_x + strlen(foo->data) + 1);
|
||||||
|
@ -138,11 +139,13 @@ void do_delete(void)
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
|
||||||
|
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||||
|
edit_refresh_needed = TRUE;
|
||||||
|
|
||||||
set_modified();
|
set_modified();
|
||||||
|
|
||||||
if (do_refresh)
|
if (edit_refresh_needed == FALSE)
|
||||||
edit_refresh_needed = TRUE;
|
|
||||||
else
|
|
||||||
update_line(openfile->current, openfile->current_x);
|
update_line(openfile->current, openfile->current_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue