softwrap: prepare for a more flexible viewport
We want to be able to scroll the line at edittop partially off the screen. For this to be possible, the new variable firstcolumn stores the starting column of the viewport -- the starting column in the line that edittop points to. Since firstcolumn is used by go_back_chunks() and go_forward_chunks(), it can't be completely #ifdefed out when NANO_TINY is set, but outside of softwrap mode it should always be zero. Currently firstcolumn is initialized to zero, reset to zero when toggling softwrap mode off, and reset to zero when switching buffers while softwrap mode is off. It's otherwise unused, but its uses are forthcoming.
Этот коммит содержится в:
родитель
80b3a3011b
Коммит
4144f76e19
@ -130,6 +130,7 @@ void initialize_buffer_text(void)
|
||||
openfile->edittop = openfile->fileage;
|
||||
openfile->current = openfile->fileage;
|
||||
|
||||
openfile->firstcolumn = 0;
|
||||
openfile->current_x = 0;
|
||||
openfile->totsize = 0;
|
||||
}
|
||||
@ -627,6 +628,14 @@ void switch_to_prevnext_buffer(bool to_next)
|
||||
fprintf(stderr, "filename is %s\n", openfile->filename);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* When not in softwrap mode, make sure firstcolumn is zero. It might
|
||||
* be nonzero if we had softwrap mode on while in this buffer, and then
|
||||
* turned softwrap mode off while in a different buffer. */
|
||||
if (!ISSET(SOFTWRAP))
|
||||
openfile->firstcolumn = 0;
|
||||
#endif
|
||||
|
||||
/* Update the screen to account for the current buffer. */
|
||||
display_buffer();
|
||||
|
||||
|
@ -1398,12 +1398,16 @@ void do_toggle(int flag)
|
||||
case SUSPEND:
|
||||
signal_init();
|
||||
break;
|
||||
case SOFTWRAP:
|
||||
if (!ISSET(SOFTWRAP))
|
||||
openfile->firstcolumn = 0;
|
||||
refresh_needed = TRUE;
|
||||
break;
|
||||
case WHITESPACE_DISPLAY:
|
||||
titlebar(NULL); /* Fall through. */
|
||||
#ifndef DISABLE_COLOR
|
||||
case NO_COLOR_SYNTAX:
|
||||
#endif
|
||||
case SOFTWRAP:
|
||||
refresh_needed = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -353,6 +353,9 @@ typedef struct openfilestruct {
|
||||
/* The current line for this file. */
|
||||
size_t totsize;
|
||||
/* The file's total number of characters. */
|
||||
size_t firstcolumn;
|
||||
/* The starting column of the top line of the edit window.
|
||||
* When not in softwrap mode, it's always zero. */
|
||||
size_t current_x;
|
||||
/* The file's x-coordinate position. */
|
||||
size_t placewewant;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user