2009-11-11 Chris Allegretta <chrisa@asty.org>
* winio.c: Large tweaking of cursor and text display based on COLS not COLS - 1, due to finally understanding that display_string wasn't being called properly when softwrap was enabled. Fixes Savnnah bug 27603, Return key doesn't scroll viewport reported by Hannes Schueller. * - Fix size_t formatting issues with -pedantic by converting vals to long unsigned for printing. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4420 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
a60910cc54
Коммит
6f08332741
@ -1,3 +1,10 @@
|
|||||||
|
2009-11-11 Chris Allegretta <chrisa@asty.org>
|
||||||
|
* winio.c: Large tweaking of cursor and text display based on COLS not COLS - 1,
|
||||||
|
due to finally understanding that display_string wasn't being called properly
|
||||||
|
when softwrap was enabled. Fixes Savnnah bug 27603, Return key doesn't scroll
|
||||||
|
viewport reported by Hannes Schueller.
|
||||||
|
* - Fix size_t formatting issues with -pedantic
|
||||||
|
|
||||||
2009-11-09 Chris Allegretta <chrisa@asty.org>
|
2009-11-09 Chris Allegretta <chrisa@asty.org>
|
||||||
* files.c (read_file): - Remove debugging messages from file load. Fixes
|
* files.c (read_file): - Remove debugging messages from file load. Fixes
|
||||||
Savannah bug 27838.
|
Savannah bug 27838.
|
||||||
|
14
src/nano.c
14
src/nano.c
@ -1737,7 +1737,7 @@ void precalc_multicolorinfo(void)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "working on lineno %zd\n", fileptr->lineno);
|
fprintf(stderr, "working on lineno %lu\n", (unsigned long) fileptr->lineno);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
alloc_multidata_if_needed(fileptr);
|
alloc_multidata_if_needed(fileptr);
|
||||||
@ -1770,7 +1770,7 @@ void precalc_multicolorinfo(void)
|
|||||||
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
|
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "advancing to line %zd to find end...\n", endptr->lineno);
|
fprintf(stderr, "advancing to line %lu to find end...\n", (unsigned long) endptr->lineno);
|
||||||
#endif
|
#endif
|
||||||
/* Check for keyboard input again */
|
/* Check for keyboard input again */
|
||||||
if ((cur_check = time(NULL)) - last_check > 1) {
|
if ((cur_check = time(NULL)) - last_check > 1) {
|
||||||
@ -1798,18 +1798,18 @@ void precalc_multicolorinfo(void)
|
|||||||
lines in between and the ends properly */
|
lines in between and the ends properly */
|
||||||
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
|
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "marking line %zd as CENDAFTER\n", fileptr->lineno);
|
fprintf(stderr, "marking line %lu as CENDAFTER\n", (unsigned long) fileptr->lineno);
|
||||||
#endif
|
#endif
|
||||||
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
|
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
|
||||||
alloc_multidata_if_needed(fileptr);
|
alloc_multidata_if_needed(fileptr);
|
||||||
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
|
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "marking intermediary line %zd as CWHOLELINE\n", fileptr->lineno);
|
fprintf(stderr, "marking intermediary line %lu as CWHOLELINE\n", (unsigned long) fileptr->lineno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
alloc_multidata_if_needed(endptr);
|
alloc_multidata_if_needed(endptr);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "marking line %zd as BEGINBEFORE\n", fileptr->lineno);
|
fprintf(stderr, "marking line %lu as BEGINBEFORE\n", (unsigned long) fileptr->lineno);
|
||||||
#endif
|
#endif
|
||||||
endptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
|
endptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
|
||||||
/* We should be able to skip all the way to the line of the match.
|
/* We should be able to skip all the way to the line of the match.
|
||||||
@ -1817,12 +1817,12 @@ void precalc_multicolorinfo(void)
|
|||||||
fileptr = endptr;
|
fileptr = endptr;
|
||||||
startx = endmatch.rm_eo;
|
startx = endmatch.rm_eo;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "jumping to line %zd pos %d to continue\n", endptr->lineno, startx);
|
fprintf(stderr, "jumping to line %lu pos %d to continue\n", (unsigned long) endptr->lineno, startx);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (nostart && startx == 0) {
|
if (nostart && startx == 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "no start found on line %zd, continuing\n", fileptr->lineno);
|
fprintf(stderr, "no start found on line %lu, continuing\n", (unsigned long) fileptr->lineno);
|
||||||
#endif
|
#endif
|
||||||
fileptr->multidata[tmpcolor->id] = CNONE;
|
fileptr->multidata[tmpcolor->id] = CNONE;
|
||||||
continue;
|
continue;
|
||||||
|
@ -956,7 +956,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
|
|||||||
currmenu = menu;
|
currmenu = menu;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer, statusbar_x);
|
fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answer, (unsigned long) statusbar_x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
update_statusbar_line(answer, statusbar_x);
|
update_statusbar_line(answer, statusbar_x);
|
||||||
|
16
src/text.c
16
src/text.c
@ -409,7 +409,7 @@ void redo_cut(undo *u) {
|
|||||||
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
|
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Advancing, lineno = %zd, data = \"%s\"\n", t->lineno, t->data);
|
fprintf(stderr, "Advancing, lineno = %lu, data = \"%s\"\n", (unsigned long) t->lineno, t->data);
|
||||||
#endif
|
#endif
|
||||||
c = c->next;
|
c = c->next;
|
||||||
t = t->next;
|
t = t->next;
|
||||||
@ -943,8 +943,8 @@ void add_undo(undo_type current_action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %zd, u->begin = %d, type = %d\n",
|
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d, type = %d\n",
|
||||||
fs->current->data, fs->current_x, u->begin, current_action);
|
fs->current->data, (unsigned long) fs->current_x, u->begin, current_action);
|
||||||
fprintf(stderr, "left add_undo...\n");
|
fprintf(stderr, "left add_undo...\n");
|
||||||
#endif
|
#endif
|
||||||
fs->last_action = current_action;
|
fs->last_action = current_action;
|
||||||
@ -966,10 +966,10 @@ void update_undo(undo_type action)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %zd",
|
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %lu",
|
||||||
action, fs->last_action, openfile->current->lineno);
|
action, fs->last_action, (unsigned long) openfile->current->lineno);
|
||||||
if (fs->current_undo)
|
if (fs->current_undo)
|
||||||
fprintf(stderr, "fs->current_undo->lineno = %zd\n", fs->current_undo->lineno);
|
fprintf(stderr, "fs->current_undo->lineno = %lu\n", (unsigned long) fs->current_undo->lineno);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
#endif
|
#endif
|
||||||
@ -989,8 +989,8 @@ void update_undo(undo_type action)
|
|||||||
switch (u->type) {
|
switch (u->type) {
|
||||||
case ADD:
|
case ADD:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %zd, u->begin = %d\n",
|
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d\n",
|
||||||
fs->current->data, fs->current_x, u->begin);
|
fs->current->data, (unsigned long) fs->current_x, u->begin);
|
||||||
#endif
|
#endif
|
||||||
len = strlen(u->strdata) + 2;
|
len = strlen(u->strdata) + 2;
|
||||||
data = nrealloc((void *) u->strdata, len * sizeof(char *));
|
data = nrealloc((void *) u->strdata, len * sizeof(char *));
|
||||||
|
45
src/winio.c
45
src/winio.c
@ -2437,14 +2437,15 @@ void reset_cursor(void)
|
|||||||
xpt = xplustabs();
|
xpt = xplustabs();
|
||||||
|
|
||||||
if (ISSET(SOFTWRAP)) {
|
if (ISSET(SOFTWRAP)) {
|
||||||
openfile->current_y = 0;
|
|
||||||
filestruct *tmp;
|
filestruct *tmp;
|
||||||
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
|
openfile->current_y = 0;
|
||||||
openfile->current_y += 1 + strlenpt(tmp->data) / (COLS - 1);
|
|
||||||
|
|
||||||
openfile->current_y += xplustabs() / (COLS - 1);
|
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
|
||||||
|
openfile->current_y += 1 + strlenpt(tmp->data) / COLS;
|
||||||
|
|
||||||
|
openfile->current_y += xplustabs() / COLS;
|
||||||
if (openfile->current_y < editwinrows)
|
if (openfile->current_y < editwinrows)
|
||||||
wmove(edit, openfile->current_y, xpt % (COLS - 1));
|
wmove(edit, openfile->current_y, xpt % COLS);
|
||||||
} else {
|
} else {
|
||||||
openfile->current_y = openfile->current->lineno -
|
openfile->current_y = openfile->current->lineno -
|
||||||
openfile->edittop->lineno;
|
openfile->edittop->lineno;
|
||||||
@ -2864,7 +2865,13 @@ int update_line(filestruct *fileptr, size_t index)
|
|||||||
|
|
||||||
/* Expand the line, replacing tabs with spaces, and control
|
/* Expand the line, replacing tabs with spaces, and control
|
||||||
* characters with their displayed forms. */
|
* characters with their displayed forms. */
|
||||||
converted = display_string(fileptr->data, page_start, COLS, TRUE);
|
converted = display_string(fileptr->data, page_start, COLS, !ISSET(SOFTWRAP));
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
|
||||||
|
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Paint the line. */
|
/* Paint the line. */
|
||||||
edit_draw(fileptr, converted, line, page_start);
|
edit_draw(fileptr, converted, line, page_start);
|
||||||
@ -2877,16 +2884,20 @@ int update_line(filestruct *fileptr, size_t index)
|
|||||||
mvwaddch(edit, line, COLS - 1, '$');
|
mvwaddch(edit, line, COLS - 1, '$');
|
||||||
} else {
|
} else {
|
||||||
int full_length = strlenpt(fileptr->data);
|
int full_length = strlenpt(fileptr->data);
|
||||||
for (index += COLS - 1; index < full_length && line < editwinrows; index += COLS - 1) {
|
for (index += COLS; index <= full_length && line < editwinrows; index += COLS) {
|
||||||
line++;
|
line++;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "update_line(): Softwrap code, moving to %d\n", line);
|
fprintf(stderr, "update_line(): Softwrap code, moving to %d index %lu\n", line, (unsigned long) index);
|
||||||
#endif
|
#endif
|
||||||
blank_line(edit, line, 0, COLS);
|
blank_line(edit, line, 0, COLS);
|
||||||
|
|
||||||
/* Expand the line, replacing tabs with spaces, and control
|
/* Expand the line, replacing tabs with spaces, and control
|
||||||
* characters with their displayed forms. */
|
* characters with their displayed forms. */
|
||||||
converted = display_string(fileptr->data, index, COLS, TRUE);
|
converted = display_string(fileptr->data, index, COLS, !ISSET(SOFTWRAP));
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
|
||||||
|
fprintf(stderr, "update_line(): converted(2) line = %s\n", converted);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Paint the line. */
|
/* Paint the line. */
|
||||||
edit_draw(fileptr, converted, line, index);
|
edit_draw(fileptr, converted, line, index);
|
||||||
@ -2950,24 +2961,24 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
|||||||
fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n");
|
fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n");
|
||||||
#endif
|
#endif
|
||||||
for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) {
|
for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) {
|
||||||
ssize_t len = strlenpt(foo->data) / (COLS - 1);
|
ssize_t len = strlenpt(foo->data) / COLS;
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
do_redraw = TRUE;
|
do_redraw = TRUE;
|
||||||
i -= len;
|
i -= len;
|
||||||
}
|
}
|
||||||
if (foo) {
|
if (foo) {
|
||||||
extracuzsoft += strlenpt(foo->data) / (COLS - 1);
|
extracuzsoft += strlenpt(foo->data) / COLS;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Setting extracuzsoft to %zd due to strlen %zd of line %zd\n", extracuzsoft,
|
fprintf(stderr, "Setting extracuzsoft to %lu due to strlen %lu of line %lu\n", (unsigned long) extracuzsoft,
|
||||||
strlenpt(foo->data), foo->lineno);
|
(unsigned long) strlenpt(foo->data), (unsigned long) foo->lineno);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Now account for whether the edittop line itself is >COLS, if scrolling down */
|
/* Now account for whether the edittop line itself is >COLS, if scrolling down */
|
||||||
for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
|
for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
|
||||||
extracuzsoft -= strlenpt(foo->data) / (COLS - 1) + 1;
|
extracuzsoft -= 1 + strlenpt(foo->data) / COLS;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Edittop adjustment, setting nlines to %zd\n", nlines);
|
fprintf(stderr, "Edittop adjustment, setting nlines to %lu\n", (unsigned long) nlines);
|
||||||
#endif
|
#endif
|
||||||
if (foo == openfile->filebot)
|
if (foo == openfile->filebot)
|
||||||
break;
|
break;
|
||||||
@ -2976,7 +2987,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
|||||||
}
|
}
|
||||||
} else if (ISSET(SOFTWRAP) && direction == UP_DIR) {
|
} else if (ISSET(SOFTWRAP) && direction == UP_DIR) {
|
||||||
for (foo = openfile->edittop, i = editwinrows; foo && i > 0; i--, foo = foo->prev) {
|
for (foo = openfile->edittop, i = editwinrows; foo && i > 0; i--, foo = foo->prev) {
|
||||||
if (strlenpt(foo->data) / (COLS - 1) > 0) {
|
if (strlenpt(foo->data) / COLS > 0) {
|
||||||
do_redraw = TRUE;
|
do_redraw = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3246,7 +3257,7 @@ void edit_update(update_type location)
|
|||||||
|
|
||||||
for (; goal > 0 && foo->prev != NULL; goal--) {
|
for (; goal > 0 && foo->prev != NULL; goal--) {
|
||||||
if (ISSET(SOFTWRAP))
|
if (ISSET(SOFTWRAP))
|
||||||
goal -= strlenpt(foo->data) / (COLS - 1);
|
goal -= strlenpt(foo->data) / COLS;
|
||||||
foo = foo->prev;
|
foo = foo->prev;
|
||||||
}
|
}
|
||||||
openfile->edittop = foo;
|
openfile->edittop = foo;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user