From 3af984c23fb51b23894ec741015a3b2eb98a8285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20R=C3=B6nnquist?= Date: Mon, 28 May 2018 14:23:41 +1000 Subject: Add styles for diffs containing patches. --- doc/ScintillaHistory.html | 4 ++++ include/SciLexer.h | 4 ++++ include/Scintilla.iface | 4 ++++ lexers/LexDiff.cxx | 8 ++++++++ 4 files changed, 20 insertions(+) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index aac974ea4..e903e8f3a 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -528,6 +528,7 @@ Raghda Morsy Giuseppe Corbelli + Andreas Rönnquist

@@ -571,6 +572,9 @@ single-byte MacRoman encoding as that will accept any byte.

  • + Diff lexer adds styles for diffs containing patches. +
  • +
  • Crashes fixed on macOS for invalid DBCS characters when dragging text, changing case of text, case-insensitive searching, and retrieving text as UTF-8.
  • diff --git a/include/SciLexer.h b/include/SciLexer.h index aa5e7876c..f4ef9954b 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -558,6 +558,10 @@ #define SCE_DIFF_DELETED 5 #define SCE_DIFF_ADDED 6 #define SCE_DIFF_CHANGED 7 +#define SCE_DIFF_PATCH_ADD 8 +#define SCE_DIFF_PATCH_DELETE 9 +#define SCE_DIFF_REMOVED_PATCH_ADD 10 +#define SCE_DIFF_REMOVED_PATCH_DELETE 11 #define SCE_CONF_DEFAULT 0 #define SCE_CONF_COMMENT 1 #define SCE_CONF_NUMBER 2 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index f211f852a..ee23c4db2 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -3415,6 +3415,10 @@ val SCE_DIFF_POSITION=4 val SCE_DIFF_DELETED=5 val SCE_DIFF_ADDED=6 val SCE_DIFF_CHANGED=7 +val SCE_DIFF_PATCH_ADD=8 +val SCE_DIFF_PATCH_DELETE=9 +val SCE_DIFF_REMOVED_PATCH_ADD=10 +val SCE_DIFF_REMOVED_PATCH_DELETE=11 # Lexical states for SCLEX_CONF (Apache Configuration Files Lexer) lex Conf=SCLEX_CONF SCE_CONF_ val SCE_CONF_DEFAULT=0 diff --git a/lexers/LexDiff.cxx b/lexers/LexDiff.cxx index f87538daa..dd008c5cb 100644 --- a/lexers/LexDiff.cxx +++ b/lexers/LexDiff.cxx @@ -78,6 +78,14 @@ static void ColouriseDiffLine(char *lineBuffer, Sci_Position endLine, Accessor & styler.ColourTo(endLine, SCE_DIFF_POSITION); } else if (lineBuffer[0] >= '0' && lineBuffer[0] <= '9') { styler.ColourTo(endLine, SCE_DIFF_POSITION); + } else if (0 == strncmp(lineBuffer, "++", 2)) { + styler.ColourTo(endLine, SCE_DIFF_PATCH_ADD); + } else if (0 == strncmp(lineBuffer, "+-", 2)) { + styler.ColourTo(endLine, SCE_DIFF_PATCH_DELETE); + } else if (0 == strncmp(lineBuffer, "-+", 2)) { + styler.ColourTo(endLine, SCE_DIFF_REMOVED_PATCH_ADD); + } else if (0 == strncmp(lineBuffer, "--", 2)) { + styler.ColourTo(endLine, SCE_DIFF_REMOVED_PATCH_DELETE); } else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') { styler.ColourTo(endLine, SCE_DIFF_DELETED); } else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') { -- cgit v1.2.3