From: Michael D. Lowis Date: Fri, 16 Jun 2017 00:16:35 +0000 (-0400) Subject: Added a cap to scan distance for syntax highlighting X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=52b43423ef7c327c7f9f23e652e5d624995d02c2;p=projs%2Ftide.git Added a cap to scan distance for syntax highlighting --- diff --git a/config.h b/config.h index a4d6544..aa3450b 100644 --- a/config.h +++ b/config.h @@ -19,22 +19,23 @@ extern int CLR_NormalText, CLR_GutterText, CLR_SelectedText, CLR_TagsBkg, /* General Config ******************************************************************************/ enum { - Width = 640, /* default window width */ - Height = 480, /* default window height */ - ExpandTabs = 1, /* Tabs will be expanded to spaces */ - TabWidth = 4, /* maximum number of spaces used to represent a tab */ - ScrollLines = 4, /* number of lines to scroll by for mouse wheel scrolling */ - BufSize = 8192, /* default buffer size */ - EventTimeout = 50, /* Maximum blocking wait time for events */ - TrimOnSave = 1, /* Enable trimming of trailing whitespace on save */ - DefaultCRLF = 0, /* Default to Unix line endings */ - DefaultCharset = UTF_8, /* We assume UTF-8 because nothing else matters */ - FontCacheSize = 16, /* Maximum number of fonts allowed in the font cache */ - LineSpacing = LNSPACE, /* Set the vertical spacing between lines */ - DblClickTime = 250, /* Millisecond time for detecting double clicks */ - RulePosition = 80, /* Column in which the vertical ruler appears */ - CopyIndent = 1, /* New lines will inherit the indent of the preceding line */ - LineNumbers = 1, /* Enable line numbers by default or not */ + Width = 640, /* default window width */ + Height = 480, /* default window height */ + ExpandTabs = 1, /* Tabs will be expanded to spaces */ + TabWidth = 4, /* maximum number of spaces used to represent a tab */ + ScrollLines = 4, /* number of lines to scroll by for mouse wheel scrolling */ + BufSize = 8192, /* default buffer size */ + EventTimeout = 50, /* Maximum blocking wait time for events */ + TrimOnSave = 1, /* Enable trimming of trailing whitespace on save */ + DefaultCRLF = 0, /* Default to Unix line endings */ + DefaultCharset = UTF_8, /* We assume UTF-8 because nothing else matters */ + FontCacheSize = 16, /* Maximum number of fonts allowed in the font cache */ + LineSpacing = LNSPACE, /* Set the vertical spacing between lines */ + DblClickTime = 250, /* Millisecond time for detecting double clicks */ + RulePosition = 80, /* Column in which the vertical ruler appears */ + CopyIndent = 1, /* New lines will inherit the indent of the preceding line */ + LineNumbers = 1, /* Enable line numbers by default or not */ + MaxScanDistance = 16384, /* Maximum distance to scan before visible lines for syntax higlighting */ }; #ifdef INCLUDE_DEFS diff --git a/lib/view.c b/lib/view.c index 8987265..ff7013f 100644 --- a/lib/view.c +++ b/lib/view.c @@ -103,12 +103,13 @@ void view_update(View* view, size_t* csrx, size_t* csry) { view_scrollto(view, csr); /* locate the cursor if visible */ find_cursor(view, csrx, csry); - /* synchronize, scan for, and apply highlighted regions */ size_t first = view->rows[0]->off, last = view->rows[view->nrows-1]->off + view->rows[view->nrows-1]->rlen; view->spans = colors_rewind(view->spans, first); - first = (view->spans ? view->spans->end : 0); + size_t start = (view->spans ? view->spans->end : 0); + if (first-start > MaxScanDistance) + start = first - MaxScanDistance; view->spans = colors_scan(view->syntax, view->spans, &(view->buffer), first, last+1); apply_colors(view); }