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.
This commit is contained in:
committed by
Benno Schulenberg
parent
80b3a3011b
commit
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user