Sorry for all these mails, I'm trying to make things better as I
understand how things works.
Attached is a fully working patch which allow to scroll the page
up/down by one line.

Regards,
Claudio Alessi


2014-09-14 18:37 GMT+02:00 Claudio <smo...@gmail.com>:
> Here is the patch containing window_scroll_line_up() and
> window_scroll_line_down().
>
> Regards,
> Claudio
>
> 2014-09-14 18:31 GMT+02:00 Claudio <smo...@gmail.com>:
>> Okay, I just noticed that the original behaviour of window_line_*() is
>> different than the one I thought. It's used by the j and k commands so
>> I'll need two new ad-hoc routines for ^y and ^e.
>>
>>
>> Regards,
>> Claudio Alessi
>>
>> 2014-09-14 18:25 GMT+02:00 Claudio <smo...@gmail.com>:
>>> Hi,
>>>
>>> thank you for writing vis. I would ask if the attached patch makes
>>> sense to you. Now window_line_up() and window_line_down() works
>>> properly and I can add the following key bindings:
>>>
>>> { { CONTROL('y')            }, cursor,   { .m = window_line_up         } },
>>> { { CONTROL('e')            }, cursor,   { .m = window_line_down       } },
>>>
>>> It works but I'm not sure it's the only (and right) way to do it.
>>>
>>>
>>> Regards,
>>> Claudio
diff --git a/window.c b/window.c
index eb1c8e7..d248af7 100644
--- a/window.c
+++ b/window.c
@@ -655,6 +655,28 @@ size_t window_line_down(Win *win) {
 	return window_cursor_update(win);
 }
 
+size_t window_scroll_line_up(Win *win) {
+	Cursor *cursor = &win->cursor;
+	window_scroll_lines_up(win, 1);
+	if(!cursor->line->next || !cursor->line->prev)
+		return cursor->pos;
+	cursor->row++;
+	cursor->line = cursor->line->next;
+	cursor->pos = pos_by_line(win, cursor->line) + cursor_offset(cursor);
+	return window_cursor_update(win);
+}
+
+size_t window_scroll_line_down(Win *win) {
+	Cursor *cursor = &win->cursor;
+	window_scroll_lines_down(win, 1);
+	if(!cursor->line->next || !cursor->line->prev)
+		return cursor->pos;
+	cursor->row--;
+	cursor->line = cursor->line->prev;
+	cursor->pos = pos_by_line(win, cursor->line) + cursor_offset(cursor);
+	return window_cursor_update(win);
+}
+
 void window_update(Win *win) {
 	wnoutrefresh(win->win);
 }
diff --git a/window.h b/window.h
index d575341..4e151f8 100644
--- a/window.h
+++ b/window.h
@@ -33,6 +33,8 @@ size_t window_char_next(Win*);
 size_t window_char_prev(Win*);
 size_t window_line_down(Win*);
 size_t window_line_up(Win*);
+size_t window_scroll_line_down(Win*);
+size_t window_scroll_line_up(Win*);
 /* place the cursor at the start ot the n-th window line, counting from 1 */
 size_t window_line_goto(Win*, int n);
 

Reply via email to