Discussion:
[PATCH] Scroll offset
Julian Orth
2012-08-30 15:59:35 UTC
Permalink
'scrolloff' 'so'
Minimal number of screen lines to keep above and below the cursor.
This will make some context visible around where you are working.
This is very useful when you are going through your library and
looking for some good music.

I was thinking about something like the attached patch.
Julian Orth
2012-08-30 16:13:07 UTC
Permalink
I just realized that this might break page-up and page-down. This should fix it:

---
window.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/window.c b/window.c
index d85f19a..4dda29a 100644
--- a/window.c
+++ b/window.c
@@ -346,12 +346,12 @@ void window_goto_bottom(struct window *win)

void window_page_up(struct window *win)
{
- window_up(win, win->nr_rows - 1);
+ window_up(win, win->nr_rows - 1 - scroll_offset);
}

void window_page_down(struct window *win)
{
- window_down(win, win->nr_rows - 1);
+ window_down(win, win->nr_rows - 1 - scroll_offset);
}

int window_get_nr_rows(struct window *win)
--
1.7.12
Jason Woofenden
2012-09-02 04:10:02 UTC
Permalink
First, thanks for implementing scroll offset! This has been
requested from time to time.

Second, it shouldn't affect how far the window is moved with the
page up/down keys. In vim I've set a very large scroll offset which
keeps the cursor in the center line of the window. When I page
up/down it moves by a full page, and keeps my cursor in the center.

- Jason
Post by Julian Orth
---
window.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/window.c b/window.c
index d85f19a..4dda29a 100644
--- a/window.c
+++ b/window.c
@@ -346,12 +346,12 @@ void window_goto_bottom(struct window *win)
void window_page_up(struct window *win)
{
- window_up(win, win->nr_rows - 1);
+ window_up(win, win->nr_rows - 1 - scroll_offset);
}
void window_page_down(struct window *win)
{
- window_down(win, win->nr_rows - 1);
+ window_down(win, win->nr_rows - 1 - scroll_offset);
}
int window_get_nr_rows(struct window *win)
--
1.7.12
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Johannes Weißl
2012-09-02 11:54:59 UTC
Permalink
Hi Julian,
Post by Julian Orth
'scrolloff' 'so'
Minimal number of screen lines to keep above and below the cursor.
This will make some context visible around where you are working.
This is very useful when you are going through your library and
looking for some good music.
I was thinking about something like the attached patch.
Thanks a lot for the patch! I tried it (without looking much at the
implementation), and it seems to work! Just a couple of things:
- It is not possible to disable 'scrolloff' (setting it to zero).
- When introducing new options, it is best to update the documentation
(Doc/cmus.txt) with the same patch, otherwise it will probably be
forgotten.
- We follow mostly the Linux Coding Style, so opening braces are in the
same line for if/while/do/switch/... blocks, but not for functions.
- If you want, you can upload your work (in incremental commits) to
your cloned gitorious repository. This way it is easier to review,
and can be rebased into one patch once you are finished! Also, it is
easier for others to test your patch.

Greetings,
Johannes
Julian Orth
2012-09-03 06:51:51 UTC
Permalink
Post by Jason Woofenden
In vim I've set a very large scroll offset which
keeps the cursor in the center line of the window. When I page
up/down it moves by a full page, and keeps my cursor in the center.
Right, I didn't think of that. My patch didn't work that way, and big
scroll_offset effectively hid the cursor. I think I have fixed this
now:
https://gitorious.org/~juorth/cmus/juorths-cmus/commits/scroll-offset
Post by Jason Woofenden
- It is not possible to disable 'scrolloff' (setting it to zero).
- When introducing new options, it is best to update the documentation
(Doc/cmus.txt) with the same patch, otherwise it will probably be
forgotten.
- We follow mostly the Linux Coding Style, so opening braces are in the
same line for if/while/do/switch/... blocks, but not for functions.
Fixed.
Jason Woofenden
2012-09-05 14:32:35 UTC
Permalink
Post by Julian Orth
Post by Jason Woofenden
In vim I've set a very large scroll offset which
keeps the cursor in the center line of the window. When I page
up/down it moves by a full page, and keeps my cursor in the center.
Right, I didn't think of that. My patch didn't work that way, and big
scroll_offset effectively hid the cursor. I think I have fixed this
https://gitorious.org/~juorth/cmus/juorths-cmus/commits/scroll-offset
Looks good. Thanks Julian!

I've reviewed the code and behavior of win-sel-up and win-sel-down
with scroll_offset=10 and scroll_offset=1000


I think the page-up/down behavior is (and always has been) weird.
But I don't think that should stop us from merging this
scroll-offset patch.

ACK: 15ec8af427e49048d0e23d4dff11e3ff7db85137

Later we can make functions to scroll the window by rows-1
regardless of the position of the selection.

- Jason
Gregory Petrosyan
2012-09-07 14:11:04 UTC
Permalink
Post by Jason Woofenden
Post by Julian Orth
Post by Jason Woofenden
In vim I've set a very large scroll offset which
keeps the cursor in the center line of the window. When I page
up/down it moves by a full page, and keeps my cursor in the center.
Right, I didn't think of that. My patch didn't work that way, and big
scroll_offset effectively hid the cursor. I think I have fixed this
https://gitorious.org/~juorth/cmus/juorths-cmus/commits/scroll-offset
Looks good. Thanks Julian!
I've reviewed the code and behavior of win-sel-up and win-sel-down
with scroll_offset=10 and scroll_offset=1000
I think the page-up/down behavior is (and always has been) weird.
But I don't think that should stop us from merging this
scroll-offset patch.
ACK: 15ec8af427e49048d0e23d4dff11e3ff7db85137
Thanks a lot — merged!

Gregory

Loading...