summaryrefslogtreecommitdiffstats
path: root/scintilla/src
diff options
context:
space:
mode:
Diffstat (limited to 'scintilla/src')
-rw-r--r--scintilla/src/AutoComplete.cxx2
-rw-r--r--scintilla/src/CaseConvert.cxx256
-rw-r--r--scintilla/src/Catalogue.cxx13
-rw-r--r--scintilla/src/CellBuffer.cxx4
-rw-r--r--scintilla/src/Decoration.cxx4
-rw-r--r--scintilla/src/Document.cxx23
-rw-r--r--scintilla/src/Document.h3
-rw-r--r--scintilla/src/Editor.cxx737
-rw-r--r--scintilla/src/Editor.h31
-rw-r--r--scintilla/src/ExternalLexer.cxx2
-rw-r--r--scintilla/src/FontQuality.h13
-rw-r--r--scintilla/src/KeyMap.h4
-rw-r--r--scintilla/src/LineMarker.h1
-rw-r--r--scintilla/src/Partitioning.h9
-rw-r--r--scintilla/src/PositionCache.cxx165
-rw-r--r--scintilla/src/PositionCache.h41
-rw-r--r--scintilla/src/RunStyles.cxx5
-rw-r--r--scintilla/src/ScintillaBase.cxx2
-rw-r--r--scintilla/src/SplitVector.h8
-rw-r--r--scintilla/src/UniConversion.cxx17
-rw-r--r--scintilla/src/UniConversion.h17
-rw-r--r--scintilla/src/UnicodeFromUTF8.h13
-rw-r--r--scintilla/src/ViewStyle.cxx139
-rw-r--r--scintilla/src/ViewStyle.h63
-rw-r--r--scintilla/src/XPM.cxx2
25 files changed, 931 insertions, 643 deletions
diff --git a/scintilla/src/AutoComplete.cxx b/scintilla/src/AutoComplete.cxx
index 9530808..e20982b 100644
--- a/scintilla/src/AutoComplete.cxx
+++ b/scintilla/src/AutoComplete.cxx
@@ -10,9 +10,9 @@
#include <stdio.h>
#include <assert.h>
-#include <algorithm>
#include <string>
#include <vector>
+#include <algorithm>
#include "Platform.h"
diff --git a/scintilla/src/CaseConvert.cxx b/scintilla/src/CaseConvert.cxx
index 647bf72..7d33078 100644
--- a/scintilla/src/CaseConvert.cxx
+++ b/scintilla/src/CaseConvert.cxx
@@ -2,7 +2,7 @@
// Encoding: UTF-8
/** @file CaseConvert.cxx
** Case fold characters and convert them to upper or lower case.
- ** Tables automatically regenerated by scripts/GenerateCharacterCategory.py
+ ** Tables automatically regenerated by scripts/GenerateCaseConvert.py
** Should only be rarely regenerated for new versions of Unicode.
**/
// Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
@@ -232,132 +232,132 @@ const char *complexCaseConversions =
// Original | Folded | Upper | Lower |
//++Autogenerated -- start of section automatically generated
//**2 \(\*\n\)
-"µ|μ|Μ||"
-"ß|ss|SS||"
-"İ|i̇||i̇|"
-"ı||I||"
-"ʼn|ʼn|ʼN||"
-"ſ|s|S||"
-"Dž|dž|DŽ|dž|"
-"Lj|lj|LJ|lj|"
-"Nj|nj|NJ|nj|"
-"ǰ|ǰ|J̌||"
-"Dz|dz|DZ|dz|"
-"ͅ|ι|Ι||"
-"ΐ|ΐ|Ϊ́||"
-"ΰ|ΰ|Ϋ́||"
-"ς|σ|Σ||"
-"ϐ|β|Β||"
-"ϑ|θ|Θ||"
-"ϕ|φ|Φ||"
-"ϖ|π|Π||"
-"ϰ|κ|Κ||"
-"ϱ|ρ|Ρ||"
-"ϴ|θ||θ|"
-"ϵ|ε|Ε||"
-"և|եւ|ԵՒ||"
-"ẖ|ẖ|H̱||"
-"ẗ|ẗ|T̈||"
-"ẘ|ẘ|W̊||"
-"ẙ|ẙ|Y̊||"
-"ẚ|aʾ|Aʾ||"
-"ẛ|ṡ|Ṡ||"
-"ẞ|ss||ß|"
-"ὐ|ὐ|Υ̓||"
-"ὒ|ὒ|Υ̓̀||"
-"ὔ|ὔ|Υ̓́||"
-"ὖ|ὖ|Υ̓͂||"
-"ᾀ|ἀι|ἈΙ||"
-"ᾁ|ἁι|ἉΙ||"
-"ᾂ|ἂι|ἊΙ||"
-"ᾃ|ἃι|ἋΙ||"
-"ᾄ|ἄι|ἌΙ||"
-"ᾅ|ἅι|ἍΙ||"
-"ᾆ|ἆι|ἎΙ||"
-"ᾇ|ἇι|ἏΙ||"
-"ᾈ|ἀι|ἈΙ|ᾀ|"
-"ᾉ|ἁι|ἉΙ|ᾁ|"
-"ᾊ|ἂι|ἊΙ|ᾂ|"
-"ᾋ|ἃι|ἋΙ|ᾃ|"
-"ᾌ|ἄι|ἌΙ|ᾄ|"
-"ᾍ|ἅι|ἍΙ|ᾅ|"
-"ᾎ|ἆι|ἎΙ|ᾆ|"
-"ᾏ|ἇι|ἏΙ|ᾇ|"
-"ᾐ|ἠι|ἨΙ||"
-"ᾑ|ἡι|ἩΙ||"
-"ᾒ|ἢι|ἪΙ||"
-"ᾓ|ἣι|ἫΙ||"
-"ᾔ|ἤι|ἬΙ||"
-"ᾕ|ἥι|ἭΙ||"
-"ᾖ|ἦι|ἮΙ||"
-"ᾗ|ἧι|ἯΙ||"
-"ᾘ|ἠι|ἨΙ|ᾐ|"
-"ᾙ|ἡι|ἩΙ|ᾑ|"
-"ᾚ|ἢι|ἪΙ|ᾒ|"
-"ᾛ|ἣι|ἫΙ|ᾓ|"
-"ᾜ|ἤι|ἬΙ|ᾔ|"
-"ᾝ|ἥι|ἭΙ|ᾕ|"
-"ᾞ|ἦι|ἮΙ|ᾖ|"
-"ᾟ|ἧι|ἯΙ|ᾗ|"
-"ᾠ|ὠι|ὨΙ||"
-"ᾡ|ὡι|ὩΙ||"
-"ᾢ|ὢι|ὪΙ||"
-"ᾣ|ὣι|ὫΙ||"
-"ᾤ|ὤι|ὬΙ||"
-"ᾥ|ὥι|ὭΙ||"
-"ᾦ|ὦι|ὮΙ||"
-"ᾧ|ὧι|ὯΙ||"
-"ᾨ|ὠι|ὨΙ|ᾠ|"
-"ᾩ|ὡι|ὩΙ|ᾡ|"
-"ᾪ|ὢι|ὪΙ|ᾢ|"
-"ᾫ|ὣι|ὫΙ|ᾣ|"
-"ᾬ|ὤι|ὬΙ|ᾤ|"
-"ᾭ|ὥι|ὭΙ|ᾥ|"
-"ᾮ|ὦι|ὮΙ|ᾦ|"
-"ᾯ|ὧι|ὯΙ|ᾧ|"
-"ᾲ|ὰι|ᾺΙ||"
-"ᾳ|αι|ΑΙ||"
-"ᾴ|άι|ΆΙ||"
-"ᾶ|ᾶ|Α͂||"
-"ᾷ|ᾶι|Α͂Ι||"
-"ᾼ|αι|ΑΙ|ᾳ|"
-"ι|ι|Ι||"
-"ῂ|ὴι|ῊΙ||"
-"ῃ|ηι|ΗΙ||"
-"ῄ|ήι|ΉΙ||"
-"ῆ|ῆ|Η͂||"
-"ῇ|ῆι|Η͂Ι||"
-"ῌ|ηι|ΗΙ|ῃ|"
-"ῒ|ῒ|Ϊ̀||"
-"ΐ|ΐ|Ϊ́||"
-"ῖ|ῖ|Ι͂||"
-"ῗ|ῗ|Ϊ͂||"
-"ῢ|ῢ|Ϋ̀||"
-"ΰ|ΰ|Ϋ́||"
-"ῤ|ῤ|Ρ̓||"
-"ῦ|ῦ|Υ͂||"
-"ῧ|ῧ|Ϋ͂||"
-"ῲ|ὼι|ῺΙ||"
-"ῳ|ωι|ΩΙ||"
-"ῴ|ώι|ΏΙ||"
-"ῶ|ῶ|Ω͂||"
-"ῷ|ῶι|Ω͂Ι||"
-"ῼ|ωι|ΩΙ|ῳ|"
-"Ω|ω||ω|"
-"K|k||k|"
-"Å|å||å|"
-"ff|ff|FF||"
-"fi|fi|FI||"
-"fl|fl|FL||"
-"ffi|ffi|FFI||"
-"ffl|ffl|FFL||"
-"ſt|st|ST||"
-"st|st|ST||"
-"ﬓ|մն|ՄՆ||"
-"ﬔ|մե|ՄԵ||"
-"ﬕ|մի|ՄԻ||"
-"ﬖ|վն|ՎՆ||"
-"ﬗ|մխ|ՄԽ||"
+"\xc2\xb5|\xce\xbc|\xce\x9c||"
+"\xc3\x9f|ss|SS||"
+"\xc4\xb0|i\xcc\x87||i\xcc\x87|"
+"\xc4\xb1||I||"
+"\xc5\x89|\xca\xbcn|\xca\xbcN||"
+"\xc5\xbf|s|S||"
+"\xc7\x85|\xc7\x86|\xc7\x84|\xc7\x86|"
+"\xc7\x88|\xc7\x89|\xc7\x87|\xc7\x89|"
+"\xc7\x8b|\xc7\x8c|\xc7\x8a|\xc7\x8c|"
+"\xc7\xb0|j\xcc\x8c|J\xcc\x8c||"
+"\xc7\xb2|\xc7\xb3|\xc7\xb1|\xc7\xb3|"
+"\xcd\x85|\xce\xb9|\xce\x99||"
+"\xce\x90|\xce\xb9\xcc\x88\xcc\x81|\xce\x99\xcc\x88\xcc\x81||"
+"\xce\xb0|\xcf\x85\xcc\x88\xcc\x81|\xce\xa5\xcc\x88\xcc\x81||"
+"\xcf\x82|\xcf\x83|\xce\xa3||"
+"\xcf\x90|\xce\xb2|\xce\x92||"
+"\xcf\x91|\xce\xb8|\xce\x98||"
+"\xcf\x95|\xcf\x86|\xce\xa6||"
+"\xcf\x96|\xcf\x80|\xce\xa0||"
+"\xcf\xb0|\xce\xba|\xce\x9a||"
+"\xcf\xb1|\xcf\x81|\xce\xa1||"
+"\xcf\xb4|\xce\xb8||\xce\xb8|"
+"\xcf\xb5|\xce\xb5|\xce\x95||"
+"\xd6\x87|\xd5\xa5\xd6\x82|\xd4\xb5\xd5\x92||"
+"\xe1\xba\x96|h\xcc\xb1|H\xcc\xb1||"
+"\xe1\xba\x97|t\xcc\x88|T\xcc\x88||"
+"\xe1\xba\x98|w\xcc\x8a|W\xcc\x8a||"
+"\xe1\xba\x99|y\xcc\x8a|Y\xcc\x8a||"
+"\xe1\xba\x9a|a\xca\xbe|A\xca\xbe||"
+"\xe1\xba\x9b|\xe1\xb9\xa1|\xe1\xb9\xa0||"
+"\xe1\xba\x9e|ss||\xc3\x9f|"
+"\xe1\xbd\x90|\xcf\x85\xcc\x93|\xce\xa5\xcc\x93||"
+"\xe1\xbd\x92|\xcf\x85\xcc\x93\xcc\x80|\xce\xa5\xcc\x93\xcc\x80||"
+"\xe1\xbd\x94|\xcf\x85\xcc\x93\xcc\x81|\xce\xa5\xcc\x93\xcc\x81||"
+"\xe1\xbd\x96|\xcf\x85\xcc\x93\xcd\x82|\xce\xa5\xcc\x93\xcd\x82||"
+"\xe1\xbe\x80|\xe1\xbc\x80\xce\xb9|\xe1\xbc\x88\xce\x99||"
+"\xe1\xbe\x81|\xe1\xbc\x81\xce\xb9|\xe1\xbc\x89\xce\x99||"
+"\xe1\xbe\x82|\xe1\xbc\x82\xce\xb9|\xe1\xbc\x8a\xce\x99||"
+"\xe1\xbe\x83|\xe1\xbc\x83\xce\xb9|\xe1\xbc\x8b\xce\x99||"
+"\xe1\xbe\x84|\xe1\xbc\x84\xce\xb9|\xe1\xbc\x8c\xce\x99||"
+"\xe1\xbe\x85|\xe1\xbc\x85\xce\xb9|\xe1\xbc\x8d\xce\x99||"
+"\xe1\xbe\x86|\xe1\xbc\x86\xce\xb9|\xe1\xbc\x8e\xce\x99||"
+"\xe1\xbe\x87|\xe1\xbc\x87\xce\xb9|\xe1\xbc\x8f\xce\x99||"
+"\xe1\xbe\x88|\xe1\xbc\x80\xce\xb9|\xe1\xbc\x88\xce\x99|\xe1\xbe\x80|"
+"\xe1\xbe\x89|\xe1\xbc\x81\xce\xb9|\xe1\xbc\x89\xce\x99|\xe1\xbe\x81|"
+"\xe1\xbe\x8a|\xe1\xbc\x82\xce\xb9|\xe1\xbc\x8a\xce\x99|\xe1\xbe\x82|"
+"\xe1\xbe\x8b|\xe1\xbc\x83\xce\xb9|\xe1\xbc\x8b\xce\x99|\xe1\xbe\x83|"
+"\xe1\xbe\x8c|\xe1\xbc\x84\xce\xb9|\xe1\xbc\x8c\xce\x99|\xe1\xbe\x84|"
+"\xe1\xbe\x8d|\xe1\xbc\x85\xce\xb9|\xe1\xbc\x8d\xce\x99|\xe1\xbe\x85|"
+"\xe1\xbe\x8e|\xe1\xbc\x86\xce\xb9|\xe1\xbc\x8e\xce\x99|\xe1\xbe\x86|"
+"\xe1\xbe\x8f|\xe1\xbc\x87\xce\xb9|\xe1\xbc\x8f\xce\x99|\xe1\xbe\x87|"
+"\xe1\xbe\x90|\xe1\xbc\xa0\xce\xb9|\xe1\xbc\xa8\xce\x99||"
+"\xe1\xbe\x91|\xe1\xbc\xa1\xce\xb9|\xe1\xbc\xa9\xce\x99||"
+"\xe1\xbe\x92|\xe1\xbc\xa2\xce\xb9|\xe1\xbc\xaa\xce\x99||"
+"\xe1\xbe\x93|\xe1\xbc\xa3\xce\xb9|\xe1\xbc\xab\xce\x99||"
+"\xe1\xbe\x94|\xe1\xbc\xa4\xce\xb9|\xe1\xbc\xac\xce\x99||"
+"\xe1\xbe\x95|\xe1\xbc\xa5\xce\xb9|\xe1\xbc\xad\xce\x99||"
+"\xe1\xbe\x96|\xe1\xbc\xa6\xce\xb9|\xe1\xbc\xae\xce\x99||"
+"\xe1\xbe\x97|\xe1\xbc\xa7\xce\xb9|\xe1\xbc\xaf\xce\x99||"
+"\xe1\xbe\x98|\xe1\xbc\xa0\xce\xb9|\xe1\xbc\xa8\xce\x99|\xe1\xbe\x90|"
+"\xe1\xbe\x99|\xe1\xbc\xa1\xce\xb9|\xe1\xbc\xa9\xce\x99|\xe1\xbe\x91|"
+"\xe1\xbe\x9a|\xe1\xbc\xa2\xce\xb9|\xe1\xbc\xaa\xce\x99|\xe1\xbe\x92|"
+"\xe1\xbe\x9b|\xe1\xbc\xa3\xce\xb9|\xe1\xbc\xab\xce\x99|\xe1\xbe\x93|"
+"\xe1\xbe\x9c|\xe1\xbc\xa4\xce\xb9|\xe1\xbc\xac\xce\x99|\xe1\xbe\x94|"
+"\xe1\xbe\x9d|\xe1\xbc\xa5\xce\xb9|\xe1\xbc\xad\xce\x99|\xe1\xbe\x95|"
+"\xe1\xbe\x9e|\xe1\xbc\xa6\xce\xb9|\xe1\xbc\xae\xce\x99|\xe1\xbe\x96|"
+"\xe1\xbe\x9f|\xe1\xbc\xa7\xce\xb9|\xe1\xbc\xaf\xce\x99|\xe1\xbe\x97|"
+"\xe1\xbe\xa0|\xe1\xbd\xa0\xce\xb9|\xe1\xbd\xa8\xce\x99||"
+"\xe1\xbe\xa1|\xe1\xbd\xa1\xce\xb9|\xe1\xbd\xa9\xce\x99||"
+"\xe1\xbe\xa2|\xe1\xbd\xa2\xce\xb9|\xe1\xbd\xaa\xce\x99||"
+"\xe1\xbe\xa3|\xe1\xbd\xa3\xce\xb9|\xe1\xbd\xab\xce\x99||"
+"\xe1\xbe\xa4|\xe1\xbd\xa4\xce\xb9|\xe1\xbd\xac\xce\x99||"
+"\xe1\xbe\xa5|\xe1\xbd\xa5\xce\xb9|\xe1\xbd\xad\xce\x99||"
+"\xe1\xbe\xa6|\xe1\xbd\xa6\xce\xb9|\xe1\xbd\xae\xce\x99||"
+"\xe1\xbe\xa7|\xe1\xbd\xa7\xce\xb9|\xe1\xbd\xaf\xce\x99||"
+"\xe1\xbe\xa8|\xe1\xbd\xa0\xce\xb9|\xe1\xbd\xa8\xce\x99|\xe1\xbe\xa0|"
+"\xe1\xbe\xa9|\xe1\xbd\xa1\xce\xb9|\xe1\xbd\xa9\xce\x99|\xe1\xbe\xa1|"
+"\xe1\xbe\xaa|\xe1\xbd\xa2\xce\xb9|\xe1\xbd\xaa\xce\x99|\xe1\xbe\xa2|"
+"\xe1\xbe\xab|\xe1\xbd\xa3\xce\xb9|\xe1\xbd\xab\xce\x99|\xe1\xbe\xa3|"
+"\xe1\xbe\xac|\xe1\xbd\xa4\xce\xb9|\xe1\xbd\xac\xce\x99|\xe1\xbe\xa4|"
+"\xe1\xbe\xad|\xe1\xbd\xa5\xce\xb9|\xe1\xbd\xad\xce\x99|\xe1\xbe\xa5|"
+"\xe1\xbe\xae|\xe1\xbd\xa6\xce\xb9|\xe1\xbd\xae\xce\x99|\xe1\xbe\xa6|"
+"\xe1\xbe\xaf|\xe1\xbd\xa7\xce\xb9|\xe1\xbd\xaf\xce\x99|\xe1\xbe\xa7|"
+"\xe1\xbe\xb2|\xe1\xbd\xb0\xce\xb9|\xe1\xbe\xba\xce\x99||"
+"\xe1\xbe\xb3|\xce\xb1\xce\xb9|\xce\x91\xce\x99||"
+"\xe1\xbe\xb4|\xce\xac\xce\xb9|\xce\x86\xce\x99||"
+"\xe1\xbe\xb6|\xce\xb1\xcd\x82|\xce\x91\xcd\x82||"
+"\xe1\xbe\xb7|\xce\xb1\xcd\x82\xce\xb9|\xce\x91\xcd\x82\xce\x99||"
+"\xe1\xbe\xbc|\xce\xb1\xce\xb9|\xce\x91\xce\x99|\xe1\xbe\xb3|"
+"\xe1\xbe\xbe|\xce\xb9|\xce\x99||"
+"\xe1\xbf\x82|\xe1\xbd\xb4\xce\xb9|\xe1\xbf\x8a\xce\x99||"
+"\xe1\xbf\x83|\xce\xb7\xce\xb9|\xce\x97\xce\x99||"
+"\xe1\xbf\x84|\xce\xae\xce\xb9|\xce\x89\xce\x99||"
+"\xe1\xbf\x86|\xce\xb7\xcd\x82|\xce\x97\xcd\x82||"
+"\xe1\xbf\x87|\xce\xb7\xcd\x82\xce\xb9|\xce\x97\xcd\x82\xce\x99||"
+"\xe1\xbf\x8c|\xce\xb7\xce\xb9|\xce\x97\xce\x99|\xe1\xbf\x83|"
+"\xe1\xbf\x92|\xce\xb9\xcc\x88\xcc\x80|\xce\x99\xcc\x88\xcc\x80||"
+"\xe1\xbf\x93|\xce\xb9\xcc\x88\xcc\x81|\xce\x99\xcc\x88\xcc\x81||"
+"\xe1\xbf\x96|\xce\xb9\xcd\x82|\xce\x99\xcd\x82||"
+"\xe1\xbf\x97|\xce\xb9\xcc\x88\xcd\x82|\xce\x99\xcc\x88\xcd\x82||"
+"\xe1\xbf\xa2|\xcf\x85\xcc\x88\xcc\x80|\xce\xa5\xcc\x88\xcc\x80||"
+"\xe1\xbf\xa3|\xcf\x85\xcc\x88\xcc\x81|\xce\xa5\xcc\x88\xcc\x81||"
+"\xe1\xbf\xa4|\xcf\x81\xcc\x93|\xce\xa1\xcc\x93||"
+"\xe1\xbf\xa6|\xcf\x85\xcd\x82|\xce\xa5\xcd\x82||"
+"\xe1\xbf\xa7|\xcf\x85\xcc\x88\xcd\x82|\xce\xa5\xcc\x88\xcd\x82||"
+"\xe1\xbf\xb2|\xe1\xbd\xbc\xce\xb9|\xe1\xbf\xba\xce\x99||"
+"\xe1\xbf\xb3|\xcf\x89\xce\xb9|\xce\xa9\xce\x99||"
+"\xe1\xbf\xb4|\xcf\x8e\xce\xb9|\xce\x8f\xce\x99||"
+"\xe1\xbf\xb6|\xcf\x89\xcd\x82|\xce\xa9\xcd\x82||"
+"\xe1\xbf\xb7|\xcf\x89\xcd\x82\xce\xb9|\xce\xa9\xcd\x82\xce\x99||"
+"\xe1\xbf\xbc|\xcf\x89\xce\xb9|\xce\xa9\xce\x99|\xe1\xbf\xb3|"
+"\xe2\x84\xa6|\xcf\x89||\xcf\x89|"
+"\xe2\x84\xaa|k||k|"
+"\xe2\x84\xab|\xc3\xa5||\xc3\xa5|"
+"\xef\xac\x80|ff|FF||"
+"\xef\xac\x81|fi|FI||"
+"\xef\xac\x82|fl|FL||"
+"\xef\xac\x83|ffi|FFI||"
+"\xef\xac\x84|ffl|FFL||"
+"\xef\xac\x85|st|ST||"
+"\xef\xac\x86|st|ST||"
+"\xef\xac\x93|\xd5\xb4\xd5\xb6|\xd5\x84\xd5\x86||"
+"\xef\xac\x94|\xd5\xb4\xd5\xa5|\xd5\x84\xd4\xb5||"
+"\xef\xac\x95|\xd5\xb4\xd5\xab|\xd5\x84\xd4\xbb||"
+"\xef\xac\x96|\xd5\xbe\xd5\xb6|\xd5\x8e\xd5\x86||"
+"\xef\xac\x97|\xd5\xb4\xd5\xad|\xd5\x84\xd4\xbd||"
//--Autogenerated -- end of section automatically generated
;
@@ -382,7 +382,7 @@ class CaseConverter : public ICaseConverter {
};
typedef std::vector<CharacterConversion> CharacterToConversion;
CharacterToConversion characterToConversion;
- // The parallel arrays
+ // The parallel arrays
std::vector<int> characters;
std::vector<ConversionString> conversions;
diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx
index fc06738..c9e3114 100644
--- a/scintilla/src/Catalogue.cxx
+++ b/scintilla/src/Catalogue.cxx
@@ -1,5 +1,5 @@
// Scintilla source code edit control
-/** @file KeyWords.cxx
+/** @file Catalogue.cxx
** Colourise for particular languages.
**/
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
@@ -7,8 +7,8 @@
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include <stdio.h>
+#include <ctype.h>
#include <stdarg.h>
#include <assert.h>
@@ -60,11 +60,6 @@ void Catalogue::AddLexerModule(LexerModule *plm) {
lexerCatalogue.push_back(plm);
}
-// Alternative historical name for Scintilla_LinkLexers
-int wxForceScintillaLexers(void) {
- return Scintilla_LinkLexers();
-}
-
// To add or remove a lexer, add or remove its file and run LexGen.py.
// Force a reference to all of the Scintilla lexers so that the linker will
@@ -79,12 +74,11 @@ int Scintilla_LinkLexers() {
// Shorten the code that declares a lexer and ensures it is linked in by calling a method.
#define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
-//++Autogenerated -- run src/LexGen.py to regenerate
+//++Autogenerated -- run scripts/LexGen.py to regenerate
//**\(\tLINK_LEXER(\*);\n\)
//LINK_LEXER(lmA68k);
//LINK_LEXER(lmAbaqus);
//LINK_LEXER(lmAda);
- LINK_LEXER(lmAHK);
//LINK_LEXER(lmAPDL);
LINK_LEXER(lmAsm);
//LINK_LEXER(lmAsn1);
@@ -127,6 +121,7 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmHTML);
LINK_LEXER(lmInno);
//LINK_LEXER(lmKix);
+ //LINK_LEXER(lmKVIrc);
LINK_LEXER(lmLatex);
//LINK_LEXER(lmLISP);
//LINK_LEXER(lmLiterateHaskell);
diff --git a/scintilla/src/CellBuffer.cxx b/scintilla/src/CellBuffer.cxx
index 7d322a9..e80e4f5 100644
--- a/scintilla/src/CellBuffer.cxx
+++ b/scintilla/src/CellBuffer.cxx
@@ -5,9 +5,9 @@
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
-#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
#include <stdarg.h>
#include <algorithm>
diff --git a/scintilla/src/Decoration.cxx b/scintilla/src/Decoration.cxx
index 955ff4f..dde4223 100644
--- a/scintilla/src/Decoration.cxx
+++ b/scintilla/src/Decoration.cxx
@@ -4,9 +4,9 @@
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
-#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
#include <stdarg.h>
#include <algorithm>
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx
index 64f6b46..9ee5e32 100644
--- a/scintilla/src/Document.cxx
+++ b/scintilla/src/Document.cxx
@@ -38,7 +38,7 @@ using namespace Scintilla;
#endif
static inline bool IsPunctuation(char ch) {
- return isascii(ch) && ispunct(ch);
+ return IsASCII(ch) && ispunct(ch);
}
void LexInterface::Colourise(int start, int end) {
@@ -825,7 +825,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const
return length;
int lastSpaceBreak = -1;
int lastPunctuationBreak = -1;
- int lastEncodingAllowedBreak = -1;
+ int lastEncodingAllowedBreak = 0;
for (int j=0; j < lengthSegment;) {
unsigned char ch = static_cast<unsigned char>(text[j]);
if (j > 0) {
@@ -854,6 +854,15 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const
return lastEncodingAllowedBreak;
}
+EncodingFamily Document::CodePageFamily() const {
+ if (SC_CP_UTF8 == dbcsCodePage)
+ return efUnicode;
+ else if (dbcsCodePage)
+ return efDBCS;
+ else
+ return efEightBit;
+}
+
void Document::ModifiedAt(int pos) {
if (endStyled > pos)
endStyled = pos;
@@ -1965,10 +1974,10 @@ int Document::WordPartLeft(int pos) {
--pos;
if (!isspacechar(cb.CharAt(pos)))
++pos;
- } else if (!isascii(startChar)) {
- while (pos > 0 && !isascii(cb.CharAt(pos)))
+ } else if (!IsASCII(startChar)) {
+ while (pos > 0 && !IsASCII(cb.CharAt(pos)))
--pos;
- if (isascii(cb.CharAt(pos)))
+ if (IsASCII(cb.CharAt(pos)))
++pos;
} else {
++pos;
@@ -1986,8 +1995,8 @@ int Document::WordPartRight(int pos) {
++pos;
startChar = cb.CharAt(pos);
}
- if (!isascii(startChar)) {
- while (pos < length && !isascii(cb.CharAt(pos)))
+ if (!IsASCII(startChar)) {
+ while (pos < length && !IsASCII(cb.CharAt(pos)))
++pos;
} else if (IsLowerCase(startChar)) {
while (pos < length && IsLowerCase(cb.CharAt(pos)))
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h
index 94e288e..3a8f01f 100644
--- a/scintilla/src/Document.h
+++ b/scintilla/src/Document.h
@@ -19,6 +19,8 @@ namespace Scintilla {
typedef int Position;
const Position invalidPosition = -1;
+enum EncodingFamily { efEightBit, efUnicode, efDBCS };
+
/**
* The range class represents a range of text in a document.
* The two values are not sorted as one end may be more significant than the other
@@ -266,6 +268,7 @@ public:
int SCI_METHOD CodePage() const;
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
int SafeSegment(const char *text, int length, int lengthSegment) const;
+ EncodingFamily CodePageFamily() const;
// Gateways to modifying document
void ModifiedAt(int pos);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx
index 6bf8c5d..a8dcfaf 100644
--- a/scintilla/src/Editor.cxx
+++ b/scintilla/src/Editor.cxx
@@ -101,6 +101,12 @@ static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) {
return true;
}
+PrintParameters::PrintParameters() {
+ magnification = 0;
+ colourMode = SC_PRINT_NORMAL;
+ wrapState = eWrapWord;
+}
+
Editor::Editor() {
ctrlID = 0;
@@ -108,11 +114,7 @@ Editor::Editor() {
technology = SC_TECHNOLOGY_DEFAULT;
scaleRGBAImage = 100;
- printMagnification = 0;
- printColourMode = SC_PRINT_NORMAL;
- printWrapState = eWrapWord;
cursorMode = SC_CURSORNORMAL;
- controlCharSymbol = 0; /* Draw the control characters */
hasFocus = false;
hideSelection = false;
@@ -167,6 +169,7 @@ Editor::Editor() {
endAtLastLine = true;
caretSticky = SC_CARETSTICKY_OFF;
marginOptions = SC_MARGINOPTION_NONE;
+ mouseSelectionRectangularSwitch = false;
multipleSelection = false;
additionalSelectionTyping = false;
multiPasteMode = SC_MULTIPASTE_ONCE;
@@ -197,9 +200,9 @@ Editor::Editor() {
bracesMatchStyle = STYLE_BRACEBAD;
highlightGuideColumn = 0;
- theEdge = 0;
-
paintState = notPainting;
+ paintAbandonedByStyling = false;
+ paintingAllText = false;
willRedrawAll = false;
modEventMask = SC_MODEVENTMASKALL;
@@ -212,24 +215,17 @@ Editor::Editor() {
foldFlags = 0;
foldAutomatic = 0;
- wrapState = eWrapNone;
wrapWidth = LineLayout::wrapWidthInfinite;
- wrapVisualFlags = 0;
- wrapVisualFlagsLocation = 0;
- wrapVisualStartIndent = 0;
- wrapIndentMode = SC_WRAPINDENT_FIXED;
convertPastes = true;
- marginNumberPadding = 3;
- ctrlCharPadding = 3; // +3 For a blank on front and rounded edge each side
- lastSegItalicsOffset = 2;
-
hsStart = -1;
hsEnd = -1;
llc.SetLevel(LineLayoutCache::llcCaret);
posCache.SetSize(0x400);
+
+ SetRepresentations();
}
Editor::~Editor() {
@@ -244,6 +240,47 @@ void Editor::Finalise() {
CancelModes();
}
+void Editor::SetRepresentations() {
+ reprs.Clear();
+
+ // C0 control set
+ const char *reps[] = {
+ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
+ "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
+ "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
+ "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
+ };
+ for (size_t j=0; j < (sizeof(reps) / sizeof(reps[0])); j++) {
+ char c[2] = { static_cast<char>(j), 0 };
+ reprs.SetRepresentation(c, reps[j]);
+ }
+
+ // C1 control set
+ // As well as Unicode mode, ISO-8859-1 should use these
+ if (IsUnicodeMode()) {
+ const char *repsC1[] = {
+ "PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA",
+ "HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3",
+ "DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA",
+ "SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC"
+ };
+ for (size_t j=0; j < (sizeof(repsC1) / sizeof(repsC1[0])); j++) {
+ char c1[3] = { '\xc2', static_cast<char>(0x80+j), 0 };
+ reprs.SetRepresentation(c1, repsC1[j]);
+ }
+ }
+
+ // UTF-8 invalid bytes
+ if (IsUnicodeMode()) {
+ for (int k=0x80; k < 0x100; k++) {
+ char hiByte[2] = { static_cast<char>(k), 0 };
+ char hexits[4];
+ sprintf(hexits, "x%2X", k);
+ reprs.SetRepresentation(hiByte, hexits);
+ }
+ }
+}
+
void Editor::DropGraphics(bool freeObjects) {
if (freeObjects) {
delete pixmapLine;
@@ -309,7 +346,7 @@ void Editor::RefreshStyleData() {
stylesValid = true;
AutoSurface surface(this);
if (surface) {
- vs.Refresh(*surface);
+ vs.Refresh(*surface, pdoc->tabInChars);
}
SetScrollBars();
SetRectangularRange();
@@ -944,6 +981,7 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b
}
if (!sel.IsRectangular() && (selt == Selection::selRectangle)) {
// Switching to rectangular
+ InvalidateSelection(sel.RangeMain(), false);
SelectionRange rangeMain = sel.RangeMain();
sel.Clear();
sel.Rectangular() = rangeMain;
@@ -1059,7 +1097,7 @@ void Editor::HorizontalScrollTo(int xPos) {
//Platform::DebugPrintf("HorizontalScroll %d\n", xPos);
if (xPos < 0)
xPos = 0;
- if ((wrapState == eWrapNone) && (xOffset != xPos)) {
+ if (!Wrapping() && (xOffset != xPos)) {
xOffset = xPos;
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
SetHorizontalScrollPos();
@@ -1353,7 +1391,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange rang
}
// Horizontal positioning
- if ((options & xysHorizontal) && (wrapState == eWrapNone)) {
+ if ((options & xysHorizontal) && !Wrapping()) {
const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2;
const bool bSlop = (caretXPolicy & CARET_SLOP) != 0;
const bool bStrict = (caretXPolicy & CARET_STRICT) != 0;
@@ -1540,13 +1578,17 @@ void Editor::InvalidateCaret() {
void Editor::UpdateSystemCaret() {
}
+bool Editor::Wrapping() const {
+ return vs.wrapState != eWrapNone;
+}
+
void Editor::NeedWrapping(int docLineStart, int docLineEnd) {
//Platform::DebugPrintf("\nNeedWrapping: %0d..%0d\n", docLineStart, docLineEnd);
if (wrapPending.AddRange(docLineStart, docLineEnd)) {
llc.Invalidate(LineLayout::llPositions);
}
// Wrap lines during idle.
- if ((wrapState != eWrapNone) && wrapPending.NeedsWrap()) {
+ if (Wrapping() && wrapPending.NeedsWrap()) {
SetIdle(true);
}
}
@@ -1570,7 +1612,7 @@ bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
bool Editor::WrapLines(enum wrapScope ws) {
int goodTopLine = topLine;
bool wrapOccurred = false;
- if (wrapState == eWrapNone) {
+ if (!Wrapping()) {
if (wrapWidth != LineLayout::wrapWidthInfinite) {
wrapWidth = LineLayout::wrapWidthInfinite;
for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) {
@@ -2030,13 +2072,13 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
PRectangle rcNumber = rcMarker;
// Right justify
XYPOSITION width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, istrlen(number));
- XYPOSITION xpos = rcNumber.right - width - marginNumberPadding;
+ XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding;
rcNumber.left = xpos;
surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
rcNumber.top + vs.maxAscent, number, istrlen(number),
vs.styles[STYLE_LINENUMBER].fore,
vs.styles[STYLE_LINENUMBER].back);
- } else if (wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) {
+ } else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) {
PRectangle rcWrapMarker = rcMarker;
rcWrapMarker.right -= 3;
rcWrapMarker.left = rcWrapMarker.right - vs.styles[STYLE_LINENUMBER].aveCharWidth;
@@ -2127,27 +2169,13 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) {
LinesOnScreen() + 1, pdoc->LinesTotal());
}
-bool BadUTF(const char *s, int len, int &trailBytes) {
- // For the rules: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- if (trailBytes) {
- trailBytes--;
- return false;
- }
- int utf8status = UTF8Classify(reinterpret_cast<const unsigned char *>(s), len);
- if (utf8status & UTF8MaskInvalid) {
- return true;
- } else {
- trailBytes = (utf8status & UTF8MaskWidth) - 1;
- return false;
- }
-}
-
/**
* Fill in the LineLayout data for the given line.
* Copy the given @a line and its styles from the document into local arrays.
* Also determine the x position at which each character starts.
*/
void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) {
+//void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width, Document *pdoc, PositionCache &posCache, SpecialRepresentations &reprs) {
if (!ll)
return;
@@ -2204,7 +2232,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ll->widthLine = LineLayout::wrapWidthInfinite;
ll->lines = 1;
if (vstyle.edgeState == EDGE_BACKGROUND) {
- ll->edgeColumn = pdoc->FindColumn(line, theEdge);
+ ll->edgeColumn = pdoc->FindColumn(line, vstyle.theEdge);
if (ll->edgeColumn >= posLineStart) {
ll->edgeColumn -= posLineStart;
}
@@ -2245,75 +2273,52 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
// Layout the line, determining the position of each character,
// with an extra element at the end for the end of the line.
- int startseg = 0; // Start of the current segment, in char. number
- XYACCUMULATOR startsegx = 0; // Start of the current segment, in pixels
ll->positions[0] = 0;
- XYPOSITION tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
bool lastSegItalics = false;
- Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;
-
- XYPOSITION ctrlCharWidth[32] = {0};
- bool isControlNext = IsControlCharacter(ll->chars[0]);
- int trailBytes = 0;
- bool isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars, numCharsInLine, trailBytes);
- for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
- bool isControl = isControlNext;
- isControlNext = IsControlCharacter(ll->chars[charInLine + 1]);
- bool isBadUTF = isBadUTFNext;
- isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars + charInLine + 1, numCharsInLine - charInLine - 1, trailBytes);
- if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) ||
- isControl || isControlNext || isBadUTF || isBadUTFNext || ((charInLine+1) >= numCharsBeforeEOL)) {
- ll->positions[startseg] = 0;
- if (vstyle.styles[ll->styles[charInLine]].visible) {
- if (isControl) {
- if (ll->chars[charInLine] == '\t') {
- ll->positions[charInLine + 1] =
- ((static_cast<int>((startsegx + 2) / tabWidth) + 1) * tabWidth) - startsegx;
- } else if (controlCharSymbol < 32) {
- if (ctrlCharWidth[ll->chars[charInLine]] == 0) {
- const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
- ctrlCharWidth[ll->chars[charInLine]] =
- surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + ctrlCharPadding;
- }
- ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]];
- } else {
- char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
- surface->MeasureWidths(ctrlCharsFont, cc, 1,
- ll->positions + startseg + 1);
- }
- lastSegItalics = false;
- } else if ((isBadUTF) || (charInLine >= numCharsBeforeEOL)) {
- char hexits[4];
- sprintf(hexits, "x%2X", ll->chars[charInLine] & 0xff);
- ll->positions[charInLine + 1] =
- surface->WidthText(ctrlCharsFont, hexits, istrlen(hexits)) + 3;
- } else { // Regular character
- int lenSeg = charInLine - startseg + 1;
- if ((lenSeg == 1) && (' ' == ll->chars[startseg])) {
- lastSegItalics = false;
- // Over half the segments are single characters and of these about half are space characters.
- ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth;
- } else {
- lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic;
- posCache.MeasureWidths(surface, vstyle, ll->styles[charInLine], ll->chars + startseg,
- lenSeg, ll->positions + startseg + 1, pdoc);
- }
+
+ BreakFinder bfLayout(ll, 0, numCharsInLine, posLineStart, 0, false, pdoc, &reprs);
+ while (bfLayout.More()) {
+
+ const TextSegment ts = bfLayout.Next();
+
+ std::fill(&ll->positions[ts.start+1], &ll->positions[ts.end()+1], 0.0f);
+ if (vstyle.styles[ll->styles[ts.start]].visible) {
+ if (ts.representation) {
+ XYPOSITION representationWidth = vstyle.controlCharWidth;
+ if (ll->chars[ts.start] == '\t') {
+ // Tab is a special case of representation, taking a variable amount of space
+ representationWidth =
+ ((static_cast<int>((ll->positions[ts.start] + 2) / vstyle.tabWidth) + 1) * vstyle.tabWidth) - ll->positions[ts.start];
+ } else {
+ if (representationWidth <= 0.0) {
+ XYPOSITION positionsRepr[256]; // Should expand when needed
+ posCache.MeasureWidths(surface, vstyle, STYLE_CONTROLCHAR, ts.representation->stringRep.c_str(),
+ static_cast<unsigned int>(ts.representation->stringRep.length()), positionsRepr, pdoc);
+ representationWidth = positionsRepr[ts.representation->stringRep.length()-1] + vstyle.ctrlCharPadding;
+ }
}
- } else { // invisible
- for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) {
- ll->positions[posToZero] = 0;
+ for (int ii=0; ii < ts.length; ii++)
+ ll->positions[ts.start + 1 + ii] = representationWidth;
+ } else {
+ if ((ts.length == 1) && (' ' == ll->chars[ts.start])) {
+ // Over half the segments are single characters and of these about half are space characters.
+ ll->positions[ts.start + 1] = vstyle.styles[ll->styles[ts.start]].spaceWidth;
+ } else {
+ posCache.MeasureWidths(surface, vstyle, ll->styles[ts.start], ll->chars + ts.start,
+ ts.length, ll->positions + ts.start + 1, pdoc);
}
}
- for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) {
- ll->positions[posToIncrease] += startsegx;
- }
- startsegx = ll->positions[charInLine + 1];
- startseg = charInLine + 1;
+ lastSegItalics = (!ts.representation) && ((ll->chars[ts.end()-1] != ' ') && vstyle.styles[ll->styles[ts.start]].italic);
+ }
+
+ for (int posToIncrease = ts.start+1; posToIncrease <= ts.end(); posToIncrease++) {
+ ll->positions[posToIncrease] += ll->positions[ts.start];
}
}
+
// Small hack to make lines that end with italics not cut off the edge of the last character
- if ((startseg > 0) && lastSegItalics) {
- ll->positions[startseg] += lastSegItalicsOffset;
+ if (lastSegItalics) {
+ ll->positions[numCharsInLine] += vstyle.lastSegItalicsOffset;
}
ll->numCharsInLine = numCharsInLine;
ll->numCharsBeforeEOL = numCharsBeforeEOL;
@@ -2331,17 +2336,17 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
// Simple common case where line does not need wrapping.
ll->lines = 1;
} else {
- if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
+ if (vstyle.wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
width -= static_cast<int>(vstyle.aveCharWidth); // take into account the space for end wrap mark
}
XYPOSITION wrapAddIndent = 0; // This will be added to initial indent of line
- if (wrapIndentMode == SC_WRAPINDENT_INDENT) {
+ if (vstyle.wrapIndentMode == SC_WRAPINDENT_INDENT) {
wrapAddIndent = pdoc->IndentSize() * vstyle.spaceWidth;
- } else if (wrapIndentMode == SC_WRAPINDENT_FIXED) {
- wrapAddIndent = wrapVisualStartIndent * vstyle.aveCharWidth;
+ } else if (vstyle.wrapIndentMode == SC_WRAPINDENT_FIXED) {
+ wrapAddIndent = vstyle.wrapVisualStartIndent * vstyle.aveCharWidth;
}
ll->wrapIndent = wrapAddIndent;
- if (wrapIndentMode != SC_WRAPINDENT_FIXED)
+ if (vstyle.wrapIndentMode != SC_WRAPINDENT_FIXED)
for (int i = 0; i < ll->numCharsInLine; i++) {
if (!IsSpaceOrTab(ll->chars[i])) {
ll->wrapIndent += ll->positions[i]; // Add line indent
@@ -2352,7 +2357,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
if (ll->wrapIndent > width - static_cast<int>(vstyle.aveCharWidth) * 15)
ll->wrapIndent = wrapAddIndent;
// Check for wrapIndent minimum
- if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < vstyle.aveCharWidth))
+ if ((vstyle.wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < vstyle.aveCharWidth))
ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual
ll->lines = 0;
// Calculate line start positions based upon width.
@@ -2384,7 +2389,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
continue;
}
if (p > 0) {
- if (wrapState == eWrapChar) {
+ if (vstyle.wrapState == eWrapChar) {
lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
- posLineStart;
p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart;
@@ -2405,18 +2410,18 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) const {
return main ?
- (primarySelection ? vsDraw.selbackground : vsDraw.selbackground2) :
+ (primarySelection ? vsDraw.selColours.back : vsDraw.selBackground2) :
vsDraw.selAdditionalBackground;
}
ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const {
if (inSelection == 1) {
- if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
+ if (vsDraw.selColours.back.isSet && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
return SelectionBackground(vsDraw, true);
}
} else if (inSelection == 2) {
- if (vsDraw.selbackset && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) {
+ if (vsDraw.selColours.back.isSet && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) {
return SelectionBackground(vsDraw, false);
}
} else {
@@ -2424,8 +2429,8 @@ ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
(i >= ll->edgeColumn) &&
(i < ll->numCharsBeforeEOL))
return vsDraw.edgecolour;
- if (inHotspot && vsDraw.hotspotBackgroundSet)
- return vsDraw.hotspotBackground;
+ if (inHotspot && vsDraw.hotspotColours.back.isSet)
+ return vsDraw.hotspotColours.back;
}
if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) {
return background;
@@ -2449,11 +2454,9 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
int w = rcPlace.right - rcPlace.left - xa - 1;
bool xStraight = isEndMarker; // x-mirrored symbol for start marker
- bool yStraight = true;
- //bool yStraight= isEndMarker; // comment in for start marker y-mirrowed
int x0 = xStraight ? rcPlace.left : rcPlace.right - 1;
- int y0 = yStraight ? rcPlace.top : rcPlace.bottom - 1;
+ int y0 = rcPlace.top;
int dy = (rcPlace.bottom - rcPlace.top) / 5;
int y = (rcPlace.bottom - rcPlace.top) / 2 + dy;
@@ -2471,7 +2474,7 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
}
};
- Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1};
+ Relative rel = {surface, x0, xStraight ? 1 : -1, y0, 1};
// arrow head
rel.MoveTo(xa, y);
@@ -2585,10 +2588,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
int styleMain = ll->styles[eolPos];
ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll);
ColourDesired textFore = vsDraw.styles[styleMain].fore;
- if (eolInSelection && vsDraw.selforeset) {
- textFore = (eolInSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground;
+ if (eolInSelection && vsDraw.selColours.fore.isSet) {
+ textFore = (eolInSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
}
- if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
+ if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1)) {
if (alpha == SC_ALPHA_NOALPHA) {
surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
} else {
@@ -2598,7 +2601,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
surface->FillRectangle(rcSegment, textBack);
}
DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
- if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+ if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
}
}
@@ -2608,7 +2611,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
rcSegment.left = xEol + xStart + virtualSpace + blobsWidth;
rcSegment.right = rcSegment.left + vsDraw.aveCharWidth;
- if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
+ if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
} else {
if (overrideBackground) {
@@ -2620,7 +2623,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
} else {
surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
}
- if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+ if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
}
}
@@ -2631,7 +2634,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
rcSegment.left = rcLine.left;
rcSegment.right = rcLine.right;
- if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
+ if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
} else {
if (overrideBackground) {
@@ -2641,7 +2644,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
} else {
surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
}
- if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+ if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
}
}
@@ -2649,7 +2652,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
if (drawWrapMarkEnd) {
PRectangle rcPlace = rcSegment;
- if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) {
+ if (vsDraw.wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) {
rcPlace.left = xEol + xStart + virtualSpace;
rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
} else {
@@ -2805,6 +2808,11 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine) {
+ if (subLine >= ll->lines) {
+ DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine);
+ return; // No further drawing
+ }
+
PRectangle rcSegment = rcLine;
// Using one font for all control characters so it can be controlled independently to ensure
@@ -2851,21 +2859,17 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
- bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) &&
- (!overrideBackground) && (vsDraw.whitespaceBackgroundSet);
+ const bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) &&
+ (!overrideBackground) && (vsDraw.whitespaceColours.back.isSet);
bool inIndentation = subLine == 0; // Do not handle indentation except on first subline.
const XYPOSITION indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth;
const XYPOSITION epsilon = 0.0001f; // A small nudge to avoid floating point precision issues
- int posLineStart = pdoc->LineStart(line);
+ const int posLineStart = pdoc->LineStart(line);
- int startseg = ll->LineStart(subLine);
- XYACCUMULATOR subLineStart = ll->positions[startseg];
- if (subLine >= ll->lines) {
- DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine);
- return; // No further drawing
- }
+ const int startseg = ll->LineStart(subLine);
+ const XYACCUMULATOR subLineStart = ll->positions[startseg];
int lineStart = 0;
int lineEnd = 0;
if (subLine < ll->lines) {
@@ -2876,13 +2880,11 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
- ColourDesired wrapColour = vsDraw.styles[STYLE_DEFAULT].fore;
- if (vsDraw.whitespaceForegroundSet)
- wrapColour = vsDraw.whitespaceForeground;
+ const ColourDesired wrapColour = vsDraw.WrapColour();
bool drawWrapMarkEnd = false;
- if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
+ if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
if (subLine + 1 < ll->lines) {
drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0;
}
@@ -2911,9 +2913,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
//int styleMain = ll->styles[lineStart];
//surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back);
- if (wrapVisualFlags & SC_WRAPVISUALFLAG_START) {
+ if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_START) {
- if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT)
+ if (vsDraw.wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT)
rcPlace.left = rcPlace.right - vsDraw.aveCharWidth;
else
rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
@@ -2925,77 +2927,76 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
- bool selBackDrawn = vsDraw.selbackset &&
+ const bool selBackDrawn = vsDraw.selColours.back.isSet &&
((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA));
// Does not take margin into account but not significant
- int xStartVisible = static_cast<int>(subLineStart) - xStart;
+ const int xStartVisible = static_cast<int>(subLineStart) - xStart;
ll->psel = &sel;
- BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc);
- int next = bfBack.First();
-
- // Background drawing loop
- while (twoPhaseDraw && (next < lineEnd)) {
-
- startseg = next;
- next = bfBack.Next();
- int i = next - 1;
- int iDoc = i + posLineStart;
-
- rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
- rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
- // Only try to draw if really visible - enhances performance by not calling environment to
- // draw strings that are completely past the right side of the window.
- if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
- // Clip to line rectangle, since may have a huge position which will not work with some platforms
- if (rcSegment.left < rcLine.left)
- rcSegment.left = rcLine.left;
- if (rcSegment.right > rcLine.right)
- rcSegment.right = rcLine.right;
-
- int styleMain = ll->styles[i];
- const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
- bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
- ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
- if (ll->chars[i] == '\t') {
- // Tab display
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
- textBack = vsDraw.whitespaceBackground;
- surface->FillRectangle(rcSegment, textBack);
- } else if (IsControlCharacter(ll->chars[i])) {
- // Control character display
- inIndentation = false;
- surface->FillRectangle(rcSegment, textBack);
- } else {
- // Normal text display
- surface->FillRectangle(rcSegment, textBack);
- if (vsDraw.viewWhitespace != wsInvisible ||
- (inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
- for (int cpos = 0; cpos <= i - startseg; cpos++) {
- if (ll->chars[cpos + startseg] == ' ') {
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
- PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
- rcSegment.top,
- ll->positions[cpos + startseg + 1] + xStart - subLineStart,
- rcSegment.bottom);
- surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground);
+ if (twoPhaseDraw) {
+ BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc, &reprs);
+
+ // Background drawing loop
+ while (bfBack.More()) {
+
+ const TextSegment ts = bfBack.Next();
+ const int i = ts.end() - 1;
+ const int iDoc = i + posLineStart;
+
+ rcSegment.left = ll->positions[ts.start] + xStart - subLineStart;
+ rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart;
+ // Only try to draw if really visible - enhances performance by not calling environment to
+ // draw strings that are completely past the right side of the window.
+ if (rcSegment.Intersects(rcLine)) {
+ // Clip to line rectangle, since may have a huge position which will not work with some platforms
+ if (rcSegment.left < rcLine.left)
+ rcSegment.left = rcLine.left;
+ if (rcSegment.right > rcLine.right)
+ rcSegment.right = rcLine.right;
+
+ const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
+ const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
+ ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection,
+ inHotspot, ll->styles[i], i, ll);
+ if (ts.representation) {
+ if (ll->chars[i] == '\t') {
+ // Tab display
+ if (drawWhitespaceBackground &&
+ (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+ textBack = vsDraw.whitespaceColours.back;
+ } else {
+ // Blob display
+ inIndentation = false;
+ }
+ surface->FillRectangle(rcSegment, textBack);
+ } else {
+ // Normal text display
+ surface->FillRectangle(rcSegment, textBack);
+ if (vsDraw.viewWhitespace != wsInvisible ||
+ (inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
+ for (int cpos = 0; cpos <= i - ts.start; cpos++) {
+ if (ll->chars[cpos + ts.start] == ' ') {
+ if (drawWhitespaceBackground &&
+ (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
+ PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart,
+ rcSegment.top,
+ ll->positions[cpos + ts.start + 1] + xStart - subLineStart,
+ rcSegment.bottom);
+ surface->FillRectangle(rcSpace, vsDraw.whitespaceColours.back);
+ }
+ } else {
+ inIndentation = false;
}
- } else {
- inIndentation = false;
}
}
}
+ } else if (rcSegment.left > rcLine.right) {
+ break;
}
- } else if (rcSegment.left > rcLine.right) {
- break;
}
- }
- if (twoPhaseDraw) {
DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
xStart, subLine, subLineStart, overrideBackground, background,
drawWrapMarkEnd, wrapColour);
@@ -3004,7 +3005,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true);
if (vsDraw.edgeState == EDGE_LINE) {
- int edgeX = theEdge * vsDraw.spaceWidth;
+ int edgeX = vsDraw.theEdge * vsDraw.spaceWidth;
rcSegment.left = edgeX + xStart;
if ((ll->wrapIndent != 0) && (lineStart != 0))
rcSegment.left -= ll->wrapIndent;
@@ -3028,111 +3029,102 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
inIndentation = subLine == 0; // Do not handle indentation except on first subline.
// Foreground drawing loop
BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, xStartVisible,
- ((!twoPhaseDraw && selBackDrawn) || vsDraw.selforeset), pdoc);
- next = bfFore.First();
-
- while (next < lineEnd) {
+ ((!twoPhaseDraw && selBackDrawn) || vsDraw.selColours.fore.isSet), pdoc, &reprs);
- startseg = next;
- next = bfFore.Next();
- int i = next - 1;
+ while (bfFore.More()) {
- int iDoc = i + posLineStart;
+ const TextSegment ts = bfFore.Next();
+ const int i = ts.end() - 1;
+ const int iDoc = i + posLineStart;
- rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
- rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+ rcSegment.left = ll->positions[ts.start] + xStart - subLineStart;
+ rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart;
// Only try to draw if really visible - enhances performance by not calling environment to
// draw strings that are completely past the right side of the window.
- if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+ if (rcSegment.Intersects(rcLine)) {
int styleMain = ll->styles[i];
ColourDesired textFore = vsDraw.styles[styleMain].fore;
Font &textFont = vsDraw.styles[styleMain].font;
//hotspot foreground
if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) {
- if (vsDraw.hotspotForegroundSet)
- textFore = vsDraw.hotspotForeground;
+ if (vsDraw.hotspotColours.fore.isSet)
+ textFore = vsDraw.hotspotColours.fore;
}
const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
- if (inSelection && (vsDraw.selforeset)) {
- textFore = (inSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground;
+ if (inSelection && (vsDraw.selColours.fore.isSet)) {
+ textFore = (inSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
}
- bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
+ const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
- if (ll->chars[i] == '\t') {
- // Tab display
- if (!twoPhaseDraw) {
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
- textBack = vsDraw.whitespaceBackground;
- surface->FillRectangle(rcSegment, textBack);
- }
- if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
- for (int indentCount = (ll->positions[i] + epsilon) / indentWidth;
- indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
- indentCount++) {
- if (indentCount > 0) {
- int xIndent = indentCount * indentWidth;
- DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
- (ll->xHighlightGuide == xIndent));
+ if (ts.representation) {
+ if (ll->chars[i] == '\t') {
+ // Tab display
+ if (!twoPhaseDraw) {
+ if (drawWhitespaceBackground &&
+ (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+ textBack = vsDraw.whitespaceColours.back;
+ surface->FillRectangle(rcSegment, textBack);
+ }
+ if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
+ for (int indentCount = (ll->positions[i] + epsilon) / indentWidth;
+ indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
+ indentCount++) {
+ if (indentCount > 0) {
+ int xIndent = indentCount * indentWidth;
+ DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment,
+ (ll->xHighlightGuide == xIndent));
+ }
}
}
- }
- if (vsDraw.viewWhitespace != wsInvisible) {
- if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- if (vsDraw.whitespaceForegroundSet)
- textFore = vsDraw.whitespaceForeground;
- surface->PenColour(textFore);
- PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
- rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
- DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ if (vsDraw.viewWhitespace != wsInvisible) {
+ if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+ if (vsDraw.whitespaceColours.fore.isSet)
+ textFore = vsDraw.whitespaceColours.fore;
+ surface->PenColour(textFore);
+ PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
+ rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
+ DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ }
}
- }
- } else if (IsControlCharacter(ll->chars[i])) {
- // Control character display
- inIndentation = false;
- if (controlCharSymbol < 32) {
- // Draw the character
- const char *ctrlChar = ControlCharacterString(ll->chars[i]);
- DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
} else {
- char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
- surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
- rcSegment.top + vsDraw.maxAscent,
- cc, 1, textBack, textFore);
+ inIndentation = false;
+ if (vsDraw.controlCharSymbol >= 32) {
+ char cc[2] = { static_cast<char>(vsDraw.controlCharSymbol), '\0' };
+ surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
+ rcSegment.top + vsDraw.maxAscent,
+ cc, 1, textBack, textFore);
+ } else {
+ DrawTextBlob(surface, vsDraw, rcSegment, ts.representation->stringRep.c_str(), textBack, textFore, twoPhaseDraw);
+ }
}
- } else if ((i == startseg) && (static_cast<unsigned char>(ll->chars[i]) >= 0x80) && IsUnicodeMode()) {
- // A single byte >= 0x80 in UTF-8 is a bad byte and is displayed as its hex value
- char hexits[4];
- sprintf(hexits, "x%2X", ll->chars[i] & 0xff);
- DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw);
} else {
// Normal text display
if (vsDraw.styles[styleMain].visible) {
if (twoPhaseDraw) {
surface->DrawTextTransparent(rcSegment, textFont,
- rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
- i - startseg + 1, textFore);
+ rcSegment.top + vsDraw.maxAscent, ll->chars + ts.start,
+ i - ts.start + 1, textFore);
} else {
surface->DrawTextNoClip(rcSegment, textFont,
- rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
- i - startseg + 1, textFore, textBack);
+ rcSegment.top + vsDraw.maxAscent, ll->chars + ts.start,
+ i - ts.start + 1, textFore, textBack);
}
}
if (vsDraw.viewWhitespace != wsInvisible ||
(inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
- for (int cpos = 0; cpos <= i - startseg; cpos++) {
- if (ll->chars[cpos + startseg] == ' ') {
+ for (int cpos = 0; cpos <= i - ts.start; cpos++) {
+ if (ll->chars[cpos + ts.start] == ' ') {
if (vsDraw.viewWhitespace != wsInvisible) {
- if (vsDraw.whitespaceForegroundSet)
- textFore = vsDraw.whitespaceForeground;
+ if (vsDraw.whitespaceColours.fore.isSet)
+ textFore = vsDraw.whitespaceColours.fore;
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- XYPOSITION xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
+ XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
if (!twoPhaseDraw && drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
- textBack = vsDraw.whitespaceBackground;
- PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
+ textBack = vsDraw.whitespaceColours.back;
+ PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart,
rcSegment.top,
- ll->positions[cpos + startseg + 1] + xStart - subLineStart,
+ ll->positions[cpos + ts.start + 1] + xStart - subLineStart,
rcSegment.bottom);
surface->FillRectangle(rcSpace, textBack);
}
@@ -3143,8 +3135,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
- for (int indentCount = (ll->positions[cpos + startseg] + epsilon) / indentWidth;
- indentCount <= (ll->positions[cpos + startseg + 1] - epsilon) / indentWidth;
+ for (int indentCount = (ll->positions[cpos + ts.start] + epsilon) / indentWidth;
+ indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth;
indentCount++) {
if (indentCount > 0) {
int xIndent = indentCount * indentWidth;
@@ -3163,8 +3155,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
PRectangle rcUL = rcSegment;
rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
rcUL.bottom = rcUL.top + 1;
- if (vsDraw.hotspotForegroundSet)
- surface->FillRectangle(rcUL, vsDraw.hotspotForeground);
+ if (vsDraw.hotspotColours.fore.isSet)
+ surface->FillRectangle(rcUL, vsDraw.hotspotColours.fore);
else
surface->FillRectangle(rcUL, textFore);
} else if (vsDraw.styles[styleMain].underline) {
@@ -3380,11 +3372,11 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
colourFMFill = vs.selbarlight;
}
- if (vs.foldmarginColourSet) {
+ if (vs.foldmarginColour.isSet) {
// override default fold margin colour
colourFMFill = vs.foldmarginColour;
}
- if (vs.foldmarginHighlightColourSet) {
+ if (vs.foldmarginHighlightColour.isSet) {
// override default fold margin highlight colour
colourFMStripes = vs.foldmarginHighlightColour;
}
@@ -3578,7 +3570,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
// Either styling or NotifyUpdateUI noticed that painting is needed
// outside the current painting rectangle
//Platform::DebugPrintf("Abandoning paint\n");
- if (wrapState != eWrapNone) {
+ if (Wrapping()) {
if (paintAbandonedByStyling) {
// Styling has spilled over a line end, such as occurs by starting a multiline
// comment. The width of subsequent text may have changed, so rewrap.
@@ -3747,7 +3739,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
if (rcBeyondEOF.top < rcBeyondEOF.bottom) {
surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back);
if (vs.edgeState == EDGE_LINE) {
- int edgeX = theEdge * vs.spaceWidth;
+ int edgeX = vs.theEdge * vs.spaceWidth;
rcBeyondEOF.left = edgeX + xStart;
rcBeyondEOF.right = rcBeyondEOF.left + 1;
surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour);
@@ -3809,17 +3801,17 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
}
}
vsPrint.fixedColumnWidth = 0;
- vsPrint.zoomLevel = printMagnification;
+ vsPrint.zoomLevel = printParameters.magnification;
// Don't show indentation guides
// If this ever gets changed, cached pixmap would need to be recreated if technology != SC_TECHNOLOGY_DEFAULT
vsPrint.viewIndentationGuides = ivNone;
// Don't show the selection when printing
- vsPrint.selbackset = false;
- vsPrint.selforeset = false;
+ vsPrint.selColours.back.isSet = false;
+ vsPrint.selColours.fore.isSet = false;
vsPrint.selAlpha = SC_ALPHA_NOALPHA;
vsPrint.selAdditionalAlpha = SC_ALPHA_NOALPHA;
- vsPrint.whitespaceBackgroundSet = false;
- vsPrint.whitespaceForegroundSet = false;
+ vsPrint.whitespaceColours.back.isSet = false;
+ vsPrint.whitespaceColours.fore.isSet = false;
vsPrint.showCaretLineBackground = false;
vsPrint.alwaysShowCaretLineBackground = false;
// Don't highlight matching braces using indicators
@@ -3828,15 +3820,15 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
// Set colours for printing according to users settings
for (size_t sty = 0; sty < vsPrint.styles.size(); sty++) {
- if (printColourMode == SC_PRINT_INVERTLIGHT) {
+ if (printParameters.colourMode == SC_PRINT_INVERTLIGHT) {
vsPrint.styles[sty].fore = InvertedLight(vsPrint.styles[sty].fore);
vsPrint.styles[sty].back = InvertedLight(vsPrint.styles[sty].back);
- } else if (printColourMode == SC_PRINT_BLACKONWHITE) {
+ } else if (printParameters.colourMode == SC_PRINT_BLACKONWHITE) {
vsPrint.styles[sty].fore = ColourDesired(0, 0, 0);
vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
- } else if (printColourMode == SC_PRINT_COLOURONWHITE) {
+ } else if (printParameters.colourMode == SC_PRINT_COLOURONWHITE) {
vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
- } else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
+ } else if (printParameters.colourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
if (sty <= STYLE_DEFAULT) {
vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
}
@@ -3849,14 +3841,14 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
vsPrint.leftMarginWidth = 0;
vsPrint.rightMarginWidth = 0;
- vsPrint.Refresh(*surfaceMeasure);
+ vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars);
// Determining width must hapen after fonts have been realised in Refresh
int lineNumberWidth = 0;
if (lineNumberIndex >= 0) {
lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
"99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
- vsPrint.Refresh(*surfaceMeasure); // Recalculate fixedColumnWidth
+ vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars); // Recalculate fixedColumnWidth
}
int linePrintStart = pdoc->LineFromPosition(pfr->chrg.cpMin);
@@ -3884,7 +3876,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
int nPrintPos = pfr->chrg.cpMin;
int visibleLine = 0;
int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth;
- if (printWrapState == eWrapNone)
+ if (printParameters.wrapState == eWrapNone)
widthPrint = LineLayout::wrapWidthInfinite;
while (lineDoc <= linePrintLast && ypos < pfr->rc.bottom) {
@@ -4011,7 +4003,7 @@ void Editor::SetScrollBars() {
void Editor::ChangeSize() {
DropGraphics(false);
SetScrollBars();
- if (wrapState != eWrapNone) {
+ if (Wrapping()) {
PRectangle rcTextArea = GetClientRectangle();
rcTextArea.left = vs.textStart;
rcTextArea.right -= vs.rightMarginWidth;
@@ -4091,7 +4083,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
currentSel->ClearVirtualSpace();
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
- if (wrapState != eWrapNone) {
+ if (Wrapping()) {
AutoSurface surface(this);
if (surface) {
if (WrapOneLine(surface, pdoc->LineFromPosition(positionInsert))) {
@@ -4104,7 +4096,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
}
}
- if (wrapState != eWrapNone) {
+ if (Wrapping()) {
SetScrollBars();
}
ThinRectangularRange();
@@ -4586,7 +4578,7 @@ void Editor::NotifyDwelling(Point pt, bool state) {
SCNotification scn = {0};
scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND;
scn.position = PositionFromLocation(pt, true);
- scn.x = pt.x;
+ scn.x = pt.x + vs.ExternalMarginWidth();
scn.y = pt.y;
NotifyParent(scn);
}
@@ -4613,7 +4605,7 @@ void Editor::CheckModificationForWrap(DocModification mh) {
llc.Invalidate(LineLayout::llCheckTextAndStyle);
int lineDoc = pdoc->LineFromPosition(mh.position);
int lines = Platform::Maximum(0, mh.linesAdded);
- if (wrapState != eWrapNone) {
+ if (Wrapping()) {
NeedWrapping(lineDoc, lineDoc + lines + 1);
}
RefreshStyleData();
@@ -6342,7 +6334,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
selectionType = selWholeLine;
} else if (selectionType != selSubLine && selectionType != selWholeLine) {
// If it is neither, reset selection type to line selection.
- selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+ selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
}
} else {
if (selectionType == selChar) {
@@ -6406,7 +6398,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
if (!shift) {
// Single click in margin: select whole line or only subline if word wrap is enabled
lineAnchorPos = newPos.Position();
- selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+ selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine);
} else {
// Single shift+click in margin: select from line anchor to clicked line
@@ -6419,7 +6411,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
// Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine.
// This ensures that we continue selecting in the same selection mode.
if (sel.Empty() || (selectionType != selSubLine && selectionType != selWholeLine))
- selectionType = ((wrapState != eWrapNone) && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+ selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
LineSelection(newPos.Position(), lineAnchorPos, selectionType == selWholeLine);
}
@@ -6521,7 +6513,7 @@ void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) const {
hsEnd_ = hsEnd;
}
-void Editor::ButtonMove(Point pt) {
+void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) {
if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) {
DwellEnd(true);
}
@@ -6555,10 +6547,14 @@ void Editor::ButtonMove(Point pt) {
SetDragPosition(movePos);
} else {
if (selectionType == selChar) {
+ if (sel.selType == Selection::selStream && (modifiers & SCI_ALT) && mouseSelectionRectangularSwitch) {
+ sel.selType = Selection::selRectangle;
+ }
if (sel.IsRectangular()) {
sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor);
SetSelection(movePos, sel.RangeMain().anchor);
} else if (sel.Count() > 1) {
+ InvalidateSelection(sel.RangeMain(), false);
SelectionRange range(movePos, sel.RangeMain().anchor);
sel.TentativeSelection(range);
InvalidateSelection(range, true);
@@ -6632,6 +6628,10 @@ void Editor::ButtonMove(Point pt) {
}
}
+void Editor::ButtonMove(Point pt) {
+ ButtonMoveWithModifiers(pt, 0);
+}
+
void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
SelectionPosition newPos = SPositionFromLocation(pt, false, false,
@@ -6745,7 +6745,7 @@ bool Editor::Idle() {
bool idleDone;
- bool wrappingDone = wrapState == eWrapNone;
+ bool wrappingDone = !Wrapping();
if (!wrappingDone) {
// Wrap lines during idle.
@@ -6881,7 +6881,7 @@ void Editor::SetAnnotationHeights(int start, int end) {
bool changedHeight = false;
for (int line=start; line<end && line<pdoc->LinesTotal(); line++) {
int linesWrapped = 1;
- if (wrapState != eWrapNone) {
+ if (Wrapping()) {
AutoSurface surface(this);
AutoLineLayout ll(llc, RetrieveLineLayout(line));
if (surface && ll) {
@@ -6919,6 +6919,8 @@ void Editor::SetDocPointer(Document *document) {
vs.ReleaseAllExtendedStyles();
+ SetRepresentations();
+
// Reset the contraction state to fully shown.
cs.Clear();
cs.InsertLines(0, pdoc->LinesTotal() - 1);
@@ -7620,6 +7622,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_POSITIONAFTER:
return pdoc->MovePositionOutsideChar(wParam + 1, 1, true);
+ case SCI_POSITIONRELATIVE:
+ return Platform::Clamp(pdoc->GetRelativePosition(wParam, lParam), 0, pdoc->Length());
+
case SCI_LINESCROLL:
ScrollTo(topLine + lParam);
HorizontalScrollTo(xOffset + static_cast<int>(wParam) * vs.spaceWidth);
@@ -7703,6 +7708,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.rightMarginWidth;
case SCI_SETMARGINLEFT:
+ lastXChosen += lParam - vs.leftMarginWidth;
vs.leftMarginWidth = lParam;
InvalidateStyleRedraw();
break;
@@ -7870,25 +7876,25 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETPRINTMAGNIFICATION:
- printMagnification = wParam;
+ printParameters.magnification = wParam;
break;
case SCI_GETPRINTMAGNIFICATION:
- return printMagnification;
+ return printParameters.magnification;
case SCI_SETPRINTCOLOURMODE:
- printColourMode = wParam;
+ printParameters.colourMode = wParam;
break;
case SCI_GETPRINTCOLOURMODE:
- return printColourMode;
+ return printParameters.colourMode;
case SCI_SETPRINTWRAPMODE:
- printWrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone;
+ printParameters.wrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone;
break;
case SCI_GETPRINTWRAPMODE:
- return printWrapState;
+ return printParameters.wrapState;
case SCI_GETSTYLEAT:
if (static_cast<int>(wParam) >= pdoc->Length())
@@ -7949,16 +7955,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_POSITIONFROMPOINT:
- return PositionFromLocation(Point(wParam, lParam), false, false);
+ return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ false, false);
case SCI_POSITIONFROMPOINTCLOSE:
- return PositionFromLocation(Point(wParam, lParam), true, false);
+ return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ true, false);
case SCI_CHARPOSITIONFROMPOINT:
- return PositionFromLocation(Point(wParam, lParam), false, true);
+ return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ false, true);
case SCI_CHARPOSITIONFROMPOINTCLOSE:
- return PositionFromLocation(Point(wParam, lParam), true, true);
+ return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam),
+ true, true);
case SCI_GOTOLINE:
GoToLine(wParam);
@@ -8120,66 +8130,55 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->ExtendWordSelect(wParam, 1, lParam != 0);
case SCI_SETWRAPMODE:
- switch (wParam) {
- case SC_WRAP_WORD:
- wrapState = eWrapWord;
- break;
- case SC_WRAP_CHAR:
- wrapState = eWrapChar;
- break;
- default:
- wrapState = eWrapNone;
- break;
+ if (vs.SetWrapState(wParam)) {
+ xOffset = 0;
+ ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
+ InvalidateStyleRedraw();
+ ReconfigureScrollBars();
}
- xOffset = 0;
- ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
- InvalidateStyleRedraw();
- ReconfigureScrollBars();
break;
case SCI_GETWRAPMODE:
- return wrapState;
+ return vs.wrapState;
case SCI_SETWRAPVISUALFLAGS:
- if (wrapVisualFlags != static_cast<int>(wParam)) {
- wrapVisualFlags = wParam;
+ if (vs.SetWrapVisualFlags(wParam)) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
case SCI_GETWRAPVISUALFLAGS:
- return wrapVisualFlags;
+ return vs.wrapVisualFlags;
case SCI_SETWRAPVISUALFLAGSLOCATION:
- wrapVisualFlagsLocation = wParam;
- InvalidateStyleRedraw();
+ if (vs.SetWrapVisualFlagsLocation(wParam)) {
+ InvalidateStyleRedraw();
+ }
break;
case SCI_GETWRAPVISUALFLAGSLOCATION:
- return wrapVisualFlagsLocation;
+ return vs.wrapVisualFlagsLocation;
case SCI_SETWRAPSTARTINDENT:
- if (wrapVisualStartIndent != static_cast<int>(wParam)) {
- wrapVisualStartIndent = wParam;
+ if (vs.SetWrapVisualStartIndent(wParam)) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
case SCI_GETWRAPSTARTINDENT:
- return wrapVisualStartIndent;
+ return vs.wrapVisualStartIndent;
case SCI_SETWRAPINDENTMODE:
- if (wrapIndentMode != static_cast<int>(wParam)) {
- wrapIndentMode = wParam;
+ if (vs.SetWrapIndentMode(wParam)) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
case SCI_GETWRAPINDENTMODE:
- return wrapIndentMode;
+ return vs.wrapIndentMode;
case SCI_SETLAYOUTCACHE:
llc.SetLevel(wParam);
@@ -8313,6 +8312,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
cs.InsertLines(0, pdoc->LinesTotal() - 1);
SetAnnotationHeights(0, pdoc->LinesTotal());
InvalidateStyleRedraw();
+ SetRepresentations();
}
}
break;
@@ -8450,6 +8450,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (ValidMargin(wParam)) {
// Short-circuit if the width is unchanged, to avoid unnecessary redraw.
if (vs.ms[wParam].width != lParam) {
+ lastXChosen += lParam - vs.ms[wParam].width;
vs.ms[wParam].width = lParam;
InvalidateStyleRedraw();
}
@@ -8713,15 +8714,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return LinesOnScreen();
case SCI_SETSELFORE:
- vs.selforeset = wParam != 0;
- vs.selforeground = ColourDesired(lParam);
+ vs.selColours.fore = ColourOptional(wParam, lParam);
vs.selAdditionalForeground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
- vs.selbackset = wParam != 0;
- vs.selbackground = ColourDesired(lParam);
+ vs.selColours.back = ColourOptional(wParam, lParam);
vs.selAdditionalBackground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
@@ -8744,14 +8743,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETWHITESPACEFORE:
- vs.whitespaceForegroundSet = wParam != 0;
- vs.whitespaceForeground = ColourDesired(lParam);
+ vs.whitespaceColours.fore = ColourOptional(wParam, lParam);
InvalidateStyleRedraw();
break;
case SCI_SETWHITESPACEBACK:
- vs.whitespaceBackgroundSet = wParam != 0;
- vs.whitespaceBackground = ColourDesired(lParam);
+ vs.whitespaceColours.back = ColourOptional(wParam, lParam);
InvalidateStyleRedraw();
break;
@@ -9022,10 +9019,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.zoomLevel;
case SCI_GETEDGECOLUMN:
- return theEdge;
+ return vs.theEdge;
case SCI_SETEDGECOLUMN:
- theEdge = wParam;
+ vs.theEdge = wParam;
InvalidateStyleRedraw();
break;
@@ -9117,6 +9114,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
sel.selType = Selection::selStream;
}
InvalidateSelection(sel.RangeMain(), true);
+ break;
}
case SCI_GETSELECTIONMODE:
switch (sel.selType) {
@@ -9181,11 +9179,31 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return cursorMode;
case SCI_SETCONTROLCHARSYMBOL:
- controlCharSymbol = wParam;
+ vs.controlCharSymbol = wParam;
+ InvalidateStyleRedraw();
break;
case SCI_GETCONTROLCHARSYMBOL:
- return controlCharSymbol;
+ return vs.controlCharSymbol;
+
+ case SCI_SETREPRESENTATION:
+ reprs.SetRepresentation(reinterpret_cast<const char *>(wParam), CharPtrFromSPtr(lParam));
+ break;
+
+ case SCI_GETREPRESENTATION: {
+ Representation *repr = reprs.RepresentationFromCharacter(
+ reinterpret_cast<const char *>(wParam), UTF8MaxBytes);
+ if (repr) {
+ if (lParam != 0)
+ strcpy(CharPtrFromSPtr(lParam), repr->stringRep.c_str());
+ return repr->stringRep.size();
+ }
+ return 0;
+ }
+
+ case SCI_CLEARREPRESENTATION:
+ reprs.ClearRepresentation(reinterpret_cast<const char *>(wParam));
+ break;
case SCI_STARTRECORD:
recordingMacro = true;
@@ -9200,34 +9218,30 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETFOLDMARGINCOLOUR:
- vs.foldmarginColourSet = wParam != 0;
- vs.foldmarginColour = ColourDesired(lParam);
+ vs.foldmarginColour = ColourOptional(wParam, lParam);
InvalidateStyleRedraw();
break;
case SCI_SETFOLDMARGINHICOLOUR:
- vs.foldmarginHighlightColourSet = wParam != 0;
- vs.foldmarginHighlightColour = ColourDesired(lParam);
+ vs.foldmarginHighlightColour = ColourOptional(wParam, lParam);
InvalidateStyleRedraw();
break;
case SCI_SETHOTSPOTACTIVEFORE:
- vs.hotspotForegroundSet = wParam != 0;
- vs.hotspotForeground = ColourDesired(lParam);
+ vs.hotspotColours.fore = ColourOptional(wParam, lParam);
InvalidateStyleRedraw();
break;
case SCI_GETHOTSPOTACTIVEFORE:
- return vs.hotspotForeground.AsLong();
+ return vs.hotspotColours.fore.AsLong();
case SCI_SETHOTSPOTACTIVEBACK:
- vs.hotspotBackgroundSet = wParam != 0;
- vs.hotspotBackground = ColourDesired(lParam);
+ vs.hotspotColours.back = ColourOptional(wParam, lParam);
InvalidateStyleRedraw();
break;
case SCI_GETHOTSPOTACTIVEBACK:
- return vs.hotspotBackground.AsLong();
+ return vs.hotspotColours.back.AsLong();
case SCI_SETHOTSPOTACTIVEUNDERLINE:
vs.hotspotUnderline = wParam != 0;
@@ -9407,6 +9421,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
pdoc->AddUndoAction(wParam, lParam & UNDO_MAY_COALESCE);
break;
+ case SCI_SETMOUSESELECTIONRECTANGULARSWITCH:
+ mouseSelectionRectangularSwitch = wParam != 0;
+ break;
+
+ case SCI_GETMOUSESELECTIONRECTANGULARSWITCH:
+ return mouseSelectionRectangularSwitch;
+
case SCI_SETMULTIPLESELECTION:
multipleSelection = wParam != 0;
InvalidateCaret();
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h
index cbd11f4..026956e 100644
--- a/scintilla/src/Editor.h
+++ b/scintilla/src/Editor.h
@@ -160,6 +160,13 @@ struct WrapPending {
}
};
+struct PrintParameters {
+ int magnification;
+ int colourMode;
+ WrapMode wrapState;
+ PrintParameters();
+};
+
/**
*/
class Editor : public DocWatcher {
@@ -182,11 +189,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
Point sizeRGBAImage;
float scaleRGBAImage;
- int printMagnification;
- int printColourMode;
- int printWrapState;
+ PrintParameters printParameters;
+
int cursorMode;
- int controlCharSymbol;
// Highlight current folding block
HighlightDelimiter highlightDelimiter;
@@ -214,6 +219,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool endAtLastLine;
int caretSticky;
int marginOptions;
+ bool mouseSelectionRectangularSwitch;
bool multipleSelection;
bool additionalSelectionTyping;
int multiPasteMode;
@@ -231,6 +237,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
LineLayoutCache llc;
PositionCache posCache;
+ SpecialRepresentations reprs;
KeyMap kmap;
@@ -271,8 +278,6 @@ protected: // ScintillaBase subclass needs access to much of Editor
int bracesMatchStyle;
int highlightGuideColumn;
- int theEdge;
-
enum { notPainting, painting, paintAbandoned } paintState;
bool paintAbandonedByStyling;
PRectangle rcPaint;
@@ -308,20 +313,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
int hsEnd;
// Wrapping support
- enum { eWrapNone, eWrapWord, eWrapChar } wrapState;
int wrapWidth;
WrapPending wrapPending;
- int wrapVisualFlags;
- int wrapVisualFlagsLocation;
- int wrapVisualStartIndent;
- int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
bool convertPastes;
- int marginNumberPadding; // the right-side padding of the number margin
- int ctrlCharPadding; // the padding around control character text blobs
- int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
-
Document *pdoc;
Editor();
@@ -332,6 +328,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void InvalidateStyleData();
void InvalidateStyleRedraw();
void RefreshStyleData();
+ void SetRepresentations();
void DropGraphics(bool freeObjects);
void AllocateGraphics();
@@ -424,6 +421,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void InvalidateCaret();
virtual void UpdateSystemCaret();
+ bool Wrapping() const;
void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge);
bool WrapOneLine(Surface *surface, int lineToWrap);
enum wrapScope {wsAll, wsVisible, wsIdle};
@@ -523,7 +521,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void ContainerNeedsUpdate(int flags);
void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false);
- enum { cmSame, cmUpper, cmLower } caseMap;
+ enum { cmSame, cmUpper, cmLower };
virtual std::string CaseMapString(const std::string &s, int caseMapping);
void ChangeCaseOfSelection(int caseMapping);
void LineTranspose();
@@ -569,6 +567,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void DwellEnd(bool mouseMoved);
void MouseLeave();
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
+ void ButtonMoveWithModifiers(Point pt, int modifiers);
void ButtonMove(Point pt);
void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
diff --git a/scintilla/src/ExternalLexer.cxx b/scintilla/src/ExternalLexer.cxx
index fc818ce..4e15c2d 100644
--- a/scintilla/src/ExternalLexer.cxx
+++ b/scintilla/src/ExternalLexer.cxx
@@ -6,8 +6,8 @@
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
+#include <stdio.h>
#include <ctype.h>
#include <assert.h>
diff --git a/scintilla/src/FontQuality.h b/scintilla/src/FontQuality.h
index 46e2c91..a8ee8c9 100644
--- a/scintilla/src/FontQuality.h
+++ b/scintilla/src/FontQuality.h
@@ -5,6 +5,13 @@
// Copyright 1998-2009 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#ifndef FONTQUALITY_H
+#define FONTQUALITY_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
#define SC_EFF_QUALITY_MASK 0xF
#define SC_EFF_QUALITY_DEFAULT 0
#define SC_EFF_QUALITY_NON_ANTIALIASED 1
@@ -13,3 +20,9 @@
#define SCWIN_TECH_GDI 0
#define SCWIN_TECH_DIRECTWRITE 1
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif
diff --git a/scintilla/src/KeyMap.h b/scintilla/src/KeyMap.h
index 3254d7c..63240af 100644
--- a/scintilla/src/KeyMap.h
+++ b/scintilla/src/KeyMap.h
@@ -5,8 +5,8 @@
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
-#ifndef KEYTOCOMMAND_H
-#define KEYTOCOMMAND_H
+#ifndef KEYMAP_H
+#define KEYMAP_H
#ifdef SCI_NAMESPACE
namespace Scintilla {
diff --git a/scintilla/src/LineMarker.h b/scintilla/src/LineMarker.h
index ac3e7e6..c9dfeb7 100644
--- a/scintilla/src/LineMarker.h
+++ b/scintilla/src/LineMarker.h
@@ -12,7 +12,6 @@
namespace Scintilla {
#endif
-
/**
*/
class LineMarker {
diff --git a/scintilla/src/Partitioning.h b/scintilla/src/Partitioning.h
index 01bdf8b..b1c24cc 100644
--- a/scintilla/src/Partitioning.h
+++ b/scintilla/src/Partitioning.h
@@ -8,6 +8,10 @@
#ifndef PARTITIONING_H
#define PARTITIONING_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/// A split vector of integers with a method for adding a value to all elements
/// in a range.
/// Used by the Partitioning class.
@@ -186,4 +190,9 @@ public:
}
};
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx
index cada960..9cd21ed 100644
--- a/scintilla/src/PositionCache.cxx
+++ b/scintilla/src/PositionCache.cxx
@@ -13,6 +13,7 @@
#include <string>
#include <vector>
#include <map>
+#include <algorithm>
#include "Platform.h"
@@ -34,6 +35,7 @@
#include "ILexer.h"
#include "CaseFolder.h"
#include "Document.h"
+#include "UniConversion.h"
#include "Selection.h"
#include "PositionCache.h"
@@ -336,35 +338,75 @@ void LineLayoutCache::Dispose(LineLayout *ll) {
}
}
-void BreakFinder::Insert(int val) {
- if (val >= nextBreak) {
- for (std::vector<int>::iterator it = selAndEdge.begin(); it != selAndEdge.end(); ++it) {
- if (val == *it) {
- return;
- }
- if (val <*it) {
- selAndEdge.insert(it, 1, val);
- return;
- }
- }
- // Not less than any so append
- selAndEdge.push_back(val);
+// Simply pack the (maximum 4) character bytes into an int
+static inline int KeyFromString(const char *charBytes, size_t len) {
+ PLATFORM_ASSERT(len <= 4);
+ int k=0;
+ for (size_t i=0; i<len && charBytes[i]; i++) {
+ k = k * 0x100;
+ k += static_cast<unsigned char>(charBytes[i]);
}
+ return k;
}
-extern bool BadUTF(const char *s, int len, int &trailBytes);
+SpecialRepresentations::SpecialRepresentations() {
+ std::fill(startByteHasReprs, startByteHasReprs+0x100, 0);
+}
+
+void SpecialRepresentations::SetRepresentation(const char *charBytes, const char *value) {
+ MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, UTF8MaxBytes));
+ if (it == mapReprs.end()) {
+ // New entry so increment for first byte
+ startByteHasReprs[static_cast<unsigned char>(charBytes[0])]++;
+ }
+ mapReprs[KeyFromString(charBytes, UTF8MaxBytes)] = value;
+}
-static int NextBadU(const char *s, int p, int len, int &trailBytes) {
- while (p < len) {
- p++;
- if (BadUTF(s + p, len - p, trailBytes))
- return p;
+void SpecialRepresentations::ClearRepresentation(const char *charBytes) {
+ MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, UTF8MaxBytes));
+ if (it != mapReprs.end()) {
+ mapReprs.erase(it);
+ startByteHasReprs[static_cast<unsigned char>(charBytes[0])]--;
+ }
+}
+
+Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) {
+ PLATFORM_ASSERT(len <= 4);
+ if (!startByteHasReprs[static_cast<unsigned char>(charBytes[0])])
+ return 0;
+ MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, len));
+ if (it != mapReprs.end()) {
+ return &(it->second);
+ }
+ return 0;
+}
+
+bool SpecialRepresentations::Contains(const char *charBytes, size_t len) const {
+ PLATFORM_ASSERT(len <= 4);
+ if (!startByteHasReprs[static_cast<unsigned char>(charBytes[0])])
+ return false;
+ MapRepresentation::const_iterator it = mapReprs.find(KeyFromString(charBytes, len));
+ return it != mapReprs.end();
+}
+
+void SpecialRepresentations::Clear() {
+ mapReprs.clear();
+ std::fill(startByteHasReprs, startByteHasReprs+0x100, 0);
+}
+
+void BreakFinder::Insert(int val) {
+ if (val > nextBreak) {
+ const std::vector<int>::iterator it = std::lower_bound(selAndEdge.begin(), selAndEdge.end(), val);
+ if (it == selAndEdge.end()) {
+ selAndEdge.push_back(val);
+ } else if (*it != val) {
+ selAndEdge.insert(it, 1, val);
+ }
}
- return -1;
}
BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_,
- int xStart, bool breakForSelection, Document *pdoc_) :
+ int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_) :
ll(ll_),
lineStart(lineStart_),
lineEnd(lineEnd_),
@@ -373,11 +415,14 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL
saeCurrentPos(0),
saeNext(0),
subBreak(-1),
- pdoc(pdoc_) {
+ pdoc(pdoc_),
+ encodingFamily(pdoc_->CodePageFamily()),
+ preprs(preprs_) {
// Search for first visible break
// First find the first visible character
- nextBreak = ll->FindBefore(xStart, lineStart, lineEnd);
+ if (xStart > 0.0f)
+ nextBreak = ll->FindBefore(xStart, lineStart, lineEnd);
// Now back to a style break
while ((nextBreak > lineStart) && (ll->styles[nextBreak] == ll->styles[nextBreak - 1])) {
nextBreak--;
@@ -391,76 +436,80 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL
SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine);
if (!(portion.start == portion.end)) {
if (portion.start.IsValid())
- Insert(portion.start.Position() - posLineStart - 1);
+ Insert(portion.start.Position() - posLineStart);
if (portion.end.IsValid())
- Insert(portion.end.Position() - posLineStart - 1);
+ Insert(portion.end.Position() - posLineStart);
}
}
}
- Insert(ll->edgeColumn - 1);
- Insert(lineEnd - 1);
-
- if (pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage)) {
- int trailBytes=0;
- for (int pos = -1;;) {
- pos = NextBadU(ll->chars, pos, lineEnd, trailBytes);
- if (pos < 0)
- break;
- Insert(pos-1);
- Insert(pos);
- }
- }
+ Insert(ll->edgeColumn);
+ Insert(lineEnd);
saeNext = (!selAndEdge.empty()) ? selAndEdge[0] : -1;
}
BreakFinder::~BreakFinder() {
}
-int BreakFinder::First() const {
- return nextBreak;
-}
-
-int BreakFinder::Next() {
+TextSegment BreakFinder::Next() {
if (subBreak == -1) {
int prev = nextBreak;
- while (nextBreak < lineEnd) {
- if ((ll->styles[nextBreak] != ll->styles[nextBreak + 1]) ||
- (nextBreak == saeNext) ||
- IsControlCharacter(ll->chars[nextBreak]) || IsControlCharacter(ll->chars[nextBreak + 1])) {
- if (nextBreak == saeNext) {
+ while (nextBreak < lineEnd) {
+ int charWidth = 1;
+ if (encodingFamily == efUnicode)
+ charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(ll->chars) + nextBreak, lineEnd - nextBreak);
+ else if (encodingFamily == efDBCS)
+ charWidth = pdoc->IsDBCSLeadByte(ll->chars[nextBreak]) ? 2 : 1;
+ Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth);
+ if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) ||
+ repr ||
+ (nextBreak == saeNext)) {
+ while ((nextBreak >= saeNext) && (saeNext < lineEnd)) {
saeCurrentPos++;
- saeNext = (saeCurrentPos < selAndEdge.size()) ? selAndEdge[saeCurrentPos] : -1;
+ saeNext = (saeCurrentPos < selAndEdge.size()) ? selAndEdge[saeCurrentPos] : lineEnd;
}
- nextBreak++;
- if ((nextBreak - prev) < lengthStartSubdivision) {
- return nextBreak;
+ if ((nextBreak > prev) || repr) {
+ // Have a segment to report
+ if (nextBreak == prev) {
+ nextBreak += charWidth;
+ } else {
+ repr = 0; // Optimize -> should remember repr
+ }
+ if ((nextBreak - prev) < lengthStartSubdivision) {
+ return TextSegment(prev, nextBreak - prev, repr);
+ } else {
+ break;
+ }
}
- break;
}
- nextBreak++;
+ nextBreak += charWidth;
}
if ((nextBreak - prev) < lengthStartSubdivision) {
- return nextBreak;
+ return TextSegment(prev, nextBreak - prev);
}
subBreak = prev;
}
// Splitting up a long run from prev to nextBreak in lots of approximately lengthEachSubdivision.
// For very long runs add extra breaks after spaces or if no spaces before low punctuation.
+ int startSegment = subBreak;
if ((nextBreak - subBreak) <= lengthEachSubdivision) {
subBreak = -1;
- return nextBreak;
+ return TextSegment(startSegment, nextBreak - startSegment);
} else {
subBreak += pdoc->SafeSegment(ll->chars + subBreak, nextBreak-subBreak, lengthEachSubdivision);
if (subBreak >= nextBreak) {
subBreak = -1;
- return nextBreak;
+ return TextSegment(startSegment, nextBreak - startSegment);
} else {
- return subBreak;
+ return TextSegment(startSegment, subBreak - startSegment);
}
}
}
+bool BreakFinder::More() const {
+ return (subBreak >= 0) || (nextBreak < lineEnd);
+}
+
PositionCacheEntry::PositionCacheEntry() :
styleNumber(0), len(0), clock(0), positions(0) {
}
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h
index 50913f4..bc43915 100644
--- a/scintilla/src/PositionCache.h
+++ b/scintilla/src/PositionCache.h
@@ -113,6 +113,39 @@ public:
void ResetClock();
};
+class Representation {
+public:
+ std::string stringRep;
+ Representation(const char *value="") : stringRep(value) {
+ }
+};
+
+typedef std::map<int, Representation> MapRepresentation;
+
+class SpecialRepresentations {
+ MapRepresentation mapReprs;
+ short startByteHasReprs[0x100];
+public:
+ SpecialRepresentations();
+ void SetRepresentation(const char *charBytes, const char *value);
+ void ClearRepresentation(const char *charBytes);
+ Representation *RepresentationFromCharacter(const char *charBytes, size_t len);
+ bool Contains(const char *charBytes, size_t len) const;
+ void Clear();
+};
+
+struct TextSegment {
+ int start;
+ int length;
+ Representation *representation;
+ TextSegment(int start_=0, int length_=0, Representation *representation_=0) :
+ start(start_), length(length_), representation(representation_) {
+ }
+ int end() const {
+ return start + length;
+ }
+};
+
// Class to break a line of text into shorter runs at sensible places.
class BreakFinder {
LineLayout *ll;
@@ -125,6 +158,8 @@ class BreakFinder {
int saeNext;
int subBreak;
Document *pdoc;
+ EncodingFamily encodingFamily;
+ SpecialRepresentations *preprs;
void Insert(int val);
// Private so BreakFinder objects can not be copied
BreakFinder(const BreakFinder &);
@@ -135,10 +170,10 @@ public:
// Try to make each subdivided run lengthEachSubdivision or shorter.
enum { lengthEachSubdivision = 100 };
BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_,
- int xStart, bool breakForSelection, Document *pdoc_);
+ int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_);
~BreakFinder();
- int First() const;
- int Next();
+ TextSegment Next();
+ bool More() const;
};
class PositionCache {
diff --git a/scintilla/src/RunStyles.cxx b/scintilla/src/RunStyles.cxx
index 56aca40..733cc0b 100644
--- a/scintilla/src/RunStyles.cxx
+++ b/scintilla/src/RunStyles.cxx
@@ -4,12 +4,13 @@
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
-#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
#include <stdarg.h>
#include <stdexcept>
+#include <algorithm>
#include "Platform.h"
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx
index 10c9260..53b05a0 100644
--- a/scintilla/src/ScintillaBase.cxx
+++ b/scintilla/src/ScintillaBase.cxx
@@ -262,7 +262,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
ac.lb->SetAverageCharWidth(aveCharWidth);
ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this);
- ac.SetList(list);
+ ac.SetList(list ? list : "");
// Fiddle the position of the list so it is right next to the target and wide enough for all its strings
PRectangle rcList = ac.lb->GetDesiredRect();
diff --git a/scintilla/src/SplitVector.h b/scintilla/src/SplitVector.h
index 5b8876c..c52e84b 100644
--- a/scintilla/src/SplitVector.h
+++ b/scintilla/src/SplitVector.h
@@ -9,6 +9,10 @@
#ifndef SPLITVECTOR_H
#define SPLITVECTOR_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
template <typename T>
class SplitVector {
protected:
@@ -280,4 +284,8 @@ public:
}
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
diff --git a/scintilla/src/UniConversion.cxx b/scintilla/src/UniConversion.cxx
index ed26c5c..8ec1bc4 100644
--- a/scintilla/src/UniConversion.cxx
+++ b/scintilla/src/UniConversion.cxx
@@ -9,6 +9,14 @@
#include "UniConversion.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
enum { SURROGATE_LEAD_FIRST = 0xD800 };
enum { SURROGATE_TRAIL_FIRST = 0xDC00 };
enum { SURROGATE_TRAIL_LAST = 0xDFFF };
@@ -246,3 +254,12 @@ int UTF8Classify(const unsigned char *us, int len) {
return UTF8MaskInvalid | 1;
}
}
+
+int UTF8DrawBytes(const unsigned char *us, int len) {
+ int utf8StatusNext = UTF8Classify(us, len);
+ return (utf8StatusNext & UTF8MaskInvalid) ? 1 : (utf8StatusNext & UTF8MaskWidth);
+}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
diff --git a/scintilla/src/UniConversion.h b/scintilla/src/UniConversion.h
index 1f1e537..573ff28 100644
--- a/scintilla/src/UniConversion.h
+++ b/scintilla/src/UniConversion.h
@@ -5,6 +5,13 @@
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#ifndef UNICONVERSION_H
+#define UNICONVERSION_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
const int UTF8MaxBytes = 4;
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen);
@@ -27,6 +34,10 @@ inline bool UTF8IsAscii(int ch) {
enum { UTF8MaskWidth=0x7, UTF8MaskInvalid=0x8 };
int UTF8Classify(const unsigned char *us, int len);
+// Similar to UTF8Classify but returns a length of 1 for invalid bytes
+// instead of setting the invalid flag
+int UTF8DrawBytes(const unsigned char *us, int len);
+
// Line separator is U+2028 \xe2\x80\xa8
// Paragraph separator is U+2029 \xe2\x80\xa9
const int UTF8SeparatorLength = 3;
@@ -39,3 +50,9 @@ const int UTF8NELLength = 2;
inline bool UTF8IsNEL(const unsigned char *us) {
return (us[0] == 0xc2) && (us[1] == 0x85);
}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif
diff --git a/scintilla/src/UnicodeFromUTF8.h b/scintilla/src/UnicodeFromUTF8.h
index 24517e8..ae66cb0 100644
--- a/scintilla/src/UnicodeFromUTF8.h
+++ b/scintilla/src/UnicodeFromUTF8.h
@@ -5,6 +5,13 @@
// Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
// This file is in the public domain.
+#ifndef UNICODEFROMUTF8_H
+#define UNICODEFROMUTF8_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
inline int UnicodeFromUTF8(const unsigned char *us) {
if (us[0] < 0xC2) {
return us[0];
@@ -17,3 +24,9 @@ inline int UnicodeFromUTF8(const unsigned char *us) {
}
return us[0];
}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx
index 4b99771..4ac2b8e 100644
--- a/scintilla/src/ViewStyle.cxx
+++ b/scintilla/src/ViewStyle.cxx
@@ -104,33 +104,24 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
indicators[ind] = source.indicators[ind];
}
- selforeset = source.selforeset;
- selforeground = source.selforeground;
+ selColours = source.selColours;
selAdditionalForeground = source.selAdditionalForeground;
- selbackset = source.selbackset;
- selbackground = source.selbackground;
selAdditionalBackground = source.selAdditionalBackground;
- selbackground2 = source.selbackground2;
+ selBackground2 = source.selBackground2;
selAlpha = source.selAlpha;
selAdditionalAlpha = source.selAdditionalAlpha;
selEOLFilled = source.selEOLFilled;
- foldmarginColourSet = source.foldmarginColourSet;
foldmarginColour = source.foldmarginColour;
- foldmarginHighlightColourSet = source.foldmarginHighlightColourSet;
foldmarginHighlightColour = source.foldmarginHighlightColour;
- hotspotForegroundSet = source.hotspotForegroundSet;
- hotspotForeground = source.hotspotForeground;
- hotspotBackgroundSet = source.hotspotBackgroundSet;
- hotspotBackground = source.hotspotBackground;
+ hotspotColours = source.hotspotColours;
hotspotUnderline = source.hotspotUnderline;
hotspotSingleLine = source.hotspotSingleLine;
- whitespaceForegroundSet = source.whitespaceForegroundSet;
- whitespaceForeground = source.whitespaceForeground;
- whitespaceBackgroundSet = source.whitespaceBackgroundSet;
- whitespaceBackground = source.whitespaceBackground;
+ whitespaceColours = source.whitespaceColours;
+ controlCharSymbol = source.controlCharSymbol;
+ controlCharWidth = source.controlCharWidth;
selbar = source.selbar;
selbarlight = source.selbarlight;
caretcolour = source.caretcolour;
@@ -169,6 +160,18 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
braceHighlightIndicator = source.braceHighlightIndicator;
braceBadLightIndicatorSet = source.braceBadLightIndicatorSet;
braceBadLightIndicator = source.braceBadLightIndicator;
+
+ theEdge = source.theEdge;
+
+ marginNumberPadding = source.marginNumberPadding;
+ ctrlCharPadding = source.ctrlCharPadding;
+ lastSegItalicsOffset = source.lastSegItalicsOffset;
+
+ wrapState = source.wrapState;
+ wrapVisualFlags = source.wrapVisualFlags;
+ wrapVisualFlagsLocation = source.wrapVisualFlagsLocation;
+ wrapVisualStartIndent = source.wrapVisualStartIndent;
+ wrapIndentMode = source.wrapIndentMode;
}
ViewStyle::~ViewStyle() {
@@ -204,27 +207,24 @@ void ViewStyle::Init(size_t stylesSize_) {
maxDescent = 1;
aveCharWidth = 8;
spaceWidth = 8;
+ tabWidth = spaceWidth * 8;
- selforeset = false;
- selforeground = ColourDesired(0xff, 0, 0);
+ selColours.fore = ColourOptional(ColourDesired(0xff, 0, 0));
+ selColours.back = ColourOptional(ColourDesired(0xc0, 0xc0, 0xc0), true);
selAdditionalForeground = ColourDesired(0xff, 0, 0);
- selbackset = true;
- selbackground = ColourDesired(0xc0, 0xc0, 0xc0);
selAdditionalBackground = ColourDesired(0xd7, 0xd7, 0xd7);
- selbackground2 = ColourDesired(0xb0, 0xb0, 0xb0);
+ selBackground2 = ColourDesired(0xb0, 0xb0, 0xb0);
selAlpha = SC_ALPHA_NOALPHA;
selAdditionalAlpha = SC_ALPHA_NOALPHA;
selEOLFilled = false;
- foldmarginColourSet = false;
- foldmarginColour = ColourDesired(0xff, 0, 0);
- foldmarginHighlightColourSet = false;
- foldmarginHighlightColour = ColourDesired(0xc0, 0xc0, 0xc0);
+ foldmarginColour = ColourOptional(ColourDesired(0xff, 0, 0));
+ foldmarginHighlightColour = ColourOptional(ColourDesired(0xc0, 0xc0, 0xc0));
- whitespaceForegroundSet = false;
- whitespaceForeground = ColourDesired(0, 0, 0);
- whitespaceBackgroundSet = false;
- whitespaceBackground = ColourDesired(0xff, 0xff, 0xff);
+ whitespaceColours.fore = ColourOptional();
+ whitespaceColours.back = ColourOptional(ColourDesired(0xff, 0xff, 0xff));
+ controlCharSymbol = 0; /* Draw the control characters */
+ controlCharWidth = 0;
selbar = Platform::Chrome();
selbarlight = Platform::ChromeHighlight();
styles[STYLE_LINENUMBER].fore = ColourDesired(0, 0, 0);
@@ -242,10 +242,8 @@ void ViewStyle::Init(size_t stylesSize_) {
someStylesProtected = false;
someStylesForceCase = false;
- hotspotForegroundSet = false;
- hotspotForeground = ColourDesired(0, 0, 0xff);
- hotspotBackgroundSet = false;
- hotspotBackground = ColourDesired(0xff, 0xff, 0xff);
+ hotspotColours.fore = ColourOptional(ColourDesired(0, 0, 0xff));
+ hotspotColours.back = ColourOptional(ColourDesired(0xff, 0xff, 0xff));
hotspotUnderline = true;
hotspotSingleLine = true;
@@ -284,9 +282,21 @@ void ViewStyle::Init(size_t stylesSize_) {
braceHighlightIndicator = 0;
braceBadLightIndicatorSet = false;
braceBadLightIndicator = 0;
+
+ theEdge = 0;
+
+ marginNumberPadding = 3;
+ ctrlCharPadding = 3; // +3 For a blank on front and rounded edge each side
+ lastSegItalicsOffset = 2;
+
+ wrapState = eWrapNone;
+ wrapVisualFlags = 0;
+ wrapVisualFlagsLocation = 0;
+ wrapVisualStartIndent = 0;
+ wrapIndentMode = SC_WRAPINDENT_FIXED;
}
-void ViewStyle::Refresh(Surface &surface) {
+void ViewStyle::Refresh(Surface &surface, int tabInChars) {
for (FontMap::iterator it = fonts.begin(); it != fonts.end(); ++it) {
delete it->second;
}
@@ -332,6 +342,12 @@ void ViewStyle::Refresh(Surface &surface) {
aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
spaceWidth = styles[STYLE_DEFAULT].spaceWidth;
+ tabWidth = spaceWidth * tabInChars;
+
+ controlCharWidth = 0.0;
+ if (controlCharSymbol >= 32) {
+ controlCharWidth = surface.WidthChar(styles[STYLE_CONTROLCHAR].font, controlCharSymbol);
+ }
fixedColumnWidth = marginInside ? leftMarginWidth : 0;
maskInLine = 0xffffffff;
@@ -350,6 +366,10 @@ void ViewStyle::ReleaseAllExtendedStyles() {
int ViewStyle::AllocateExtendedStyles(int numberStyles) {
int startRange = static_cast<int>(nextExtendedStyle);
nextExtendedStyle += numberStyles;
+ EnsureStyle(nextExtendedStyle);
+ for (size_t i=startRange; i<nextExtendedStyle; i++) {
+ styles[i].ClearTo(styles[STYLE_DEFAULT]);
+ }
return startRange;
}
@@ -389,6 +409,10 @@ bool ViewStyle::ProtectionActive() const {
return someStylesProtected;
}
+int ViewStyle::ExternalMarginWidth() const {
+ return marginInside ? 0 : fixedColumnWidth;
+}
+
bool ViewStyle::ValidStyle(size_t styleIndex) const {
return styleIndex < styles.size();
}
@@ -409,6 +433,55 @@ void ViewStyle::CalcLargestMarkerHeight() {
}
}
+ColourDesired ViewStyle::WrapColour() const {
+ if (whitespaceColours.fore.isSet)
+ return whitespaceColours.fore;
+ else
+ return styles[STYLE_DEFAULT].fore;
+}
+
+bool ViewStyle::SetWrapState(int wrapState_) {
+ WrapMode wrapStateWanted;
+ switch (wrapState_) {
+ case SC_WRAP_WORD:
+ wrapStateWanted = eWrapWord;
+ break;
+ case SC_WRAP_CHAR:
+ wrapStateWanted = eWrapChar;
+ break;
+ default:
+ wrapStateWanted = eWrapNone;
+ break;
+ }
+ bool changed = wrapState != wrapStateWanted;
+ wrapState = wrapStateWanted;
+ return changed;
+}
+
+bool ViewStyle::SetWrapVisualFlags(int wrapVisualFlags_) {
+ bool changed = wrapVisualFlags != wrapVisualFlags_;
+ wrapVisualFlags = wrapVisualFlags_;
+ return changed;
+}
+
+bool ViewStyle::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) {
+ bool changed = wrapVisualFlagsLocation != wrapVisualFlagsLocation_;
+ wrapVisualFlagsLocation = wrapVisualFlagsLocation_;
+ return changed;
+}
+
+bool ViewStyle::SetWrapVisualStartIndent(int wrapVisualStartIndent_) {
+ bool changed = wrapVisualStartIndent != wrapVisualStartIndent_;
+ wrapVisualStartIndent = wrapVisualStartIndent_;
+ return changed;
+}
+
+bool ViewStyle::SetWrapIndentMode(int wrapIndentMode_) {
+ bool changed = wrapIndentMode != wrapIndentMode_;
+ wrapIndentMode = wrapIndentMode_;
+ return changed;
+}
+
void ViewStyle::AllocStyles(size_t sizeNew) {
size_t i=styles.size();
styles.resize(sizeNew);
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h
index 2288a64..f795993 100644
--- a/scintilla/src/ViewStyle.h
+++ b/scintilla/src/ViewStyle.h
@@ -56,6 +56,22 @@ enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterInden
typedef std::map<FontSpecification, FontRealised *> FontMap;
+enum WrapMode { eWrapNone, eWrapWord, eWrapChar };
+
+class ColourOptional : public ColourDesired {
+public:
+ bool isSet;
+ ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) : ColourDesired(colour_), isSet(isSet_) {
+ }
+ ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(lParam), isSet(wParam != 0) {
+ }
+};
+
+struct ForeBackColours {
+ ColourOptional fore;
+ ColourOptional back;
+};
+
/**
*/
class ViewStyle {
@@ -73,30 +89,22 @@ public:
unsigned int maxDescent;
XYPOSITION aveCharWidth;
XYPOSITION spaceWidth;
- bool selforeset;
- ColourDesired selforeground;
+ XYPOSITION tabWidth;
+ ForeBackColours selColours;
ColourDesired selAdditionalForeground;
- bool selbackset;
- ColourDesired selbackground;
ColourDesired selAdditionalBackground;
- ColourDesired selbackground2;
+ ColourDesired selBackground2;
int selAlpha;
int selAdditionalAlpha;
bool selEOLFilled;
- bool whitespaceForegroundSet;
- ColourDesired whitespaceForeground;
- bool whitespaceBackgroundSet;
- ColourDesired whitespaceBackground;
+ ForeBackColours whitespaceColours;
+ int controlCharSymbol;
+ XYPOSITION controlCharWidth;
ColourDesired selbar;
ColourDesired selbarlight;
- bool foldmarginColourSet;
- ColourDesired foldmarginColour;
- bool foldmarginHighlightColourSet;
- ColourDesired foldmarginHighlightColour;
- bool hotspotForegroundSet;
- ColourDesired hotspotForeground;
- bool hotspotBackgroundSet;
- ColourDesired hotspotBackground;
+ ColourOptional foldmarginColour;
+ ColourOptional foldmarginHighlightColour;
+ ForeBackColours hotspotColours;
bool hotspotUnderline;
bool hotspotSingleLine;
/// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
@@ -134,12 +142,23 @@ public:
int braceHighlightIndicator;
bool braceBadLightIndicatorSet;
int braceBadLightIndicator;
+ int theEdge;
+ int marginNumberPadding; // the right-side padding of the number margin
+ int ctrlCharPadding; // the padding around control character text blobs
+ int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
+
+ // Wrapping support
+ WrapMode wrapState;
+ int wrapVisualFlags;
+ int wrapVisualFlagsLocation;
+ int wrapVisualStartIndent;
+ int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
ViewStyle();
ViewStyle(const ViewStyle &source);
~ViewStyle();
void Init(size_t stylesSize_=64);
- void Refresh(Surface &surface);
+ void Refresh(Surface &surface, int tabInChars);
void ReleaseAllExtendedStyles();
int AllocateExtendedStyles(int numberStyles);
void EnsureStyle(size_t index);
@@ -147,8 +166,16 @@ public:
void ClearStyles();
void SetStyleFontName(int styleIndex, const char *name);
bool ProtectionActive() const;
+ int ExternalMarginWidth() const;
bool ValidStyle(size_t styleIndex) const;
void CalcLargestMarkerHeight();
+ ColourDesired WrapColour() const;
+ bool SetWrapState(int wrapState_);
+ bool SetWrapVisualFlags(int wrapVisualFlags_);
+ bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_);
+ bool SetWrapVisualStartIndent(int wrapVisualStartIndent_);
+ bool SetWrapIndentMode(int wrapIndentMode_);
+
private:
void AllocStyles(size_t sizeNew);
void CreateFont(const FontSpecification &fs);
diff --git a/scintilla/src/XPM.cxx b/scintilla/src/XPM.cxx
index 59fa2c2..eeadce9 100644
--- a/scintilla/src/XPM.cxx
+++ b/scintilla/src/XPM.cxx
@@ -5,8 +5,8 @@
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <vector>
#include <map>