From d54139cfb635c6ff599673118dff36caf0ecb4f4 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 19 Jul 2017 16:12:07 +0200 Subject: [PATCH] Resolves: #1472421 - optimize syntax highlighting of pasted python script content --- ...se-of-the-multidata-of-the-preceding.patch | 90 +++++++++++++++++++ nano.spec | 9 +- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 0003-painting-make-use-of-the-multidata-of-the-preceding.patch diff --git a/0003-painting-make-use-of-the-multidata-of-the-preceding.patch b/0003-painting-make-use-of-the-multidata-of-the-preceding.patch new file mode 100644 index 0000000..77fea8d --- /dev/null +++ b/0003-painting-make-use-of-the-multidata-of-the-preceding.patch @@ -0,0 +1,90 @@ +From 7de236c3652431b12c3e9390fe47777317e93d6c Mon Sep 17 00:00:00 2001 +From: Benno Schulenberg +Date: Mon, 23 Jan 2017 14:41:25 +0100 +Subject: [PATCH] painting: make use of the multidata of the preceding line + +When painting a line, the multidata of the line /before/ it is valid +in most cases: it was determined just a moment ago. And it tells us +all we need to know: whether there is an unpaired start match before +the current line or not. + +The only exception is when painting the first line of the screen: +the multidata of the line before it might be stale. So for the +first screen line we will always have to do some backtracking. +But that is left for later. + +This fixes https://savannah.gnu.org/bugs/?50121. + +Upstream-commit: b3bcc8eeac45a5ae249d3ff2fc198c190e198af2 +Signed-off-by: Kamil Dudka +--- + src/color.c | 3 +++ + src/winio.c | 24 +++++++++++++++++++++--- + 2 files changed, 24 insertions(+), 3 deletions(-) + +diff --git a/src/color.c b/src/color.c +index 39355ca..6b174e3 100644 +--- a/src/color.c ++++ b/src/color.c +@@ -374,6 +374,9 @@ void reset_multis(filestruct *fileptr, bool force) + continue; + } + ++ refresh_needed = TRUE; ++ return; ++ + /* If we got here, things have changed. */ + reset_multis_for_id(fileptr, tmpcolor->id); + } +diff --git a/src/winio.c b/src/winio.c +index 731e8b5..e94fbd6 100644 +--- a/src/winio.c ++++ b/src/winio.c +@@ -2364,6 +2364,22 @@ void edit_draw(filestruct *fileptr, const char *converted, int + const filestruct *end_line; + /* The line that matches 'end'. */ + ++ /* First check the multidata of the preceding line -- it tells ++ * us about the situation so far, and thus what to do here. */ ++ if (start_line != NULL && start_line->multidata != NULL) { ++ if (start_line->multidata[varnish->id] == CWHOLELINE || ++ start_line->multidata[varnish->id] == CENDAFTER) { ++ fileptr->multidata[varnish->id] = CNONE; ++ goto seek_an_end; ++ } ++ if (start_line->multidata[varnish->id] == CNONE || ++ start_line->multidata[varnish->id] == CBEGINBEFORE || ++ start_line->multidata[varnish->id] == CSTARTENDHERE) { ++ fileptr->multidata[varnish->id] = CNONE; ++ goto step_two; ++ } ++ } ++ + /* First see if the multidata was maybe already calculated. */ + if (fileptr->multidata[varnish->id] == CNONE) + goto tail_of_loop; +@@ -2379,9 +2395,10 @@ void edit_draw(filestruct *fileptr, const char *converted, int + endmatch.rm_eo) - start); + mvwaddnstr(edit, line, 0, converted, paintlen); + goto tail_of_loop; +- } if (fileptr->multidata[varnish->id] == -1) +- /* Assume this until proven otherwise below. */ +- fileptr->multidata[varnish->id] = CNONE; ++ } ++ ++ /* Assume nothing gets painted until proven otherwise below. */ ++ fileptr->multidata[varnish->id] = CNONE; + + /* There is no precalculated multidata, so find it out now. + * First check if the beginning of the line is colored by a +@@ -2438,6 +2455,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int + } + /* Indeed, there is a start without an end on that line. */ + ++ seek_an_end: + /* We've already checked that there is no end before fileptr + * and after the start. But is there an end after the start + * at all? We don't paint unterminated starts. */ +-- +2.9.4 + diff --git a/nano.spec b/nano.spec index af3ff0b..919af99 100644 --- a/nano.spec +++ b/nano.spec @@ -1,7 +1,7 @@ Summary: A small text editor Name: nano Version: 2.6.1 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3+ Group: Applications/Editors URL: http://www.nano-editor.org @@ -13,6 +13,9 @@ Patch1: 0001-fix-compile-time-warnings-in-nano-2.3.3.patch # http://lists.gnu.org/archive/html/nano-devel/2010-08/msg00005.html Patch2: 0002-use-futimens-if-available-instead-of-utime.patch +# optimize syntax highlighting of pasted python script content (#1472421) +Patch3: 0003-painting-make-use-of-the-multidata-of-the-preceding.patch + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: file-devel BuildRequires: gettext-devel @@ -31,6 +34,7 @@ GNU nano is a small and friendly text editor. %setup -q %patch1 -p1 %patch2 -p1 +%patch3 -p1 for f in doc/man/fr/{nano.1,nanorc.5,rnano.1} ; do iconv -f iso-8859-1 -t utf-8 -o $f.tmp $f && mv $f.tmp $f @@ -93,6 +97,9 @@ exit 0 %{_datadir}/nano %changelog +* Wed Jul 19 2017 Kamil Dudka - 2.6.1-2 +- optimize syntax highlighting of pasted python script content (#1472421) + * Mon Jun 27 2016 Kamil Dudka - 2.6.1-1 - new upstream release