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
master
Chris Allegretta 2009-11-11 06:00:33 +00:00
parent a60910cc54
commit 6f08332741
5 changed files with 51 additions and 33 deletions

View File

@ -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>
* files.c (read_file): - Remove debugging messages from file load. Fixes
Savannah bug 27838.

View File

@ -1737,7 +1737,7 @@ void precalc_multicolorinfo(void)
#ifdef DEBUG
fprintf(stderr, "working on lineno %zd\n", fileptr->lineno);
fprintf(stderr, "working on lineno %lu\n", (unsigned long) fileptr->lineno);
#endif
alloc_multidata_if_needed(fileptr);
@ -1770,7 +1770,7 @@ void precalc_multicolorinfo(void)
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
#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
/* Check for keyboard input again */
if ((cur_check = time(NULL)) - last_check > 1) {
@ -1798,18 +1798,18 @@ void precalc_multicolorinfo(void)
lines in between and the ends properly */
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
#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
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
alloc_multidata_if_needed(fileptr);
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
#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
}
alloc_multidata_if_needed(endptr);
#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
endptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
/* 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;
startx = endmatch.rm_eo;
#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
}
if (nostart && startx == 0) {
#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
fileptr->multidata[tmpcolor->id] = CNONE;
continue;

View File

@ -956,7 +956,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
currmenu = menu;
#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
update_statusbar_line(answer, statusbar_x);

View File

@ -409,7 +409,7 @@ void redo_cut(undo *u) {
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
#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
c = c->next;
t = t->next;
@ -943,8 +943,8 @@ void add_undo(undo_type current_action)
}
#ifdef DEBUG
fprintf(stderr, "fs->current->data = \"%s\", current_x = %zd, u->begin = %d, type = %d\n",
fs->current->data, fs->current_x, u->begin, current_action);
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d, type = %d\n",
fs->current->data, (unsigned long) fs->current_x, u->begin, current_action);
fprintf(stderr, "left add_undo...\n");
#endif
fs->last_action = current_action;
@ -966,10 +966,10 @@ void update_undo(undo_type action)
return;
#ifdef DEBUG
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %zd",
action, fs->last_action, openfile->current->lineno);
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %lu",
action, fs->last_action, (unsigned long) openfile->current->lineno);
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
fprintf(stderr, "\n");
#endif
@ -989,8 +989,8 @@ void update_undo(undo_type action)
switch (u->type) {
case ADD:
#ifdef DEBUG
fprintf(stderr, "fs->current->data = \"%s\", current_x = %zd, u->begin = %d\n",
fs->current->data, fs->current_x, u->begin);
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d\n",
fs->current->data, (unsigned long) fs->current_x, u->begin);
#endif
len = strlen(u->strdata) + 2;
data = nrealloc((void *) u->strdata, len * sizeof(char *));

View File

@ -2437,14 +2437,15 @@ void reset_cursor(void)
xpt = xplustabs();
if (ISSET(SOFTWRAP)) {
openfile->current_y = 0;
filestruct *tmp;
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
openfile->current_y += 1 + strlenpt(tmp->data) / (COLS - 1);
openfile->current_y = 0;
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)
wmove(edit, openfile->current_y, xpt % (COLS - 1));
wmove(edit, openfile->current_y, xpt % COLS);
} else {
openfile->current_y = openfile->current->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
* 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. */
edit_draw(fileptr, converted, line, page_start);
@ -2877,16 +2884,20 @@ int update_line(filestruct *fileptr, size_t index)
mvwaddch(edit, line, COLS - 1, '$');
} else {
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++;
#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
blank_line(edit, line, 0, COLS);
/* Expand the line, replacing tabs with spaces, and control
* 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. */
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");
#endif
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)
do_redraw = TRUE;
i -= len;
}
if (foo) {
extracuzsoft += strlenpt(foo->data) / (COLS - 1);
extracuzsoft += strlenpt(foo->data) / COLS;
#ifdef DEBUG
fprintf(stderr, "Setting extracuzsoft to %zd due to strlen %zd of line %zd\n", extracuzsoft,
strlenpt(foo->data), foo->lineno);
fprintf(stderr, "Setting extracuzsoft to %lu due to strlen %lu of line %lu\n", (unsigned long) extracuzsoft,
(unsigned long) strlenpt(foo->data), (unsigned long) foo->lineno);
#endif
/* Now account for whether the edittop line itself is >COLS, if scrolling down */
for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
extracuzsoft -= strlenpt(foo->data) / (COLS - 1) + 1;
extracuzsoft -= 1 + strlenpt(foo->data) / COLS;
#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
if (foo == openfile->filebot)
break;
@ -2976,7 +2987,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
}
} else if (ISSET(SOFTWRAP) && direction == UP_DIR) {
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;
break;
}
@ -3246,7 +3257,7 @@ void edit_update(update_type location)
for (; goal > 0 && foo->prev != NULL; goal--) {
if (ISSET(SOFTWRAP))
goal -= strlenpt(foo->data) / (COLS - 1);
goal -= strlenpt(foo->data) / COLS;
foo = foo->prev;
}
openfile->edittop = foo;