diff options
| author | David B. Lamkins <david@lamkins.net> | 2016-04-19 22:51:29 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-19 23:03:09 +0200 |
| commit | 754b1cec7a39723b415ee76e797e587a7b5054dc (patch) | |
| tree | 556d63ccefd7301719aec4f51a9b66b2964c98cc /view.c | |
| parent | aab8b6c44151cb086850ba9872251cfc452506b7 (diff) | |
| download | vis-754b1cec7a39723b415ee76e797e587a7b5054dc.tar.gz vis-754b1cec7a39723b415ee76e797e587a7b5054dc.tar.xz | |
vis: add :set horizon option
Can be used to specify the number of bytes before the visible area
to consider for syntax highlighting.
Defaults to 32K for now, whereas before it was 16K.
Diffstat (limited to 'view.c')
| -rw-r--r-- | view.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -90,6 +90,8 @@ struct View { lua_State *lua; /* lua state used for syntax highlighting */ int cursor_generation; /* used to filter out newly created cursors during iteration */ char *lexer_name; + size_t horizon; /* maximal number of bytes to consider for syntax highlighting + * before the visible area */ bool need_update; /* whether view has been redrawn */ bool large_file; /* optimize for displaying large files */ int colorcolumn; @@ -137,11 +139,9 @@ static void view_syntax_color(View *view) { if (lua_isnil(L, -1)) return; - /* maximal number of bytes to consider for syntax highlighting before - * the visible area */ - const size_t lexer_before_max = 16384; /* absolute position to start syntax highlighting */ - const size_t lexer_start = view->start >= lexer_before_max ? view->start - lexer_before_max : 0; + const size_t lexer_start = view->start >= view->horizon ? + view->start - view->horizon : 0; /* number of bytes used for syntax highlighting before visible are */ size_t lexer_before = view->start - lexer_start; /* number of bytes to read in one go */ @@ -753,6 +753,7 @@ View *view_new(Text *text, lua_State *lua) { view->text = text; view->lua = lua; view->tabwidth = 8; + view->horizon = 1 << 15; view_options_set(view, 0); if (!view_resize(view, 1, 1)) { @@ -1052,6 +1053,14 @@ int view_colorcolumn_get(View *view) { return view->colorcolumn; } +void view_horizon_set(View *view, size_t bytes) { + view->horizon = bytes; +} + +size_t view_horizon_get(View *view) { + return view->horizon; +} + size_t view_screenline_goto(View *view, int n) { size_t pos = view->start; for (Line *line = view->topline; --n > 0 && line != view->lastline; line = line->next) |
