Update Scintilla from 3.5.2 to 3.5.5

This commit is contained in:
ARATA Mizuki 2015-04-25 23:49:22 +09:00 committed by Vadim Zeitlin
parent 4ce52bc7a2
commit 28e80e5b58
52 changed files with 3372 additions and 966 deletions

View File

@ -261,6 +261,7 @@ WXSCINTILLA_OBJECTS = \
wxscintilla_LexGAP.o \
wxscintilla_LexGui4Cli.o \
wxscintilla_LexHaskell.o \
wxscintilla_LexHex.o \
wxscintilla_LexHTML.o \
wxscintilla_LexInno.o \
wxscintilla_LexKix.o \
@ -17140,6 +17141,9 @@ wxscintilla_LexGui4Cli.o: $(srcdir)/src/stc/scintilla/lexers/LexGui4Cli.cxx
wxscintilla_LexHaskell.o: $(srcdir)/src/stc/scintilla/lexers/LexHaskell.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexHaskell.cxx
wxscintilla_LexHex.o: $(srcdir)/src/stc/scintilla/lexers/LexHex.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexHex.cxx
wxscintilla_LexHTML.o: $(srcdir)/src/stc/scintilla/lexers/LexHTML.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexHTML.cxx

View File

@ -94,6 +94,7 @@
src/stc/scintilla/lexers/LexGAP.cxx
src/stc/scintilla/lexers/LexGui4Cli.cxx
src/stc/scintilla/lexers/LexHaskell.cxx
src/stc/scintilla/lexers/LexHex.cxx
src/stc/scintilla/lexers/LexHTML.cxx
src/stc/scintilla/lexers/LexInno.cxx
src/stc/scintilla/lexers/LexKix.cxx

View File

@ -242,6 +242,7 @@ WXSCINTILLA_OBJECTS = \
$(OBJS)\wxscintilla_LexGAP.obj \
$(OBJS)\wxscintilla_LexGui4Cli.obj \
$(OBJS)\wxscintilla_LexHaskell.obj \
$(OBJS)\wxscintilla_LexHex.obj \
$(OBJS)\wxscintilla_LexHTML.obj \
$(OBJS)\wxscintilla_LexInno.obj \
$(OBJS)\wxscintilla_LexKix.obj \
@ -6022,6 +6023,9 @@ $(OBJS)\wxscintilla_LexGui4Cli.obj: ..\..\src\stc\scintilla\lexers\LexGui4Cli.cx
$(OBJS)\wxscintilla_LexHaskell.obj: ..\..\src\stc\scintilla\lexers\LexHaskell.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\lexers\LexHaskell.cxx
$(OBJS)\wxscintilla_LexHex.obj: ..\..\src\stc\scintilla\lexers\LexHex.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\lexers\LexHex.cxx
$(OBJS)\wxscintilla_LexHTML.obj: ..\..\src\stc\scintilla\lexers\LexHTML.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\lexers\LexHTML.cxx

View File

@ -230,6 +230,7 @@ WXSCINTILLA_OBJECTS = \
$(OBJS)\wxscintilla_LexGAP.o \
$(OBJS)\wxscintilla_LexGui4Cli.o \
$(OBJS)\wxscintilla_LexHaskell.o \
$(OBJS)\wxscintilla_LexHex.o \
$(OBJS)\wxscintilla_LexHTML.o \
$(OBJS)\wxscintilla_LexInno.o \
$(OBJS)\wxscintilla_LexKix.o \
@ -6197,6 +6198,9 @@ $(OBJS)\wxscintilla_LexGui4Cli.o: ../../src/stc/scintilla/lexers/LexGui4Cli.cxx
$(OBJS)\wxscintilla_LexHaskell.o: ../../src/stc/scintilla/lexers/LexHaskell.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexHex.o: ../../src/stc/scintilla/lexers/LexHex.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexHTML.o: ../../src/stc/scintilla/lexers/LexHTML.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<

View File

@ -253,6 +253,7 @@ WXSCINTILLA_OBJECTS = \
$(OBJS)\wxscintilla_LexGAP.obj \
$(OBJS)\wxscintilla_LexGui4Cli.obj \
$(OBJS)\wxscintilla_LexHaskell.obj \
$(OBJS)\wxscintilla_LexHex.obj \
$(OBJS)\wxscintilla_LexHTML.obj \
$(OBJS)\wxscintilla_LexInno.obj \
$(OBJS)\wxscintilla_LexKix.obj \
@ -6714,6 +6715,9 @@ $(OBJS)\wxscintilla_LexGui4Cli.obj: ..\..\src\stc\scintilla\lexers\LexGui4Cli.cx
$(OBJS)\wxscintilla_LexHaskell.obj: ..\..\src\stc\scintilla\lexers\LexHaskell.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\lexers\LexHaskell.cxx
$(OBJS)\wxscintilla_LexHex.obj: ..\..\src\stc\scintilla\lexers\LexHex.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\lexers\LexHex.cxx
$(OBJS)\wxscintilla_LexHTML.obj: ..\..\src\stc\scintilla\lexers\LexHTML.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\lexers\LexHTML.cxx

View File

@ -421,6 +421,9 @@
<File
RelativePath="..\..\src\stc\scintilla\lexers\LexHaskell.cxx">
</File>
<File
RelativePath="..\..\src\stc\scintilla\lexers\LexHex.cxx">
</File>
<File
RelativePath="..\..\src\stc\scintilla\lexers\LexInno.cxx">
</File>

View File

@ -910,6 +910,10 @@
RelativePath="..\..\src\stc\scintilla\lexers\LexHaskell.cxx"
>
</File>
<File
RelativePath="..\..\src\stc\scintilla\lexers\LexHex.cxx"
>
</File>
<File
RelativePath="..\..\src\stc\scintilla\lexers\LexInno.cxx"
>

View File

@ -906,6 +906,10 @@
RelativePath="..\..\src\stc\scintilla\lexers\LexHaskell.cxx"
>
</File>
<File
RelativePath="..\..\src\stc\scintilla\lexers\LexHex.cxx"
>
</File>
<File
RelativePath="..\..\src\stc\scintilla\lexers\LexInno.cxx"
>

View File

@ -192,6 +192,9 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar;
#define wxSTC_INDIC_DOTBOX 12
#define wxSTC_INDIC_SQUIGGLEPIXMAP 13
#define wxSTC_INDIC_COMPOSITIONTHICK 14
#define wxSTC_INDIC_COMPOSITIONTHIN 15
#define wxSTC_INDIC_FULLBOX 16
#define wxSTC_INDIC_TEXTFORE 17
#define wxSTC_INDIC_IME 32
#define wxSTC_INDIC_IME_MAX 35
#define wxSTC_INDIC_MAX 35
@ -200,6 +203,9 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar;
#define wxSTC_INDIC1_MASK 0x40
#define wxSTC_INDIC2_MASK 0x80
#define wxSTC_INDICS_MASK 0xE0
#define wxSTC_INDICVALUEBIT 0x1000000
#define wxSTC_INDICVALUEMASK 0xFFFFFF
#define wxSTC_INDICFLAG_VALUEFORE 1
#define wxSTC_IV_NONE 0
#define wxSTC_IV_REAL 1
#define wxSTC_IV_LOOKFORWARD 2
@ -539,6 +545,9 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar;
#define wxSTC_LEX_DMIS 114
#define wxSTC_LEX_REGISTRY 115
#define wxSTC_LEX_BIBTEX 116
#define wxSTC_LEX_SREC 117
#define wxSTC_LEX_IHEX 118
#define wxSTC_LEX_TEHEX 119
/// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
/// value assigned in sequence from SCLEX_AUTOMATIC+1.
@ -1422,6 +1431,11 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar;
#define wxSTC_V_IDENTIFIER 11
#define wxSTC_V_STRINGEOL 12
#define wxSTC_V_USER 19
#define wxSTC_V_COMMENT_WORD 20
#define wxSTC_V_INPUT 21
#define wxSTC_V_OUTPUT 22
#define wxSTC_V_INOUT 23
#define wxSTC_V_PORT_CONNECT 24
/// Lexical states for SCLEX_KIX
#define wxSTC_KIX_DEFAULT 0
@ -2366,6 +2380,27 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar;
#define wxSTC_BIBTEX_VALUE 5
#define wxSTC_BIBTEX_COMMENT 6
/// Lexical state for SCLEX_SREC
#define wxSTC_HEX_DEFAULT 0
#define wxSTC_HEX_RECSTART 1
#define wxSTC_HEX_RECTYPE 2
#define wxSTC_HEX_RECTYPE_UNKNOWN 3
#define wxSTC_HEX_BYTECOUNT 4
#define wxSTC_HEX_BYTECOUNT_WRONG 5
#define wxSTC_HEX_NOADDRESS 6
#define wxSTC_HEX_DATAADDRESS 7
#define wxSTC_HEX_RECCOUNT 8
#define wxSTC_HEX_STARTADDRESS 9
#define wxSTC_HEX_ADDRESSFIELD_UNKNOWN 10
#define wxSTC_HEX_EXTENDEDADDRESS 11
#define wxSTC_HEX_DATA_ODD 12
#define wxSTC_HEX_DATA_EVEN 13
#define wxSTC_HEX_DATA_UNKNOWN 14
#define wxSTC_HEX_DATA_EMPTY 15
#define wxSTC_HEX_CHECKSUM 16
#define wxSTC_HEX_CHECKSUM_WRONG 17
#define wxSTC_HEX_GARBAGE 18
//}}}
//----------------------------------------------------------------------
@ -2813,6 +2848,7 @@ public:
// Retrieve the text of the line containing the caret.
// Returns the index of the caret on the line.
// Result is NUL-terminated.
#ifdef SWIG
wxString GetCurLine(int* OUTPUT);
#else
@ -3108,6 +3144,24 @@ public:
// Retrieve whether indicator drawn under or over text.
bool IndicatorGetUnder(int indic) const;
// Set a hover indicator to plain, squiggle or TT.
void IndicatorSetHoverStyle(int indic, int style);
// Retrieve the hover style of an indicator.
int IndicatorGetHoverStyle(int indic) const;
// Set the foreground hover colour of an indicator.
void IndicatorSetHoverForeground(int indic, const wxColour& fore);
// Retrieve the foreground hover colour of an indicator.
wxColour IndicatorGetHoverForeground(int indic) const;
// Set the attributes of an indicator.
void IndicatorSetFlags(int indic, int flags);
// Retrieve the attributes of an indicator.
int IndicatorGetFlags(int indic) const;
// Set the foreground colour of all whitespace and whether to use this setting.
void SetWhitespaceForeground(bool useSetting, const wxColour& fore);
@ -3466,6 +3520,12 @@ public:
// Get the position that ends the target.
int GetTargetEnd() const;
// Sets both the start and end of the target in one call.
void SetTargetRange(int start, int end);
// Retrieve the text in the target.
wxString GetTargetText() const;
// Replace the target text with the argument text.
// Text is counted so it can contain NULs.
// Returns the length of the replacement text.
@ -3719,6 +3779,7 @@ public:
int GetMultiPaste() const;
// Retrieve the value of a tag from a regular expression search.
// Result is NUL-terminated.
wxString GetTag(int tagNumber) const;
// Make the target range start and end be the same as the selection range start and end.
@ -4322,12 +4383,6 @@ public:
// the range of a call to GetRangePointer.
int GetGapPosition() const;
// Always interpret keyboard input as Unicode
void SetKeysUnicode(bool keysUnicode);
// Are keys always interpreted as Unicode?
bool GetKeysUnicode() const;
// Set the alpha fill colour of the given indicator.
void IndicatorSetAlpha(int indicator, int alpha);
@ -4637,6 +4692,7 @@ public:
void SetRepresentation(const wxString& encodedCharacter, const wxString& representation);
// Set the way a character is drawn.
// Result is NUL-terminated.
wxString GetRepresentation(const wxString& encodedCharacter) const;
// Remove a character representation.
@ -4684,15 +4740,18 @@ public:
void* PrivateLexerCall(int operation, void* pointer);
// Retrieve a '\n' separated list of properties understood by the current lexer.
// Result is NUL-terminated.
wxString PropertyNames() const;
// Retrieve the type of a property.
int PropertyType(const wxString& name);
// Describe a property.
// Result is NUL-terminated.
wxString DescribeProperty(const wxString& name) const;
// Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
// Result is NUL-terminated.
wxString DescribeKeyWordSets() const;
// Bit set of LineEndType enumertion for which line ends beyond the standard
@ -4725,6 +4784,7 @@ public:
int DistanceToSecondaryStyles() const;
// Get the set of base styles that can be extended with sub styles
// Result is NUL-terminated.
wxString GetSubStyleBases() const;
//}}}

View File

@ -148,6 +148,9 @@
#define wxSTC_INDIC_DOTBOX 12
#define wxSTC_INDIC_SQUIGGLEPIXMAP 13
#define wxSTC_INDIC_COMPOSITIONTHICK 14
#define wxSTC_INDIC_COMPOSITIONTHIN 15
#define wxSTC_INDIC_FULLBOX 16
#define wxSTC_INDIC_TEXTFORE 17
#define wxSTC_INDIC_IME 32
#define wxSTC_INDIC_IME_MAX 35
#define wxSTC_INDIC_MAX 35
@ -156,6 +159,9 @@
#define wxSTC_INDIC1_MASK 0x40
#define wxSTC_INDIC2_MASK 0x80
#define wxSTC_INDICS_MASK 0xE0
#define wxSTC_INDICVALUEBIT 0x1000000
#define wxSTC_INDICVALUEMASK 0xFFFFFF
#define wxSTC_INDICFLAG_VALUEFORE 1
#define wxSTC_IV_NONE 0
#define wxSTC_IV_REAL 1
#define wxSTC_IV_LOOKFORWARD 2
@ -495,6 +501,9 @@
#define wxSTC_LEX_DMIS 114
#define wxSTC_LEX_REGISTRY 115
#define wxSTC_LEX_BIBTEX 116
#define wxSTC_LEX_SREC 117
#define wxSTC_LEX_IHEX 118
#define wxSTC_LEX_TEHEX 119
/// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
/// value assigned in sequence from SCLEX_AUTOMATIC+1.
@ -1378,6 +1387,11 @@
#define wxSTC_V_IDENTIFIER 11
#define wxSTC_V_STRINGEOL 12
#define wxSTC_V_USER 19
#define wxSTC_V_COMMENT_WORD 20
#define wxSTC_V_INPUT 21
#define wxSTC_V_OUTPUT 22
#define wxSTC_V_INOUT 23
#define wxSTC_V_PORT_CONNECT 24
/// Lexical states for SCLEX_KIX
#define wxSTC_KIX_DEFAULT 0
@ -2322,6 +2336,27 @@
#define wxSTC_BIBTEX_VALUE 5
#define wxSTC_BIBTEX_COMMENT 6
/// Lexical state for SCLEX_SREC
#define wxSTC_HEX_DEFAULT 0
#define wxSTC_HEX_RECSTART 1
#define wxSTC_HEX_RECTYPE 2
#define wxSTC_HEX_RECTYPE_UNKNOWN 3
#define wxSTC_HEX_BYTECOUNT 4
#define wxSTC_HEX_BYTECOUNT_WRONG 5
#define wxSTC_HEX_NOADDRESS 6
#define wxSTC_HEX_DATAADDRESS 7
#define wxSTC_HEX_RECCOUNT 8
#define wxSTC_HEX_STARTADDRESS 9
#define wxSTC_HEX_ADDRESSFIELD_UNKNOWN 10
#define wxSTC_HEX_EXTENDEDADDRESS 11
#define wxSTC_HEX_DATA_ODD 12
#define wxSTC_HEX_DATA_EVEN 13
#define wxSTC_HEX_DATA_UNKNOWN 14
#define wxSTC_HEX_DATA_EMPTY 15
#define wxSTC_HEX_CHECKSUM 16
#define wxSTC_HEX_CHECKSUM_WRONG 17
#define wxSTC_HEX_GARBAGE 18
//}}}
// Commands that can be bound to keystrokes {{{
@ -2906,6 +2941,7 @@ public:
/**
Retrieve the text of the line containing the caret.
Returns the index of the caret on the line.
Result is NUL-terminated.
*/
wxString GetCurLine(int* linePos=NULL);
@ -3384,6 +3420,36 @@ public:
*/
bool IndicatorGetUnder(int indic) const;
/**
Set a hover indicator to plain, squiggle or TT.
*/
void IndicatorSetHoverStyle(int indic, int style);
/**
Retrieve the hover style of an indicator.
*/
int IndicatorGetHoverStyle(int indic) const;
/**
Set the foreground hover colour of an indicator.
*/
void IndicatorSetHoverForeground(int indic, const wxColour& fore);
/**
Retrieve the foreground hover colour of an indicator.
*/
wxColour IndicatorGetHoverForeground(int indic) const;
/**
Set the attributes of an indicator.
*/
void IndicatorSetFlags(int indic, int flags);
/**
Retrieve the attributes of an indicator.
*/
int IndicatorGetFlags(int indic) const;
/**
Set the foreground colour of all whitespace and whether to use this setting.
*/
@ -3964,6 +4030,16 @@ public:
*/
int GetTargetEnd() const;
/**
Sets both the start and end of the target in one call.
*/
void SetTargetRange(int start, int end);
/**
Retrieve the text in the target.
*/
wxString GetTargetText() const;
/**
Replace the target text with the argument text.
Text is counted so it can contain NULs.
@ -4372,6 +4448,7 @@ public:
/**
Retrieve the value of a tag from a regular expression search.
Result is NUL-terminated.
*/
wxString GetTag(int tagNumber) const;
@ -5346,16 +5423,6 @@ public:
*/
int GetGapPosition() const;
/**
Always interpret keyboard input as Unicode
*/
void SetKeysUnicode(bool keysUnicode);
/**
Are keys always interpreted as Unicode?
*/
bool GetKeysUnicode() const;
/**
Set the alpha fill colour of the given indicator.
*/
@ -5852,6 +5919,7 @@ public:
/**
Set the way a character is drawn.
Result is NUL-terminated.
*/
wxString GetRepresentation(const wxString& encodedCharacter) const;
@ -5929,6 +5997,7 @@ public:
/**
Retrieve a '\n' separated list of properties understood by the current lexer.
Result is NUL-terminated.
*/
wxString PropertyNames() const;
@ -5939,11 +6008,13 @@ public:
/**
Describe a property.
Result is NUL-terminated.
*/
wxString DescribeProperty(const wxString& name) const;
/**
Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
Result is NUL-terminated.
*/
wxString DescribeKeyWordSets() const;
@ -5996,6 +6067,7 @@ public:
/**
Get the set of base styles that can be extended with sub styles
Result is NUL-terminated.
*/
wxString GetSubStyleBases() const;

View File

@ -371,6 +371,12 @@ methodOverrideMap = {
'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
'IndicSetUnder': ('IndicatorSetUnder', 0, 0, 0),
'IndicGetUnder': ('IndicatorGetUnder', 0, 0, 0),
'IndicSetHoverStyle': ('IndicatorSetHoverStyle', 0, 0, 0),
'IndicGetHoverStyle': ('IndicatorGetHoverStyle', 0, 0, 0),
'IndicSetHoverFore': ('IndicatorSetHoverForeground', 0, 0, 0),
'IndicGetHoverFore': ('IndicatorGetHoverForeground', 0, 0, 0),
'IndicSetFlags': ('IndicatorSetFlags', 0, 0, 0),
'IndicGetFlags': ('IndicatorGetFlags', 0, 0, 0),
'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0),
'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0),
@ -588,6 +594,22 @@ methodOverrideMap = {
'GetDirectFunction' : (None, 0, 0, 0),
'GetDirectPointer' : (None, 0, 0, 0),
'GetTargetText' :
(0,
'wxString %s() const;',
'''wxString %s() const {
int startPos = GetTargetStart();
int endPos = GetTargetEnd();
wxMemoryBuffer mbuf(endPos-startPos+1); // leave room for the null...
char* buf = (char*)mbuf.GetWriteBuf(endPos-startPos+1);
SendMsg(%s, 0, (sptr_t)buf);
mbuf.UngetWriteBuf(endPos-startPos);
mbuf.AppendByte(0);
return stc2wx(buf);''',
0),
'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
'CallTipSetPosStart': ('CallTipSetPosAtStart', 0, 0, 0),
'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),

View File

@ -3,7 +3,7 @@ directories from the Scintilla source distribution. All other code
needed to implement Scintilla on top of wxWidgets is located in the
directory above this one.
The current version of the Scintilla code is 3.5.2
The current version of the Scintilla code is 3.5.5
These are the basic steps needed to update the version of Scintilla used by wxSTC.

View File

@ -144,6 +144,11 @@ public:
return (pt.x >= left) && (pt.x <= right) &&
(pt.y >= top) && (pt.y <= bottom);
}
bool ContainsWholePixel(Point pt) const {
// Does the rectangle contain all of the pixel to left/below the point
return (pt.x >= left) && ((pt.x+1) <= right) &&
(pt.y >= top) && ((pt.y+1) <= bottom);
}
bool Contains(PRectangle rc) const {
return (rc.left >= left) && (rc.right <= right) &&
(rc.top >= top) && (rc.bottom <= bottom);
@ -266,7 +271,6 @@ struct FontParameters {
class Font {
protected:
FontID fid;
// Private so Font objects can not be copied
Font(const Font &);
Font &operator=(const Font &);
@ -280,7 +284,6 @@ public:
FontID GetID() { return fid; }
// Alias another font - caller guarantees not to Release
void SetID(FontID fid_) { fid = fid_; }
friend class Surface;
friend class SurfaceImpl;
};

View File

@ -129,6 +129,9 @@
#define SCLEX_DMIS 114
#define SCLEX_REGISTRY 115
#define SCLEX_BIBTEX 116
#define SCLEX_SREC 117
#define SCLEX_IHEX 118
#define SCLEX_TEHEX 119
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
@ -898,6 +901,11 @@
#define SCE_V_IDENTIFIER 11
#define SCE_V_STRINGEOL 12
#define SCE_V_USER 19
#define SCE_V_COMMENT_WORD 20
#define SCE_V_INPUT 21
#define SCE_V_OUTPUT 22
#define SCE_V_INOUT 23
#define SCE_V_PORT_CONNECT 24
#define SCE_KIX_DEFAULT 0
#define SCE_KIX_COMMENT 1
#define SCE_KIX_STRING1 2
@ -1741,6 +1749,25 @@
#define SCE_BIBTEX_PARAMETER 4
#define SCE_BIBTEX_VALUE 5
#define SCE_BIBTEX_COMMENT 6
#define SCE_HEX_DEFAULT 0
#define SCE_HEX_RECSTART 1
#define SCE_HEX_RECTYPE 2
#define SCE_HEX_RECTYPE_UNKNOWN 3
#define SCE_HEX_BYTECOUNT 4
#define SCE_HEX_BYTECOUNT_WRONG 5
#define SCE_HEX_NOADDRESS 6
#define SCE_HEX_DATAADDRESS 7
#define SCE_HEX_RECCOUNT 8
#define SCE_HEX_STARTADDRESS 9
#define SCE_HEX_ADDRESSFIELD_UNKNOWN 10
#define SCE_HEX_EXTENDEDADDRESS 11
#define SCE_HEX_DATA_ODD 12
#define SCE_HEX_DATA_EVEN 13
#define SCE_HEX_DATA_UNKNOWN 14
#define SCE_HEX_DATA_EMPTY 15
#define SCE_HEX_CHECKSUM 16
#define SCE_HEX_CHECKSUM_WRONG 17
#define SCE_HEX_GARBAGE 18
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif

View File

@ -285,6 +285,9 @@ inline int isascii(int c) { return !(c & ~0x7F); }
#define INDIC_DOTBOX 12
#define INDIC_SQUIGGLEPIXMAP 13
#define INDIC_COMPOSITIONTHICK 14
#define INDIC_COMPOSITIONTHIN 15
#define INDIC_FULLBOX 16
#define INDIC_TEXTFORE 17
#define INDIC_IME 32
#define INDIC_IME_MAX 35
#define INDIC_MAX 35
@ -299,6 +302,15 @@ inline int isascii(int c) { return !(c & ~0x7F); }
#define SCI_INDICGETFORE 2083
#define SCI_INDICSETUNDER 2510
#define SCI_INDICGETUNDER 2511
#define SCI_INDICSETHOVERSTYLE 2680
#define SCI_INDICGETHOVERSTYLE 2681
#define SCI_INDICSETHOVERFORE 2682
#define SCI_INDICGETHOVERFORE 2683
#define SC_INDICVALUEBIT 0x1000000
#define SC_INDICVALUEMASK 0xFFFFFF
#define SC_INDICFLAG_VALUEFORE 1
#define SCI_INDICSETFLAGS 2684
#define SCI_INDICGETFLAGS 2685
#define SCI_SETWHITESPACEFORE 2084
#define SCI_SETWHITESPACEBACK 2085
#define SCI_SETWHITESPACESIZE 2086
@ -431,6 +443,8 @@ inline int isascii(int c) { return !(c & ~0x7F); }
#define SCI_GETTARGETSTART 2191
#define SCI_SETTARGETEND 2192
#define SCI_GETTARGETEND 2193
#define SCI_SETTARGETRANGE 2686
#define SCI_GETTARGETTEXT 2687
#define SCI_REPLACETARGET 2194
#define SCI_REPLACETARGETRE 2195
#define SCI_SEARCHINTARGET 2197
@ -794,8 +808,6 @@ inline int isascii(int c) { return !(c & ~0x7F); }
#define SCI_GETCHARACTERPOINTER 2520
#define SCI_GETRANGEPOINTER 2643
#define SCI_GETGAPPOSITION 2644
#define SCI_SETKEYSUNICODE 2521
#define SCI_GETKEYSUNICODE 2522
#define SCI_INDICSETALPHA 2523
#define SCI_INDICGETALPHA 2524
#define SCI_INDICSETOUTLINEALPHA 2558
@ -1154,6 +1166,8 @@ struct SCNotification {
#define SC_CP_DBCS 1
#define SCI_SETUSEPALETTE 2039
#define SCI_GETUSEPALETTE 2139
#define SCI_SETKEYSUNICODE 2521
#define SCI_GETKEYSUNICODE 2522
#endif

View File

@ -72,11 +72,11 @@
## Line numbers and positions start at 0.
## String arguments may contain NUL ('\0') characters where the calls provide a length
## argument and retrieve NUL characters. All retrieved strings except for those retrieved
## by GetLine also have a NUL appended but client code should calculate the size that
## will be returned rather than relying upon the NUL whenever possible. Allow for the
## extra NUL character when allocating buffers. The size to allocate for a stringresult
## can be determined by calling with a NULL (0) pointer.
## argument and retrieve NUL characters. APIs marked as NUL-terminated also have a
## NUL appended but client code should calculate the size that will be returned rather
## than relying upon the NUL whenever possible. Allow for the extra NUL character when
## allocating buffers. The size to allocate for a stringresult (not including NUL) can be
## determined by calling with a NULL (0) pointer.
cat Basics
@ -186,6 +186,7 @@ set void SetAnchor=2026(position posAnchor,)
# Retrieve the text of the line containing the caret.
# Returns the index of the caret on the line.
# Result is NUL-terminated.
fun int GetCurLine=2027(int length, stringresult text)
# Retrieve the position of the last correctly styled character.
@ -479,6 +480,7 @@ get int StyleGetSize=2485(int style,)
# Get the font of a style.
# Returns the length of the fontName
# Result is NUL-terminated.
get int StyleGetFont=2486(int style, stringresult fontName)
# Get is a style to have its end of line filled or not.
@ -578,7 +580,7 @@ set void SetCaretPeriod=2076(int periodMilliseconds,)
set void SetWordChars=2077(, string characters)
# Get the set of characters making up words for when moving or selecting by word.
# Retuns the number of characters
# Returns the number of characters
get int GetWordChars=2646(, stringresult characters)
# Start a sequence of actions that is undone and redone as a unit.
@ -605,6 +607,9 @@ val INDIC_SQUIGGLELOW=11
val INDIC_DOTBOX=12
val INDIC_SQUIGGLEPIXMAP=13
val INDIC_COMPOSITIONTHICK=14
val INDIC_COMPOSITIONTHIN=15
val INDIC_FULLBOX=16
val INDIC_TEXTFORE=17
val INDIC_IME=32
val INDIC_IME_MAX=35
val INDIC_MAX=35
@ -632,6 +637,30 @@ set void IndicSetUnder=2510(int indic, bool under)
# Retrieve whether indicator drawn under or over text.
get bool IndicGetUnder=2511(int indic,)
# Set a hover indicator to plain, squiggle or TT.
set void IndicSetHoverStyle=2680(int indic, int style)
# Retrieve the hover style of an indicator.
get int IndicGetHoverStyle=2681(int indic,)
# Set the foreground hover colour of an indicator.
set void IndicSetHoverFore=2682(int indic, colour fore)
# Retrieve the foreground hover colour of an indicator.
get colour IndicGetHoverFore=2683(int indic,)
val SC_INDICVALUEBIT=0x1000000
val SC_INDICVALUEMASK=0xFFFFFF
enu IndicFlag=SC_INDICFLAG_
val SC_INDICFLAG_VALUEFORE=1
# Set the attributes of an indicator.
set void IndicSetFlags=2684(int indic, int flags)
# Retrieve the attributes of an indicator.
get int IndicGetFlags=2685(int indic,)
# Set the foreground colour of all whitespace and whether to use this setting.
fun void SetWhitespaceFore=2084(bool useSetting, colour fore)
@ -924,6 +953,7 @@ fun void SetSel=2160(position start, position end)
# Retrieve the selected text.
# Return the length of the text.
# Result is NUL-terminated.
fun int GetSelText=2161(, stringresult text)
# Retrieve a range of text.
@ -994,6 +1024,7 @@ fun void SetText=2181(, string text)
# Retrieve all the text in the document.
# Returns number of characters retrieved.
# Result is NUL-terminated.
fun int GetText=2182(int length, stringresult text)
# Retrieve the number of characters in the document.
@ -1032,6 +1063,12 @@ set void SetTargetEnd=2192(position pos,)
# Get the position that ends the target.
get position GetTargetEnd=2193(,)
# Sets both the start and end of the target in one call.
fun void SetTargetRange=2686(position start, position end)
# Retrieve the text in the target.
get int GetTargetText=2687(, stringresult characters)
# Replace the target text with the argument text.
# Text is counted so it can contain NULs.
# Returns the length of the replacement text.
@ -1363,6 +1400,7 @@ set void SetMultiPaste=2614(int multiPaste,)
get int GetMultiPaste=2615(,)
# Retrieve the value of a tag from a regular expression search.
# Result is NUL-terminated.
get int GetTag=2616(int tagNumber, stringresult tagValue)
# Make the target range start and end be the same as the selection range start and end.
@ -1910,6 +1948,7 @@ get int AutoCGetCurrent=2445(,)
# Get currently selected item text in the auto-completion list
# Returns the length of the item text
# Result is NUL-terminated.
get int AutoCGetCurrentText=2610(, stringresult s)
enu CaseInsensitiveBehaviour=SC_CASEINSENSITIVEBEHAVIOUR_
@ -2059,12 +2098,6 @@ get int GetRangePointer=2643(int position, int rangeLength)
# the range of a call to GetRangePointer.
get position GetGapPosition=2644(,)
# Always interpret keyboard input as Unicode
set void SetKeysUnicode=2521(bool keysUnicode,)
# Are keys always interpreted as Unicode?
get bool GetKeysUnicode=2522(,)
# Set the alpha fill colour of the given indicator.
set void IndicSetAlpha=2523(int indicator, int alpha)
@ -2419,6 +2452,7 @@ get int GetLineEndTypesActive=2658(,)
set void SetRepresentation=2665(string encodedCharacter, string representation)
# Set the way a character is drawn.
# Result is NUL-terminated.
get int GetRepresentation=2666(string encodedCharacter, stringresult representation)
# Remove a character representation.
@ -2455,10 +2489,12 @@ set void SetLexerLanguage=4006(, string language)
fun void LoadLexerLibrary=4007(, string path)
# Retrieve a "property" value previously set with SetProperty.
# Result is NUL-terminated.
get int GetProperty=4008(string key, stringresult buf)
# Retrieve a "property" value previously set with SetProperty,
# with "$()" variable replacement on returned buffer.
# Result is NUL-terminated.
get int GetPropertyExpanded=4009(string key, stringresult buf)
# Retrieve a "property" value previously set with SetProperty,
@ -2470,12 +2506,14 @@ get int GetStyleBitsNeeded=4011(,)
# Retrieve the name of the lexer.
# Return the length of the text.
# Result is NUL-terminated.
get int GetLexerLanguage=4012(, stringresult text)
# For private communication between an application and a known lexer.
fun int PrivateLexerCall=4013(int operation, int pointer)
# Retrieve a '\n' separated list of properties understood by the current lexer.
# Result is NUL-terminated.
fun int PropertyNames=4014(, stringresult names)
enu TypeProperty=SC_TYPE_
@ -2487,9 +2525,11 @@ val SC_TYPE_STRING=2
fun int PropertyType=4015(string name,)
# Describe a property.
# Result is NUL-terminated.
fun int DescribeProperty=4016(string name, stringresult description)
# Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
# Result is NUL-terminated.
fun int DescribeKeyWordSets=4017(, stringresult descriptions)
# Bit set of LineEndType enumertion for which line ends beyond the standard
@ -2522,6 +2562,7 @@ set void SetIdentifiers=4024(int style, string identifiers)
get int DistanceToSecondaryStyles=4025(,)
# Get the set of base styles that can be extended with sub styles
# Result is NUL-terminated.
get int GetSubStyleBases=4026(, stringresult styles)
# Notifications
@ -2719,6 +2760,9 @@ val SCLEX_AS=113
val SCLEX_DMIS=114
val SCLEX_REGISTRY=115
val SCLEX_BIBTEX=116
val SCLEX_SREC=117
val SCLEX_IHEX=118
val SCLEX_TEHEX=119
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
@ -3599,6 +3643,11 @@ val SCE_V_OPERATOR=10
val SCE_V_IDENTIFIER=11
val SCE_V_STRINGEOL=12
val SCE_V_USER=19
val SCE_V_COMMENT_WORD=20
val SCE_V_INPUT=21
val SCE_V_OUTPUT=22
val SCE_V_INOUT=23
val SCE_V_PORT_CONNECT=24
# Lexical states for SCLEX_KIX
lex Kix=SCLEX_KIX SCE_KIX_
val SCE_KIX_DEFAULT=0
@ -4542,6 +4591,31 @@ val SCE_BIBTEX_KEY=3
val SCE_BIBTEX_PARAMETER=4
val SCE_BIBTEX_VALUE=5
val SCE_BIBTEX_COMMENT=6
# Lexical state for SCLEX_SREC
lex Srec=SCLEX_SREC SCE_HEX_
val SCE_HEX_DEFAULT=0
val SCE_HEX_RECSTART=1
val SCE_HEX_RECTYPE=2
val SCE_HEX_RECTYPE_UNKNOWN=3
val SCE_HEX_BYTECOUNT=4
val SCE_HEX_BYTECOUNT_WRONG=5
val SCE_HEX_NOADDRESS=6
val SCE_HEX_DATAADDRESS=7
val SCE_HEX_RECCOUNT=8
val SCE_HEX_STARTADDRESS=9
val SCE_HEX_ADDRESSFIELD_UNKNOWN=10
val SCE_HEX_EXTENDEDADDRESS=11
val SCE_HEX_DATA_ODD=12
val SCE_HEX_DATA_EVEN=13
val SCE_HEX_DATA_UNKNOWN=14
val SCE_HEX_DATA_EMPTY=15
val SCE_HEX_CHECKSUM=16
val SCE_HEX_CHECKSUM_WRONG=17
val SCE_HEX_GARBAGE=18
# Lexical state for SCLEX_IHEX (shared with Srec)
lex IHex=SCLEX_IHEX SCE_HEX_
# Lexical state for SCLEX_TEHEX (shared with Srec)
lex TEHex=SCLEX_TEHEX SCE_HEX_
# Events
@ -4594,3 +4668,11 @@ get bool GetUsePalette=2139(,)
# In palette mode, Scintilla uses the environment's palette calls to display
# more colours. This may lead to ugly displays.
set void SetUsePalette=2039(bool usePalette,)
# Deprecated in 3.5.5
# Always interpret keyboard input as Unicode
set void SetKeysUnicode=2521(bool keysUnicode,)
# Are keys always interpreted as Unicode?
get bool GetKeysUnicode=2522(,)

View File

@ -419,8 +419,6 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.Forward();
HereDoc.Quoted = true;
HereDoc.State = 1;
} else if (!HereDoc.Indent && sc.chNext == '-') { // <<- indent case
HereDoc.Indent = true;
} else if (setHereDoc.Contains(sc.chNext)) {
// an unquoted here-doc delimiter, no special handling
// TODO check what exactly bash considers part of the delim
@ -469,7 +467,7 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
if (sc.atLineStart) {
sc.SetState(SCE_SH_HERE_Q);
int prefixws = 0;
while (IsASpace(sc.ch) && !sc.atLineEnd) { // whitespace prefix
while (sc.ch == '\t' && !sc.atLineEnd) { // tabulation prefix
sc.Forward();
prefixws++;
}
@ -481,7 +479,8 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
char s[HERE_DELIM_MAX];
sc.GetCurrent(s, sizeof(s));
if (sc.LengthCurrent() == 0) { // '' or "" delimiters
if (prefixws == 0 && HereDoc.Quoted && HereDoc.DelimiterLength == 0)
if ((prefixws == 0 || HereDoc.Indent) &&
HereDoc.Quoted && HereDoc.DelimiterLength == 0)
sc.SetState(SCE_SH_DEFAULT);
break;
}
@ -672,7 +671,12 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
} else if (sc.Match('<', '<')) {
sc.SetState(SCE_SH_HERE_DELIM);
HereDoc.State = 0;
HereDoc.Indent = false;
if (sc.GetRelative(2) == '-') { // <<- indent case
HereDoc.Indent = true;
sc.Forward();
} else {
HereDoc.Indent = false;
}
} else if (sc.ch == '-' && // one-char file test operators
setSingleCharOp.Contains(sc.chNext) &&
!setWord.Contains(sc.GetRelative(2)) &&

View File

@ -306,6 +306,7 @@ struct OptionsCPP {
bool identifiersAllowDollars;
bool trackPreprocessor;
bool updatePreprocessor;
bool verbatimStringsAllowEscapes;
bool triplequotedStrings;
bool hashquotedStrings;
bool backQuotedStrings;
@ -326,6 +327,7 @@ struct OptionsCPP {
identifiersAllowDollars = true;
trackPreprocessor = true;
updatePreprocessor = true;
verbatimStringsAllowEscapes = false;
triplequotedStrings = false;
hashquotedStrings = false;
backQuotedStrings = false;
@ -370,6 +372,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
DefineProperty("lexer.cpp.update.preprocessor", &OptionsCPP::updatePreprocessor,
"Set to 1 to update preprocessor definitions when #define found.");
DefineProperty("lexer.cpp.verbatim.strings.allow.escapes", &OptionsCPP::verbatimStringsAllowEscapes,
"Set to 1 to allow verbatim strings to contain escape sequences.");
DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings,
"Set to 1 to enable highlighting of triple-quoted strings.");
@ -1036,7 +1041,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
break;
case SCE_C_VERBATIM:
if (sc.ch == '\"') {
if (options.verbatimStringsAllowEscapes && (sc.ch == '\\')) {
sc.Forward(); // Skip all characters after the backslash
} else if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.Forward();
} else {
@ -1344,14 +1351,14 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle,
}
}
if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) {
if (ch == '{') {
if (ch == '{' || ch == '[') {
// Measure the minimum before a '{' to allow
// folding on "} else {"
if (levelMinCurrent > levelNext) {
levelMinCurrent = levelNext;
}
levelNext++;
} else if (ch == '}') {
} else if (ch == '}' || ch == ']') {
levelNext--;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -271,7 +271,7 @@ static void ScanNumber(Accessor& styler, int& pos) {
pos++;
c = styler.SafeGetCharAt(pos, '\0');
n = styler.SafeGetCharAt(pos + 1, '\0');
if (c == '8') {
if (c == '8' || c == 's') {
pos++;
} else if (c == '1' && n == '6') {
pos += 2;
@ -279,6 +279,8 @@ static void ScanNumber(Accessor& styler, int& pos) {
pos += 2;
} else if (c == '6' && n == '4') {
pos += 2;
} else {
error = true;
}
/* See if it's a floating point literal. These literals have to be base 10.
*/

View File

@ -54,12 +54,12 @@ static inline bool IsADoxygenChar(int ch) {
ch == '}' || ch == '[' || ch == ']');
}
static inline bool IsANumberChar(int ch) {
static inline bool IsANumberChar(int ch, int chPrev) {
// Not exactly following number definition (several dots are seen as OK, etc.)
// but probably enough in most cases.
return (ch < 0x80) &&
(isdigit(ch) || toupper(ch) == 'E' ||
ch == '.' || ch == '-' || ch == '+');
ch == '.' || ((ch == '-' || ch == '+') && chPrev < 0x80 && toupper(chPrev) == 'E'));
}
typedef unsigned int sql_state_t;
@ -444,7 +444,6 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
StyleContext sc(startPos, length, initStyle, styler);
int styleBeforeDCKeyword = SCE_SQL_DEFAULT;
int offset = 0;
char qOperator = 0x00;
for (; sc.More(); sc.Forward(), offset++) {
// Determine if the current state should terminate.
@ -454,7 +453,7 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
break;
case SCE_SQL_NUMBER:
// We stop the number definition on non-numerical non-dot non-eE non-sign char
if (!IsANumberChar(sc.ch)) {
if (!IsANumberChar(sc.ch, sc.chPrev)) {
sc.SetState(SCE_SQL_DEFAULT);
}
break;
@ -559,29 +558,34 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
}
break;
case SCE_SQL_QOPERATOR:
if (qOperator == 0x00) {
qOperator = sc.ch;
} else {
char qComplement = 0x00;
if (qOperator == '<') {
qComplement = '>';
} else if (qOperator == '(') {
qComplement = ')';
} else if (qOperator == '{') {
qComplement = '}';
} else if (qOperator == '[') {
qComplement = ']';
} else {
qComplement = qOperator;
}
if (sc.Match(qComplement, '\'')) {
sc.Forward();
sc.ForwardSetState(SCE_SQL_DEFAULT);
qOperator = 0x00;
// Locate the unique Q operator character
sc.Complete();
char qOperator = 0x00;
for (int styleStartPos = sc.currentPos; styleStartPos > 0; --styleStartPos) {
if (styler.StyleAt(styleStartPos - 1) != SCE_SQL_QOPERATOR) {
qOperator = styler.SafeGetCharAt(styleStartPos + 2);
break;
}
}
}
char qComplement = 0x00;
if (qOperator == '<') {
qComplement = '>';
} else if (qOperator == '(') {
qComplement = ')';
} else if (qOperator == '{') {
qComplement = '}';
} else if (qOperator == '[') {
qComplement = ']';
} else {
qComplement = qOperator;
}
if (sc.Match(qComplement, '\'')) {
sc.Forward();
sc.ForwardSetState(SCE_SQL_DEFAULT);
}
break;
}
@ -590,7 +594,8 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
if (sc.Match('q', '\'') || sc.Match('Q', '\'')) {
sc.SetState(SCE_SQL_QOPERATOR);
sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)) ||
((sc.ch == '-' || sc.ch == '+') && IsADigit(sc.chNext) && !IsADigit(sc.chPrev))) {
sc.SetState(SCE_SQL_NUMBER);
} else if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_SQL_IDENTIFIER);

View File

@ -30,7 +30,7 @@ using namespace Scintilla;
// Extended to accept accented characters
static inline bool IsAWordChar(int ch) {
return ch >= 0x80 ||
(isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator
(isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator
}
static inline bool IsAWordStart(int ch) {
@ -49,17 +49,18 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
#define isComment(s) (s==SCE_TCL_COMMENT || s==SCE_TCL_COMMENTLINE || s==SCE_TCL_COMMENT_BOX || s==SCE_TCL_BLOCK_COMMENT)
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool commentLevel = false;
bool subBrace = false; // substitution begin with a brace ${.....}
bool subBrace = false; // substitution begin with a brace ${.....}
enum tLineState {LS_DEFAULT, LS_OPEN_COMMENT, LS_OPEN_DOUBLE_QUOTE, LS_COMMENT_BOX, LS_MASK_STATE = 0xf,
LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32 } lineState = LS_DEFAULT;
LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32
} lineState = LS_DEFAULT;
bool prevSlash = false;
int currentLevel = 0;
bool expected = 0;
bool subParen = 0;
bool expected = 0;
bool subParen = 0;
int currentLine = styler.GetLine(startPos);
if (currentLine > 0)
currentLine--;
if (currentLine > 0)
currentLine--;
length += startPos - styler.LineStart(currentLine);
// make sure lines overlap
startPos = styler.LineStart(currentLine);
@ -71,14 +72,14 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
WordList &keywords5 = *keywordlists[4];
WordList &keywords6 = *keywordlists[5];
WordList &keywords7 = *keywordlists[6];
WordList &keywords8 = *keywordlists[7];
WordList &keywords9 = *keywordlists[8];
WordList &keywords8 = *keywordlists[7];
WordList &keywords9 = *keywordlists[8];
if (currentLine > 0) {
int ls = styler.GetLineState(currentLine - 1);
int ls = styler.GetLineState(currentLine - 1);
lineState = tLineState(ls & LS_MASK_STATE);
expected = LS_COMMAND_EXPECTED == tLineState(ls & LS_COMMAND_EXPECTED);
subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY);
subBrace = LS_BRACE_ONLY == tLineState(ls & LS_BRACE_ONLY);
currentLevel = styler.LevelAt(currentLine - 1) >> 17;
commentLevel = (styler.LevelAt(currentLine - 1) >> 16) & 1;
} else
@ -86,105 +87,104 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
bool visibleChars = false;
int previousLevel = currentLevel;
StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler);
StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler);
for (; ; sc.Forward()) {
next:
if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac
continue;
bool atEnd = !sc.More(); // make sure we coloured the last word
if (lineState != LS_DEFAULT) {
sc.SetState(SCE_TCL_DEFAULT);
if (lineState == LS_OPEN_COMMENT)
sc.SetState(SCE_TCL_COMMENTLINE);
else if (lineState == LS_OPEN_DOUBLE_QUOTE)
sc.SetState(SCE_TCL_IN_QUOTE);
else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#')))
sc.SetState(SCE_TCL_COMMENT_BOX);
lineState = LS_DEFAULT;
}
if (subBrace) { // ${ overrides every thing even \ except }
if (sc.ch == '}') {
subBrace = false;
sc.SetState(SCE_TCL_OPERATOR);
sc.ForwardSetState(SCE_TCL_DEFAULT);
goto next;
}
else
sc.SetState(SCE_TCL_SUB_BRACE);
if (!sc.atLineEnd)
continue;
} else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) {
expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#';
} else if (sc.state == SCE_TCL_SUBSTITUTION) {
switch(sc.ch) {
case '(':
subParen=true;
sc.SetState(SCE_TCL_OPERATOR);
sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
continue;
case ')':
sc.SetState(SCE_TCL_OPERATOR);
subParen=false;
continue;
case '$':
continue;
case ',':
sc.SetState(SCE_TCL_OPERATOR);
if (subParen)
sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
continue;
default :
// maybe spaces should be allowed ???
if (!IsAWordChar(sc.ch)) { // probably the code is wrong
sc.SetState(SCE_TCL_DEFAULT);
subParen = 0;
}
break;
}
} else if (isComment(sc.state)) {
} else if (!IsAWordChar(sc.ch)) {
if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) {
char w[100];
char *s=w;
sc.GetCurrent(w, sizeof(w));
if (w[strlen(w)-1]=='\r')
w[strlen(w)-1]=0;
while(*s == ':') // ignore leading : like in ::set a 10
++s;
bool quote = sc.state == SCE_TCL_IN_QUOTE;
if (commentLevel || expected) {
if (keywords.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
} else if (keywords2.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
} else if (keywords3.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
} else if (keywords4.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
} else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
sc.ChangeState(SCE_TCL_EXPAND);
}
if (keywords6.InList(s)) {
sc.ChangeState(SCE_TCL_WORD5);
} else if (keywords7.InList(s)) {
sc.ChangeState(SCE_TCL_WORD6);
} else if (keywords8.InList(s)) {
sc.ChangeState(SCE_TCL_WORD7);
} else if (keywords9.InList(s)) {
sc.ChangeState(SCE_TCL_WORD8);
}
}
expected = false;
sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
} else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) {
sc.SetState(SCE_TCL_DEFAULT);
}
}
if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac
continue;
bool atEnd = !sc.More(); // make sure we coloured the last word
if (lineState != LS_DEFAULT) {
sc.SetState(SCE_TCL_DEFAULT);
if (lineState == LS_OPEN_COMMENT)
sc.SetState(SCE_TCL_COMMENTLINE);
else if (lineState == LS_OPEN_DOUBLE_QUOTE)
sc.SetState(SCE_TCL_IN_QUOTE);
else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#')))
sc.SetState(SCE_TCL_COMMENT_BOX);
lineState = LS_DEFAULT;
}
if (subBrace) { // ${ overrides every thing even \ except }
if (sc.ch == '}') {
subBrace = false;
sc.SetState(SCE_TCL_OPERATOR);
sc.ForwardSetState(SCE_TCL_DEFAULT);
goto next;
} else
sc.SetState(SCE_TCL_SUB_BRACE);
if (!sc.atLineEnd)
continue;
} else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) {
expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#';
} else if (sc.state == SCE_TCL_SUBSTITUTION) {
switch (sc.ch) {
case '(':
subParen=true;
sc.SetState(SCE_TCL_OPERATOR);
sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
continue;
case ')':
sc.SetState(SCE_TCL_OPERATOR);
subParen=false;
continue;
case '$':
continue;
case ',':
sc.SetState(SCE_TCL_OPERATOR);
if (subParen)
sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
continue;
default :
// maybe spaces should be allowed ???
if (!IsAWordChar(sc.ch)) { // probably the code is wrong
sc.SetState(SCE_TCL_DEFAULT);
subParen = 0;
}
break;
}
} else if (isComment(sc.state)) {
} else if (!IsAWordChar(sc.ch)) {
if ((sc.state == SCE_TCL_IDENTIFIER && expected) || sc.state == SCE_TCL_MODIFIER) {
char w[100];
char *s=w;
sc.GetCurrent(w, sizeof(w));
if (w[strlen(w)-1]=='\r')
w[strlen(w)-1]=0;
while (*s == ':') // ignore leading : like in ::set a 10
++s;
bool quote = sc.state == SCE_TCL_IN_QUOTE;
if (commentLevel || expected) {
if (keywords.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
} else if (keywords2.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
} else if (keywords3.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
} else if (keywords4.InList(s)) {
sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
} else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
sc.ChangeState(SCE_TCL_EXPAND);
}
if (keywords6.InList(s)) {
sc.ChangeState(SCE_TCL_WORD5);
} else if (keywords7.InList(s)) {
sc.ChangeState(SCE_TCL_WORD6);
} else if (keywords8.InList(s)) {
sc.ChangeState(SCE_TCL_WORD7);
} else if (keywords9.InList(s)) {
sc.ChangeState(SCE_TCL_WORD8);
}
}
expected = false;
sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
} else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) {
sc.SetState(SCE_TCL_DEFAULT);
}
}
if (atEnd)
break;
if (sc.atLineEnd) {
lineState = LS_DEFAULT;
if (sc.atLineEnd) {
lineState = LS_DEFAULT;
currentLine = styler.GetLine(sc.currentPos);
if (foldComment && sc.state!=SCE_TCL_COMMENT && isComment(sc.state)) {
if (currentLevel == 0) {
@ -206,45 +206,45 @@ next:
styler.SetLevel(currentLine, flag + previousLevel + SC_FOLDLEVELBASE + (currentLevel << 17) + (commentLevel << 16));
// Update the line state, so it can be seen by next line
if (sc.state == SCE_TCL_IN_QUOTE)
if (sc.state == SCE_TCL_IN_QUOTE) {
lineState = LS_OPEN_DOUBLE_QUOTE;
else {
if (prevSlash) {
if (isComment(sc.state))
lineState = LS_OPEN_COMMENT;
} else if (sc.state == SCE_TCL_COMMENT_BOX)
lineState = LS_COMMENT_BOX;
} else {
if (prevSlash) {
if (isComment(sc.state))
lineState = LS_OPEN_COMMENT;
} else if (sc.state == SCE_TCL_COMMENT_BOX)
lineState = LS_COMMENT_BOX;
}
styler.SetLineState(currentLine,
(subBrace ? LS_BRACE_ONLY : 0) |
(expected ? LS_COMMAND_EXPECTED : 0) | lineState);
if (lineState == LS_COMMENT_BOX)
sc.ForwardSetState(SCE_TCL_COMMENT_BOX);
else if (lineState == LS_OPEN_DOUBLE_QUOTE)
sc.ForwardSetState(SCE_TCL_IN_QUOTE);
else
sc.ForwardSetState(SCE_TCL_DEFAULT);
styler.SetLineState(currentLine,
(subBrace ? LS_BRACE_ONLY : 0) |
(expected ? LS_COMMAND_EXPECTED : 0) | lineState);
if (lineState == LS_COMMENT_BOX)
sc.ForwardSetState(SCE_TCL_COMMENT_BOX);
else if (lineState == LS_OPEN_DOUBLE_QUOTE)
sc.ForwardSetState(SCE_TCL_IN_QUOTE);
else
sc.ForwardSetState(SCE_TCL_DEFAULT);
prevSlash = false;
previousLevel = currentLevel;
goto next;
}
if (prevSlash) {
prevSlash = false;
if (sc.ch == '#' && IsANumberChar(sc.chNext))
sc.ForwardSetState(SCE_TCL_NUMBER);
continue;
prevSlash = false;
if (sc.ch == '#' && IsANumberChar(sc.chNext))
sc.ForwardSetState(SCE_TCL_NUMBER);
continue;
}
prevSlash = sc.ch == '\\';
if (isComment(sc.state))
continue;
prevSlash = sc.ch == '\\';
if (isComment(sc.state))
continue;
if (sc.atLineStart) {
visibleChars = false;
if (sc.state!=SCE_TCL_IN_QUOTE && !isComment(sc.state))
{
{
sc.SetState(SCE_TCL_DEFAULT);
expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch));
}
expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch));
}
}
switch (sc.state) {
@ -259,28 +259,28 @@ next:
goto next;
} else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$') {
sc.SetState(SCE_TCL_OPERATOR);
expected = sc.ch == '[';
sc.ForwardSetState(SCE_TCL_IN_QUOTE);
expected = sc.ch == '[';
sc.ForwardSetState(SCE_TCL_IN_QUOTE);
goto next;
}
continue;
case SCE_TCL_OPERATOR:
continue;
case SCE_TCL_OPERATOR:
sc.SetState(SCE_TCL_DEFAULT);
break;
}
if (sc.ch == '#') {
if (visibleChars) {
if (sc.state != SCE_TCL_IN_QUOTE && expected)
if (sc.state != SCE_TCL_IN_QUOTE && expected)
sc.SetState(SCE_TCL_COMMENT);
} else {
sc.SetState(SCE_TCL_COMMENTLINE);
if (sc.chNext == '~')
sc.SetState(SCE_TCL_BLOCK_COMMENT);
if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-'))
sc.SetState(SCE_TCL_COMMENT_BOX);
}
}
sc.SetState(SCE_TCL_COMMENTLINE);
if (sc.chNext == '~')
sc.SetState(SCE_TCL_BLOCK_COMMENT);
if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-'))
sc.SetState(SCE_TCL_COMMENT_BOX);
}
}
if (!isspacechar(static_cast<unsigned char>(sc.ch))) {
visibleChars = true;
@ -293,7 +293,7 @@ next:
// Determine if a new state should be entered.
if (sc.state == SCE_TCL_DEFAULT) {
if (IsAWordStart(sc.ch)) {
if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_TCL_IDENTIFIER);
} else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) {
sc.SetState(SCE_TCL_NUMBER);
@ -313,39 +313,38 @@ next:
--currentLevel;
break;
case '[':
expected = true;
expected = true;
case ']':
case '(':
case ')':
sc.SetState(SCE_TCL_OPERATOR);
break;
case ';':
expected = true;
expected = true;
break;
case '$':
subParen = 0;
if (sc.chNext != '{') {
sc.SetState(SCE_TCL_SUBSTITUTION);
}
else {
sc.SetState(SCE_TCL_OPERATOR); // $
sc.Forward(); // {
sc.ForwardSetState(SCE_TCL_SUB_BRACE);
subBrace = true;
}
break;
case '#':
if ((isspacechar(static_cast<unsigned char>(sc.chPrev))||
isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10))
sc.SetState(SCE_TCL_NUMBER);
break;
case '-':
sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER);
break;
default:
if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_TCL_OPERATOR);
}
case '$':
subParen = 0;
if (sc.chNext != '{') {
sc.SetState(SCE_TCL_SUBSTITUTION);
} else {
sc.SetState(SCE_TCL_OPERATOR); // $
sc.Forward(); // {
sc.ForwardSetState(SCE_TCL_SUB_BRACE);
subBrace = true;
}
break;
case '#':
if ((isspacechar(static_cast<unsigned char>(sc.chPrev))||
isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10))
sc.SetState(SCE_TCL_NUMBER);
break;
case '-':
sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER);
break;
default:
if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_TCL_OPERATOR);
}
}
}
}
@ -353,18 +352,18 @@ next:
sc.Complete();
}
static const char * const tclWordListDesc[] = {
"TCL Keywords",
"TK Keywords",
"iTCL Keywords",
"tkCommands",
"expand",
"user1",
"user2",
"user3",
"user4",
0
};
static const char *const tclWordListDesc[] = {
"TCL Keywords",
"TK Keywords",
"iTCL Keywords",
"tkCommands",
"expand",
"user1",
"user2",
"user3",
"user4",
0
};
// this code supports folding in the colourizer
LexerModule lmTCL(SCLEX_TCL, ColouriseTCLDoc, "tcl", 0, tclWordListDesc);

View File

@ -72,6 +72,7 @@ static void ColouriseVHDLDoc(
WordList &User = *keywordlists[6];
StyleContext sc(startPos, length, initStyle, styler);
bool isExtendedId = false; // true when parsing an extended identifier
for (; sc.More(); sc.Forward())
{
@ -84,7 +85,7 @@ static void ColouriseVHDLDoc(
sc.SetState(SCE_VHDL_DEFAULT);
}
} else if (sc.state == SCE_VHDL_IDENTIFIER) {
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
if (!isExtendedId && (!IsAWordChar(sc.ch) || (sc.ch == '.'))) {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
if (Keywords.InList(s)) {
@ -103,6 +104,10 @@ static void ColouriseVHDLDoc(
sc.ChangeState(SCE_VHDL_USERWORD);
}
sc.SetState(SCE_VHDL_DEFAULT);
} else if (isExtendedId && ((sc.ch == '\\') || sc.atLineEnd)) {
// extended identifiers are terminated by backslash, check for end of line in case we have invalid syntax
isExtendedId = false;
sc.ForwardSetState(SCE_VHDL_DEFAULT);
}
} else if (sc.state == SCE_VHDL_COMMENT || sc.state == SCE_VHDL_COMMENTLINEBANG) {
if (sc.atLineEnd) {
@ -141,6 +146,9 @@ static void ColouriseVHDLDoc(
sc.SetState(SCE_VHDL_BLOCK_COMMENT);
} else if (sc.ch == '\"') {
sc.SetState(SCE_VHDL_STRING);
} else if (sc.ch == '\\') {
isExtendedId = true;
sc.SetState(SCE_VHDL_IDENTIFIER);
} else if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_VHDL_OPERATOR);
}
@ -388,13 +396,14 @@ static void FoldNoBoxVHDLDoc(
strcmp(s, "entity") == 0 ||
strcmp(s, "configuration") == 0 )
{
if (strcmp(prevWord, "end") != 0)
if (strcmp(prevWord, "end") != 0 && lastStart)
{ // check for instantiated unit by backward searching for the colon.
unsigned pos = lastStart-1;
unsigned pos = lastStart;
char chAtPos, styleAtPos;
do{// skip white spaces
pos--;
styleAtPos = styler.StyleAt(pos);
chAtPos = styler.SafeGetCharAt(pos--);
chAtPos = styler.SafeGetCharAt(pos);
}while(pos>0 &&
(chAtPos == ' ' || chAtPos == '\t' ||
chAtPos == '\n' || chAtPos == '\r' ||

File diff suppressed because it is too large Load Diff

View File

@ -58,6 +58,9 @@ public:
validLen(0),
startSeg(0), startPosStyling(0),
documentVersion(pAccess->Version()) {
// Prevent warnings by static analyzers about uninitialized buf and styleBuf.
buf[0] = 0;
styleBuf[0] = 0;
switch (codePage) {
case 65001:
encodingType = encUnicode;

View File

@ -166,7 +166,8 @@ public:
}
const WordClassifier &Classifier(int baseStyle) const {
return classifiers[BlockFromBaseStyle(baseStyle)];
const int block = BlockFromBaseStyle(baseStyle);
return classifiers[block >= 0 ? block : 0];
}
};

View File

@ -69,6 +69,8 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa
WordList::WordList(bool onlyLineEnds_) :
words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_) {
// Prevent warnings by static analyzers about uninitialized starts.
starts[0] = -1;
}
WordList::~WordList() {

View File

@ -167,7 +167,9 @@ void AutoComplete::SetList(const char *list) {
char item[maxItemLen];
for (size_t i = 0; i < sortMatrix.size(); ++i) {
int wordLen = IndexSort.indices[sortMatrix[i] * 2 + 2] - IndexSort.indices[sortMatrix[i] * 2];
strncpy(item, list + IndexSort.indices[sortMatrix[i] * 2], wordLen);
if (wordLen > maxItemLen-2)
wordLen = maxItemLen - 2;
memcpy(item, list + IndexSort.indices[sortMatrix[i] * 2], wordLen);
if ((i+1) == sortMatrix.size()) {
// Last item so remove separator if present
if ((wordLen > 0) && (item[wordLen-1] == separator))

View File

@ -123,6 +123,7 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmGui4Cli);
LINK_LEXER(lmHaskell);
LINK_LEXER(lmHTML);
LINK_LEXER(lmIHex);
LINK_LEXER(lmInno);
LINK_LEXER(lmKix);
LINK_LEXER(lmKVIrc);
@ -174,12 +175,14 @@ int Scintilla_LinkLexers() {
LINK_LEXER(lmSpecman);
LINK_LEXER(lmSpice);
LINK_LEXER(lmSQL);
LINK_LEXER(lmSrec);
LINK_LEXER(lmSTTXT);
LINK_LEXER(lmTACL);
LINK_LEXER(lmTADS3);
LINK_LEXER(lmTAL);
LINK_LEXER(lmTCL);
LINK_LEXER(lmTCMD);
LINK_LEXER(lmTEHex);
LINK_LEXER(lmTeX);
LINK_LEXER(lmTxt2tags);
LINK_LEXER(lmVB);

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <stdexcept>
#include <algorithm>
#include "Platform.h"
@ -786,6 +787,10 @@ const Action &CellBuffer::GetUndoStep() const {
void CellBuffer::PerformUndoStep() {
const Action &actionStep = uh.GetUndoStep();
if (actionStep.at == insertAction) {
if (substance.Length() < actionStep.lenData) {
throw std::runtime_error(
"CellBuffer::PerformUndoStep: deletion must be less than document length.");
}
BasicDeleteChars(actionStep.position, actionStep.lenData);
} else if (actionStep.at == removeAction) {
BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);

View File

@ -37,6 +37,7 @@
#include "Document.h"
#include "RESearch.h"
#include "UniConversion.h"
#include "UnicodeFromUTF8.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
@ -766,19 +767,6 @@ bool Document::NextCharacter(int &pos, int moveDir) const {
}
}
static inline int UnicodeFromBytes(const unsigned char *us) {
if (us[0] < 0xC2) {
return us[0];
} else if (us[0] < 0xE0) {
return ((us[0] & 0x1F) << 6) + (us[1] & 0x3F);
} else if (us[0] < 0xF0) {
return ((us[0] & 0xF) << 12) + ((us[1] & 0x3F) << 6) + (us[2] & 0x3F);
} else if (us[0] < 0xF5) {
return ((us[0] & 0x7) << 18) + ((us[1] & 0x3F) << 12) + ((us[2] & 0x3F) << 6) + (us[3] & 0x3F);
}
return us[0];
}
// Return -1 on out-of-bounds
int SCI_METHOD Document::GetRelativePosition(int positionStart, int characterOffset) const {
int pos = positionStart;
@ -799,6 +787,27 @@ int SCI_METHOD Document::GetRelativePosition(int positionStart, int characterOff
return pos;
}
int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) const {
int pos = positionStart;
if (dbcsCodePage) {
const int increment = (characterOffset > 0) ? 1 : -1;
while (characterOffset != 0) {
const int posNext = NextPosition(pos, increment);
if (posNext == pos)
return INVALID_POSITION;
if (abs(pos-posNext) > 3) // 4 byte character = 2*UTF16.
characterOffset -= increment;
pos = posNext;
characterOffset -= increment;
}
} else {
pos = positionStart + characterOffset;
if ((pos < 0) || (pos > Length()))
return INVALID_POSITION;
}
return pos;
}
int SCI_METHOD Document::GetCharacterAndWidth(int position, int *pWidth) const {
int character;
int bytesInCharacter = 1;
@ -819,7 +828,7 @@ int SCI_METHOD Document::GetCharacterAndWidth(int position, int *pWidth) const {
character = 0xDC80 + leadByte;
} else {
bytesInCharacter = utf8status & UTF8MaskWidth;
character = UnicodeFromBytes(charBytes);
character = UnicodeFromUTF8(charBytes);
}
}
} else {
@ -1320,6 +1329,21 @@ int Document::CountCharacters(int startPos, int endPos) const {
return count;
}
int Document::CountUTF16(int startPos, int endPos) const {
startPos = MovePositionOutsideChar(startPos, 1, false);
endPos = MovePositionOutsideChar(endPos, -1, false);
int count = 0;
int i = startPos;
while (i < endPos) {
count++;
const int next = NextPosition(i, 1);
if ((next - i) > 3)
count++;
i = next;
}
return count;
}
int Document::FindColumn(int line, int column) {
int position = LineStart(line);
if ((line >= 0) && (line < LinesTotal())) {
@ -1610,7 +1634,7 @@ Document::CharacterExtracted Document::ExtractCharacter(int position) const {
// Treat as invalid and use up just one byte
return CharacterExtracted(unicodeReplacementChar, 1);
} else {
return CharacterExtracted(UnicodeFromBytes(charBytes), utf8status & UTF8MaskWidth);
return CharacterExtracted(UnicodeFromUTF8(charBytes), utf8status & UTF8MaskWidth);
}
}
@ -2359,6 +2383,9 @@ public:
doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0) {
buffered[0] = 0;
buffered[1] = 0;
if (doc) {
ReadCharacter();
}
}
UTF8Iterator(const UTF8Iterator &other) {
doc = other.doc;
@ -2381,10 +2408,8 @@ public:
}
return *this;
}
wchar_t operator*() {
if (lenCharacters == 0) {
ReadCharacter();
}
wchar_t operator*() const {
assert(lenCharacters != 0);
return buffered[characterIndex];
}
UTF8Iterator &operator++() {

View File

@ -279,6 +279,7 @@ public:
int NextPosition(int pos, int moveDir) const;
bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed
int SCI_METHOD GetRelativePosition(int positionStart, int characterOffset) const;
int GetRelativePositionUTF16(int positionStart, int characterOffset) const;
int SCI_METHOD GetCharacterAndWidth(int position, int *pWidth) const;
int SCI_METHOD CodePage() const;
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
@ -322,6 +323,7 @@ public:
int GetLineIndentPosition(int line) const;
int GetColumn(int position);
int CountCharacters(int startPos, int endPos) const;
int CountUTF16(int startPos, int endPos) const;
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);

View File

@ -65,6 +65,7 @@ EditModel::EditModel() {
imeInteraction = imeWindowed;
foldFlags = 0;
hotspot = Range(invalidPosition);
hoverIndicatorPos = invalidPosition;
wrapWidth = LineLayout::wrapWidthInfinite;
pdoc = new Document();
pdoc->AddRef();

View File

@ -48,6 +48,7 @@ public:
ContractionState cs;
// Hotspot support
Range hotspot;
int hoverIndicatorPos;
// Wrapping support
int wrapWidth;

View File

@ -173,6 +173,7 @@ const XYPOSITION epsilon = 0.0001f; // A small nudge to avoid floating point pre
EditView::EditView() {
ldTabstops = NULL;
tabWidthMinimumPixels = 2; // needed for calculating tab stops for fractional proportional fonts
hideSelection = false;
drawOverstrikeCaret = true;
bufferedDraw = true;
@ -220,10 +221,10 @@ void EditView::ClearAllTabstops() {
}
XYPOSITION EditView::NextTabstopPos(int line, XYPOSITION x, XYPOSITION tabWidth) const {
int next = GetNextTabstop(line, static_cast<int>(x + 2));
int next = GetNextTabstop(line, static_cast<int>(x + tabWidthMinimumPixels));
if (next > 0)
return static_cast<XYPOSITION>(next);
return (static_cast<int>((x + 2) / tabWidth) + 1) * tabWidth;
return (static_cast<int>((x + tabWidthMinimumPixels) / tabWidth) + 1) * tabWidth;
}
bool EditView::ClearTabstops(int line) {
@ -445,7 +446,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co
ll->positions[0] = 0;
bool lastSegItalics = false;
BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs);
BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, NULL);
while (bfLayout.More()) {
const TextSegment ts = bfLayout.Next();
@ -793,7 +794,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart);
// Fill the virtual space and show selections within it
if (virtualSpace) {
if (virtualSpace > 0.0f) {
rcSegment.left = xEol + xStart;
rcSegment.right = xEol + xStart + virtualSpace;
surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[ll->styles[ll->numCharsInLine]].back);
@ -940,18 +941,18 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
}
static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw,
const LineLayout *ll, int xStart, PRectangle rcLine, int subLine) {
const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Indicator::DrawState drawState, int value) {
const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)];
PRectangle rcIndic(
ll->positions[startPos] + xStart - subLineStart,
rcLine.top + vsDraw.maxAscent,
ll->positions[endPos] + xStart - subLineStart,
rcLine.top + vsDraw.maxAscent + 3);
vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine);
vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, drawState, value);
}
static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under) {
int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under, int hoverIndicatorPos) {
// Draw decorators
const int posLineStart = model.pdoc->LineStart(line);
const int lineStart = ll->LineStart(subLine);
@ -967,8 +968,12 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
int endPos = deco->rs.EndRun(startPos);
if (endPos > posLineEnd)
endPos = posLineEnd;
const bool hover = vsDraw.indicators[deco->indicator].IsDynamic() &&
((hoverIndicatorPos >= startPos) && (hoverIndicatorPos <= endPos));
const int value = deco->rs.ValueAt(startPos);
Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal;
DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart,
surface, vsDraw, ll, xStart, rcLine, subLine);
surface, vsDraw, ll, xStart, rcLine, subLine, drawState, value);
startPos = endPos;
if (!deco->rs.ValueAt(startPos)) {
startPos = deco->rs.EndRun(startPos);
@ -986,13 +991,13 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
if (rangeLine.ContainsCharacter(model.braces[0])) {
int braceOffset = model.braces[0] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine);
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1);
}
}
if (rangeLine.ContainsCharacter(model.braces[1])) {
int braceOffset = model.braces[1] - posLineStart;
if (braceOffset < ll->numCharsInLine) {
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine);
DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1);
}
}
}
@ -1247,7 +1252,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
// Does not take margin into account but not significant
const int xStartVisible = static_cast<int>(subLineStart)-xStart;
BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs);
BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, NULL);
const bool drawWhitespaceBackground = vsDraw.WhitespaceBackgroundDrawn() && !background.isSet;
@ -1424,7 +1429,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// Foreground drawing loop
BreakFinder bfFore(ll, &model.sel, lineRange, posLineStart, xStartVisible,
(((phasesDraw == phasesOne) && selBackDrawn) || vsDraw.selColours.fore.isSet), model.pdoc, &model.reprs);
(((phasesDraw == phasesOne) && selBackDrawn) || vsDraw.selColours.fore.isSet), model.pdoc, &model.reprs, &vsDraw);
while (bfFore.More()) {
@ -1447,6 +1452,30 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (vsDraw.hotspotColours.fore.isSet)
textFore = vsDraw.hotspotColours.fore;
}
if (vsDraw.indicatorsSetFore > 0) {
// At least one indicator sets the text colour so see if it applies to this segment
for (Decoration *deco = model.pdoc->decorations.root; deco; deco = deco->next) {
const int indicatorValue = deco->rs.ValueAt(ts.start + posLineStart);
if (indicatorValue) {
const Indicator &indicator = vsDraw.indicators[deco->indicator];
const bool hover = indicator.IsDynamic() &&
((model.hoverIndicatorPos >= ts.start + posLineStart) &&
(model.hoverIndicatorPos <= ts.end() + posLineStart));
if (hover) {
if (indicator.sacHover.style == INDIC_TEXTFORE) {
textFore = indicator.sacHover.fore;
}
} else {
if (indicator.sacNormal.style == INDIC_TEXTFORE) {
if (indicator.Flags() & SC_INDICFLAG_VALUEFORE)
textFore = indicatorValue & SC_INDICVALUEMASK;
else
textFore = indicator.sacNormal.fore;
}
}
}
}
}
const int inSelection = hideSelection ? 0 : model.sel.CharacterInSelection(iDoc);
if (inSelection && (vsDraw.selColours.fore.isSet)) {
textFore = (inSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
@ -1662,7 +1691,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
}
if (phase & drawIndicatorsBack) {
DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, true);
DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, true, model.hoverIndicatorPos);
DrawEdgeLine(surface, vsDraw, ll, rcLine, lineRange, xStart);
DrawMarkUnderline(surface, model, vsDraw, line, rcLine);
}
@ -1677,7 +1706,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
}
if (phase & drawIndicatorsFore) {
DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, false);
DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, false, model.hoverIndicatorPos);
}
// End of the drawing of the current line
@ -1975,11 +2004,11 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface,
vsPrint.Refresh(*surfaceMeasure, model.pdoc->tabInChars); // Recalculate fixedColumnWidth
}
int linePrintStart = model.pdoc->LineFromPosition(pfr->chrg.cpMin);
int linePrintStart = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMin));
int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1;
if (linePrintLast < linePrintStart)
linePrintLast = linePrintStart;
int linePrintMax = model.pdoc->LineFromPosition(pfr->chrg.cpMax);
int linePrintMax = model.pdoc->LineFromPosition(static_cast<int>(pfr->chrg.cpMax));
if (linePrintLast > linePrintMax)
linePrintLast = linePrintMax;
//Platform::DebugPrintf("Formatting lines=[%0d,%0d,%0d] top=%0d bottom=%0d line=%0d %0d\n",
@ -1997,7 +2026,7 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface,
int lineDoc = linePrintStart;
int nPrintPos = pfr->chrg.cpMin;
int nPrintPos = static_cast<int>(pfr->chrg.cpMin);
int visibleLine = 0;
int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth;
if (printParameters.wrapState == eWrapNone)

View File

@ -51,6 +51,7 @@ class EditView {
public:
PrintParameters printParameters;
PerLine *ldTabstops;
int tabWidthMinimumPixels;
bool hideSelection;
bool drawOverstrikeCaret;

View File

@ -8,10 +8,10 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <ctype.h>
#include <cmath>
#include <stdexcept>
#include <string>
#include <vector>
@ -630,6 +630,7 @@ void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition ancho
sel.RangeMain() = rangeNew;
SetRectangularRange();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
@ -657,6 +658,7 @@ void Editor::SetSelection(SelectionPosition currentPos_) {
SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor);
}
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
@ -678,6 +680,7 @@ void Editor::SetEmptySelection(SelectionPosition currentPos_) {
sel.RangeMain() = rangeNew;
SetRectangularRange();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
@ -1333,7 +1336,9 @@ void Editor::ShowCaretAtCurrentPosition() {
void Editor::DropCaret() {
caret.active = false;
FineTickerCancel(tickCaret);
if (FineTickerAvailable()) {
FineTickerCancel(tickCaret);
}
InvalidateCaret();
}
@ -1867,28 +1872,9 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
// Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
// characters representing themselves.
} else {
// Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
// http://www.cl.cam.ac.uk/~mgk25/unicode.html
// http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
if (byte < 0xE0) {
int byte2 = static_cast<unsigned char>(s[1]);
if ((byte2 & 0xC0) == 0x80) {
// Two-byte-character lead-byte followed by a trail-byte.
byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
}
// A two-byte-character lead-byte not followed by trail-byte
// represents itself.
} else if (byte < 0xF0) {
int byte2 = static_cast<unsigned char>(s[1]);
int byte3 = static_cast<unsigned char>(s[2]);
if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
// Three-byte-character lead byte followed by two trail bytes.
byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
(byte3 & 0x3F));
}
// A three-byte-character lead-byte not followed by two trail-bytes
// represents itself.
}
unsigned int utf32[1] = { 0 };
UTF32FromUTF8(s, len, utf32, ELEMENTS(utf32));
byte = utf32[0];
}
NotifyChar(byte);
}
@ -1898,6 +1884,13 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
}
}
void Editor::FillVirtualSpace() {
const bool tmpOverstrike = inOverstrike;
inOverstrike = false; // not allow to be deleted twice.
AddCharUTF("", 0);
inOverstrike = tmpOverstrike;
}
void Editor::InsertPaste(const char *text, int len) {
if (multiPasteMode == SC_MULTIPASTE_ONCE) {
SelectionPosition selStart = sel.Start();
@ -1979,6 +1972,7 @@ void Editor::ClearSelection(bool retainMultipleSelections) {
ThinRectangularRange();
sel.RemoveDuplicates();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
}
void Editor::ClearAll() {
@ -2062,6 +2056,7 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert));
if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) {
while (XFromPosition(sel.MainCaret()) < xInsert) {
assert(pdoc);
const int lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1);
sel.RangeMain().caret.Add(lengthInserted);
}
@ -3283,7 +3278,6 @@ int Editor::KeyCommand(unsigned int iMessage) {
break;
case SCI_EDITTOGGLEOVERTYPE:
inOverstrike = !inOverstrike;
DropCaret();
ShowCaretAtCurrentPosition();
ContainerNeedsUpdate(SC_UPDATE_CONTENT);
NotifyUpdateUI();
@ -3645,7 +3639,10 @@ long Editor::FindText(
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText,
long pos = pdoc->FindText(
static_cast<int>(ft->chrg.cpMin),
static_cast<int>(ft->chrg.cpMax),
ft->lpstrText,
(wParam & SCFIND_MATCHCASE) != 0,
(wParam & SCFIND_WHOLEWORD) != 0,
(wParam & SCFIND_WORDSTART) != 0,
@ -3656,7 +3653,7 @@ long Editor::FindText(
ft->chrgText.cpMin = pos;
ft->chrgText.cpMax = pos + lengthFound;
}
return pos;
return static_cast<int>(pos);
} catch (RegexError &) {
errorStatus = SC_STATUS_WARN_REGEX;
return -1;
@ -3690,7 +3687,7 @@ long Editor::SearchText(
sptr_t lParam) { ///< The text to search for.
const char *txt = reinterpret_cast<char *>(lParam);
int pos;
long pos;
int lengthFound = istrlen(txt);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
@ -3717,7 +3714,7 @@ long Editor::SearchText(
return -1;
}
if (pos != -1) {
SetSelection(pos, pos + lengthFound);
SetSelection(static_cast<int>(pos), static_cast<int>(pos + lengthFound));
}
return pos;
@ -3750,7 +3747,7 @@ long Editor::SearchInTarget(const char *text, int length) {
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
int pos = pdoc->FindText(targetStart, targetEnd, text,
long pos = pdoc->FindText(targetStart, targetEnd, text,
(searchFlags & SCFIND_MATCHCASE) != 0,
(searchFlags & SCFIND_WHOLEWORD) != 0,
(searchFlags & SCFIND_WORDSTART) != 0,
@ -3758,8 +3755,8 @@ long Editor::SearchInTarget(const char *text, int length) {
searchFlags,
&lengthFound);
if (pos != -1) {
targetStart = pos;
targetEnd = pos + lengthFound;
targetStart = static_cast<int>(pos);
targetEnd = static_cast<int>(pos + lengthFound);
}
return pos;
} catch (RegexError &) {
@ -3779,9 +3776,9 @@ void Editor::GoToLine(int lineNo) {
}
static bool Close(Point pt1, Point pt2, Point threshold) {
if (abs(pt1.x - pt2.x) > threshold.x)
if (std::abs(pt1.x - pt2.x) > threshold.x)
return false;
if (abs(pt1.y - pt2.y) > threshold.y)
if (std::abs(pt1.y - pt2.y) > threshold.y)
return false;
return true;
}
@ -4000,7 +3997,7 @@ bool Editor::PointInSelMargin(Point pt) const {
PRectangle rcSelMargin = GetClientRectangle();
rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart - vs.leftMarginWidth);
rcSelMargin.left = static_cast<XYPOSITION>(vs.textStart - vs.fixedColumnWidth);
return rcSelMargin.Contains(pt);
return rcSelMargin.ContainsWholePixel(pt);
} else {
return false;
}
@ -4109,6 +4106,7 @@ static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) {
}
void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) {
SetHoverIndicatorPoint(pt);
//Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop);
ptMouseLast = pt;
const bool ctrl = (modifiers & SCI_CTRL) != 0;
@ -4307,6 +4305,36 @@ bool Editor::PointIsHotspot(Point pt) {
return PositionIsHotspot(pos);
}
void Editor::SetHoverIndicatorPosition(int position) {
int hoverIndicatorPosPrev = hoverIndicatorPos;
hoverIndicatorPos = INVALID_POSITION;
if (vs.indicatorsDynamic == 0)
return;
if (position != INVALID_POSITION) {
for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
if (vs.indicators[deco->indicator].IsDynamic()) {
if (pdoc->decorations.ValueAt(deco->indicator, position)) {
hoverIndicatorPos = position;
}
}
}
}
if (hoverIndicatorPosPrev != hoverIndicatorPos) {
if (hoverIndicatorPosPrev != INVALID_POSITION)
InvalidateRange(hoverIndicatorPosPrev, hoverIndicatorPosPrev + 1);
if (hoverIndicatorPos != INVALID_POSITION)
InvalidateRange(hoverIndicatorPos, hoverIndicatorPos + 1);
}
}
void Editor::SetHoverIndicatorPoint(Point pt) {
if (vs.indicatorsDynamic == 0) {
SetHoverIndicatorPosition(INVALID_POSITION);
} else {
SetHoverIndicatorPosition(PositionFromLocation(pt, true, true));
}
}
void Editor::SetHotSpotRange(Point *pt) {
if (pt) {
int pos = PositionFromLocation(*pt, false, true);
@ -4449,12 +4477,18 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) {
// Display regular (drag) cursor over selection
if (PointInSelection(pt) && !SelectionEmpty()) {
DisplayCursor(Window::cursorArrow);
} else if (PointIsHotspot(pt)) {
DisplayCursor(Window::cursorHand);
SetHotSpotRange(&pt);
} else {
DisplayCursor(Window::cursorText);
SetHotSpotRange(NULL);
SetHoverIndicatorPoint(pt);
if (PointIsHotspot(pt)) {
DisplayCursor(Window::cursorHand);
SetHotSpotRange(&pt);
} else {
if (hoverIndicatorPos != invalidPosition)
DisplayCursor(Window::cursorHand);
else
DisplayCursor(Window::cursorText);
SetHotSpotRange(NULL);
}
}
}
}
@ -4467,6 +4501,8 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
SelectionPosition newPos = SPositionFromLocation(pt, false, false,
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
if (hoverIndicatorPos != INVALID_POSITION)
InvalidateRange(newPos.Position(), newPos.Position() + 1);
newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
if (inDragDrop == ddInitial) {
inDragDrop = ddNone;
@ -4671,12 +4707,10 @@ void Editor::FineTickerCancel(TickReason) {
void Editor::SetFocusState(bool focusState) {
hasFocus = focusState;
NotifyFocus(hasFocus);
if (hasFocus) {
ShowCaretAtCurrentPosition();
} else {
if (!hasFocus) {
CancelModes();
DropCaret();
}
ShowCaretAtCurrentPosition();
}
int Editor::PositionAfterArea(PRectangle rcArea) const {
@ -4784,6 +4818,7 @@ void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) {
void Editor::SetAnnotationHeights(int start, int end) {
if (vs.annotationVisible) {
RefreshStyleData();
bool changedHeight = false;
for (int line=start; line<end && line<pdoc->LinesTotal(); line++) {
int linesWrapped = 1;
@ -4834,6 +4869,9 @@ void Editor::SetDocPointer(Document *document) {
view.llc.Deallocate();
NeedWrapping();
hotspot = Range(invalidPosition);
hoverIndicatorPos = invalidPosition;
view.ClearAllTabstops();
pdoc->AddWatcher(this, 0);
@ -5287,7 +5325,7 @@ sptr_t Editor::StringResult(sptr_t lParam, const char *val) {
sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len) {
// No NUL termination: len is number of valid/displayed bytes
if (lParam) {
if ((lParam) && (len > 0)) {
char *ptr = CharPtrFromSPtr(lParam);
if (val)
memcpy(ptr, val, len);
@ -5505,6 +5543,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETTARGETEND:
return targetEnd;
case SCI_SETTARGETRANGE:
targetStart = static_cast<int>(wParam);
targetEnd = static_cast<int>(lParam);
break;
case SCI_TARGETFROMSELECTION:
if (sel.MainCaret() < sel.MainAnchor()) {
targetStart = sel.MainCaret();
@ -5515,6 +5558,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
case SCI_GETTARGETTEXT: {
std::string text = RangeText(targetStart, targetEnd);
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(text.c_str()), text.length());
}
case SCI_REPLACETARGET:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
@ -5603,12 +5651,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (lParam == 0)
return 0;
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
int cpMax = tr->chrg.cpMax;
int cpMax = static_cast<int>(tr->chrg.cpMax);
if (cpMax == -1)
cpMax = pdoc->Length();
PLATFORM_ASSERT(cpMax <= pdoc->Length());
int len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions
pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len);
int len = static_cast<int>(cpMax - tr->chrg.cpMin); // No -1 as cpMin and cpMax are referring to inter character positions
pdoc->GetCharRange(tr->lpstrText, static_cast<int>(tr->chrg.cpMin), len);
// Spec says copied text is terminated with a NUL
tr->lpstrText[len] = '\0';
return len; // Not including NUL
@ -5846,9 +5894,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 0;
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
int iPlace = 0;
for (int iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) {
tr->lpstrText[iPlace++] = pdoc->CharAt(iChar);
tr->lpstrText[iPlace++] = pdoc->StyleAt(iChar);
for (long iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) {
tr->lpstrText[iPlace++] = pdoc->CharAt(static_cast<int>(iChar));
tr->lpstrText[iPlace++] = pdoc->StyleAt(static_cast<int>(iChar));
}
tr->lpstrText[iPlace] = '\0';
tr->lpstrText[iPlace + 1] = '\0';
@ -6179,6 +6227,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return TextWidth(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
case SCI_TEXTHEIGHT:
RefreshStyleData();
return vs.lineHeight;
case SCI_SETENDATLASTLINE:
@ -6759,23 +6808,55 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETSTYLE:
if (wParam <= INDIC_MAX) {
vs.indicators[wParam].style = static_cast<int>(lParam);
vs.indicators[wParam].sacNormal.style = static_cast<int>(lParam);
vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETSTYLE:
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].style : 0;
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.style : 0;
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
vs.indicators[wParam].fore = ColourDesired(static_cast<long>(lParam));
vs.indicators[wParam].sacNormal.fore = ColourDesired(static_cast<long>(lParam));
vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETFORE:
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.AsLong() : 0;
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.fore.AsLong() : 0;
case SCI_INDICSETHOVERSTYLE:
if (wParam <= INDIC_MAX) {
vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETHOVERSTYLE:
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.style : 0;
case SCI_INDICSETHOVERFORE:
if (wParam <= INDIC_MAX) {
vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETHOVERFORE:
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsLong() : 0;
case SCI_INDICSETFLAGS:
if (wParam <= INDIC_MAX) {
vs.indicators[wParam].SetFlags(static_cast<int>(lParam));
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETFLAGS:
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].Flags() : 0;
case SCI_INDICSETUNDER:
if (wParam <= INDIC_MAX) {

View File

@ -388,6 +388,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
int InsertSpace(int position, unsigned int spaces);
void AddChar(char ch);
virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
void FillVirtualSpace();
void InsertPaste(const char *text, int len);
enum PasteShape { pasteStream=0, pasteRectangular = 1, pasteLine = 2 };
void InsertPasteShape(const char *text, int len, PasteShape shape);
@ -544,6 +545,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool PointIsHotspot(Point pt);
void SetHotSpotRange(Point *pt);
Range GetHotSpotRange() const;
void SetHoverIndicatorPosition(int position);
void SetHoverIndicatorPoint(Point pt);
int CodePage() const;
virtual bool ValidCodePage(int /* codePage */) const { return true; }

View File

@ -23,10 +23,17 @@ static PRectangle PixelGridAlign(const PRectangle &rc) {
return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom));
}
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const {
surface->PenColour(fore);
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const {
StyleAndColour sacDraw = sacNormal;
if (Flags() & SC_INDICFLAG_VALUEFORE) {
sacDraw.fore = value & SC_INDICVALUEMASK;
}
if (drawState == drawHover) {
sacDraw = sacHover;
}
surface->PenColour(sacDraw.fore);
int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
if (style == INDIC_SQUIGGLE) {
if (sacDraw.style == INDIC_SQUIGGLE) {
int x = int(rc.left+0.5);
int xLast = int(rc.right+0.5);
int y = 0;
@ -42,7 +49,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
surface->LineTo(x, static_cast<int>(rc.top) + y);
}
} else if (style == INDIC_SQUIGGLEPIXMAP) {
} else if (sacDraw.style == INDIC_SQUIGGLEPIXMAP) {
PRectangle rcSquiggle = PixelGridAlign(rc);
int width = Platform::Minimum(4000, static_cast<int>(rcSquiggle.Width()));
@ -51,17 +58,17 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
for (int x = 0; x < width; x++) {
if (x%2) {
// Two halfway columns have a full pixel in middle flanked by light pixels
image.SetPixel(x, 0, fore, alphaSide);
image.SetPixel(x, 1, fore, alphaFull);
image.SetPixel(x, 2, fore, alphaSide);
image.SetPixel(x, 0, sacDraw.fore, alphaSide);
image.SetPixel(x, 1, sacDraw.fore, alphaFull);
image.SetPixel(x, 2, sacDraw.fore, alphaSide);
} else {
// Extreme columns have a full pixel at bottom or top and a mid-tone pixel in centre
image.SetPixel(x, (x%4) ? 0 : 2, fore, alphaFull);
image.SetPixel(x, 1, fore, alphaSide2);
image.SetPixel(x, (x % 4) ? 0 : 2, sacDraw.fore, alphaFull);
image.SetPixel(x, 1, sacDraw.fore, alphaSide2);
}
}
surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels());
} else if (style == INDIC_SQUIGGLELOW) {
} else if (sacDraw.style == INDIC_SQUIGGLELOW) {
surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top));
int x = static_cast<int>(rc.left) + 3;
int y = 0;
@ -72,7 +79,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
x += 3;
}
surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) + y); // Finish the line
} else if (style == INDIC_TT) {
} else if (sacDraw.style == INDIC_TT) {
surface->MoveTo(static_cast<int>(rc.left), ymid);
int x = static_cast<int>(rc.left) + 5;
while (x < rc.right) {
@ -88,7 +95,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->MoveTo(x-3, ymid);
surface->LineTo(x-3, ymid+2);
}
} else if (style == INDIC_DIAGONAL) {
} else if (sacDraw.style == INDIC_DIAGONAL) {
int x = static_cast<int>(rc.left);
while (x < rc.right) {
surface->MoveTo(x, static_cast<int>(rc.top) + 2);
@ -101,24 +108,28 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->LineTo(endX, endY);
x += 4;
}
} else if (style == INDIC_STRIKE) {
} else if (sacDraw.style == INDIC_STRIKE) {
surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top) - 4);
surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) - 4);
} else if (style == INDIC_HIDDEN) {
} else if ((sacDraw.style == INDIC_HIDDEN) || (sacDraw.style == INDIC_TEXTFORE)) {
// Draw nothing
} else if (style == INDIC_BOX) {
} else if (sacDraw.style == INDIC_BOX) {
surface->MoveTo(static_cast<int>(rc.left), ymid + 1);
surface->LineTo(static_cast<int>(rc.right), ymid + 1);
surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rcLine.top) + 1);
surface->LineTo(static_cast<int>(rc.left), static_cast<int>(rcLine.top) + 1);
surface->LineTo(static_cast<int>(rc.left), ymid + 1);
} else if (style == INDIC_ROUNDBOX || style == INDIC_STRAIGHTBOX) {
} else if (sacDraw.style == INDIC_ROUNDBOX ||
sacDraw.style == INDIC_STRAIGHTBOX ||
sacDraw.style == INDIC_FULLBOX) {
PRectangle rcBox = rcLine;
rcBox.top = rcLine.top + 1;
if (sacDraw.style != INDIC_FULLBOX)
rcBox.top = rcLine.top + 1;
rcBox.left = rc.left;
rcBox.right = rc.right;
surface->AlphaRectangle(rcBox, (style == INDIC_ROUNDBOX) ? 1 : 0, fore, fillAlpha, fore, outlineAlpha, 0);
} else if (style == INDIC_DOTBOX) {
surface->AlphaRectangle(rcBox, (sacDraw.style == INDIC_ROUNDBOX) ? 1 : 0,
sacDraw.fore, fillAlpha, sacDraw.fore, outlineAlpha, 0);
} else if (sacDraw.style == INDIC_DOTBOX) {
PRectangle rcBox = PixelGridAlign(rc);
rcBox.top = rcLine.top + 1;
rcBox.bottom = rcLine.bottom;
@ -128,36 +139,42 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
// Draw horizontal lines top and bottom
for (int x=0; x<width; x++) {
for (int y = 0; y<static_cast<int>(rcBox.Height()); y += static_cast<int>(rcBox.Height()) - 1) {
image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
// Draw vertical lines left and right
for (int y = 1; y<static_cast<int>(rcBox.Height()); y++) {
for (int x=0; x<width; x += width-1) {
image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels());
} else if (style == INDIC_DASH) {
} else if (sacDraw.style == INDIC_DASH) {
int x = static_cast<int>(rc.left);
while (x < rc.right) {
surface->MoveTo(x, ymid);
surface->LineTo(Platform::Minimum(x + 4, static_cast<int>(rc.right)), ymid);
x += 7;
}
} else if (style == INDIC_DOTS) {
} else if (sacDraw.style == INDIC_DOTS) {
int x = static_cast<int>(rc.left);
while (x < static_cast<int>(rc.right)) {
PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1);
surface->FillRectangle(rcDot, fore);
surface->FillRectangle(rcDot, sacDraw.fore);
x += 2;
}
} else if (style == INDIC_COMPOSITIONTHICK) {
} else if (sacDraw.style == INDIC_COMPOSITIONTHICK) {
PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom);
surface->FillRectangle(rcComposition, fore);
surface->FillRectangle(rcComposition, sacDraw.fore);
} else if (sacDraw.style == INDIC_COMPOSITIONTHIN) {
PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1);
surface->FillRectangle(rcComposition, sacDraw.fore);
} else { // Either INDIC_PLAIN or unknown
surface->MoveTo(static_cast<int>(rc.left), ymid);
surface->LineTo(static_cast<int>(rc.right), ymid);
}
}
void Indicator::SetFlags(int attributes_) {
attributes = attributes_;
}

View File

@ -12,21 +12,45 @@
namespace Scintilla {
#endif
struct StyleAndColour {
int style;
ColourDesired fore;
StyleAndColour() : style(INDIC_PLAIN), fore(0, 0, 0) {
}
StyleAndColour(int style_, ColourDesired fore_ = ColourDesired(0, 0, 0)) : style(style_), fore(fore_) {
}
bool operator==(const StyleAndColour &other) const {
return (style == other.style) && (fore == other.fore);
}
};
/**
*/
class Indicator {
public:
int style;
ColourDesired fore;
enum DrawState { drawNormal, drawHover };
StyleAndColour sacNormal;
StyleAndColour sacHover;
bool under;
int fillAlpha;
int outlineAlpha;
Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)), under(false), fillAlpha(30), outlineAlpha(50) {
int attributes;
Indicator() : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) {
}
Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) :
style(style_), fore(fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_) {
sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) {
}
void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const;
void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const;
bool IsDynamic() const {
return !(sacNormal == sacHover);
}
bool OverridesTextFore() const {
return sacNormal.style == INDIC_TEXTFORE || sacHover.style == INDIC_TEXTFORE;
}
int Flags() const {
return attributes;
}
void SetFlags(int attributes_);
};
#ifdef SCI_NAMESPACE

View File

@ -263,8 +263,10 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
PLATFORM_ASSERT(visibleLine < model.cs.LinesDisplayed());
const int lineDoc = model.cs.DocFromDisplay(visibleLine);
PLATFORM_ASSERT(model.cs.GetVisible(lineDoc));
const bool firstSubLine = visibleLine == model.cs.DisplayFromDoc(lineDoc);
const bool lastSubLine = visibleLine == model.cs.DisplayLastFromDoc(lineDoc);
const int firstVisibleLine = model.cs.DisplayFromDoc(lineDoc);
const int lastVisibleLine = model.cs.DisplayLastFromDoc(lineDoc);
const bool firstSubLine = visibleLine == firstVisibleLine;
const bool lastSubLine = visibleLine == lastVisibleLine;
int marks = model.pdoc->GetMark(lineDoc);
if (!firstSubLine)
@ -403,9 +405,9 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
}
}
} else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) {
if (firstSubLine) {
const StyledText stMargin = model.pdoc->MarginStyledText(lineDoc);
if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) {
const StyledText stMargin = model.pdoc->MarginStyledText(lineDoc);
if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) {
if (firstSubLine) {
surface->FillRectangle(rcMarker,
vs.styles[stMargin.StyleAt(0) + vs.marginStyleOffset].back);
if (vs.ms[margin].style == SC_MARGIN_RTEXT) {
@ -414,6 +416,12 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
}
DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker,
stMargin, 0, stMargin.length, drawAll);
} else {
// if we're displaying annotation lines, color the margin to match the associated document line
const int annotationLines = model.pdoc->AnnotationLines(lineDoc);
if (annotationLines && (visibleLine > lastVisibleLine - annotationLines)) {
surface->FillRectangle(rcMarker, vs.styles[stMargin.StyleAt(0) + vs.marginStyleOffset].back);
}
}
}
}

View File

@ -440,7 +440,7 @@ void BreakFinder::Insert(int val) {
}
BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, int posLineStart_,
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_) :
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) :
ll(ll_),
lineRange(lineRange_),
posLineStart(posLineStart_),
@ -475,7 +475,17 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin
}
}
}
if (pvsDraw && pvsDraw->indicatorsSetFore > 0) {
for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
if (pvsDraw->indicators[deco->indicator].OverridesTextFore()) {
int startPos = deco->rs.EndRun(posLineStart);
while (startPos < (posLineStart + lineRange.end)) {
Insert(startPos - posLineStart);
startPos = deco->rs.EndRun(startPos);
}
}
}
}
Insert(ll->edgeColumn);
Insert(lineRange.end);
saeNext = (!selAndEdge.empty()) ? selAndEdge[0] : -1;

View File

@ -168,7 +168,7 @@ public:
// Try to make each subdivided run lengthEachSubdivision or shorter.
enum { lengthEachSubdivision = 100 };
BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, int posLineStart_,
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_);
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw);
~BreakFinder();
TextSegment Next();
bool More() const;

View File

@ -342,8 +342,8 @@ static int GetHexaChar(unsigned char hd1, unsigned char hd2) {
/**
* Called when the parser finds a backslash not followed
* by a valid expression (like \( in non-Posix mode).
* @param pattern: pointer on the char after the backslash.
* @param incr: (out) number of chars to skip after expression evaluation.
* @param pattern : pointer on the char after the backslash.
* @param incr : (out) number of chars to skip after expression evaluation.
* @return the char if it resolves to a simple char,
* or -1 for a char class. In this case, bittab is changed.
*/

View File

@ -449,12 +449,12 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
PRectangle rcClient = GetClientRectangle();
int offset = vs.lineHeight + static_cast<int>(rc.Height());
// adjust so it displays above the text.
if (rc.bottom > rcClient.bottom) {
if (rc.bottom > rcClient.bottom && rc.Height() < rcClient.Height()) {
rc.top -= offset;
rc.bottom -= offset;
}
// adjust so it displays below the text.
if (rc.top < rcClient.top) {
if (rc.top < rcClient.top && rc.Height() < rcClient.Height()) {
rc.top += offset;
rc.bottom += offset;
}
@ -587,7 +587,7 @@ void LexState::SetLexerModule(const LexerModule *lex) {
}
void LexState::SetLexer(uptr_t wParam) {
lexLanguage = wParam;
lexLanguage = static_cast<int>(wParam);
if (lexLanguage == SCLEX_CONTAINER) {
SetLexerModule(0);
} else {
@ -999,7 +999,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), static_cast<int>(lParam));
case SCI_SETKEYWORDS:
DocumentLexState()->SetWordList(wParam, reinterpret_cast<const char *>(lParam));
DocumentLexState()->SetWordList(static_cast<int>(wParam), reinterpret_cast<const char *>(lParam));
break;
case SCI_SETLEXERLANGUAGE:
@ -1011,7 +1011,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_PRIVATELEXERCALL:
return reinterpret_cast<sptr_t>(
DocumentLexState()->PrivateCall(wParam, reinterpret_cast<void *>(lParam)));
DocumentLexState()->PrivateCall(static_cast<int>(wParam), reinterpret_cast<void *>(lParam)));
case SCI_GETSTYLEBITSNEEDED:
return 8;
@ -1023,7 +1023,8 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return DocumentLexState()->PropertyType(reinterpret_cast<const char *>(wParam));
case SCI_DESCRIBEPROPERTY:
return StringResult(lParam, DocumentLexState()->DescribeProperty(reinterpret_cast<const char *>(wParam)));
return StringResult(lParam,
DocumentLexState()->DescribeProperty(reinterpret_cast<const char *>(wParam)));
case SCI_DESCRIBEKEYWORDSETS:
return StringResult(lParam, DocumentLexState()->DescribeWordListSets());
@ -1032,26 +1033,27 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return DocumentLexState()->LineEndTypesSupported();
case SCI_ALLOCATESUBSTYLES:
return DocumentLexState()->AllocateSubStyles(wParam, lParam);
return DocumentLexState()->AllocateSubStyles(static_cast<int>(wParam), static_cast<int>(lParam));
case SCI_GETSUBSTYLESSTART:
return DocumentLexState()->SubStylesStart(wParam);
return DocumentLexState()->SubStylesStart(static_cast<int>(wParam));
case SCI_GETSUBSTYLESLENGTH:
return DocumentLexState()->SubStylesLength(wParam);
return DocumentLexState()->SubStylesLength(static_cast<int>(wParam));
case SCI_GETSTYLEFROMSUBSTYLE:
return DocumentLexState()->StyleFromSubStyle(wParam);
return DocumentLexState()->StyleFromSubStyle(static_cast<int>(wParam));
case SCI_GETPRIMARYSTYLEFROMSTYLE:
return DocumentLexState()->PrimaryStyleFromStyle(wParam);
return DocumentLexState()->PrimaryStyleFromStyle(static_cast<int>(wParam));
case SCI_FREESUBSTYLES:
DocumentLexState()->FreeSubStyles();
break;
case SCI_SETIDENTIFIERS:
DocumentLexState()->SetIdentifiers(wParam, reinterpret_cast<const char *>(lParam));
DocumentLexState()->SetIdentifiers(static_cast<int>(wParam),
reinterpret_cast<const char *>(lParam));
break;
case SCI_DISTANCETOSECONDARYSTYLES:

View File

@ -17,7 +17,6 @@ using namespace Scintilla;
namespace Scintilla {
#endif
enum { SURROGATE_LEAD_FIRST = 0xD800 };
enum { SURROGATE_TRAIL_FIRST = 0xDC00 };
enum { SURROGATE_TRAIL_LAST = 0xDFFF };
enum { SUPPLEMENTAL_PLANE_FIRST = 0x10000 };
@ -43,7 +42,7 @@ unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
}
void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
int k = 0;
unsigned int k = 0;
for (unsigned int i = 0; i < tlen && uptr[i];) {
unsigned int uch = uptr[i];
if (uch < 0x80) {
@ -67,7 +66,8 @@ void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned
}
i++;
}
putf[len] = '\0';
if (k < len)
putf[k] = '\0';
}
unsigned int UTF8CharLength(unsigned char ch) {
@ -82,10 +82,10 @@ unsigned int UTF8CharLength(unsigned char ch) {
}
}
unsigned int UTF16Length(const char *s, unsigned int len) {
unsigned int ulen = 0;
unsigned int charLen;
for (unsigned int i=0; i<len;) {
size_t UTF16Length(const char *s, size_t len) {
size_t ulen = 0;
size_t charLen;
for (size_t i = 0; i<len;) {
unsigned char ch = static_cast<unsigned char>(s[i]);
if (ch < 0x80) {
charLen = 1;
@ -103,10 +103,10 @@ unsigned int UTF16Length(const char *s, unsigned int len) {
return ulen;
}
unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
unsigned int ui=0;
size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen) {
size_t ui = 0;
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
unsigned int i=0;
size_t i = 0;
while ((i<len) && (ui<tlen)) {
unsigned char ch = us[i++];
if (ch < 0x80) {
@ -145,7 +145,7 @@ unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf,
unsigned int i=0;
while ((i<len) && (ui<tlen)) {
unsigned char ch = us[i++];
wchar_t value = 0;
unsigned int value = 0;
if (ch < 0x80) {
value = ch;
} else if (((len-i) >= 1) && (ch < 0x80 + 0x40 + 0x20)) {

View File

@ -19,8 +19,8 @@ const int unicodeReplacementChar = 0xFFFD;
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen);
void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len);
unsigned int UTF8CharLength(unsigned char ch);
unsigned int UTF16Length(const char *s, unsigned int len);
unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen);
size_t UTF16Length(const char *s, size_t len);
size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen);
unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int tlen);
unsigned int UTF16FromUTF32Character(unsigned int val, wchar_t *tbuf);
@ -55,6 +55,12 @@ inline bool UTF8IsNEL(const unsigned char *us) {
return (us[0] == 0xc2) && (us[1] == 0x85);
}
enum { SURROGATE_LEAD_FIRST = 0xD800 };
enum { SURROGATE_LEAD_LAST = 0xDBFF };
inline unsigned int UTF16CharLength(wchar_t uch) {
return ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_LEAD_LAST)) ? 2 : 1;
}
#ifdef SCI_NAMESPACE
}
#endif

View File

@ -101,8 +101,14 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
markers[mrk] = source.markers[mrk];
}
CalcLargestMarkerHeight();
indicatorsDynamic = 0;
indicatorsSetFore = 0;
for (int ind=0; ind<=INDIC_MAX; ind++) {
indicators[ind] = source.indicators[ind];
if (indicators[ind].IsDynamic())
indicatorsDynamic++;
if (indicators[ind].OverridesTextFore())
indicatorsSetFore++;
}
selColours = source.selColours;
@ -197,6 +203,8 @@ void ViewStyle::Init(size_t stylesSize_) {
indicators[2] = Indicator(INDIC_PLAIN, ColourDesired(0xff, 0, 0));
technology = SC_TECHNOLOGY_DEFAULT;
indicatorsDynamic = 0;
indicatorsSetFore = 0;
lineHeight = 1;
lineOverlap = 0;
maxAscent = 1;
@ -318,6 +326,14 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {
FontRealised *fr = Find(styles[k]);
styles[k].Copy(fr->font, *fr);
}
indicatorsDynamic = 0;
indicatorsSetFore = 0;
for (int ind = 0; ind <= INDIC_MAX; ind++) {
if (indicators[ind].IsDynamic())
indicatorsDynamic++;
if (indicators[ind].OverridesTextFore())
indicatorsSetFore++;
}
maxAscent = 1;
maxDescent = 1;
FindMaxAscentDescent();

View File

@ -83,6 +83,8 @@ public:
LineMarker markers[MARKER_MAX + 1];
int largestMarkerHeight;
Indicator indicators[INDIC_MAX + 1];
unsigned int indicatorsDynamic;
unsigned int indicatorsSetFore;
int technology;
int lineHeight;
int lineOverlap;

View File

@ -449,6 +449,7 @@ void wxStyledTextCtrl::SetAnchor(int posAnchor)
// Retrieve the text of the line containing the caret.
// Returns the index of the caret on the line.
// Result is NUL-terminated.
wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
int len = LineLength(GetCurrentLine());
if (!len) {
@ -1069,6 +1070,43 @@ bool wxStyledTextCtrl::IndicatorGetUnder(int indic) const
return SendMsg(SCI_INDICGETUNDER, indic, 0) != 0;
}
// Set a hover indicator to plain, squiggle or TT.
void wxStyledTextCtrl::IndicatorSetHoverStyle(int indic, int style)
{
SendMsg(SCI_INDICSETHOVERSTYLE, indic, style);
}
// Retrieve the hover style of an indicator.
int wxStyledTextCtrl::IndicatorGetHoverStyle(int indic) const
{
return SendMsg(SCI_INDICGETHOVERSTYLE, indic, 0);
}
// Set the foreground hover colour of an indicator.
void wxStyledTextCtrl::IndicatorSetHoverForeground(int indic, const wxColour& fore)
{
SendMsg(SCI_INDICSETHOVERFORE, indic, wxColourAsLong(fore));
}
// Retrieve the foreground hover colour of an indicator.
wxColour wxStyledTextCtrl::IndicatorGetHoverForeground(int indic) const
{
long c = SendMsg(SCI_INDICGETHOVERFORE, indic, 0);
return wxColourFromLong(c);
}
// Set the attributes of an indicator.
void wxStyledTextCtrl::IndicatorSetFlags(int indic, int flags)
{
SendMsg(SCI_INDICSETFLAGS, indic, flags);
}
// Retrieve the attributes of an indicator.
int wxStyledTextCtrl::IndicatorGetFlags(int indic) const
{
return SendMsg(SCI_INDICGETFLAGS, indic, 0);
}
// Set the foreground colour of all whitespace and whether to use this setting.
void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore)
{
@ -1833,6 +1871,24 @@ int wxStyledTextCtrl::GetTargetEnd() const
return SendMsg(SCI_GETTARGETEND, 0, 0);
}
// Sets both the start and end of the target in one call.
void wxStyledTextCtrl::SetTargetRange(int start, int end)
{
SendMsg(SCI_SETTARGETRANGE, start, end);
}
// Retrieve the text in the target.
wxString wxStyledTextCtrl::GetTargetText() const {
int startPos = GetTargetStart();
int endPos = GetTargetEnd();
wxMemoryBuffer mbuf(endPos-startPos+1); // leave room for the null...
char* buf = (char*)mbuf.GetWriteBuf(endPos-startPos+1);
SendMsg(SCI_GETTARGETTEXT, 0, (sptr_t)buf);
mbuf.UngetWriteBuf(endPos-startPos);
mbuf.AppendByte(0);
return stc2wx(buf);
}
// Replace the target text with the argument text.
// Text is counted so it can contain NULs.
// Returns the length of the replacement text.
@ -2320,6 +2376,7 @@ int wxStyledTextCtrl::GetMultiPaste() const
}
// Retrieve the value of a tag from a regular expression search.
// Result is NUL-terminated.
wxString wxStyledTextCtrl::GetTag(int tagNumber) const {
const int msg = SCI_GETTAG;
int len = SendMsg(msg, tagNumber, (sptr_t)NULL);
@ -3531,18 +3588,6 @@ int wxStyledTextCtrl::GetGapPosition() const
return SendMsg(SCI_GETGAPPOSITION, 0, 0);
}
// Always interpret keyboard input as Unicode
void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode)
{
SendMsg(SCI_SETKEYSUNICODE, keysUnicode, 0);
}
// Are keys always interpreted as Unicode?
bool wxStyledTextCtrl::GetKeysUnicode() const
{
return SendMsg(SCI_GETKEYSUNICODE, 0, 0) != 0;
}
// Set the alpha fill colour of the given indicator.
void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha)
{
@ -4211,6 +4256,7 @@ void wxStyledTextCtrl::SetRepresentation(const wxString& encodedCharacter, const
}
// Set the way a character is drawn.
// Result is NUL-terminated.
wxString wxStyledTextCtrl::GetRepresentation(const wxString& encodedCharacter) const {
int msg = SCI_GETREPRESENTATION;
int len = SendMsg(msg, (sptr_t)(const char*)wx2stc(encodedCharacter), (sptr_t)NULL);
@ -4324,6 +4370,7 @@ void* wxStyledTextCtrl::PrivateLexerCall(int operation, void* pointer) {
}
// Retrieve a '\n' separated list of properties understood by the current lexer.
// Result is NUL-terminated.
wxString wxStyledTextCtrl::PropertyNames() const {
const int msg = SCI_PROPERTYNAMES;
int len = SendMsg(msg, 0, (sptr_t)NULL);
@ -4344,6 +4391,7 @@ int wxStyledTextCtrl::PropertyType(const wxString& name)
}
// Describe a property.
// Result is NUL-terminated.
wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const {
const int msg = SCI_DESCRIBEPROPERTY;
int len = SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)NULL);
@ -4358,6 +4406,7 @@ wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const {
}
// Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
// Result is NUL-terminated.
wxString wxStyledTextCtrl::DescribeKeyWordSets() const {
const int msg = SCI_DESCRIBEKEYWORDSETS;
int len = SendMsg(msg, 0, (sptr_t)NULL);
@ -4428,6 +4477,7 @@ int wxStyledTextCtrl::DistanceToSecondaryStyles() const
}
// Get the set of base styles that can be extended with sub styles
// Result is NUL-terminated.
wxString wxStyledTextCtrl::GetSubStyleBases() const {
int msg = SCI_GETSUBSTYLEBASES;
int len = SendMsg(msg, 0, (sptr_t)NULL);
@ -5380,7 +5430,7 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
/*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo()
{
return wxVersionInfo("Scintilla", 3, 5, 2, "Scintilla 3.5.2");
return wxVersionInfo("Scintilla", 3, 5, 5, "Scintilla 3.5.5");
}
#endif // wxUSE_STC

View File

@ -1205,7 +1205,7 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
/*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo()
{
return wxVersionInfo("Scintilla", 3, 5, 2, "Scintilla 3.5.2");
return wxVersionInfo("Scintilla", 3, 5, 5, "Scintilla 3.5.5");
}
#endif // wxUSE_STC