+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.
#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);
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) {
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.
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;
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);
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;
}
#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;
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
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 *));
xpt = xplustabs();
if (ISSET(SOFTWRAP)) {
- openfile->current_y = 0;
filestruct *tmp;
+ openfile->current_y = 0;
+
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
- openfile->current_y += 1 + strlenpt(tmp->data) / (COLS - 1);
+ openfile->current_y += 1 + strlenpt(tmp->data) / COLS;
- openfile->current_y += xplustabs() / (COLS - 1);
+ 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;
/* 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);
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);
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;
}
} 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;
}
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;