From 60fe132d6c59d54021091af8e5aa09fcd4704562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 30 Jun 2015 11:13:17 +0200 Subject: Cleanup insert/replace mode input handling View should only display the file content, but not modify it. --- view.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'view.h') diff --git a/view.h b/view.h index 9a9cd8c..01b4918 100644 --- a/view.h +++ b/view.h @@ -46,12 +46,6 @@ void view_ui(View*, UiWin*); void view_reload(View*, Text*); void view_free(View*); -/* keyboard input at cursor position */ -size_t view_insert_key(View*, const char *c, size_t len); -size_t view_replace_key(View*, const char *c, size_t len); -size_t view_backspace_key(View*); -size_t view_delete_key(View*); - bool view_resize(View*, int width, int height); int view_height_get(View*); void view_draw(View*); @@ -83,6 +77,12 @@ size_t view_screenline_goto(View*, int n); /* get cursor position in bytes from start of the file */ size_t view_cursor_get(View*); +typedef struct { + int x, y; +} ViewPos; + +ViewPos view_cursor_viewpos(View*); + const Line *view_lines_get(View*); /* get cursor position in terms of screen coordinates */ CursorPos view_cursor_getpos(View*); @@ -108,6 +108,12 @@ void view_selection_set(View*, Filerange *sel); void view_selection_clear(View*); /* get the currently displayed area in bytes from the start of the file */ Filerange view_viewport_get(View*); +/* move visible viewport n-lines up/down, redraws the view but does not change + * cursor position which becomes invalid and should be corrected by calling + * view_cursor_to. the return value indicates wether the visible area changed. + */ +bool view_viewport_up(View *view, int n); +bool view_viewport_down(View *view, int n); /* associate a set of syntax highlighting rules to this window. */ void view_syntax_set(View*, Syntax*); Syntax *view_syntax_get(View*); -- cgit v1.2.3