Upgraded to version 1.39 of Scintilla, and upated wxStyledTextCtrl

accordingly.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-09-01 03:06:33 +00:00
parent b8fbf1a035
commit 65ec6247df
150 changed files with 22043 additions and 10836 deletions

View File

@@ -57,6 +57,28 @@
#define wxSTC_MARK_ARROWDOWN 6 #define wxSTC_MARK_ARROWDOWN 6
#define wxSTC_MARK_MINUS 7 #define wxSTC_MARK_MINUS 7
#define wxSTC_MARK_PLUS 8 #define wxSTC_MARK_PLUS 8
// Shapes used for outlining column
#define wxSTC_MARK_VLINE 9
#define wxSTC_MARK_LCORNER 10
#define wxSTC_MARK_TCORNER 11
#define wxSTC_MARK_BOXPLUS 12
#define wxSTC_MARK_BOXPLUSCONNECTED 13
#define wxSTC_MARK_BOXMINUS 14
#define wxSTC_MARK_BOXMINUSCONNECTED 15
#define wxSTC_MARK_LCORNERCURVE 16
#define wxSTC_MARK_TCORNERCURVE 17
#define wxSTC_MARK_CIRCLEPLUS 18
#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
#define wxSTC_MARK_CIRCLEMINUS 20
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
// Markers used for outlining column
#define wxSTC_MARKNUM_FOLDEREND 25
#define wxSTC_MARKNUM_FOLDEROPENMID 26
#define wxSTC_MARKNUM_FOLDERMIDTAIL 27
#define wxSTC_MARKNUM_FOLDERTAIL 28
#define wxSTC_MARKNUM_FOLDERSUB 29
#define wxSTC_MARKNUM_FOLDER 30 #define wxSTC_MARKNUM_FOLDER 30
#define wxSTC_MARKNUM_FOLDEROPEN 31 #define wxSTC_MARKNUM_FOLDEROPEN 31
#define wxSTC_MARGIN_SYMBOL 0 #define wxSTC_MARGIN_SYMBOL 0
@@ -90,6 +112,9 @@
#define wxSTC_CHARSET_ARABIC 178 #define wxSTC_CHARSET_ARABIC 178
#define wxSTC_CHARSET_VIETNAMESE 163 #define wxSTC_CHARSET_VIETNAMESE 163
#define wxSTC_CHARSET_THAI 222 #define wxSTC_CHARSET_THAI 222
#define wxSTC_CASE_MIXED 0
#define wxSTC_CASE_UPPER 1
#define wxSTC_CASE_LOWER 2
#define wxSTC_INDIC_MAX 7 #define wxSTC_INDIC_MAX 7
#define wxSTC_INDIC_PLAIN 0 #define wxSTC_INDIC_PLAIN 0
#define wxSTC_INDIC_SQUIGGLE 1 #define wxSTC_INDIC_SQUIGGLE 1
@@ -109,12 +134,15 @@
// PrintColourMode - force black text on white background for printing. // PrintColourMode - force black text on white background for printing.
#define wxSTC_PRINT_BLACKONWHITE 2 #define wxSTC_PRINT_BLACKONWHITE 2
#define wxSTC_FIND_DOWN 1
// PrintColourMode - text stays coloured, but all background is forced to be white for printing.
#define wxSTC_PRINT_COLOURONWHITE 3
// PrintColourMode - only the default-background is forced to be white for printing.
#define wxSTC_PRINT_COLOURONWHITEDEFAULTBG 4
#define wxSTC_FIND_WHOLEWORD 2 #define wxSTC_FIND_WHOLEWORD 2
#define wxSTC_FIND_MATCHCASE 4 #define wxSTC_FIND_MATCHCASE 4
#define wxSTC_FIND_WORDSTART 0x00100000 #define wxSTC_FIND_WORDSTART 0x00100000
// SCFIND_REGEXP is not yet implemented.
#define wxSTC_FIND_REGEXP 0x00200000 #define wxSTC_FIND_REGEXP 0x00200000
#define wxSTC_CMD_UNDO 2176 #define wxSTC_CMD_UNDO 2176
#define wxSTC_CMD_CUT 2177 #define wxSTC_CMD_CUT 2177
@@ -124,6 +152,7 @@
#define wxSTC_FOLDLEVELWHITEFLAG 0x1000 #define wxSTC_FOLDLEVELWHITEFLAG 0x1000
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000 #define wxSTC_FOLDLEVELHEADERFLAG 0x2000
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF #define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
#define wxSTC_TIME_FOREVER 10000000
#define wxSTC_CMD_LINEDOWN 2300 #define wxSTC_CMD_LINEDOWN 2300
#define wxSTC_CMD_LINEDOWNEXTEND 2301 #define wxSTC_CMD_LINEDOWNEXTEND 2301
#define wxSTC_CMD_LINEUP 2302 #define wxSTC_CMD_LINEUP 2302
@@ -173,15 +202,31 @@
#define wxSTC_EDGE_BACKGROUND 2 #define wxSTC_EDGE_BACKGROUND 2
// Show caret within N lines of edge when it's scrolled to view // Show caret within N lines of edge when it's scrolled to view
// If CARET_SLOP not set then centre caret on screen when it's
// scrolled to view
#define wxSTC_CARET_SLOP 0x01 #define wxSTC_CARET_SLOP 0x01
// Center caret on screen when it's scrolled to view // Value not used
#define wxSTC_CARET_CENTER 0x02 #define wxSTC_CARET_CENTER 0x02
// OR this with CARET_CENTER to reposition even when visible, or // If CARET_SLOP also set then reposition whenever outside slop border
// OR this with CARET_SLOP to reposition whenever outside slop border // If CARET_SLOP not set then recentre even when visible
#define wxSTC_CARET_STRICT 0x04 #define wxSTC_CARET_STRICT 0x04
// If CARET_XEVEN set then both left and right margins are given equal weight
// rather than favouring left following behaviour.
#define wxSTC_CARET_XEVEN 0x08
// If CARET_XJUMPS set then when caret reaches the margin the display jumps
// enough to leave the caret solidly within the display.
#define wxSTC_CARET_XJUMPS 0x10
#define wxSTC_CURSORNORMAL -1
#define wxSTC_CURSORWAIT 3
// Constants for use with SetVisiblePolicy, similar to SetCaretPolicy
#define wxSTC_VISIBLE_SLOP 0x01
#define wxSTC_VISIBLE_STRICT 0x04
// Notifications // Notifications
// Type of modification and the action which caused the modification // Type of modification and the action which caused the modification
// These are defined as a bit mask to make it easy to specify which notifications are wanted. // These are defined as a bit mask to make it easy to specify which notifications are wanted.
@@ -241,6 +286,19 @@
#define wxSTC_LEX_LATEX 14 #define wxSTC_LEX_LATEX 14
#define wxSTC_LEX_LUA 15 #define wxSTC_LEX_LUA 15
#define wxSTC_LEX_DIFF 16 #define wxSTC_LEX_DIFF 16
#define wxSTC_LEX_CONF 17
#define wxSTC_LEX_PASCAL 18
#define wxSTC_LEX_AVE 19
#define wxSTC_LEX_ADA 20
#define wxSTC_LEX_LISP 21
#define wxSTC_LEX_RUBY 22
#define wxSTC_LEX_EIFFEL 23
#define wxSTC_LEX_EIFFELKW 24
#define wxSTC_LEX_TCL 25
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1.
#define wxSTC_LEX_AUTOMATIC 1000
// Lexical states for SCLEX_PYTHON // Lexical states for SCLEX_PYTHON
#define wxSTC_P_DEFAULT 0 #define wxSTC_P_DEFAULT 0
@@ -273,6 +331,9 @@
#define wxSTC_C_IDENTIFIER 11 #define wxSTC_C_IDENTIFIER 11
#define wxSTC_C_STRINGEOL 12 #define wxSTC_C_STRINGEOL 12
#define wxSTC_C_VERBATIM 13 #define wxSTC_C_VERBATIM 13
#define wxSTC_C_REGEX 14
#define wxSTC_C_COMMENTLINEDOC 15
#define wxSTC_C_WORD2 16
// Lexical states for SCLEX_HTML, SCLEX_XML // Lexical states for SCLEX_HTML, SCLEX_XML
#define wxSTC_H_DEFAULT 0 #define wxSTC_H_DEFAULT 0
@@ -300,6 +361,12 @@
// More HTML // More HTML
#define wxSTC_H_VALUE 19 #define wxSTC_H_VALUE 19
// X-Code
#define wxSTC_H_XCCOMMENT 20
// SGML
#define wxSTC_H_SGML 21
// Embedded Javascript // Embedded Javascript
#define wxSTC_HJ_START 40 #define wxSTC_HJ_START 40
#define wxSTC_HJ_DEFAULT 41 #define wxSTC_HJ_DEFAULT 41
@@ -313,6 +380,7 @@
#define wxSTC_HJ_SINGLESTRING 49 #define wxSTC_HJ_SINGLESTRING 49
#define wxSTC_HJ_SYMBOLS 50 #define wxSTC_HJ_SYMBOLS 50
#define wxSTC_HJ_STRINGEOL 51 #define wxSTC_HJ_STRINGEOL 51
#define wxSTC_HJ_REGEX 52
// ASP Javascript // ASP Javascript
#define wxSTC_HJA_START 55 #define wxSTC_HJA_START 55
@@ -327,6 +395,7 @@
#define wxSTC_HJA_SINGLESTRING 64 #define wxSTC_HJA_SINGLESTRING 64
#define wxSTC_HJA_SYMBOLS 65 #define wxSTC_HJA_SYMBOLS 65
#define wxSTC_HJA_STRINGEOL 66 #define wxSTC_HJA_STRINGEOL 66
#define wxSTC_HJA_REGEX 67
// Embedded VBScript // Embedded VBScript
#define wxSTC_HB_START 70 #define wxSTC_HB_START 70
@@ -387,11 +456,12 @@
#define wxSTC_HPHP_VARIABLE 123 #define wxSTC_HPHP_VARIABLE 123
#define wxSTC_HPHP_COMMENT 124 #define wxSTC_HPHP_COMMENT 124
#define wxSTC_HPHP_COMMENTLINE 125 #define wxSTC_HPHP_COMMENTLINE 125
#define wxSTC_HPHP_STRINGEOL 126 #define wxSTC_HPHP_HSTRING_VARIABLE 126
#define wxSTC_HPHP_OPERATOR 127
// Lexical states for SCLEX_PERL // Lexical states for SCLEX_PERL
#define wxSTC_PL_DEFAULT 0 #define wxSTC_PL_DEFAULT 0
#define wxSTC_PL_HERE 1 #define wxSTC_PL_ERROR 1
#define wxSTC_PL_COMMENTLINE 2 #define wxSTC_PL_COMMENTLINE 2
#define wxSTC_PL_POD 3 #define wxSTC_PL_POD 3
#define wxSTC_PL_NUMBER 4 #define wxSTC_PL_NUMBER 4
@@ -406,12 +476,20 @@
#define wxSTC_PL_ARRAY 13 #define wxSTC_PL_ARRAY 13
#define wxSTC_PL_HASH 14 #define wxSTC_PL_HASH 14
#define wxSTC_PL_SYMBOLTABLE 15 #define wxSTC_PL_SYMBOLTABLE 15
#define wxSTC_PL_REF 16
#define wxSTC_PL_REGEX 17 #define wxSTC_PL_REGEX 17
#define wxSTC_PL_REGSUBST 18 #define wxSTC_PL_REGSUBST 18
#define wxSTC_PL_LONGQUOTE 19 #define wxSTC_PL_LONGQUOTE 19
#define wxSTC_PL_BACKTICKS 20 #define wxSTC_PL_BACKTICKS 20
#define wxSTC_PL_DATASECTION 21 #define wxSTC_PL_DATASECTION 21
#define wxSTC_PL_HERE_DELIM 22
#define wxSTC_PL_HERE_Q 23
#define wxSTC_PL_HERE_QQ 24
#define wxSTC_PL_HERE_QX 25
#define wxSTC_PL_STRING_Q 26
#define wxSTC_PL_STRING_QQ 27
#define wxSTC_PL_STRING_QX 28
#define wxSTC_PL_STRING_QR 29
#define wxSTC_PL_STRING_QW 30
// Lexical states for SCLEX_LATEX // Lexical states for SCLEX_LATEX
#define wxSTC_L_DEFAULT 0 #define wxSTC_L_DEFAULT 0
@@ -434,6 +512,8 @@
#define wxSTC_LUA_OPERATOR 10 #define wxSTC_LUA_OPERATOR 10
#define wxSTC_LUA_IDENTIFIER 11 #define wxSTC_LUA_IDENTIFIER 11
#define wxSTC_LUA_STRINGEOL 12 #define wxSTC_LUA_STRINGEOL 12
// Lexical states for SCLEX_ERRORLIST
#define wxSTC_ERR_DEFAULT 0 #define wxSTC_ERR_DEFAULT 0
#define wxSTC_ERR_PYTHON 1 #define wxSTC_ERR_PYTHON 1
#define wxSTC_ERR_GCC 2 #define wxSTC_ERR_GCC 2
@@ -441,6 +521,88 @@
#define wxSTC_ERR_CMD 4 #define wxSTC_ERR_CMD 4
#define wxSTC_ERR_BORLAND 5 #define wxSTC_ERR_BORLAND 5
#define wxSTC_ERR_PERL 6 #define wxSTC_ERR_PERL 6
#define wxSTC_ERR_NET 7
#define wxSTC_ERR_LUA 8
#define wxSTC_ERR_DIFF_CHANGED 10
#define wxSTC_ERR_DIFF_ADDITION 11
#define wxSTC_ERR_DIFF_DELETION 12
#define wxSTC_ERR_DIFF_MESSAGE 13
// Lexical states for SCLEX_BATCH
#define wxSTC_BAT_DEFAULT 0
#define wxSTC_BAT_COMMENT 1
#define wxSTC_BAT_WORD 2
#define wxSTC_BAT_LABEL 3
#define wxSTC_BAT_HIDE 4
#define wxSTC_BAT_COMMAND 5
#define wxSTC_BAT_IDENTIFIER 6
#define wxSTC_BAT_OPERATOR 7
// Lexical states for SCLEX_MAKEFILE
#define wxSTC_MAKE_DEFAULT 0
#define wxSTC_MAKE_COMMENT 1
#define wxSTC_MAKE_PREPROCESSOR 2
#define wxSTC_MAKE_IDENTIFIER 3
#define wxSTC_MAKE_OPERATOR 4
#define wxSTC_MAKE_TARGET 5
#define wxSTC_MAKE_IDEOL 9
// Lexical states for the SCLEX_CONF (Apache Configuration Files Lexer)
#define wxSTC_CONF_DEFAULT 0
#define wxSTC_CONF_COMMENT 1
#define wxSTC_CONF_NUMBER 2
#define wxSTC_CONF_IDENTIFIER 3
#define wxSTC_CONF_EXTENSION 4
#define wxSTC_CONF_PARAMETER 5
#define wxSTC_CONF_STRING 6
#define wxSTC_CONF_OPERATOR 7
#define wxSTC_CONF_IP 8
#define wxSTC_CONF_DIRECTIVE 9
// Avenue
#define wxSTC_AVE_DEFAULT 0
#define wxSTC_AVE_COMMENT 1
#define wxSTC_AVE_NUMBER 2
#define wxSTC_AVE_WORD 3
#define wxSTC_AVE_KEYWORD 4
#define wxSTC_AVE_STATEMENT 5
#define wxSTC_AVE_STRING 6
#define wxSTC_AVE_ENUM 7
#define wxSTC_AVE_STRINGEOL 8
#define wxSTC_AVE_IDENTIFIER 9
#define wxSTC_AVE_OPERATOR 10
// Lexical states for SCLEX_ADA
#define wxSTC_ADA_DEFAULT 0
#define wxSTC_ADA_COMMENT 1
#define wxSTC_ADA_NUMBER 2
#define wxSTC_ADA_WORD 3
#define wxSTC_ADA_STRING 4
#define wxSTC_ADA_CHARACTER 5
#define wxSTC_ADA_OPERATOR 6
#define wxSTC_ADA_IDENTIFIER 7
#define wxSTC_ADA_STRINGEOL 8
// Lexical states for SCLEX_LISP
#define wxSTC_LISP_DEFAULT 0
#define wxSTC_LISP_COMMENT 1
#define wxSTC_LISP_NUMBER 2
#define wxSTC_LISP_KEYWORD 3
#define wxSTC_LISP_STRING 6
#define wxSTC_LISP_STRINGEOL 8
#define wxSTC_LISP_IDENTIFIER 9
#define wxSTC_LISP_OPERATOR 10
// Lexical states for SCLEX_EIFFEL and SCLEX_EIFFELKW
#define wxSTC_EIFFEL_DEFAULT 0
#define wxSTC_EIFFEL_COMMENTLINE 1
#define wxSTC_EIFFEL_NUMBER 2
#define wxSTC_EIFFEL_WORD 3
#define wxSTC_EIFFEL_STRING 4
#define wxSTC_EIFFEL_CHARACTER 5
#define wxSTC_EIFFEL_OPERATOR 6
#define wxSTC_EIFFEL_IDENTIFIER 7
#define wxSTC_EIFFEL_STRINGEOL 8
// END of generated section // END of generated section
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -556,6 +718,10 @@ public:
// Find the position from a point within the window. // Find the position from a point within the window.
int PositionFromPoint(wxPoint pt); int PositionFromPoint(wxPoint pt);
// Find the position from a point within the window but return
// INVALID_POSITION if not close to text.
int PositionFromPointClose(int x, int y);
// Set caret to start of a line and ensure it is visible. // Set caret to start of a line and ensure it is visible.
void GotoLine(int line); void GotoLine(int line);
@@ -573,8 +739,8 @@ public:
// Retrieve the position of the last correctly styled character. // Retrieve the position of the last correctly styled character.
int GetEndStyled(); int GetEndStyled();
// Convert all line endings in the document to use the current mode. // Convert all line endings in the document to one mode.
void ConvertEOLs(); void ConvertEOLs(int eolMode);
// Retrieve the current end of line mode - one of CRLF, CR, or LF. // Retrieve the current end of line mode - one of CRLF, CR, or LF.
int GetEOLMode(); int GetEOLMode();
@@ -693,6 +859,9 @@ public:
// Set a style to be underlined or not. // Set a style to be underlined or not.
void StyleSetUnderline(int style, bool underline); void StyleSetUnderline(int style, bool underline);
// Set a style to be mixed case, or to force upper or lower case.
void StyleSetCase(int style, int caseForce);
// Set the foreground colour of the selection and whether to use this setting. // Set the foreground colour of the selection and whether to use this setting.
void SetSelForeground(bool useSetting, const wxColour& fore); void SetSelForeground(bool useSetting, const wxColour& fore);
@@ -763,6 +932,18 @@ public:
// Retrieve the last line number that has line state. // Retrieve the last line number that has line state.
int GetMaxLineState(); int GetMaxLineState();
// Is the background of the line containing the caret in a different colour?
bool GetCaretLineVisible();
// Display the background of the line containing the caret in a different colour.
void SetCaretLineVisible(bool show);
// Get the colour of the background of the line containing the caret.
wxColour GetCaretLineBack();
// Set the colour of the background of the line containing the caret.
void SetCaretLineBack(const wxColour& back);
// Display a auto-completion list. // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
@@ -816,6 +997,15 @@ public:
// Retrieve state of ignore case flag. // Retrieve state of ignore case flag.
bool AutoCompGetIgnoreCase(); bool AutoCompGetIgnoreCase();
// Display a list of strings and send notification when user chooses one.
void UserListShow(int listType, const wxString& itemList);
// Set whether or not autocompletion is hidden automatically when nothing matches
void AutoCompSetAutoHide(bool autoHide);
// Retrieve whether or not autocompletion is hidden automatically when nothing matches
bool AutoCompGetAutoHide();
// Set the number of spaces used for one level of indentation. // Set the number of spaces used for one level of indentation.
void SetIndent(int indentSize); void SetIndent(int indentSize);
@@ -923,13 +1113,13 @@ public:
int GetLineCount(); int GetLineCount();
// Sets the size in pixels of the left margin. // Sets the size in pixels of the left margin.
void SetMarginLeft(int width); void SetMarginLeft(int pixelWidth);
// Returns the size in pixels of the left margin. // Returns the size in pixels of the left margin.
int GetMarginLeft(); int GetMarginLeft();
// Sets the size in pixels of the right margin. // Sets the size in pixels of the right margin.
void SetMarginRight(int width); void SetMarginRight(int pixelWidth);
// Returns the size in pixels of the right margin. // Returns the size in pixels of the right margin.
int GetMarginRight(); int GetMarginRight();
@@ -1006,6 +1196,48 @@ public:
// Returns true if overtype mode is active otherwise false is returned. // Returns true if overtype mode is active otherwise false is returned.
bool GetOvertype(); bool GetOvertype();
// Set the width of the insert mode caret
void SetCaretWidth(int pixelWidth);
// Returns the width of the insert mode caret
int GetCaretWidth();
// Sets the position that starts the target which is used for updating the
// document without affecting the scroll position.
void SetTargetStart(int pos);
// Get the position that starts the target.
int GetTargetStart();
// Sets the position that ends the target which is used for updating the
// document without affecting the scroll position.
void SetTargetEnd(int pos);
// Get the position that ends the target.
int GetTargetEnd();
// Replace the target text with the argument text.
// Returns the length of the replacement text.
int ReplaceTarget(const wxString& text);
// Replace the target text with the argument text after \d processing.
// Looks for \d where d is between 1 and 9 and replaces these with the strings
// matched in the last search operation which were surrounded by \( and \).
// Returns the length of the replacement text including any change
// caused by processing the \d patterns.
int ReplaceTargetRE(const wxString& text);
// Search for a counted string in the target and set the target to the found
// range.
// Returns length of range or -1 for failure in which case target is not moved.
int SearchInTarget(const wxString& text);
// Set the search flags used by SearchInTarget
void SetSearchFlags(int flags);
// Get the search flags used by SearchInTarget
int GetSearchFlags();
// Show a call tip containing a definition near position pos. // Show a call tip containing a definition near position pos.
void CallTipShow(int pos, const wxString& definition); void CallTipShow(int pos, const wxString& definition);
@@ -1068,6 +1300,31 @@ public:
// Set some debugging options for folding // Set some debugging options for folding
void SetFoldFlags(int flags); void SetFoldFlags(int flags);
// Ensure a particular line is visible by expanding any header line hiding it.
// Use the currently set visibility policy to determine which range to display.
void EnsureVisibleEnforcePolicy(int line);
// Sets whether a tab pressed when caret is within indentation indents
void SetTabIndents(bool tabIndents);
// Does a tab pressed when caret is within indentation indent?
bool GetTabIndents();
// Sets whether a backspace pressed when caret is within indentation unindents
void SetBackSpaceUnIndents(bool bsUnIndents);
// Does a backspace pressed when caret is within indentation unindent?
bool GetBackSpaceUnIndents();
// Sets the time the mouse must sit still to generate a mouse dwell event
void SetMouseDwellTime(int periodMilliseconds);
// Retrieve the time the mouse must sit still to generate a mouse dwell event
int GetMouseDwellTime();
// Move the caret inside current view if it's not there already
void MoveCaretInsideView();
// How many characters are on a line, not including end of line characters. // How many characters are on a line, not including end of line characters.
int LineLength(int line); int LineLength(int line);
@@ -1119,9 +1376,11 @@ public:
void SearchAnchor(); void SearchAnchor();
// Find some text starting at the search anchor. // Find some text starting at the search anchor.
// Does not ensure the selection is visible.
int SearchNext(int flags, const wxString& text); int SearchNext(int flags, const wxString& text);
// Find some text starting at the search anchor and moving backwards. // Find some text starting at the search anchor and moving backwards.
// Does not ensure the selection is visible.
int SearchPrev(int flags, const wxString& text); int SearchPrev(int flags, const wxString& text);
// Set the way the line the caret is on is kept visible. // Set the way the line the caret is on is kept visible.
@@ -1157,6 +1416,51 @@ public:
// Get which document modification events are sent to the container. // Get which document modification events are sent to the container.
int GetModEventMask(); int GetModEventMask();
// Change internal focus flag
void SetFocus(bool focus);
// Get internal focus flag
bool GetFocus();
// Change error status - 0 = OK
void SetStatus(int statusCode);
// Get error status
int GetStatus();
// Set whether the mouse is captured when its button is pressed
void SetMouseDownCaptures(bool captures);
// Get whether mouse gets captured
bool GetMouseDownCaptures();
// Sets the cursor to one of the SC_CURSOR* values
void SetCursor(int cursorType);
// Get cursor type
int GetCursor();
// Move to the previous change in capitalistion
void WordPartLeft();
// Move to the previous change in capitalistion extending selection to new caret position.
void WordPartLeftExtend();
// Move to the change next in capitalistion
void WordPartRight();
// Move to the next change in capitalistion extending selection to new caret position.
void WordPartRightExtend();
// Set the way the display area is determined when a particular line is to be moved to.
void SetVisiblePolicy(int visiblePolicy, int visibleSlop);
// Delete back from the current position to the start of the line
void DelLineLeft();
// Delete forwards from the current position to the end of the line
void DelLineRight();
// Start notifying the container of all key presses and commands. // Start notifying the container of all key presses and commands.
void StartRecord(); void StartRecord();
@@ -1178,6 +1482,9 @@ public:
// Set up the key words used by the lexer. // Set up the key words used by the lexer.
void SetKeyWords(int keywordSet, const wxString& keyWords); void SetKeyWords(int keywordSet, const wxString& keyWords);
// Set the lexing language of the document based on string name.
void SetLexerLanguage(const wxString& language);
// END of generated section // END of generated section
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Others... // Others...
@@ -1243,6 +1550,10 @@ public:
// Scroll enough to make the given column visible // Scroll enough to make the given column visible
void ScrollToColumn(int column); void ScrollToColumn(int column);
// Send a message to Scintilla
long SendMsg(int msg, long wp=0, long lp=0);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -1255,7 +1566,7 @@ private:
void OnMouseLeftDown(wxMouseEvent& evt); void OnMouseLeftDown(wxMouseEvent& evt);
void OnMouseMove(wxMouseEvent& evt); void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt); void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt); void OnContextMenu(wxContextMenuEvent& evt);
void OnMouseWheel(wxMouseEvent& evt); void OnMouseWheel(wxMouseEvent& evt);
void OnChar(wxKeyEvent& evt); void OnChar(wxKeyEvent& evt);
void OnKeyDown(wxKeyEvent& evt); void OnKeyDown(wxKeyEvent& evt);
@@ -1271,8 +1582,6 @@ private:
void NotifyChange(); void NotifyChange();
void NotifyParent(SCNotification* scn); void NotifyParent(SCNotification* scn);
long SendMsg(int msg, long wp=0, long lp=0);
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxStyledTextCtrl) DECLARE_CLASS(wxStyledTextCtrl)
@@ -1307,6 +1616,9 @@ public:
void SetMessage(int val) { m_message = val; } void SetMessage(int val) { m_message = val; }
void SetWParam(int val) { m_wParam = val; } void SetWParam(int val) { m_wParam = val; }
void SetLParam(int val) { m_lParam = val; } void SetLParam(int val) { m_lParam = val; }
void SetListType(int val) { m_listType = val; }
void SetX(int val) { m_x = val; }
void SetY(int val) { m_y = val; }
int GetPosition() const { return m_position; } int GetPosition() const { return m_position; }
int GetKey() const { return m_key; } int GetKey() const { return m_key; }
@@ -1322,6 +1634,9 @@ public:
int GetMessage() const { return m_message; } int GetMessage() const { return m_message; }
int GetWParam() const { return m_wParam; } int GetWParam() const { return m_wParam; }
int GetLParam() const { return m_lParam; } int GetLParam() const { return m_lParam; }
int GetListType() const { return m_listType; }
int GetX() const { return m_x; }
int GetY() const { return m_y; }
bool GetShift() const; bool GetShift() const;
bool GetControl() const; bool GetControl() const;
@@ -1350,42 +1665,56 @@ private:
int m_message; // wxEVT_STC_MACRORECORD int m_message; // wxEVT_STC_MACRORECORD
int m_wParam; int m_wParam;
int m_lParam; int m_lParam;
int m_listType;
int m_x;
int m_y;
#endif #endif
}; };
#ifndef SWIG #ifndef SWIG
BEGIN_DECLARE_EVENT_TYPES() BEGIN_DECLARE_EVENT_TYPES()
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1653) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1653)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1654) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1654)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1655) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1655)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1656) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1656)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1658) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1658)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1659) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1659)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_PAINTED, 1664)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_USERLISTSELECTION, 1665)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668)
END_DECLARE_EVENT_TYPES() END_DECLARE_EVENT_TYPES()
#else #else
enum { enum {
wxEVT_STC_CHANGE, wxEVT_STC_CHANGE,
wxEVT_STC_STYLENEEDED, wxEVT_STC_STYLENEEDED,
wxEVT_STC_CHARADDED, wxEVT_STC_CHARADDED,
wxEVT_STC_UPDATEUI,
wxEVT_STC_SAVEPOINTREACHED, wxEVT_STC_SAVEPOINTREACHED,
wxEVT_STC_SAVEPOINTLEFT, wxEVT_STC_SAVEPOINTLEFT,
wxEVT_STC_ROMODIFYATTEMPT, wxEVT_STC_ROMODIFYATTEMPT,
wxEVT_STC_DOUBLECLICK,
wxEVT_STC_MODIFIED,
wxEVT_STC_KEY, wxEVT_STC_KEY,
wxEVT_STC_DOUBLECLICK,
wxEVT_STC_UPDATEUI,
wxEVT_STC_MODIFIED,
wxEVT_STC_MACRORECORD, wxEVT_STC_MACRORECORD,
wxEVT_STC_MARGINCLICK, wxEVT_STC_MARGINCLICK,
wxEVT_STC_NEEDSHOWN, wxEVT_STC_NEEDSHOWN,
wxEVT_STC_POSCHANGED wxEVT_STC_POSCHANGED,
wxEVT_STC_PAINTED,
wxEVT_STC_USERLISTSELECTION,
wxEVT_STC_URIDROPPED,
wxEVT_STC_DWELLSTART,
wxEVT_STC_DWELLEND,
}; };
#endif #endif
@@ -1394,20 +1723,26 @@ END_DECLARE_EVENT_TYPES()
#ifndef SWIG #ifndef SWIG
typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
#define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_PAINTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_PAINTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_USERLISTSELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_USERLISTSELECTION, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#endif #endif

View File

@@ -112,6 +112,8 @@ Font::~Font() {
} }
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) { void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
// TODO: what to do about the characterSet?
Release(); Release();
id = new wxFont(size, id = new wxFont(size,
wxDEFAULT, wxDEFAULT,
@@ -161,13 +163,11 @@ void Surface::Init() {
Release(); Release();
hdc = new wxMemoryDC(); hdc = new wxMemoryDC();
hdcOwned = true; hdcOwned = true;
// **** ::SetTextAlign(hdc, TA_BASELINE);
} }
void Surface::Init(SurfaceID hdc_) { void Surface::Init(SurfaceID hdc_) {
Release(); Release();
hdc = hdc_; hdc = hdc_;
// **** ::SetTextAlign(hdc, TA_BASELINE);
} }
void Surface::InitPixMap(int width, int height, Surface *surface_) { void Surface::InitPixMap(int width, int height, Surface *surface_) {
@@ -176,7 +176,6 @@ void Surface::InitPixMap(int width, int height, Surface *surface_) {
hdcOwned = true; hdcOwned = true;
bitmap = new wxBitmap(width, height); bitmap = new wxBitmap(width, height);
((wxMemoryDC*)hdc)->SelectObject(*bitmap); ((wxMemoryDC*)hdc)->SelectObject(*bitmap);
// **** ::SetTextAlign(hdc, TA_BASELINE);
} }
void Surface::PenColour(Colour fore) { void Surface::PenColour(Colour fore) {
@@ -353,7 +352,7 @@ int Surface::AverageCharWidth(Font &font) {
} }
int Surface::SetPalette(Palette *pal, bool inBackGround) { int Surface::SetPalette(Palette *pal, bool inBackGround) {
return 0; // **** figure out what to do with palettes... return 0;
} }
void Surface::SetClip(PRectangle rc) { void Surface::SetClip(PRectangle rc) {
@@ -697,6 +696,36 @@ void Platform::DebugPrintf(const char *format, ...) {
#endif #endif
} }
static bool assertionPopUps = true;
bool Platform::ShowAssertionPopUps(bool assertionPopUps_) {
bool ret = assertionPopUps;
assertionPopUps = assertionPopUps_;
return ret;
}
void Platform::Assert(const char *c, const char *file, int line) {
char buffer[2000];
sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
if (assertionPopUps) {
int idButton = wxMessageBox(buffer, "Assertion failure",
wxICON_HAND | wxOK);
// if (idButton == IDRETRY) {
// ::DebugBreak();
// } else if (idButton == IDIGNORE) {
// // all OK
// } else {
// abort();
// }
} else {
strcat(buffer, "\r\n");
Platform::DebugDisplay(buffer);
abort();
}
}
int Platform::Clamp(int val, int minVal, int maxVal) { int Platform::Clamp(int val, int minVal, int maxVal) {
if (val > maxVal) if (val > maxVal)
val = maxVal; val = maxVal;

View File

@@ -93,7 +93,6 @@ END_EVENT_TABLE()
ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
capturedMouse = false; capturedMouse = false;
wMain = win; wMain = win;
wDraw = win;
stc = win; stc = win;
wheelRotation = 0; wheelRotation = 0;
Initialise(); Initialise();
@@ -170,8 +169,8 @@ bool ScintillaWX::HaveMouseCapture() {
void ScintillaWX::ScrollText(int linesToMove) { void ScintillaWX::ScrollText(int linesToMove) {
int dy = vs.lineHeight * (linesToMove); int dy = vs.lineHeight * (linesToMove);
// TODO: calculate the rectangle to refreshed...
wMain.GetID()->ScrollWindow(0, dy); wMain.GetID()->ScrollWindow(0, dy);
wMain.GetID()->Update();
} }
void ScintillaWX::SetVerticalScrollPos() { void ScintillaWX::SetVerticalScrollPos() {
@@ -261,7 +260,7 @@ bool ScintillaWX::CanPaste() {
} }
void ScintillaWX::CreateCallTipWindow(PRectangle) { void ScintillaWX::CreateCallTipWindow(PRectangle) {
ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct); ct.wCallTip = new wxSTCCallTip(wMain.GetID(), -1, &ct);
ct.wDraw = ct.wCallTip; ct.wDraw = ct.wCallTip;
} }
@@ -365,17 +364,27 @@ void ScintillaWX::DoVScroll(int type, int pos) {
} }
void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction) { void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown) {
int topLineNew = topLine; int topLineNew = topLine;
int lines; int lines;
wheelRotation += rotation; if (ctrlDown) { // Zoom the fonts if Ctrl key down
lines = wheelRotation / delta; if (rotation < 0) {
wheelRotation -= lines * delta; KeyCommand(SCI_ZOOMIN);
if (lines != 0) { }
lines *= linesPerAction; else {
topLineNew -= lines; KeyCommand(SCI_ZOOMOUT);
ScrollTo(topLineNew); }
}
else { // otherwise just scroll the window
wheelRotation += rotation;
lines = wheelRotation / delta;
wheelRotation -= lines * delta;
if (lines != 0) {
lines *= linesPerAction;
topLineNew -= lines;
ScrollTo(topLineNew);
}
} }
} }
@@ -387,11 +396,11 @@ void ScintillaWX::DoSize(int width, int height) {
} }
void ScintillaWX::DoLoseFocus(){ void ScintillaWX::DoLoseFocus(){
DropCaret(); SetFocusState(false);
} }
void ScintillaWX::DoGainFocus(){ void ScintillaWX::DoGainFocus(){
ShowCaretAtCurrentPosition(); SetFocusState(true);
} }
void ScintillaWX::DoSysColourChange() { void ScintillaWX::DoSysColourChange() {
@@ -418,7 +427,7 @@ void ScintillaWX::DoAddChar(char ch) {
// AutoCompleteChanged(ch); // AutoCompleteChanged(ch);
} }
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) { int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
switch (key) { switch (key) {
case WXK_DOWN: key = SCK_DOWN; break; case WXK_DOWN: key = SCK_DOWN; break;
case WXK_UP: key = SCK_UP; break; case WXK_UP: key = SCK_UP; break;
@@ -442,7 +451,7 @@ int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
case WXK_SHIFT: key = 0; break; case WXK_SHIFT: key = 0; break;
} }
return KeyDown(key, shift, ctrl, alt); return KeyDown(key, shift, ctrl, alt, consumed);
} }

View File

@@ -119,9 +119,9 @@ public:
void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl); void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
void DoButtonMove(Point pt); void DoButtonMove(Point pt);
void DoMouseWheel(int rotation, int delta, int linesPerAction); void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown);
void DoAddChar(char ch); void DoAddChar(char ch);
int DoKeyDown(int key, bool shift, bool ctrl, bool alt); int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
void DoTick() { Tick(); } void DoTick() { Tick(); }
bool DoDropText(long x, long y, const wxString& data); bool DoDropText(long x, long y, const wxString& data);

View File

@@ -12,15 +12,15 @@
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
import sys, string, re import sys, string, re, os
from fileinput import FileInput from fileinput import FileInput
IFACE = './scintilla/include/Scintilla.iface' IFACE = os.path.abspath('./scintilla/include/Scintilla.iface')
H_TEMPLATE = './stc.h.in' H_TEMPLATE = os.path.abspath('./stc.h.in')
CPP_TEMPLATE = './stc.cpp.in' CPP_TEMPLATE = os.path.abspath('./stc.cpp.in')
H_DEST = '../../include/wx/stc/stc.h' H_DEST = os.path.abspath('../../include/wx/stc/stc.h')
CPP_DEST = './stc.cpp' CPP_DEST = os.path.abspath('./stc.cpp')
# Value prefixes to convert # Value prefixes to convert
@@ -215,6 +215,9 @@ methodOverrideMap = {
'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0), 'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0), 'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0), 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0), 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0), 'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
@@ -360,6 +363,38 @@ methodOverrideMap = {
'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0), 'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
'ReplaceTarget' : (0,
'int %s(const wxString& text);',
'''
int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str());
''',
0),
'ReplaceTargetRE' : (0,
'int %s(const wxString& text);',
'''
int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str());
''',
0),
'SearchInTarget' : (0,
'int %s(const wxString& text);',
'''
int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str());
''',
0),
# Remove all methods that are key commands since they can be # Remove all methods that are key commands since they can be
# executed with CmdKeyExecute # executed with CmdKeyExecute
'LineDown' : (None, 0, 0, 0), 'LineDown' : (None, 0, 0, 0),
@@ -417,7 +452,7 @@ methodOverrideMap = {
'SetDocPointer' : (0, 'SetDocPointer' : (0,
'void %s(void* docPointer);', 'void %s(void* docPointer);',
'''void %s(void* docPointer) { '''void %s(void* docPointer) {
SendMsg(%s, (long)docPointer);''', SendMsg(%s, 0, (long)docPointer);''',
0), 0),
'CreateDocument' : (0, 'CreateDocument' : (0,
@@ -685,4 +720,3 @@ if __name__ == '__main__':
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------

View File

@@ -3,5 +3,5 @@ scintilla/include directories from the Scintilla/SCiTE source
distribution. All other code needed to implement Scintilla on top of distribution. All other code needed to implement Scintilla on top of
wxWindows is located in the directory above this one. wxWindows is located in the directory above this one.
The current version of the Scintilla code is 1.32 The current version of the Scintilla code is 1.39

View File

@@ -1,6 +1,8 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// Accessor.h - rapid easy access to contents of a Scintilla /** @file Accessor.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8}; enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
@@ -9,12 +11,16 @@ class Accessor;
typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len); typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
// Interface to data in a Scintilla /**
* Interface to data in a Scintilla.
*/
class Accessor { class Accessor {
protected: protected:
enum {extremePosition=0x7FFFFFFF}; enum {extremePosition=0x7FFFFFFF};
// bufferSize is a trade off between time taken to copy the characters and retrieval overhead /** @a bufferSize is a trade off between time taken to copy the characters
// slopSize positions the buffer before the desired position in case there is some backtracking * and retrieval overhead.
* @a slopSize positions the buffer before the desired position
* in case there is some backtracking. */
enum {bufferSize=4000, slopSize=bufferSize/8}; enum {bufferSize=4000, slopSize=bufferSize/8};
char buf[bufferSize+1]; char buf[bufferSize+1];
int startPos; int startPos;
@@ -23,6 +29,7 @@ protected:
virtual bool InternalIsLeadByte(char ch)=0; virtual bool InternalIsLeadByte(char ch)=0;
virtual void Fill(int position)=0; virtual void Fill(int position)=0;
public: public:
Accessor() : startPos(extremePosition), endPos(0), codePage(0) {} Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
virtual ~Accessor() {} virtual ~Accessor() {}
@@ -32,8 +39,8 @@ public:
} }
return buf[position - startPos]; return buf[position - startPos];
} }
/** Safe version of operator[], returning a defined value for invalid position. */
char SafeGetCharAt(int position, char chDefault=' ') { char SafeGetCharAt(int position, char chDefault=' ') {
// Safe version of operator[], returning a defined value for invalid position
if (position < startPos || position >= endPos) { if (position < startPos || position >= endPos) {
Fill(position); Fill(position);
if (position < startPos || position >= endPos) { if (position < startPos || position >= endPos) {
@@ -57,6 +64,7 @@ public:
virtual int GetLineState(int line)=0; virtual int GetLineState(int line)=0;
virtual int SetLineState(int line, int state)=0; virtual int SetLineState(int line, int state)=0;
virtual int GetPropertyInt(const char *key, int defaultValue=0)=0; virtual int GetPropertyInt(const char *key, int defaultValue=0)=0;
virtual char *GetProperties()=0;
// Style setting // Style setting
virtual void StartAt(unsigned int start, char chMask=31)=0; virtual void StartAt(unsigned int start, char chMask=31)=0;
@@ -67,4 +75,3 @@ public:
virtual void SetLevel(int line, int level)=0; virtual void SetLevel(int line, int level)=0;
virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0; virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
}; };

View File

@@ -1,32 +1,59 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// KeyWords.h - colourise for particular languages /** @file KeyWords.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Colourise for particular languages.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler); WordList *keywordlists[], Accessor &styler);
/**
* A LexerModule is responsible for lexing and folding a particular language.
* The class maintains a list of LexerModules which can be searched to find a
* module appropriate to a particular language.
*/
class LexerModule { class LexerModule {
static LexerModule *base; protected:
LexerModule *next; LexerModule *next;
int language; int language;
LexerFunction fn; const char *languageName;
LexerFunction fnLexer;
LexerFunction fnFolder;
static LexerModule *base;
static int nextLanguage;
public: public:
LexerModule(int language_, LexerFunction fn_); LexerModule(int language_, LexerFunction fnLexer_,
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle, const char *languageName_=0, LexerFunction fnFolder_=0);
int language, WordList *keywordlists[], Accessor &styler); int GetLanguage() { return language; }
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler);
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler);
static LexerModule *Find(int language);
static LexerModule *Find(const char *languageName);
}; };
/**
* Check if a character is a space.
* This is ASCII specific but is safe with chars >= 0x80.
*/
inline bool isspacechar(unsigned char ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
inline bool iswordchar(char ch) { inline bool iswordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '_'; return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_');
} }
inline bool iswordstart(char ch) { inline bool iswordstart(char ch) {
return isalnum(ch) || ch == '_'; return isascii(ch) && (isalnum(ch) || ch == '_');
} }
inline bool isoperator(char ch) { inline bool isoperator(char ch) {
if (isalnum(ch)) if (isascii(ch) && isalnum(ch))
return false; return false;
// '.' left out as it is used to make up numbers // '.' left out as it is used to make up numbers
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
@@ -38,4 +65,3 @@ inline bool isoperator(char ch) {
return true; return true;
return false; return false;
} }

View File

@@ -1,18 +1,21 @@
// Scintilla source code edit control // Scintilla source code edit control
// Platform.h - interface to platform facilities /** @file Platform.h
// Also includes some basic utilities ** Interface to platform facilities. Also includes some basic utilities.
// Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> **/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PLATFORM_H #ifndef PLATFORM_H
#define PLATFORM_H #define PLATFORM_H
// PLAT_GTK = GTK+ on Linux, PLAT_WIN = Win32 API on Win32 OS // PLAT_GTK = GTK+ on Linux or Win32
// PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32
// PLAT_WIN = Win32 API on Win32 OS
// PLAT_WX is wxWindows on any supported platform // PLAT_WX is wxWindows on any supported platform
// Could also have PLAT_GTKWIN = GTK+ on Win32 OS in future
#define PLAT_GTK 0 #define PLAT_GTK 0
#define PLAT_GTK_WIN32 0
#define PLAT_WIN 0 #define PLAT_WIN 0
#define PLAT_WX 0 #define PLAT_WX 0
@@ -24,6 +27,11 @@
#undef PLAT_GTK #undef PLAT_GTK
#define PLAT_GTK 1 #define PLAT_GTK 1
#ifdef _MSC_VER
#undef PLAT_GTK_WIN32
#define PLAT_GTK_WIN32 1
#endif
#else #else
#undef PLAT_WIN #undef PLAT_WIN
#define PLAT_WIN 1 #define PLAT_WIN 1
@@ -34,6 +42,9 @@
// Include the main header for each platform // Include the main header for each platform
#if PLAT_GTK #if PLAT_GTK
#ifdef _MSC_VER
#pragma warning(disable: 4505 4514 4710 4800)
#endif
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#endif #endif
@@ -42,7 +53,7 @@
#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out #define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out
// Vassili Bourdo: shut up annoying Visual C++ warnings: // Vassili Bourdo: shut up annoying Visual C++ warnings:
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable: 4800 4244 4309) #pragma warning(disable: 4244 4309 4710 4800)
#endif #endif
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
@@ -80,23 +91,28 @@ typedef wxWindow* WindowID;
typedef wxMenu* MenuID; typedef wxMenu* MenuID;
#endif #endif
// Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably /**
* A geometric point class.
* Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably.
*/
class Point { class Point {
public: public:
int x; int x;
int y; int y;
Point(int x_=0, int y_=0) : x(x_), y(y_) { Point(int x_=0, int y_=0) : x(x_), y(y_) {
} }
// Other automatically defined methods (assignment, copy constructor, destructor) are fine // Other automatically defined methods (assignment, copy constructor, destructor) are fine
static Point FromLong(long lpoint); static Point FromLong(long lpoint);
}; };
// PRectangle is exactly the same as the Win32 RECT so can be used interchangeably /**
// PRectangles contain their top and left sides, but not their right and bottom sides * A geometric rectangle class.
* PRectangle is exactly the same as the Win32 RECT so can be used interchangeably.
* PRectangles contain their top and left sides, but not their right and bottom sides.
*/
class PRectangle { class PRectangle {
public: public:
int left; int left;
@@ -110,6 +126,10 @@ public:
// Other automatically defined methods (assignment, copy constructor, destructor) are fine // Other automatically defined methods (assignment, copy constructor, destructor) are fine
bool operator==(PRectangle &rc) {
return (rc.left == left) && (rc.right == right) &&
(rc.top == top) && (rc.bottom == bottom);
}
bool Contains(Point pt) { bool Contains(Point pt) {
return (pt.x >= left) && (pt.x <= right) && return (pt.x >= left) && (pt.x <= right) &&
(pt.y >= top) && (pt.y <= bottom); (pt.y >= top) && (pt.y <= bottom);
@@ -131,6 +151,9 @@ wxRect wxRectFromPRectangle(PRectangle prc);
PRectangle PRectangleFromwxRect(wxRect rc); PRectangle PRectangleFromwxRect(wxRect rc);
#endif #endif
/**
* A colour class.
*/
class Colour { class Colour {
ColourID co; ColourID co;
public: public:
@@ -141,15 +164,17 @@ public:
unsigned int GetRed(); unsigned int GetRed();
unsigned int GetGreen(); unsigned int GetGreen();
unsigned int GetBlue(); unsigned int GetBlue();
friend class Surface; friend class Surface;
friend class Palette; friend class Palette;
}; };
// Colour pairs hold a desired colour and the colour that the graphics engine /**
// allocates to approximate the desired colour. * Colour pairs hold a desired colour and the colour that the graphics engine
// To make palette management more automatic, ColourPairs could register at * allocates to approximate the desired colour.
// construction time with a palette management object. * To make palette management more automatic, ColourPairs could register at
* construction time with a palette management object.
*/
struct ColourPair { struct ColourPair {
Colour desired; Colour desired;
Colour allocated; Colour allocated;
@@ -162,6 +187,9 @@ struct ColourPair {
class Window; // Forward declaration for Palette class Window; // Forward declaration for Palette
/**
* Colour palette management.
*/
class Palette { class Palette {
int used; int used;
enum {numEntries = 100}; enum {numEntries = 100};
@@ -176,22 +204,27 @@ class Palette {
#endif #endif
public: public:
bool allowRealization; bool allowRealization;
Palette(); Palette();
~Palette(); ~Palette();
void Release(); void Release();
// This method either adds a colour to the list of wanted colours (want==true) /**
// or retrieves the allocated colour back to the ColourPair. * This method either adds a colour to the list of wanted colours (want==true)
// This is one method to make it easier to keep the code for wanting and retrieving in sync. * or retrieves the allocated colour back to the ColourPair.
* This is one method to make it easier to keep the code for wanting and retrieving in sync.
*/
void WantFind(ColourPair &cp, bool want); void WantFind(ColourPair &cp, bool want);
void Allocate(Window &w); void Allocate(Window &w);
friend class Surface; friend class Surface;
}; };
/**
* Font management.
*/
class Font { class Font {
protected: protected:
FontID id; FontID id;
@@ -214,7 +247,9 @@ public:
friend class Surface; friend class Surface;
}; };
// A surface abstracts a place to draw /**
* A surface abstracts a place to draw.
*/
class Surface { class Surface {
private: private:
bool unicodeMode; bool unicodeMode;
@@ -256,7 +291,7 @@ private:
public: public:
Surface(); Surface();
~Surface(); ~Surface();
void Init(); void Init();
void Init(SurfaceID hdc_); void Init(SurfaceID hdc_);
void InitPixMap(int width, int height, Surface *surface_); void InitPixMap(int width, int height, Surface *surface_);
@@ -287,7 +322,7 @@ public:
int ExternalLeading(Font &font_); int ExternalLeading(Font &font_);
int Height(Font &font_); int Height(Font &font_);
int AverageCharWidth(Font &font_); int AverageCharWidth(Font &font_);
int SetPalette(Palette *pal, bool inBackGround); int SetPalette(Palette *pal, bool inBackGround);
void SetClip(PRectangle rc); void SetClip(PRectangle rc);
void FlushCachedState(); void FlushCachedState();
@@ -297,8 +332,10 @@ public:
} }
}; };
// Class to hide the details of window manipulation /**
// Does not own the window which will normally have a longer life than this object * Class to hide the details of window manipulation.
* Does not own the window which will normally have a longer life than this object.
*/
class Window { class Window {
friend class ListBox; friend class ListBox;
protected: protected:
@@ -333,6 +370,9 @@ public:
#endif #endif
}; };
/**
* Listbox management.
*/
class ListBox : public Window { class ListBox : public Window {
#if PLAT_GTK #if PLAT_GTK
WindowID list; WindowID list;
@@ -360,6 +400,9 @@ public:
void Sort(); void Sort();
}; };
/**
* Menu management.
*/
class Menu { class Menu {
MenuID id; MenuID id;
public: public:
@@ -370,8 +413,10 @@ public:
void Show(Point pt, Window &w); void Show(Point pt, Window &w);
}; };
// Platform class used to retrieve system wide parameters such as double click speed /**
// and chrome colour. Not a creatable object, more of a module with several functions. * Platform class used to retrieve system wide parameters such as double click speed
* and chrome colour. Not a creatable object, more of a module with several functions.
*/
class Platform { class Platform {
// Private so Platform objects can not be copied // Private so Platform objects can not be copied
Platform(const Platform &) {} Platform(const Platform &) {}
@@ -390,7 +435,7 @@ public:
static bool IsKeyDown(int key); static bool IsKeyDown(int key);
static long SendScintilla( static long SendScintilla(
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0); WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
// These are utility functions not really tied to a platform // These are utility functions not really tied to a platform
static int Minimum(int a, int b); static int Minimum(int a, int b);
static int Maximum(int a, int b); static int Maximum(int a, int b);
@@ -405,7 +450,15 @@ public:
return static_cast<short>(x & 0xffff); return static_cast<short>(x & 0xffff);
} }
static void DebugPrintf(const char *format, ...); static void DebugPrintf(const char *format, ...);
static bool ShowAssertionPopUps(bool assertionPopUps_);
static void Assert(const char *c, const char *file, int line);
static int Clamp(int val, int minVal, int maxVal); static int Clamp(int val, int minVal, int maxVal);
}; };
#ifdef NDEBUG
#define PLATFORM_ASSERT(c) ((void)0)
#else
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif
#endif #endif

View File

@@ -1,138 +0,0 @@
#ifndef POSREGEXP_H
#define POSREGEXP_H
#define MatchesNum 0x10
enum EOps
{
ReBlockOps = 0x1000,
ReMul, // *
RePlus, // +
ReQuest, // ?
ReNGMul, // *?
ReNGPlus, // +?
ReNGQuest, // ??
ReRangeN, // {n,}
ReRangeNM, // {n,m}
ReNGRangeN, // {n,}?
ReNGRangeNM, // {n,m}?
ReOr, // |
ReBehind = 0x1100, // ?#n
ReNBehind = 0x1200, // ?~n
ReAhead = 0x1300, // ?=
ReNAhead = 0x1400, // ?!
ReSymbolOps = 0x2000,
ReEmpty,
ReSymb, // a b \W \s ...
ReEnum, // []
ReNEnum, // [^]
ReBrackets, // (...)
ReBkTrace = 0x2100, // \yN
ReBkBrack = 0x2200 // \N
};
enum ESymbols
{
ReAnyChr = 0x4000, // .
ReSoL, // ^
ReEoL, // $
ReDigit, // \d
ReNDigit, // \D
ReWordSymb, // \w
ReNWordSymb, // \W
ReWSpace, // \s
ReNWSpace, // \S
ReUCase, // \u
ReNUCase , // \l
ReWBound, // \b
ReNWBound, // \B
RePreNW, // \c
ReStart, // \m
ReEnd, // \M
ReChr = 0x0 // Char in Lower Byte
};
enum ETempSymb
{
ReTemp = 0x7000,
ReLBrack, ReRBrack,
ReEnumS, ReEnumE, ReNEnumS,
ReRangeS, ReRangeE, ReNGRangeE, ReFrToEnum
};
#define BackSlash '\\'
typedef union SCharData
{
int IArr[8];
char CArr[32];
void SetBit(unsigned char Bit);
void ClearBit(unsigned char Bit);
bool GetBit(unsigned char Bit);
} *PCharData;
typedef struct SRegInfo
{
SRegInfo();
~SRegInfo();
EOps Op;
union{
SRegInfo *Param;
int Symb;
PCharData ChrClass;
}un;
int s,e;
SRegInfo *Parent;
SRegInfo *Next;
} *PRegInfo;
typedef struct SMatches
{
int s[MatchesNum];
int e[MatchesNum];
int CurMatch;
} *PMatches;
typedef class PosRegExp
{
PRegInfo Info;
PMatches BkTrace;
bool NoCase,Extend,NoMoves;
bool Error;
int *Exprn;
int posParse;
int posEnd,posStart;
int posBkStr;
int FirstChar;
bool SetExprLow(const char *Expr);
bool SetStructs(PRegInfo &Info,int st,int end);
void Optimize();
bool CheckSymb(int Symb,bool Inc);
bool LowParse(PRegInfo Re);
bool LowParseRe(PRegInfo &Next);
bool LowCheckNext(PRegInfo Re);
bool ParseRe(int posStr);
bool QuickCheck();
public:
PMatches Matches;
int Ok, CurMatch;
void *param;
char (*CharAt)(int pos, void *param);
PosRegExp();
~PosRegExp();
bool isok();
bool SetNoMoves(bool Moves);
bool SetBkTrace(int posStr,PMatches Trace);
bool SetExpr(const char *Expr);
bool Parse(int posStr, int posStop, PMatches Mtch);
bool Parse(int posStr,int posSol, int posEol, PMatches Mtch, int Moves = -1);
bool Evaluate(char *Expr, int posStr, PMatches Mtch, char **Res);
} *PPosRegExp;
#endif /* POSREGEXP_H */

View File

@@ -1,188 +1,17 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// PropSet.h - a java style properties file module /** @file PropSet.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** A Java style properties file module.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PROPSET_H #ifndef PROPSET_H
#define PROPSET_H #define PROPSET_H
#include "SString.h"
bool EqualCaseInsensitive(const char *a, const char *b); bool EqualCaseInsensitive(const char *a, const char *b);
#if PLAT_WIN bool isprefix(const char *target, const char *prefix);
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
#ifdef __WXMSW__
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
// Define another string class.
// While it would be 'better' to use std::string, that doubles the executable size.
inline char *StringDup(const char *s, int len=-1) {
if (!s)
return 0;
if (len == -1)
len = strlen(s);
char *sNew = new char[len + 1];
if (sNew) {
strncpy(sNew, s, len);
sNew[len] = '\0';
}
return sNew;
}
class SString {
char *s;
int ssize;
public:
typedef const char* const_iterator;
typedef int size_type;
static size_type npos;
const char* begin(void) const {
return s;
}
const char* end(void) const {
return &s[ssize];
}
size_type size(void) const {
if (s)
return ssize;
else
return 0;
}
SString &assign(const char* sother, int size_ = -1) {
char *t = s;
s = StringDup(sother,size_);
ssize = (s) ? strlen(s) : 0;
delete []t;
return *this;
}
SString &assign(const SString& sother, int size_ = -1) {
return assign(sother.s,size_);
}
SString &assign(const_iterator ibeg, const_iterator iend) {
return assign(ibeg,iend - ibeg);
}
SString() {
s = 0;
ssize = 0;
}
SString(const SString &source) {
s = StringDup(source.s);
ssize = (s) ? strlen(s) : 0;
}
SString(const char *s_) {
s = StringDup(s_);
ssize = (s) ? strlen(s) : 0;
}
SString(int i) {
char number[100];
sprintf(number, "%0d", i);
s = StringDup(number);
ssize = (s) ? strlen(s) : 0;
}
~SString() {
delete []s;
s = 0;
ssize = 0;
}
SString &operator=(const SString &source) {
if (this != &source) {
delete []s;
s = StringDup(source.s);
ssize = (s) ? strlen(s) : 0;
}
return *this;
}
bool operator==(const SString &other) const {
if ((s == 0) && (other.s == 0))
return true;
if ((s == 0) || (other.s == 0))
return false;
return strcmp(s, other.s) == 0;
}
bool operator!=(const SString &other) const {
return !operator==(other);
}
bool operator==(const char *sother) const {
if ((s == 0) && (sother == 0))
return true;
if ((s == 0) || (sother == 0))
return false;
return strcmp(s, sother) == 0;
}
bool operator!=(const char *sother) const {
return !operator==(sother);
}
const char *c_str() const {
if (s)
return s;
else
return "";
}
int length() const {
if (s)
return strlen(s);
else
return 0;
}
char operator[](int i) const {
if (s)
return s[i];
else
return '\0';
}
SString &operator +=(const char *sother) {
return append(sother,-1);
}
SString &operator +=(const SString &sother) {
return append(sother.s,sother.ssize);
}
SString &operator +=(char ch) {
return append(&ch,1);
}
SString &append(const char* sother, int lenOther) {
int len = length();
if(lenOther < 0)
lenOther = strlen(sother);
char *sNew = new char[len + lenOther + 1];
if (sNew) {
if (s)
memcpy(sNew, s, len);
strncpy(&sNew[len], sother, lenOther);
sNew[len + lenOther] = '\0';
delete []s;
s = sNew;
ssize = (s) ? strlen(s) : 0;
}
return *this;
}
int value() const {
if (s)
return atoi(s);
else
return 0;
}
void substitute(char find, char replace) {
char *t = s;
while (t) {
t = strchr(t, find);
if (t)
*t = replace;
}
}
// I don't think this really belongs here -- Neil
void correctPath() {
#ifdef unix
substitute('\\', '/');
#else
substitute('/', '\\');
#endif
}
};
struct Property { struct Property {
unsigned int hash; unsigned int hash;
@@ -192,53 +21,66 @@ struct Property {
Property() : hash(0), key(0), val(0), next(0) {} Property() : hash(0), key(0), val(0), next(0) {}
}; };
/**
*/
class PropSet { class PropSet {
private: private:
enum { hashRoots=31 }; enum { hashRoots=31 };
Property *props[hashRoots]; Property *props[hashRoots];
Property *enumnext;
int enumhash;
public: public:
PropSet *superPS; PropSet *superPS;
PropSet(); PropSet();
~PropSet(); ~PropSet();
void Set(const char *key, const char *val); void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
void Set(char *keyval); void Set(const char *keyVal);
void SetMultiple(const char *s);
SString Get(const char *key); SString Get(const char *key);
SString GetExpanded(const char *key); SString GetExpanded(const char *key);
SString Expand(const char *withvars); SString Expand(const char *withVars);
int GetInt(const char *key, int defaultValue=0); int GetInt(const char *key, int defaultValue=0);
SString GetWild(const char *keybase, const char *filename); SString GetWild(const char *keybase, const char *filename);
SString GetNewExpand(const char *keybase, const char *filename); SString GetNewExpand(const char *keybase, const char *filename);
void Clear(); void Clear();
void ReadFromMemory(const char *data, int len, const char *directoryForImports=0); char *ToString(); // Caller must delete[] the return value
void Read(const char *filename, const char *directoryForImports); bool GetFirst(char **key, char **val);
bool GetNext(char **key, char **val);
}; };
/**
*/
class WordList { class WordList {
public: public:
// Each word contains at least one character - a empty word acts as sentinal at the end. // Each word contains at least one character - a empty word acts as sentinel at the end.
char **words; char **words;
char **wordsNoCase; char **wordsNoCase;
char *list; char *list;
int len; int len;
bool onlyLineEnds; // Delimited by any white space or only line ends bool onlyLineEnds; ///< Delimited by any white space or only line ends
bool sorted; bool sorted;
int starts[256]; int starts[256];
WordList(bool onlyLineEnds_ = false) : WordList(bool onlyLineEnds_ = false) :
words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {} words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {}
~WordList() { Clear(); } ~WordList() { Clear(); }
operator bool() { return words ? true : false; } operator bool() { return len ? true : false; }
const char *operator[](int ind) { return words[ind]; } char *operator[](int ind) { return words[ind]; }
void Clear(); void Clear();
void Set(const char *s); void Set(const char *s);
char *Allocate(int size); char *Allocate(int size);
void SetFromAllocated(); void SetFromAllocated();
bool InList(const char *s); bool InList(const char *s);
const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false); const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
char *GetNearestWords(const char *wordStart, int searchLen = -1, bool ignoreCase = false); char *GetNearestWords(const char *wordStart, int searchLen=-1,
bool ignoreCase=false, char otherSeparator='\0');
}; };
inline bool nonFuncChar(char ch) { inline bool nonFuncChar(char ch) {
return strchr("\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", ch) != NULL; return strchr("\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", ch) != NULL;
} }
inline bool IsAlphabetic(unsigned int ch) {
return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
}
#endif #endif

View File

@@ -0,0 +1,255 @@
// SciTE - Scintilla based Text Editor
/** @file SString.h
** A simple string class.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef SSTRING_H
#define SSTRING_H
// These functions are implemented because each platform calls them something different
int CompareCaseInsensitive(const char *a, const char *b);
int CompareNCaseInsensitive(const char *a, const char *b, int len);
bool EqualCaseInsensitive(const char *a, const char *b);
// Define another string class.
// While it would be 'better' to use std::string, that doubles the executable size.
// An SString may contain embedded nul characters.
/**
* Duplicate a C string.
* Allocate memory of the given size, or big enough to fit the string if length isn't given;
* then copy the given string in the allocated memory.
* @return the pointer to the new string
*/
inline char *StringDup(
const char *s, ///< The string to duplicate
int len=-1) ///< The length of memory to allocate. Optional.
{
if (!s)
return 0;
if (len == -1)
len = strlen(s);
char *sNew = new char[len + 1];
if (sNew) {
strncpy(sNew, s, len);
sNew[len] = '\0';
}
return sNew;
}
/**
* @brief A simple string class.
* Hold the length of the string for quick operations,
* can have a buffer bigger than the string to avoid too many memory allocations and copies.
* May have embedded zeroes as a result of @a substitute, but rely too heavily on C string
* functions to allow reliable manipulations of these strings.
**/
class SString {
char *s; ///< The C string
int sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
int sLen; ///< The size of the string in s
int sizeGrowth; ///< Minimum growth size when appending strings
enum { sizeGrowthDefault = 64 };
public:
typedef int size_type;
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
}
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(source.s);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(s_);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(const char *s_, int first, int last) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(s_ + first, last - first);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(int i) : sizeGrowth(sizeGrowthDefault) {
char number[32];
sprintf(number, "%0d", i);
s = StringDup(number);
sSize = sLen = (s) ? strlen(s) : 0;
}
~SString() {
delete []s;
s = 0;
sSize = 0;
sLen = 0;
}
void clear(void) {
if (s) {
*s = '\0';
}
sLen = 0;
}
/** Size of buffer. */
size_type size(void) const { ///<
if (s)
return sSize;
else
return 0;
}
/** Size of string in buffer. */
int length() const {
return sLen;
}
SString &assign(const char* sOther, int sSize_ = -1) {
if (!sOther) {
sSize_ = 0;
}
if (sSize_ < 0) {
sSize_ = strlen(sOther);
}
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
if (s && sSize_) {
strncpy(s, sOther, sSize_);
}
s[sSize_] = '\0';
sLen = sSize_;
} else {
delete []s;
s = StringDup(sOther, sSize_);
if (s) {
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
sLen = strlen(s);
} else {
sSize = sLen = 0;
}
}
return *this;
}
SString &assign(const SString& sOther, int sSize_ = -1) {
return assign(sOther.s, sSize_);
}
SString &operator=(const char *source) {
return assign(source);
}
SString &operator=(const SString &source) {
if (this != &source) {
assign(source.c_str());
}
return *this;
}
bool operator==(const SString &sOther) const {
if ((s == 0) && (sOther.s == 0))
return true;
if ((s == 0) || (sOther.s == 0))
return false;
return strcmp(s, sOther.s) == 0;
}
bool operator!=(const SString &sOther) const {
return !operator==(sOther);
}
bool operator==(const char *sOther) const {
if ((s == 0) && (sOther == 0))
return true;
if ((s == 0) || (sOther == 0))
return false;
return strcmp(s, sOther) == 0;
}
bool operator!=(const char *sOther) const {
return !operator==(sOther);
}
bool contains(char ch) {
if (s && *s)
return strchr(s, ch) != 0;
else
return false;
}
void setsizegrowth(int sizeGrowth_) {
sizeGrowth = sizeGrowth_;
}
const char *c_str() const {
if (s)
return s;
else
return "";
}
/** Give ownership of buffer to caller which must use delete[] to free buffer. */
char *detach() {
char *sRet = s;
s = 0;
sSize = 0;
sLen = 0;
return sRet;
}
char operator[](int i) const {
if (s && i < sSize) // Or < sLen? Depends on the use, both are OK
return s[i];
else
return '\0';
}
SString &append(const char* sOther, int sLenOther=-1, char sep=0) {
if (sLenOther < 0)
sLenOther = strlen(sOther);
int lenSep = 0;
if (sLen && sep) // Only add a separator if not empty
lenSep = 1;
int lenNew = sLen + sLenOther + lenSep;
if (lenNew + 1 < sSize) {
// Conservative about growing the buffer: don't do it, unless really needed
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
s[sLen + sLenOther] = '\0';
sLen += sLenOther;
} else {
// Grow the buffer bigger than really needed, to have room for other appends
char *sNew = new char[lenNew + sizeGrowth + 1];
if (sNew) {
if (s) {
memcpy(sNew, s, sLen);
delete []s;
}
s = sNew;
sSize = lenNew + sizeGrowth;
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
sNew[sLen + sLenOther] = '\0';
sLen += sLenOther;
}
}
return *this;
}
SString &operator +=(const char *sOther) {
return append(sOther, -1);
}
SString &operator +=(const SString &sOther) {
return append(sOther.s, sOther.sSize);
}
SString &operator +=(char ch) {
return append(&ch, 1);
}
SString &appendwithseparator(const char* sOther, char sep) {
return append(sOther, strlen(sOther), sep);
}
int value() const {
if (s)
return atoi(s);
else
return 0;
}
void substitute(char find, char replace) {
char *t = s;
while (t) {
t = strchr(t, find);
if (t) {
*t = replace;
t++;
}
}
}
};
#endif

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// SciLexer - interface to the added lexer functions in the SciLexer version of the edit control /** @file SciLexer.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Interface to the added lexer functions in the SciLexer version of the edit control.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -29,6 +31,16 @@
#define SCLEX_LATEX 14 #define SCLEX_LATEX 14
#define SCLEX_LUA 15 #define SCLEX_LUA 15
#define SCLEX_DIFF 16 #define SCLEX_DIFF 16
#define SCLEX_CONF 17
#define SCLEX_PASCAL 18
#define SCLEX_AVE 19
#define SCLEX_ADA 20
#define SCLEX_LISP 21
#define SCLEX_RUBY 22
#define SCLEX_EIFFEL 23
#define SCLEX_EIFFELKW 24
#define SCLEX_TCL 25
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0 #define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1 #define SCE_P_COMMENTLINE 1
#define SCE_P_NUMBER 2 #define SCE_P_NUMBER 2
@@ -57,6 +69,9 @@
#define SCE_C_IDENTIFIER 11 #define SCE_C_IDENTIFIER 11
#define SCE_C_STRINGEOL 12 #define SCE_C_STRINGEOL 12
#define SCE_C_VERBATIM 13 #define SCE_C_VERBATIM 13
#define SCE_C_REGEX 14
#define SCE_C_COMMENTLINEDOC 15
#define SCE_C_WORD2 16
#define SCE_H_DEFAULT 0 #define SCE_H_DEFAULT 0
#define SCE_H_TAG 1 #define SCE_H_TAG 1
#define SCE_H_TAGUNKNOWN 2 #define SCE_H_TAGUNKNOWN 2
@@ -77,6 +92,8 @@
#define SCE_H_CDATA 17 #define SCE_H_CDATA 17
#define SCE_H_QUESTION 18 #define SCE_H_QUESTION 18
#define SCE_H_VALUE 19 #define SCE_H_VALUE 19
#define SCE_H_XCCOMMENT 20
#define SCE_H_SGML 21
#define SCE_HJ_START 40 #define SCE_HJ_START 40
#define SCE_HJ_DEFAULT 41 #define SCE_HJ_DEFAULT 41
#define SCE_HJ_COMMENT 42 #define SCE_HJ_COMMENT 42
@@ -89,6 +106,7 @@
#define SCE_HJ_SINGLESTRING 49 #define SCE_HJ_SINGLESTRING 49
#define SCE_HJ_SYMBOLS 50 #define SCE_HJ_SYMBOLS 50
#define SCE_HJ_STRINGEOL 51 #define SCE_HJ_STRINGEOL 51
#define SCE_HJ_REGEX 52
#define SCE_HJA_START 55 #define SCE_HJA_START 55
#define SCE_HJA_DEFAULT 56 #define SCE_HJA_DEFAULT 56
#define SCE_HJA_COMMENT 57 #define SCE_HJA_COMMENT 57
@@ -101,6 +119,7 @@
#define SCE_HJA_SINGLESTRING 64 #define SCE_HJA_SINGLESTRING 64
#define SCE_HJA_SYMBOLS 65 #define SCE_HJA_SYMBOLS 65
#define SCE_HJA_STRINGEOL 66 #define SCE_HJA_STRINGEOL 66
#define SCE_HJA_REGEX 67
#define SCE_HB_START 70 #define SCE_HB_START 70
#define SCE_HB_DEFAULT 71 #define SCE_HB_DEFAULT 71
#define SCE_HB_COMMENTLINE 72 #define SCE_HB_COMMENTLINE 72
@@ -151,9 +170,10 @@
#define SCE_HPHP_VARIABLE 123 #define SCE_HPHP_VARIABLE 123
#define SCE_HPHP_COMMENT 124 #define SCE_HPHP_COMMENT 124
#define SCE_HPHP_COMMENTLINE 125 #define SCE_HPHP_COMMENTLINE 125
#define SCE_HPHP_STRINGEOL 126 #define SCE_HPHP_HSTRING_VARIABLE 126
#define SCE_HPHP_OPERATOR 127
#define SCE_PL_DEFAULT 0 #define SCE_PL_DEFAULT 0
#define SCE_PL_HERE 1 #define SCE_PL_ERROR 1
#define SCE_PL_COMMENTLINE 2 #define SCE_PL_COMMENTLINE 2
#define SCE_PL_POD 3 #define SCE_PL_POD 3
#define SCE_PL_NUMBER 4 #define SCE_PL_NUMBER 4
@@ -168,12 +188,20 @@
#define SCE_PL_ARRAY 13 #define SCE_PL_ARRAY 13
#define SCE_PL_HASH 14 #define SCE_PL_HASH 14
#define SCE_PL_SYMBOLTABLE 15 #define SCE_PL_SYMBOLTABLE 15
#define SCE_PL_REF 16
#define SCE_PL_REGEX 17 #define SCE_PL_REGEX 17
#define SCE_PL_REGSUBST 18 #define SCE_PL_REGSUBST 18
#define SCE_PL_LONGQUOTE 19 #define SCE_PL_LONGQUOTE 19
#define SCE_PL_BACKTICKS 20 #define SCE_PL_BACKTICKS 20
#define SCE_PL_DATASECTION 21 #define SCE_PL_DATASECTION 21
#define SCE_PL_HERE_DELIM 22
#define SCE_PL_HERE_Q 23
#define SCE_PL_HERE_QQ 24
#define SCE_PL_HERE_QX 25
#define SCE_PL_STRING_Q 26
#define SCE_PL_STRING_QQ 27
#define SCE_PL_STRING_QX 28
#define SCE_PL_STRING_QR 29
#define SCE_PL_STRING_QW 30
#define SCE_L_DEFAULT 0 #define SCE_L_DEFAULT 0
#define SCE_L_COMMAND 1 #define SCE_L_COMMAND 1
#define SCE_L_TAG 2 #define SCE_L_TAG 2
@@ -199,6 +227,74 @@
#define SCE_ERR_CMD 4 #define SCE_ERR_CMD 4
#define SCE_ERR_BORLAND 5 #define SCE_ERR_BORLAND 5
#define SCE_ERR_PERL 6 #define SCE_ERR_PERL 6
#define SCE_ERR_NET 7
#define SCE_ERR_LUA 8
#define SCE_ERR_DIFF_CHANGED 10
#define SCE_ERR_DIFF_ADDITION 11
#define SCE_ERR_DIFF_DELETION 12
#define SCE_ERR_DIFF_MESSAGE 13
#define SCE_BAT_DEFAULT 0
#define SCE_BAT_COMMENT 1
#define SCE_BAT_WORD 2
#define SCE_BAT_LABEL 3
#define SCE_BAT_HIDE 4
#define SCE_BAT_COMMAND 5
#define SCE_BAT_IDENTIFIER 6
#define SCE_BAT_OPERATOR 7
#define SCE_MAKE_DEFAULT 0
#define SCE_MAKE_COMMENT 1
#define SCE_MAKE_PREPROCESSOR 2
#define SCE_MAKE_IDENTIFIER 3
#define SCE_MAKE_OPERATOR 4
#define SCE_MAKE_TARGET 5
#define SCE_MAKE_IDEOL 9
#define SCE_CONF_DEFAULT 0
#define SCE_CONF_COMMENT 1
#define SCE_CONF_NUMBER 2
#define SCE_CONF_IDENTIFIER 3
#define SCE_CONF_EXTENSION 4
#define SCE_CONF_PARAMETER 5
#define SCE_CONF_STRING 6
#define SCE_CONF_OPERATOR 7
#define SCE_CONF_IP 8
#define SCE_CONF_DIRECTIVE 9
#define SCE_AVE_DEFAULT 0
#define SCE_AVE_COMMENT 1
#define SCE_AVE_NUMBER 2
#define SCE_AVE_WORD 3
#define SCE_AVE_KEYWORD 4
#define SCE_AVE_STATEMENT 5
#define SCE_AVE_STRING 6
#define SCE_AVE_ENUM 7
#define SCE_AVE_STRINGEOL 8
#define SCE_AVE_IDENTIFIER 9
#define SCE_AVE_OPERATOR 10
#define SCE_ADA_DEFAULT 0
#define SCE_ADA_COMMENT 1
#define SCE_ADA_NUMBER 2
#define SCE_ADA_WORD 3
#define SCE_ADA_STRING 4
#define SCE_ADA_CHARACTER 5
#define SCE_ADA_OPERATOR 6
#define SCE_ADA_IDENTIFIER 7
#define SCE_ADA_STRINGEOL 8
#define SCE_LISP_DEFAULT 0
#define SCE_LISP_COMMENT 1
#define SCE_LISP_NUMBER 2
#define SCE_LISP_KEYWORD 3
#define SCE_LISP_STRING 6
#define SCE_LISP_STRINGEOL 8
#define SCE_LISP_IDENTIFIER 9
#define SCE_LISP_OPERATOR 10
#define SCE_EIFFEL_DEFAULT 0
#define SCE_EIFFEL_COMMENTLINE 1
#define SCE_EIFFEL_NUMBER 2
#define SCE_EIFFEL_WORD 3
#define SCE_EIFFEL_STRING 4
#define SCE_EIFFEL_CHARACTER 5
#define SCE_EIFFEL_OPERATOR 6
#define SCE_EIFFEL_IDENTIFIER 7
#define SCE_EIFFEL_STRINGEOL 8
//--Autogenerated -- end of section automatically generated from Scintilla.iface //--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif #endif

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// Scintilla.h - interface to the edit control /** @file Scintilla.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Interface to the edit control.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -18,7 +20,13 @@ void Scintilla_RegisterClasses(HINSTANCE hInstance);
#endif #endif
#endif #endif
typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wParam, long lParam); // Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
// hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
// May need to be changed for 64 bit platforms.
typedef unsigned long uptr_t;
typedef long sptr_t;
typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam);
//++Autogenerated -- start of section automatically generated from Scintilla.iface //++Autogenerated -- start of section automatically generated from Scintilla.iface
#define INVALID_POSITION -1 #define INVALID_POSITION -1
@@ -50,15 +58,16 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_GETVIEWWS 2020 #define SCI_GETVIEWWS 2020
#define SCI_SETVIEWWS 2021 #define SCI_SETVIEWWS 2021
#define SCI_POSITIONFROMPOINT 2022 #define SCI_POSITIONFROMPOINT 2022
#define SCI_POSITIONFROMPOINTCLOSE 2023
#define SCI_GOTOLINE 2024 #define SCI_GOTOLINE 2024
#define SCI_GOTOPOS 2025 #define SCI_GOTOPOS 2025
#define SCI_SETANCHOR 2026 #define SCI_SETANCHOR 2026
#define SCI_GETCURLINE 2027 #define SCI_GETCURLINE 2027
#define SCI_GETENDSTYLED 2028 #define SCI_GETENDSTYLED 2028
#define SCI_CONVERTEOLS 2029
#define SC_EOL_CRLF 0 #define SC_EOL_CRLF 0
#define SC_EOL_CR 1 #define SC_EOL_CR 1
#define SC_EOL_LF 2 #define SC_EOL_LF 2
#define SCI_CONVERTEOLS 2029
#define SCI_GETEOLMODE 2030 #define SCI_GETEOLMODE 2030
#define SCI_SETEOLMODE 2031 #define SCI_SETEOLMODE 2031
#define SCI_STARTSTYLING 2032 #define SCI_STARTSTYLING 2032
@@ -80,6 +89,24 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SC_MARK_ARROWDOWN 6 #define SC_MARK_ARROWDOWN 6
#define SC_MARK_MINUS 7 #define SC_MARK_MINUS 7
#define SC_MARK_PLUS 8 #define SC_MARK_PLUS 8
#define SC_MARK_VLINE 9
#define SC_MARK_LCORNER 10
#define SC_MARK_TCORNER 11
#define SC_MARK_BOXPLUS 12
#define SC_MARK_BOXPLUSCONNECTED 13
#define SC_MARK_BOXMINUS 14
#define SC_MARK_BOXMINUSCONNECTED 15
#define SC_MARK_LCORNERCURVE 16
#define SC_MARK_TCORNERCURVE 17
#define SC_MARK_CIRCLEPLUS 18
#define SC_MARK_CIRCLEPLUSCONNECTED 19
#define SC_MARK_CIRCLEMINUS 20
#define SC_MARK_CIRCLEMINUSCONNECTED 21
#define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26
#define SC_MARKNUM_FOLDERMIDTAIL 27
#define SC_MARKNUM_FOLDERTAIL 28
#define SC_MARKNUM_FOLDERSUB 29
#define SC_MARKNUM_FOLDER 30 #define SC_MARKNUM_FOLDER 30
#define SC_MARKNUM_FOLDEROPEN 31 #define SC_MARKNUM_FOLDEROPEN 31
#define SCI_MARKERDEFINE 2040 #define SCI_MARKERDEFINE 2040
@@ -137,6 +164,10 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_STYLESETEOLFILLED 2057 #define SCI_STYLESETEOLFILLED 2057
#define SCI_STYLERESETDEFAULT 2058 #define SCI_STYLERESETDEFAULT 2058
#define SCI_STYLESETUNDERLINE 2059 #define SCI_STYLESETUNDERLINE 2059
#define SC_CASE_MIXED 0
#define SC_CASE_UPPER 1
#define SC_CASE_LOWER 2
#define SCI_STYLESETCASE 2060
#define SCI_STYLESETCHARACTERSET 2066 #define SCI_STYLESETCHARACTERSET 2066
#define SCI_SETSELFORE 2067 #define SCI_SETSELFORE 2067
#define SCI_SETSELBACK 2068 #define SCI_SETSELBACK 2068
@@ -170,6 +201,10 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_SETLINESTATE 2092 #define SCI_SETLINESTATE 2092
#define SCI_GETLINESTATE 2093 #define SCI_GETLINESTATE 2093
#define SCI_GETMAXLINESTATE 2094 #define SCI_GETMAXLINESTATE 2094
#define SCI_GETCARETLINEVISIBLE 2095
#define SCI_SETCARETLINEVISIBLE 2096
#define SCI_GETCARETLINEBACK 2097
#define SCI_SETCARETLINEBACK 2098
#define SCI_AUTOCSHOW 2100 #define SCI_AUTOCSHOW 2100
#define SCI_AUTOCCANCEL 2101 #define SCI_AUTOCCANCEL 2101
#define SCI_AUTOCACTIVE 2102 #define SCI_AUTOCACTIVE 2102
@@ -186,6 +221,9 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_AUTOCGETCHOOSESINGLE 2114 #define SCI_AUTOCGETCHOOSESINGLE 2114
#define SCI_AUTOCSETIGNORECASE 2115 #define SCI_AUTOCSETIGNORECASE 2115
#define SCI_AUTOCGETIGNORECASE 2116 #define SCI_AUTOCGETIGNORECASE 2116
#define SCI_USERLISTSHOW 2117
#define SCI_AUTOCSETAUTOHIDE 2118
#define SCI_AUTOCGETAUTOHIDE 2119
#define SCI_SETINDENT 2122 #define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123 #define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124 #define SCI_SETUSETABS 2124
@@ -215,9 +253,10 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SC_PRINT_NORMAL 0 #define SC_PRINT_NORMAL 0
#define SC_PRINT_INVERTLIGHT 1 #define SC_PRINT_INVERTLIGHT 1
#define SC_PRINT_BLACKONWHITE 2 #define SC_PRINT_BLACKONWHITE 2
#define SC_PRINT_COLOURONWHITE 3
#define SC_PRINT_COLOURONWHITEDEFAULTBG 4
#define SCI_SETPRINTCOLOURMODE 2148 #define SCI_SETPRINTCOLOURMODE 2148
#define SCI_GETPRINTCOLOURMODE 2149 #define SCI_GETPRINTCOLOURMODE 2149
#define SCFIND_DOWN 1
#define SCFIND_WHOLEWORD 2 #define SCFIND_WHOLEWORD 2
#define SCFIND_MATCHCASE 4 #define SCFIND_MATCHCASE 4
#define SCFIND_WORDSTART 0x00100000 #define SCFIND_WORDSTART 0x00100000
@@ -260,6 +299,17 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_GETDIRECTPOINTER 2185 #define SCI_GETDIRECTPOINTER 2185
#define SCI_SETOVERTYPE 2186 #define SCI_SETOVERTYPE 2186
#define SCI_GETOVERTYPE 2187 #define SCI_GETOVERTYPE 2187
#define SCI_SETCARETWIDTH 2188
#define SCI_GETCARETWIDTH 2189
#define SCI_SETTARGETSTART 2190
#define SCI_GETTARGETSTART 2191
#define SCI_SETTARGETEND 2192
#define SCI_GETTARGETEND 2193
#define SCI_REPLACETARGET 2194
#define SCI_REPLACETARGETRE 2195
#define SCI_SEARCHINTARGET 2197
#define SCI_SETSEARCHFLAGS 2198
#define SCI_GETSEARCHFLAGS 2199
#define SCI_CALLTIPSHOW 2200 #define SCI_CALLTIPSHOW 2200
#define SCI_CALLTIPCANCEL 2201 #define SCI_CALLTIPCANCEL 2201
#define SCI_CALLTIPACTIVE 2202 #define SCI_CALLTIPACTIVE 2202
@@ -284,6 +334,14 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_TOGGLEFOLD 2231 #define SCI_TOGGLEFOLD 2231
#define SCI_ENSUREVISIBLE 2232 #define SCI_ENSUREVISIBLE 2232
#define SCI_SETFOLDFLAGS 2233 #define SCI_SETFOLDFLAGS 2233
#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234
#define SCI_SETTABINDENTS 2260
#define SCI_GETTABINDENTS 2261
#define SCI_SETBACKSPACEUNINDENTS 2262
#define SCI_GETBACKSPACEUNINDENTS 2263
#define SC_TIME_FOREVER 10000000
#define SCI_SETMOUSEDWELLTIME 2264
#define SCI_GETMOUSEDWELLTIME 2265
#define SCI_LINEDOWN 2300 #define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301 #define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302 #define SCI_LINEUP 2302
@@ -328,6 +386,7 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_UPPERCASE 2341 #define SCI_UPPERCASE 2341
#define SCI_LINESCROLLDOWN 2342 #define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343 #define SCI_LINESCROLLUP 2343
#define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350 #define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351 #define SCI_BRACEHIGHLIGHT 2351
#define SCI_BRACEBADLIGHT 2352 #define SCI_BRACEBADLIGHT 2352
@@ -352,6 +411,8 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define CARET_SLOP 0x01 #define CARET_SLOP 0x01
#define CARET_CENTER 0x02 #define CARET_CENTER 0x02
#define CARET_STRICT 0x04 #define CARET_STRICT 0x04
#define CARET_XEVEN 0x08
#define CARET_XJUMPS 0x10
#define SCI_SETCARETPOLICY 2369 #define SCI_SETCARETPOLICY 2369
#define SCI_LINESONSCREEN 2370 #define SCI_LINESONSCREEN 2370
#define SCI_USEPOPUP 2371 #define SCI_USEPOPUP 2371
@@ -362,6 +423,25 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_ADDREFDOCUMENT 2376 #define SCI_ADDREFDOCUMENT 2376
#define SCI_RELEASEDOCUMENT 2377 #define SCI_RELEASEDOCUMENT 2377
#define SCI_GETMODEVENTMASK 2378 #define SCI_GETMODEVENTMASK 2378
#define SCI_SETFOCUS 2380
#define SCI_GETFOCUS 2381
#define SCI_SETSTATUS 2382
#define SCI_GETSTATUS 2383
#define SCI_SETMOUSEDOWNCAPTURES 2384
#define SCI_GETMOUSEDOWNCAPTURES 2385
#define SC_CURSORNORMAL -1
#define SC_CURSORWAIT 3
#define SCI_SETCURSOR 2386
#define SCI_GETCURSOR 2387
#define SCI_WORDPARTLEFT 2390
#define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392
#define SCI_WORDPARTRIGHTEXTEND 2393
#define VISIBLE_SLOP 0x01
#define VISIBLE_STRICT 0x04
#define SCI_SETVISIBLEPOLICY 2394
#define SCI_DELLINELEFT 2395
#define SCI_DELLINERIGHT 2396
#define SCI_GRABFOCUS 2400 #define SCI_GRABFOCUS 2400
#define SCI_STARTRECORD 3001 #define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002 #define SCI_STOPRECORD 3002
@@ -370,6 +450,7 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_COLOURISE 4003 #define SCI_COLOURISE 4003
#define SCI_SETPROPERTY 4004 #define SCI_SETPROPERTY 4004
#define SCI_SETKEYWORDS 4005 #define SCI_SETKEYWORDS 4005
#define SCI_SETLEXERLANGUAGE 4006
#define SC_MOD_INSERTTEXT 0x1 #define SC_MOD_INSERTTEXT 0x1
#define SC_MOD_DELETETEXT 0x2 #define SC_MOD_DELETETEXT 0x2
#define SC_MOD_CHANGESTYLE 0x4 #define SC_MOD_CHANGESTYLE 0x4
@@ -419,6 +500,11 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCN_MARGINCLICK 2010 #define SCN_MARGINCLICK 2010
#define SCN_NEEDSHOWN 2011 #define SCN_NEEDSHOWN 2011
#define SCN_POSCHANGED 2012 #define SCN_POSCHANGED 2012
#define SCN_PAINTED 2013
#define SCN_USERLISTSELECTION 2014
#define SCN_URIDROPPED 2015
#define SCN_DWELLSTART 2016
#define SCN_DWELLEND 2017
//--Autogenerated -- end of section automatically generated from Scintilla.iface //--Autogenerated -- end of section automatically generated from Scintilla.iface
// Optional module for macro recording // Optional module for macro recording
@@ -437,14 +523,14 @@ struct CharacterRange {
}; };
struct TextRange { struct TextRange {
CharacterRange chrg; struct CharacterRange chrg;
char *lpstrText; char *lpstrText;
}; };
struct TextToFind { struct TextToFind {
CharacterRange chrg; struct CharacterRange chrg;
char *lpstrText; char *lpstrText;
CharacterRange chrgText; struct CharacterRange chrgText;
}; };
#ifdef PLATFORM_H #ifdef PLATFORM_H
@@ -463,8 +549,8 @@ struct RangeToFormat {
#endif #endif
struct NotifyHeader { struct NotifyHeader {
// hwndFrom is really an environment specifc window handle or pointer // hwndFrom is really an environment specifc window handle or pointer
// but most clients of Scintilla.h do not have this type visible. // but most clients of Scintilla.h do not have this type visible.
//WindowID hwndFrom; //WindowID hwndFrom;
void *hwndFrom; void *hwndFrom;
unsigned int idFrom; unsigned int idFrom;
@@ -472,26 +558,35 @@ struct NotifyHeader {
}; };
struct SCNotification { struct SCNotification {
NotifyHeader nmhdr; struct NotifyHeader nmhdr;
int position; // SCN_STYLENEEDED, SCN_MODIFIED int position; // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND
int ch; // SCN_CHARADDED, SCN_KEY int ch; // SCN_CHARADDED, SCN_KEY
int modifiers; // SCN_KEY int modifiers; // SCN_KEY
int modificationType; // SCN_MODIFIED int modificationType; // SCN_MODIFIED
const char *text; // SCN_MODIFIED const char *text; // SCN_MODIFIED
int length; // SCN_MODIFIED int length; // SCN_MODIFIED
int linesAdded; // SCN_MODIFIED int linesAdded; // SCN_MODIFIED
#ifdef MACRO_SUPPORT #ifdef MACRO_SUPPORT
int message; // SCN_MACRORECORD int message; // SCN_MACRORECORD
int wParam; // SCN_MACRORECORD uptr_t wParam; // SCN_MACRORECORD
int lParam; // SCN_MACRORECORD sptr_t lParam; // SCN_MACRORECORD
#endif #endif
int line; // SCN_MODIFIED int line; // SCN_MODIFIED
int foldLevelNow; // SCN_MODIFIED int foldLevelNow; // SCN_MODIFIED
int foldLevelPrev; // SCN_MODIFIED int foldLevelPrev; // SCN_MODIFIED
int margin; // SCN_MARGINCLICK int margin; // SCN_MARGINCLICK
int listType; // SCN_USERLISTSELECTION
int x; // SCN_DWELLSTART, SCN_DWELLEND
int y; // SCN_DWELLSTART, SCN_DWELLEND
}; };
#define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | (1<<SC_MARKNUM_FOLDEROPEN)) #define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | \
(1<<SC_MARKNUM_FOLDEROPEN) | \
(1<<SC_MARKNUM_FOLDERSUB) | \
(1<<SC_MARKNUM_FOLDERTAIL) | \
(1<<SC_MARKNUM_FOLDERMIDTAIL) | \
(1<<SC_MARKNUM_FOLDEROPENMID) | \
(1<<SC_MARKNUM_FOLDEREND))
// Deprecation section listing all API features that are deprecated and will // Deprecation section listing all API features that are deprecated and will
// will be removed completely in a future version. // will be removed completely in a future version.
@@ -499,10 +594,6 @@ struct SCNotification {
#ifdef INCLUDE_DEPRECATED_FEATURES #ifdef INCLUDE_DEPRECATED_FEATURES
// Deprecated in 1.27
#define SC_UNDOCOLLECT_NONE 0
#define SC_UNDOCOLLECT_AUTOSTART 1
#endif #endif
#endif #endif

View File

@@ -134,6 +134,10 @@ set void SetViewWS=2021(int viewWS,)
# Find the position from a point within the window. # Find the position from a point within the window.
fun int PositionFromPoint=2022(int x, int y) fun int PositionFromPoint=2022(int x, int y)
# Find the position from a point within the window but return
# INVALID_POSITION if not close to text.
fun int PositionFromPointClose=2023(int x, int y)
# Set caret to start of a line and ensure it is visible. # Set caret to start of a line and ensure it is visible.
fun void GotoLine=2024(int line,) fun void GotoLine=2024(int line,)
@@ -151,13 +155,13 @@ fun int GetCurLine=2027(int length, stringresult text)
# Retrieve the position of the last correctly styled character. # Retrieve the position of the last correctly styled character.
get position GetEndStyled=2028(,) get position GetEndStyled=2028(,)
# Convert all line endings in the document to use the current mode.
fun void ConvertEOLs=2029(,)
val SC_EOL_CRLF=0 val SC_EOL_CRLF=0
val SC_EOL_CR=1 val SC_EOL_CR=1
val SC_EOL_LF=2 val SC_EOL_LF=2
# Convert all line endings in the document to one mode.
fun void ConvertEOLs=2029(int eolMode,)
# Retrieve the current end of line mode - one of CRLF, CR, or LF. # Retrieve the current end of line mode - one of CRLF, CR, or LF.
get int GetEOLMode=2030(,) get int GetEOLMode=2030(,)
@@ -210,6 +214,27 @@ val SC_MARK_ARROWDOWN=6
val SC_MARK_MINUS=7 val SC_MARK_MINUS=7
val SC_MARK_PLUS=8 val SC_MARK_PLUS=8
# Shapes used for outlining column
val SC_MARK_VLINE=9
val SC_MARK_LCORNER=10
val SC_MARK_TCORNER=11
val SC_MARK_BOXPLUS=12
val SC_MARK_BOXPLUSCONNECTED=13
val SC_MARK_BOXMINUS=14
val SC_MARK_BOXMINUSCONNECTED=15
val SC_MARK_LCORNERCURVE=16
val SC_MARK_TCORNERCURVE=17
val SC_MARK_CIRCLEPLUS=18
val SC_MARK_CIRCLEPLUSCONNECTED=19
val SC_MARK_CIRCLEMINUS=20
val SC_MARK_CIRCLEMINUSCONNECTED=21
# Markers used for outlining column
val SC_MARKNUM_FOLDEREND=25
val SC_MARKNUM_FOLDEROPENMID=26
val SC_MARKNUM_FOLDERMIDTAIL=27
val SC_MARKNUM_FOLDERTAIL=28
val SC_MARKNUM_FOLDERSUB=29
val SC_MARKNUM_FOLDER=30 val SC_MARKNUM_FOLDER=30
val SC_MARKNUM_FOLDEROPEN=31 val SC_MARKNUM_FOLDEROPEN=31
@@ -327,6 +352,12 @@ fun void StyleResetDefault=2058(,)
# Set a style to be underlined or not. # Set a style to be underlined or not.
set void StyleSetUnderline=2059(int style, bool underline) set void StyleSetUnderline=2059(int style, bool underline)
val SC_CASE_MIXED=0
val SC_CASE_UPPER=1
val SC_CASE_LOWER=2
# Set a style to be mixed case, or to force upper or lower case.
set void StyleSetCase=2060(int style, int caseForce)
# Set the character set of the font in a style. # Set the character set of the font in a style.
set void StyleSetCharacterSet=2066(int style, int characterSet) set void StyleSetCharacterSet=2066(int style, int characterSet)
@@ -412,6 +443,18 @@ get int GetLineState=2093(int line,)
# Retrieve the last line number that has line state. # Retrieve the last line number that has line state.
get int GetMaxLineState=2094(,) get int GetMaxLineState=2094(,)
# Is the background of the line containing the caret in a different colour?
get bool GetCaretLineVisible=2095(,)
# Display the background of the line containing the caret in a different colour.
set void SetCaretLineVisible=2096(bool show,)
# Get the colour of the background of the line containing the caret.
get colour GetCaretLineBack=2097(,)
# Set the colour of the background of the line containing the caret.
set void SetCaretLineBack=2098(colour back,)
# Display a auto-completion list. # Display a auto-completion list.
# The lenEntered parameter indicates how many characters before # The lenEntered parameter indicates how many characters before
# the caret should be used to provide context. # the caret should be used to provide context.
@@ -465,6 +508,15 @@ set void AutoCSetIgnoreCase=2115(bool ignoreCase,)
# Retrieve state of ignore case flag. # Retrieve state of ignore case flag.
get bool AutoCGetIgnoreCase=2116(,) get bool AutoCGetIgnoreCase=2116(,)
# Display a list of strings and send notification when user chooses one.
fun void UserListShow=2117(int listType, string itemList)
# Set whether or not autocompletion is hidden automatically when nothing matches
set void AutoCSetAutoHide=2118(bool autoHide,)
# Retrieve whether or not autocompletion is hidden automatically when nothing matches
get bool AutoCGetAutoHide=2119(,)
# Set the number of spaces used for one level of indentation. # Set the number of spaces used for one level of indentation.
set void SetIndent=2122(int indentSize,) set void SetIndent=2122(int indentSize,)
@@ -551,6 +603,10 @@ val SC_PRINT_NORMAL=0
val SC_PRINT_INVERTLIGHT=1 val SC_PRINT_INVERTLIGHT=1
# PrintColourMode - force black text on white background for printing. # PrintColourMode - force black text on white background for printing.
val SC_PRINT_BLACKONWHITE=2 val SC_PRINT_BLACKONWHITE=2
# PrintColourMode - text stays coloured, but all background is forced to be white for printing.
val SC_PRINT_COLOURONWHITE=3
# PrintColourMode - only the default-background is forced to be white for printing.
val SC_PRINT_COLOURONWHITEDEFAULTBG=4
# Modify colours when printing for clearer printed text. # Modify colours when printing for clearer printed text.
set void SetPrintColourMode=2148(int mode,) set void SetPrintColourMode=2148(int mode,)
@@ -558,11 +614,9 @@ set void SetPrintColourMode=2148(int mode,)
# Returns the print colour mode. # Returns the print colour mode.
get int GetPrintColourMode=2149(,) get int GetPrintColourMode=2149(,)
val SCFIND_DOWN=1
val SCFIND_WHOLEWORD=2 val SCFIND_WHOLEWORD=2
val SCFIND_MATCHCASE=4 val SCFIND_MATCHCASE=4
val SCFIND_WORDSTART=0x00100000 val SCFIND_WORDSTART=0x00100000
# SCFIND_REGEXP is not yet implemented.
val SCFIND_REGEXP=0x00200000 val SCFIND_REGEXP=0x00200000
# Find some text in the document. # Find some text in the document.
@@ -582,13 +636,13 @@ fun int GetLine=2153(int line, stringresult text)
get int GetLineCount=2154(,) get int GetLineCount=2154(,)
# Sets the size in pixels of the left margin. # Sets the size in pixels of the left margin.
set void SetMarginLeft=2155(, int width) set void SetMarginLeft=2155(, int pixelWidth)
# Returns the size in pixels of the left margin. # Returns the size in pixels of the left margin.
get int GetMarginLeft=2156(,) get int GetMarginLeft=2156(,)
# Sets the size in pixels of the right margin. # Sets the size in pixels of the right margin.
set void SetMarginRight=2157(, int width) set void SetMarginRight=2157(, int pixelWidth)
# Returns the size in pixels of the right margin. # Returns the size in pixels of the right margin.
get int GetMarginRight=2158(,) get int GetMarginRight=2158(,)
@@ -684,6 +738,48 @@ set void SetOvertype=2186(bool overtype,)
# Returns true if overtype mode is active otherwise false is returned. # Returns true if overtype mode is active otherwise false is returned.
get bool GetOvertype=2187(,) get bool GetOvertype=2187(,)
# Set the width of the insert mode caret
set void SetCaretWidth=2188(int pixelWidth,)
# Returns the width of the insert mode caret
get int GetCaretWidth=2189(,)
# Sets the position that starts the target which is used for updating the
# document without affecting the scroll position.
set void SetTargetStart=2190(position pos,)
# Get the position that starts the target.
get position GetTargetStart=2191(,)
# Sets the position that ends the target which is used for updating the
# document without affecting the scroll position.
set void SetTargetEnd=2192(position pos,)
# Get the position that ends the target.
get position GetTargetEnd=2193(,)
# Replace the target text with the argument text.
# Returns the length of the replacement text.
fun int ReplaceTarget=2194(int length, string text)
# Replace the target text with the argument text after \d processing.
# Looks for \d where d is between 1 and 9 and replaces these with the strings
# matched in the last search operation which were surrounded by \( and \).
# Returns the length of the replacement text including any change
# caused by processing the \d patterns.
fun int ReplaceTargetRE=2195(int length, string text)
# Search for a counted string in the target and set the target to the found
# range.
# Returns length of range or -1 for failure in which case target is not moved.
fun int SearchInTarget=2197(int length, string text)
# Set the search flags used by SearchInTarget
set void SetSearchFlags=2198(int flags,)
# Get the search flags used by SearchInTarget
get int GetSearchFlags=2199(,)
# Show a call tip containing a definition near position pos. # Show a call tip containing a definition near position pos.
fun void CallTipShow=2200(position pos, string definition) fun void CallTipShow=2200(position pos, string definition)
@@ -751,6 +847,30 @@ fun void EnsureVisible=2232(int line,)
# Set some debugging options for folding # Set some debugging options for folding
fun void SetFoldFlags=2233(int flags,) fun void SetFoldFlags=2233(int flags,)
# Ensure a particular line is visible by expanding any header line hiding it.
# Use the currently set visibility policy to determine which range to display.
fun void EnsureVisibleEnforcePolicy=2234(int line,)
# Sets whether a tab pressed when caret is within indentation indents
set void SetTabIndents=2260(bool tabIndents,)
# Does a tab pressed when caret is within indentation indent?
get bool GetTabIndents=2261(,)
# Sets whether a backspace pressed when caret is within indentation unindents
set void SetBackSpaceUnIndents=2262(bool bsUnIndents,)
# Does a backspace pressed when caret is within indentation unindent?
get bool GetBackSpaceUnIndents=2263(,)
val SC_TIME_FOREVER=10000000
# Sets the time the mouse must sit still to generate a mouse dwell event
set void SetMouseDwellTime=2264(int periodMilliseconds,)
# Retrieve the time the mouse must sit still to generate a mouse dwell event
get int GetMouseDwellTime=2265(,)
## Start of key messages ## Start of key messages
# Move caret down one line. # Move caret down one line.
fun void LineDown=2300(,) fun void LineDown=2300(,)
@@ -887,6 +1007,9 @@ fun void LineScrollDown=2342(,)
# Scroll the document up, keeping the caret visible. # Scroll the document up, keeping the caret visible.
fun void LineScrollUp=2343(,) fun void LineScrollUp=2343(,)
# Move the caret inside current view if it's not there already
fun void MoveCaretInsideView=2401(,)
# How many characters are on a line, not including end of line characters. # How many characters are on a line, not including end of line characters.
fun int LineLength=2350(int line,) fun int LineLength=2350(int line,)
@@ -909,7 +1032,7 @@ set void SetViewEOL=2356(bool visible,)
get int GetDocPointer=2357(,) get int GetDocPointer=2357(,)
# Change the document object used. # Change the document object used.
set void SetDocPointer=2358(int pointer,) set void SetDocPointer=2358(,int pointer)
# Set which document modification events are sent to the container. # Set which document modification events are sent to the container.
set void SetModEventMask=2359(int mask,) set void SetModEventMask=2359(int mask,)
@@ -942,18 +1065,28 @@ set void SetEdgeColour=2365(colour edgeColour,)
fun void SearchAnchor=2366(,) fun void SearchAnchor=2366(,)
# Find some text starting at the search anchor. # Find some text starting at the search anchor.
# Does not ensure the selection is visible.
fun int SearchNext=2367(int flags, string text) fun int SearchNext=2367(int flags, string text)
# Find some text starting at the search anchor and moving backwards. # Find some text starting at the search anchor and moving backwards.
# Does not ensure the selection is visible.
fun int SearchPrev=2368(int flags, string text) fun int SearchPrev=2368(int flags, string text)
# Show caret within N lines of edge when it's scrolled to view # Show caret within N lines of edge when it's scrolled to view
# If CARET_SLOP not set then centre caret on screen when it's
# scrolled to view
val CARET_SLOP=0x01 val CARET_SLOP=0x01
# Center caret on screen when it's scrolled to view # Value not used
val CARET_CENTER=0x02 val CARET_CENTER=0x02
# OR this with CARET_CENTER to reposition even when visible, or # If CARET_SLOP also set then reposition whenever outside slop border
# OR this with CARET_SLOP to reposition whenever outside slop border # If CARET_SLOP not set then recentre even when visible
val CARET_STRICT=0x04 val CARET_STRICT=0x04
# If CARET_XEVEN set then both left and right margins are given equal weight
# rather than favouring left following behaviour.
val CARET_XEVEN=0x08
# If CARET_XJUMPS set then when caret reaches the margin the display jumps
# enough to leave the caret solidly within the display.
val CARET_XJUMPS=0x10
# Set the way the line the caret is on is kept visible. # Set the way the line the caret is on is kept visible.
fun void SetCaretPolicy=2369(int caretPolicy, int caretSlop) fun void SetCaretPolicy=2369(int caretPolicy, int caretSlop)
@@ -984,6 +1117,49 @@ fun void ReleaseDocument=2377(, int doc)
# Get which document modification events are sent to the container. # Get which document modification events are sent to the container.
get int GetModEventMask=2378(,) get int GetModEventMask=2378(,)
# Change internal focus flag
set void SetFocus=2380(bool focus,)
# Get internal focus flag
get bool GetFocus=2381(,)
# Change error status - 0 = OK
set void SetStatus=2382(int statusCode,)
# Get error status
get int GetStatus=2383(,)
# Set whether the mouse is captured when its button is pressed
set void SetMouseDownCaptures=2384(bool captures,)
# Get whether mouse gets captured
get bool GetMouseDownCaptures=2385(,)
val SC_CURSORNORMAL=-1
val SC_CURSORWAIT=3
# Sets the cursor to one of the SC_CURSOR* values
set void SetCursor=2386(int cursorType,)
# Get cursor type
get int GetCursor=2387(,)
# Move to the previous change in capitalistion
fun void WordPartLeft=2390(,)
# Move to the previous change in capitalistion extending selection to new caret position.
fun void WordPartLeftExtend=2391(,)
# Move to the change next in capitalistion
fun void WordPartRight=2392(,)
# Move to the next change in capitalistion extending selection to new caret position.
fun void WordPartRightExtend=2393(,)
# Constants for use with SetVisiblePolicy, similar to SetCaretPolicy
val VISIBLE_SLOP=0x01
val VISIBLE_STRICT=0x04
# Set the way the display area is determined when a particular line is to be moved to.
fun void SetVisiblePolicy=2394(int visiblePolicy, int visibleSlop)
# Delete back from the current position to the start of the line
fun void DelLineLeft=2395(,)
# Delete forwards from the current position to the end of the line
fun void DelLineRight=2396(,)
# Set the focus to this Scintilla widget. # Set the focus to this Scintilla widget.
# GTK+ Specific # GTK+ Specific
fun void GrabFocus=2400(,) fun void GrabFocus=2400(,)
@@ -1009,6 +1185,9 @@ set void SetProperty=4004(string key, string value)
# Set up the key words used by the lexer. # Set up the key words used by the lexer.
set void SetKeyWords=4005(int keywordSet, string keyWords) set void SetKeyWords=4005(int keywordSet, string keyWords)
# Set the lexing language of the document based on string name.
set void SetLexerLanguage=4006(, string language)
# Notifications # Notifications
# Type of modification and the action which caused the modification # Type of modification and the action which caused the modification
# These are defined as a bit mask to make it easy to specify which notifications are wanted. # These are defined as a bit mask to make it easy to specify which notifications are wanted.
@@ -1077,6 +1256,18 @@ val SCLEX_XCODE=13
val SCLEX_LATEX=14 val SCLEX_LATEX=14
val SCLEX_LUA=15 val SCLEX_LUA=15
val SCLEX_DIFF=16 val SCLEX_DIFF=16
val SCLEX_CONF=17
val SCLEX_PASCAL=18
val SCLEX_AVE=19
val SCLEX_ADA=20
val SCLEX_LISP=21
val SCLEX_RUBY=22
val SCLEX_EIFFEL=23
val SCLEX_EIFFELKW=24
val SCLEX_TCL=25
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
val SCLEX_AUTOMATIC=1000
# Lexical states for SCLEX_PYTHON # Lexical states for SCLEX_PYTHON
val SCE_P_DEFAULT=0 val SCE_P_DEFAULT=0
val SCE_P_COMMENTLINE=1 val SCE_P_COMMENTLINE=1
@@ -1107,6 +1298,9 @@ val SCE_C_OPERATOR=10
val SCE_C_IDENTIFIER=11 val SCE_C_IDENTIFIER=11
val SCE_C_STRINGEOL=12 val SCE_C_STRINGEOL=12
val SCE_C_VERBATIM=13 val SCE_C_VERBATIM=13
val SCE_C_REGEX=14
val SCE_C_COMMENTLINEDOC=15
val SCE_C_WORD2=16
# Lexical states for SCLEX_HTML, SCLEX_XML # Lexical states for SCLEX_HTML, SCLEX_XML
val SCE_H_DEFAULT=0 val SCE_H_DEFAULT=0
val SCE_H_TAG=1 val SCE_H_TAG=1
@@ -1130,6 +1324,10 @@ val SCE_H_CDATA=17
val SCE_H_QUESTION=18 val SCE_H_QUESTION=18
# More HTML # More HTML
val SCE_H_VALUE=19 val SCE_H_VALUE=19
# X-Code
val SCE_H_XCCOMMENT=20
# SGML
val SCE_H_SGML=21
# Embedded Javascript # Embedded Javascript
val SCE_HJ_START=40 val SCE_HJ_START=40
val SCE_HJ_DEFAULT=41 val SCE_HJ_DEFAULT=41
@@ -1143,6 +1341,7 @@ val SCE_HJ_DOUBLESTRING=48
val SCE_HJ_SINGLESTRING=49 val SCE_HJ_SINGLESTRING=49
val SCE_HJ_SYMBOLS=50 val SCE_HJ_SYMBOLS=50
val SCE_HJ_STRINGEOL=51 val SCE_HJ_STRINGEOL=51
val SCE_HJ_REGEX=52
# ASP Javascript # ASP Javascript
val SCE_HJA_START=55 val SCE_HJA_START=55
val SCE_HJA_DEFAULT=56 val SCE_HJA_DEFAULT=56
@@ -1156,6 +1355,7 @@ val SCE_HJA_DOUBLESTRING=63
val SCE_HJA_SINGLESTRING=64 val SCE_HJA_SINGLESTRING=64
val SCE_HJA_SYMBOLS=65 val SCE_HJA_SYMBOLS=65
val SCE_HJA_STRINGEOL=66 val SCE_HJA_STRINGEOL=66
val SCE_HJA_REGEX=67
# Embedded VBScript # Embedded VBScript
val SCE_HB_START=70 val SCE_HB_START=70
val SCE_HB_DEFAULT=71 val SCE_HB_DEFAULT=71
@@ -1211,10 +1411,11 @@ val SCE_HPHP_NUMBER=122
val SCE_HPHP_VARIABLE=123 val SCE_HPHP_VARIABLE=123
val SCE_HPHP_COMMENT=124 val SCE_HPHP_COMMENT=124
val SCE_HPHP_COMMENTLINE=125 val SCE_HPHP_COMMENTLINE=125
val SCE_HPHP_STRINGEOL=126 val SCE_HPHP_HSTRING_VARIABLE=126
val SCE_HPHP_OPERATOR=127
# Lexical states for SCLEX_PERL # Lexical states for SCLEX_PERL
val SCE_PL_DEFAULT=0 val SCE_PL_DEFAULT=0
val SCE_PL_HERE=1 val SCE_PL_ERROR=1
val SCE_PL_COMMENTLINE=2 val SCE_PL_COMMENTLINE=2
val SCE_PL_POD=3 val SCE_PL_POD=3
val SCE_PL_NUMBER=4 val SCE_PL_NUMBER=4
@@ -1229,12 +1430,20 @@ val SCE_PL_SCALAR=12
val SCE_PL_ARRAY=13 val SCE_PL_ARRAY=13
val SCE_PL_HASH=14 val SCE_PL_HASH=14
val SCE_PL_SYMBOLTABLE=15 val SCE_PL_SYMBOLTABLE=15
val SCE_PL_REF=16
val SCE_PL_REGEX=17 val SCE_PL_REGEX=17
val SCE_PL_REGSUBST=18 val SCE_PL_REGSUBST=18
val SCE_PL_LONGQUOTE=19 val SCE_PL_LONGQUOTE=19
val SCE_PL_BACKTICKS=20 val SCE_PL_BACKTICKS=20
val SCE_PL_DATASECTION=21 val SCE_PL_DATASECTION=21
val SCE_PL_HERE_DELIM=22
val SCE_PL_HERE_Q=23
val SCE_PL_HERE_QQ=24
val SCE_PL_HERE_QX=25
val SCE_PL_STRING_Q=26
val SCE_PL_STRING_QQ=27
val SCE_PL_STRING_QX=28
val SCE_PL_STRING_QR=29
val SCE_PL_STRING_QW=30
# Lexical states for SCLEX_LATEX # Lexical states for SCLEX_LATEX
val SCE_L_DEFAULT=0 val SCE_L_DEFAULT=0
val SCE_L_COMMAND=1 val SCE_L_COMMAND=1
@@ -1255,6 +1464,7 @@ val SCE_LUA_PREPROCESSOR=9
val SCE_LUA_OPERATOR=10 val SCE_LUA_OPERATOR=10
val SCE_LUA_IDENTIFIER=11 val SCE_LUA_IDENTIFIER=11
val SCE_LUA_STRINGEOL=12 val SCE_LUA_STRINGEOL=12
# Lexical states for SCLEX_ERRORLIST
val SCE_ERR_DEFAULT=0 val SCE_ERR_DEFAULT=0
val SCE_ERR_PYTHON=1 val SCE_ERR_PYTHON=1
val SCE_ERR_GCC=2 val SCE_ERR_GCC=2
@@ -1262,6 +1472,81 @@ val SCE_ERR_MS=3
val SCE_ERR_CMD=4 val SCE_ERR_CMD=4
val SCE_ERR_BORLAND=5 val SCE_ERR_BORLAND=5
val SCE_ERR_PERL=6 val SCE_ERR_PERL=6
val SCE_ERR_NET=7
val SCE_ERR_LUA=8
val SCE_ERR_DIFF_CHANGED=10
val SCE_ERR_DIFF_ADDITION=11
val SCE_ERR_DIFF_DELETION=12
val SCE_ERR_DIFF_MESSAGE=13
# Lexical states for SCLEX_BATCH
val SCE_BAT_DEFAULT=0
val SCE_BAT_COMMENT=1
val SCE_BAT_WORD=2
val SCE_BAT_LABEL=3
val SCE_BAT_HIDE=4
val SCE_BAT_COMMAND=5
val SCE_BAT_IDENTIFIER=6
val SCE_BAT_OPERATOR=7
# Lexical states for SCLEX_MAKEFILE
val SCE_MAKE_DEFAULT=0
val SCE_MAKE_COMMENT=1
val SCE_MAKE_PREPROCESSOR=2
val SCE_MAKE_IDENTIFIER=3
val SCE_MAKE_OPERATOR=4
val SCE_MAKE_TARGET=5
val SCE_MAKE_IDEOL=9
# Lexical states for the SCLEX_CONF (Apache Configuration Files Lexer)
val SCE_CONF_DEFAULT=0
val SCE_CONF_COMMENT=1
val SCE_CONF_NUMBER=2
val SCE_CONF_IDENTIFIER=3
val SCE_CONF_EXTENSION=4
val SCE_CONF_PARAMETER=5
val SCE_CONF_STRING=6
val SCE_CONF_OPERATOR=7
val SCE_CONF_IP=8
val SCE_CONF_DIRECTIVE=9
# Avenue
val SCE_AVE_DEFAULT=0
val SCE_AVE_COMMENT=1
val SCE_AVE_NUMBER=2
val SCE_AVE_WORD=3
val SCE_AVE_KEYWORD=4
val SCE_AVE_STATEMENT=5
val SCE_AVE_STRING=6
val SCE_AVE_ENUM=7
val SCE_AVE_STRINGEOL=8
val SCE_AVE_IDENTIFIER=9
val SCE_AVE_OPERATOR=10
# Lexical states for SCLEX_ADA
val SCE_ADA_DEFAULT=0
val SCE_ADA_COMMENT=1
val SCE_ADA_NUMBER=2
val SCE_ADA_WORD=3
val SCE_ADA_STRING=4
val SCE_ADA_CHARACTER=5
val SCE_ADA_OPERATOR=6
val SCE_ADA_IDENTIFIER=7
val SCE_ADA_STRINGEOL=8
# Lexical states for SCLEX_LISP
val SCE_LISP_DEFAULT=0
val SCE_LISP_COMMENT=1
val SCE_LISP_NUMBER=2
val SCE_LISP_KEYWORD=3
val SCE_LISP_STRING=6
val SCE_LISP_STRINGEOL=8
val SCE_LISP_IDENTIFIER=9
val SCE_LISP_OPERATOR=10
# Lexical states for SCLEX_EIFFEL and SCLEX_EIFFELKW
val SCE_EIFFEL_DEFAULT=0
val SCE_EIFFEL_COMMENTLINE=1
val SCE_EIFFEL_NUMBER=2
val SCE_EIFFEL_WORD=3
val SCE_EIFFEL_STRING=4
val SCE_EIFFEL_CHARACTER=5
val SCE_EIFFEL_OPERATOR=6
val SCE_EIFFEL_IDENTIFIER=7
val SCE_EIFFEL_STRINGEOL=8
# Events # Events
@@ -1282,9 +1567,16 @@ evt void MacroRecord=2009(int message, int wParam, int lParam)
evt void MarginClick=2010(int modifiers, int position, int margin) evt void MarginClick=2010(int modifiers, int position, int margin)
evt void NeedShown=2011(int position, int length) evt void NeedShown=2011(int position, int length)
evt void PosChanged=2012(int position) evt void PosChanged=2012(int position)
evt void Painted=2013(void)
evt void UserListSelection=2014(int listType, string text)
evt void URIDropped=2015(string text)
evt void DwellStart=2016(int position)
evt void DwellEnd=2017(int position)
cat Deprecated cat Deprecated
val SCFIND_DOWN=1
################################################ ################################################
# From WinDefs.h # From WinDefs.h

View File

@@ -1,7 +1,9 @@
// Scintilla source code edit control // Scintilla source code edit control
// ScintillaWidget.h - definition of Scintilla widget for GTK+ /** @file ScintillaWidget.h
// Only needed by GTK+ code but is harmless on other platforms. ** Definition of Scintilla widget for GTK+.
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Only needed by GTK+ code but is harmless on other platforms.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef SCINTILLAWIDGET_H #ifndef SCINTILLAWIDGET_H
@@ -9,6 +11,17 @@
#if PLAT_GTK #if PLAT_GTK
#ifndef SCINTILLA_H
#ifdef _MSC_VER
#pragma message(__FILE__ "(1) : warning : Scintilla.h should be included before ScintillaWidget.h")
#pragma message("This will be required in the next version of Scintilla")
#else
#warning Scintilla.h should be included before ScintillaWidget.h
#warning This will be required in the next version of Scintilla
#endif
#include "Scintilla.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -21,7 +34,7 @@ typedef struct _ScintillaObject ScintillaObject;
typedef struct _ScintillaClass ScintillaClass; typedef struct _ScintillaClass ScintillaClass;
struct _ScintillaObject { struct _ScintillaObject {
GtkFixed vbox; GtkContainer cont;
void *pscin; void *pscin;
}; };
@@ -35,7 +48,7 @@ struct _ScintillaClass {
guint scintilla_get_type (void); guint scintilla_get_type (void);
GtkWidget* scintilla_new (void); GtkWidget* scintilla_new (void);
void scintilla_set_id (ScintillaObject *sci,int id); void scintilla_set_id (ScintillaObject *sci,int id);
long scintilla_send_message (ScintillaObject *sci,int iMessage,int wParam,int lParam); sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,11 +1,23 @@
// Scintilla source code edit control // Scintilla source code edit control
// WinDefs.h - the subset of definitions from Windows needed by Scintilla for GTK+ /** @file WinDefs.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** The subset of definitions from Windows needed by Scintilla for GTK+.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef WINDEFS_H #ifndef WINDEFS_H
#define WINDEFS_H #define WINDEFS_H
/* Running GTK version on win32 */
#if PLAT_GTK_WIN32
#include "Windows.h"
#include "Richedit.h"
/* Name conflicts */
#undef DrawText
#undef FindText
#else
#define WORD short #define WORD short
#define WPARAM unsigned long #define WPARAM unsigned long
#define LPARAM long #define LPARAM long
@@ -180,4 +192,6 @@ struct FORMATRANGE {
//#define LOWORD(x) (x & 0xffff) //#define LOWORD(x) (x & 0xffff)
//#define HIWORD(x) (x >> 16) //#define HIWORD(x) (x >> 16)
#endif /* !_MSC_VER */
#endif #endif

View File

@@ -1,7 +1,13 @@
// WindowAccessor.h - implementation of BufferAccess and StylingAccess on a Scintilla rapid easy access to contents of a Scintilla // Scintilla source code edit control
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> /** @file WindowAccessor.h
** Implementation of BufferAccess and StylingAccess on a Scintilla
** rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
/**
*/
class WindowAccessor : public Accessor { class WindowAccessor : public Accessor {
// Private so WindowAccessor objects can not be copied // Private so WindowAccessor objects can not be copied
WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {} WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {}
@@ -36,6 +42,9 @@ public:
int GetPropertyInt(const char *key, int defaultValue=0) { int GetPropertyInt(const char *key, int defaultValue=0) {
return props.GetInt(key, defaultValue); return props.GetInt(key, defaultValue);
} }
char *GetProperties() {
return props.ToString();
}
void StartAt(unsigned int start, char chMask=31); void StartAt(unsigned int start, char chMask=31);
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };

View File

@@ -1,13 +1,17 @@
// Scintilla source code edit control // Scintilla source code edit control
// AutoComplete.cxx - defines the auto completion list box /** @file AutoComplete.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the auto completion list box.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include "Platform.h" #include "Platform.h"
#include "PropSet.h"
#include "AutoComplete.h" #include "AutoComplete.h"
AutoComplete::AutoComplete() : AutoComplete::AutoComplete() :
@@ -17,7 +21,8 @@ AutoComplete::AutoComplete() :
chooseSingle(false), chooseSingle(false),
posStart(0), posStart(0),
startLen(0), startLen(0),
cancelAtStartPos(true) { cancelAtStartPos(true),
autoHide(true) {
stopChars[0] = '\0'; stopChars[0] = '\0';
fillUpChars[0] = '\0'; fillUpChars[0] = '\0';
} }
@@ -85,7 +90,6 @@ void AutoComplete::SetList(const char *list) {
} }
delete []words; delete []words;
} }
lb.Sort();
} }
void AutoComplete::Show() { void AutoComplete::Show() {
@@ -113,9 +117,42 @@ void AutoComplete::Move(int delta) {
} }
void AutoComplete::Select(const char *word) { void AutoComplete::Select(const char *word) {
int pos = lb.Find(word); int lenWord = strlen(word);
//Platform::DebugPrintf("Autocompleting at <%s> %d\n", wordCurrent, pos); int location = -1;
if (pos != -1) const int maxItemLen=1000;
lb.Select(pos); char item[maxItemLen];
int start = 0; // lower bound of the api array block to search
int end = lb.Length() - 1; // upper bound of the api array block to search
while ((start <= end) && (location == -1)) { // Binary searching loop
int pivot = (start + end) / 2;
lb.GetValue(pivot, item, maxItemLen);
int cond;
if (ignoreCase)
cond = CompareNCaseInsensitive(word, item, lenWord);
else
cond = strncmp(word, item, lenWord);
if (!cond) {
// Find first match
while (pivot > start) {
lb.GetValue(pivot-1, item, maxItemLen);
if (ignoreCase)
cond = CompareNCaseInsensitive(word, item, lenWord);
else
cond = strncmp(word, item, lenWord);
if (0 != cond)
break;
--pivot;
}
location = pivot;
} else if (cond < 0) {
end = pivot - 1;
} else if (cond > 0) {
start = pivot + 1;
}
}
if (location == -1 && autoHide)
Cancel();
else
lb.Select(location);
} }

View File

@@ -1,56 +1,62 @@
// Scintilla source code edit control // Scintilla source code edit control
// AutoComplete.h - defines the auto completion list box /** @file AutoComplete.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the auto completion list box.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef AUTOCOMPLETE_H #ifndef AUTOCOMPLETE_H
#define AUTOCOMPLETE_H #define AUTOCOMPLETE_H
/**
*/
class AutoComplete { class AutoComplete {
bool active; bool active;
char stopChars[256]; char stopChars[256];
char fillUpChars[256]; char fillUpChars[256];
char separator; char separator;
public: public:
bool ignoreCase; bool ignoreCase;
bool chooseSingle; bool chooseSingle;
ListBox lb; ListBox lb;
int posStart; int posStart;
int startLen; int startLen;
// Should autocompletion be canceled if editor's currentPos <= startPos? /// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos; bool cancelAtStartPos;
bool autoHide;
AutoComplete(); AutoComplete();
~AutoComplete(); ~AutoComplete();
// Is the auto completion list displayed? /// Is the auto completion list displayed?
bool Active(); bool Active();
// Display the auto completion list positioned to be near a character position /// Display the auto completion list positioned to be near a character position
void Start(Window &parent, int ctrlID, int position, int startLen_); void Start(Window &parent, int ctrlID, int position, int startLen_);
// The stop chars are characters which, when typed, cause the auto completion list to disappear /// The stop chars are characters which, when typed, cause the auto completion list to disappear
void SetStopChars(const char *stopChars_); void SetStopChars(const char *stopChars_);
bool IsStopChar(char ch); bool IsStopChar(char ch);
// The fillup chars are characters which, when typed, fill up the selected word /// The fillup chars are characters which, when typed, fill up the selected word
void SetFillUpChars(const char *fillUpChars_); void SetFillUpChars(const char *fillUpChars_);
bool IsFillUpChar(char ch); bool IsFillUpChar(char ch);
// The separator character is used when interpreting the list in SetList /// The separator character is used when interpreting the list in SetList
void SetSeparator(char separator_); void SetSeparator(char separator_);
char GetSeparator(); char GetSeparator();
// The list string contains a sequence of words separated by the separator character /// The list string contains a sequence of words separated by the separator character
void SetList(const char *list); void SetList(const char *list);
void Show(); void Show();
void Cancel(); void Cancel();
// Move the current list element by delta, scrolling appropriately /// Move the current list element by delta, scrolling appropriately
void Move(int delta); void Move(int delta);
// Select a list element that starts with word as the current element /// Select a list element that starts with word as the current element
void Select(const char *word); void Select(const char *word);
}; };

View File

@@ -1,10 +1,12 @@
// Scintilla source code edit control // Scintilla source code edit control
// CallTip.cxx - code for displaying call tips /** @file CallTip.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Code for displaying call tips.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "Platform.h" #include "Platform.h"
@@ -27,6 +29,7 @@ CallTip::CallTip() {
} }
CallTip::~CallTip() { CallTip::~CallTip() {
font.Release();
wCallTip.Destroy(); wCallTip.Destroy();
delete []val; delete []val;
val = 0; val = 0;
@@ -42,7 +45,7 @@ void CallTip::RefreshColourPalette(Palette &pal, bool want) {
void CallTip::PaintCT(Surface *surfaceWindow) { void CallTip::PaintCT(Surface *surfaceWindow) {
if (!val) if (!val)
return; return ;
PRectangle rcClientPos = wCallTip.GetClientPosition(); PRectangle rcClientPos = wCallTip.GetClientPosition();
PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left, PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left,
rcClientPos.bottom - rcClientPos.top); rcClientPos.bottom - rcClientPos.top);
@@ -117,7 +120,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size) { const char *faceName, int size) {
Surface surfaceMeasure; Surface surfaceMeasure;
surfaceMeasure.Init(); surfaceMeasure.Init();
int deviceHeight = (size * surfaceMeasure.LogPixelsY()) / 72; int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false); font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
if (val) if (val)
delete []val; delete []val;
@@ -146,10 +149,9 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
int lineHeight = surfaceMeasure.Height(font); int lineHeight = surfaceMeasure.Height(font);
// Extra line for border and an empty line at top and bottom // Extra line for border and an empty line at top and bottom
int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2; int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2;
return PRectangle(pt.x -5, pt.y + lineHeight + 1, pt.x + width - 5, pt.y + lineHeight + 1 + height); return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
} }
void CallTip::CallTipCancel() { void CallTip::CallTipCancel() {
inCallTipMode = false; inCallTipMode = false;
if (wCallTip.Created()) { if (wCallTip.Created()) {

View File

@@ -1,11 +1,15 @@
// Scintilla source code edit control // Scintilla source code edit control
// CallTip.h - interface to the call tip control /** @file CallTip.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Interface to the call tip control.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef CALLTIP_H #ifndef CALLTIP_H
#define CALLTIP_H #define CALLTIP_H
/**
*/
class CallTip { class CallTip {
int startHighlight; int startHighlight;
int endHighlight; int endHighlight;
@@ -14,6 +18,7 @@ class CallTip {
// Private so CallTip objects can not be copied // Private so CallTip objects can not be copied
CallTip(const CallTip &) {} CallTip(const CallTip &) {}
CallTip &operator=(const CallTip &) { return *this; } CallTip &operator=(const CallTip &) { return *this; }
public: public:
Window wCallTip; Window wCallTip;
Window wDraw; Window wDraw;
@@ -28,19 +33,19 @@ public:
CallTip(); CallTip();
~CallTip(); ~CallTip();
// Claim or accept palette entries for the colours required to paint a calltip /// Claim or accept palette entries for the colours required to paint a calltip.
void RefreshColourPalette(Palette &pal, bool want); void RefreshColourPalette(Palette &pal, bool want);
void PaintCT(Surface *surfaceWindow); void PaintCT(Surface *surfaceWindow);
// Setup the calltip and return a rectangle of the area required /// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(int pos, Point pt, const char *defn, PRectangle CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size); const char *faceName, int size);
void CallTipCancel(); void CallTipCancel();
// Set a range of characters to be displayed in a highlight style. /// Set a range of characters to be displayed in a highlight style.
// Commonly used to highlight the current parameter. /// Commonly used to highlight the current parameter.
void SetHighlight(int start, int end); void SetHighlight(int start, int end);
}; };

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// CellBuffer.cxx - manages a buffer of cells /** @file CellBuffer.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages a buffer of cells.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdio.h> #include <stdio.h>
@@ -416,22 +418,19 @@ UndoHistory::~UndoHistory() {
} }
void UndoHistory::EnsureUndoRoom() { void UndoHistory::EnsureUndoRoom() {
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction); // Have to test that there is room for 2 more actions in the array
if (currentAction >= 2) { // as two actions may be created by the calling function
// Have to test that there is room for 2 more actions in the array if (currentAction >= (lenActions - 2)) {
// as two actions may be created by this function // Run out of undo nodes so extend the array
if (currentAction >= (lenActions - 2)) { int lenActionsNew = lenActions * 2;
// Run out of undo nodes so extend the array Action *actionsNew = new Action[lenActionsNew];
int lenActionsNew = lenActions * 2; if (!actionsNew)
Action *actionsNew = new Action[lenActionsNew]; return ;
if (!actionsNew) for (int act = 0; act <= currentAction; act++)
return ; actionsNew[act].Grab(&actions[act]);
for (int act = 0; act <= currentAction; act++) delete []actions;
actionsNew[act].Grab(&actions[act]); lenActions = lenActionsNew;
delete []actions; actions = actionsNew;
lenActions = lenActionsNew;
actions = actionsNew;
}
} }
} }
@@ -450,14 +449,27 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng
currentAction++; currentAction++;
} else if (currentAction == savePoint) { } else if (currentAction == savePoint) {
currentAction++; currentAction++;
} else if ((at == removeAction) &&
((position + lengthData * 2) != actPrevious.position)) {
// Removals must be at same position to coalesce
currentAction++;
} else if ((at == insertAction) && } else if ((at == insertAction) &&
(position != (actPrevious.position + actPrevious.lenData*2))) { (position != (actPrevious.position + actPrevious.lenData*2))) {
// Insertions must be immediately after to coalesce // Insertions must be immediately after to coalesce
currentAction++; currentAction++;
} else if (!actions[currentAction].mayCoalesce) {
// Not allowed to coalesce if this set
currentAction++;
} else if (at == removeAction) {
if ((lengthData == 1) || (lengthData == 2)){
if ((position + lengthData * 2) == actPrevious.position) {
; // Backspace -> OK
} else if (position == actPrevious.position) {
; // Delete -> OK
} else {
// Removals must be at same position to coalesce
currentAction++;
}
} else {
// Removals must be of one character to coalesce
currentAction++;
}
} else { } else {
//Platform::DebugPrintf("action coalesced\n"); //Platform::DebugPrintf("action coalesced\n");
} }
@@ -582,6 +594,7 @@ CellBuffer::CellBuffer(int initialLength) {
part2body = body + gaplen; part2body = body + gaplen;
readOnly = false; readOnly = false;
collectingUndo = true; collectingUndo = true;
growSize = 4000;
} }
CellBuffer::~CellBuffer() { CellBuffer::~CellBuffer() {
@@ -612,7 +625,9 @@ void CellBuffer::RoomFor(int insertionLength) {
if (gaplen <= insertionLength) { if (gaplen <= insertionLength) {
//Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength); //Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
GapTo(length); GapTo(length);
int newSize = size + insertionLength + 4000; if (growSize * 6 < size)
growSize *= 2;
int newSize = size + insertionLength + growSize;
//Platform::DebugPrintf("moved gap %d\n", newSize); //Platform::DebugPrintf("moved gap %d\n", newSize);
char *newBody = new char[newSize]; char *newBody = new char[newSize];
memcpy(newBody, body, size); memcpy(newBody, body, size);
@@ -733,6 +748,8 @@ bool CellBuffer::SetStyleAt(int position, char style, char mask) {
bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mask) { bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mask) {
int bytePos = position * 2 + 1; int bytePos = position * 2 + 1;
bool changed = false; bool changed = false;
PLATFORM_ASSERT(lengthStyle == 0 ||
(lengthStyle > 0 && lengthStyle + position < length));
while (lengthStyle--) { while (lengthStyle--) {
char curVal = ByteAt(bytePos); char curVal = ByteAt(bytePos);
if ((curVal & mask) != style) { if ((curVal & mask) != style) {
@@ -779,7 +796,7 @@ int CellBuffer::LineStart(int line) {
if (line < 0) if (line < 0)
return 0; return 0;
else if (line > lv.lines) else if (line > lv.lines)
return length; return Length();
else else
return lv.linesData[line].startPosition; return lv.linesData[line].startPosition;
} }
@@ -930,7 +947,6 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
ignoreNL = true; // First \n is not real deletion ignoreNL = true; // First \n is not real deletion
} }
char ch = chNext; char ch = chNext;
for (int i = 0; i < deleteLength; i += 2) { for (int i = 0; i < deleteLength; i += 2) {
chNext = ' '; chNext = ' ';
@@ -948,7 +964,6 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
ignoreNL = false; // Further \n are not real deletions ignoreNL = false; // Further \n are not real deletions
} }
ch = chNext; ch = chNext;
} }
// May have to fix up end if last deletion causes cr to be next to lf // May have to fix up end if last deletion causes cr to be next to lf

View File

@@ -1,28 +1,35 @@
// Scintilla source code edit control // Scintilla source code edit control
// CellBuffer.h - manages the text of the document /** @file CellBuffer.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages the text of the document.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef CELLBUFFER_H #ifndef CELLBUFFER_H
#define CELLBUFFER_H #define CELLBUFFER_H
// This holds the marker identifier and the marker type to display. /**
// MarkerHandleNumbers are members of lists. * This holds the marker identifier and the marker type to display.
* MarkerHandleNumbers are members of lists.
*/
struct MarkerHandleNumber { struct MarkerHandleNumber {
int handle; int handle;
int number; int number;
MarkerHandleNumber *next; MarkerHandleNumber *next;
}; };
// A marker handle set contains any number of MarkerHandleNumbers /**
* A marker handle set contains any number of MarkerHandleNumbers.
*/
class MarkerHandleSet { class MarkerHandleSet {
MarkerHandleNumber *root; MarkerHandleNumber *root;
public: public:
MarkerHandleSet(); MarkerHandleSet();
~MarkerHandleSet(); ~MarkerHandleSet();
int Length(); int Length();
int NumberFromHandle(int handle); int NumberFromHandle(int handle);
int MarkValue(); // Bit set of marker numbers int MarkValue(); ///< Bit set of marker numbers.
bool Contains(int handle); bool Contains(int handle);
bool InsertHandle(int handle, int markerNum); bool InsertHandle(int handle, int markerNum);
void RemoveHandle(int handle); void RemoveHandle(int handle);
@@ -30,8 +37,10 @@ public:
void CombineWith(MarkerHandleSet *other); void CombineWith(MarkerHandleSet *other);
}; };
// Each line stores the starting position of the first character of the line in the cell buffer /**
// and potentially a marker handle set. Often a line will not have any attached markers. * Each line stores the starting position of the first character of the line in the cell buffer
* and potentially a marker handle set. Often a line will not have any attached markers.
*/
struct LineData { struct LineData {
int startPosition; int startPosition;
MarkerHandleSet *handleSet; MarkerHandleSet *handleSet;
@@ -39,7 +48,9 @@ struct LineData {
} }
}; };
// The line vector contains information about each of the lines in a cell buffer. /**
* The line vector contains information about each of the lines in a cell buffer.
*/
class LineVector { class LineVector {
public: public:
enum { growSize = 4000 }; enum { growSize = 4000 };
@@ -48,22 +59,22 @@ public:
int size; int size;
int *levels; int *levels;
int sizeLevels; int sizeLevels;
// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
int handleCurrent; int handleCurrent;
LineVector(); LineVector();
~LineVector(); ~LineVector();
void Init(); void Init();
void Expand(int sizeNew); void Expand(int sizeNew);
void ExpandLevels(int sizeNew=-1); void ExpandLevels(int sizeNew=-1);
void ClearLevels(); void ClearLevels();
void InsertValue(int pos, int value); void InsertValue(int pos, int value);
void SetValue(int pos, int value); void SetValue(int pos, int value);
void Remove(int pos); void Remove(int pos);
int LineFromPosition(int pos); int LineFromPosition(int pos);
int AddMark(int line, int marker); int AddMark(int line, int marker);
void MergeMarkers(int pos); void MergeMarkers(int pos);
void DeleteMark(int line, int markerNum); void DeleteMark(int line, int markerNum);
@@ -71,9 +82,11 @@ public:
int LineFromHandle(int markerHandle); int LineFromHandle(int markerHandle);
}; };
// Actions are used to store all the information required to perform one undo/redo step.
enum actionType { insertAction, removeAction, startAction }; enum actionType { insertAction, removeAction, startAction };
/**
* Actions are used to store all the information required to perform one undo/redo step.
*/
class Action { class Action {
public: public:
actionType at; actionType at;
@@ -89,6 +102,9 @@ public:
void Grab(Action *source); void Grab(Action *source);
}; };
/**
*
*/
class UndoHistory { class UndoHistory {
Action *actions; Action *actions;
int lenActions; int lenActions;
@@ -98,25 +114,25 @@ class UndoHistory {
int savePoint; int savePoint;
void EnsureUndoRoom(); void EnsureUndoRoom();
public: public:
UndoHistory(); UndoHistory();
~UndoHistory(); ~UndoHistory();
void AppendAction(actionType at, int position, char *data, int length); void AppendAction(actionType at, int position, char *data, int length);
void BeginUndoAction(); void BeginUndoAction();
void EndUndoAction(); void EndUndoAction();
void DropUndoSequence(); void DropUndoSequence();
void DeleteUndoHistory(); void DeleteUndoHistory();
// The save point is a marker in the undo stack where the container has stated that /// The save point is a marker in the undo stack where the container has stated that
// the buffer was saved. Undo and redo can move over the save point. /// the buffer was saved. Undo and redo can move over the save point.
void SetSavePoint(); void SetSavePoint();
bool IsSavePoint() const; bool IsSavePoint() const;
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// called that many times. Similarly for redo. /// called that many times. Similarly for redo.
bool CanUndo() const; bool CanUndo() const;
int StartUndo(); int StartUndo();
const Action &GetUndoStep() const; const Action &GetUndoStep() const;
@@ -127,9 +143,11 @@ public:
void CompletedRedoStep(); void CompletedRedoStep();
}; };
// Holder for an expandable array of characters that supports undo and line markers /**
// Based on article "Data Structures in a Bit-Mapped Text Editor" * Holder for an expandable array of characters that supports undo and line markers.
// by Wilfred J. Hansen, Byte January 1987, page 183 * Based on article "Data Structures in a Bit-Mapped Text Editor"
* by Wilfred J. Hansen, Byte January 1987, page 183.
*/
class CellBuffer { class CellBuffer {
private: private:
char *body; char *body;
@@ -139,6 +157,7 @@ private:
int gaplen; int gaplen;
char *part2body; char *part2body;
bool readOnly; bool readOnly;
int growSize;
bool collectingUndo; bool collectingUndo;
UndoHistory uh; UndoHistory uh;
@@ -157,12 +176,12 @@ public:
CellBuffer(int initialLength = 4000); CellBuffer(int initialLength = 4000);
~CellBuffer(); ~CellBuffer();
// Retrieving positions outside the range of the buffer works and returns 0 /// Retrieving positions outside the range of the buffer works and returns 0
char CharAt(int position); char CharAt(int position);
void GetCharRange(char *buffer, int position, int lengthRetrieve); void GetCharRange(char *buffer, int position, int lengthRetrieve);
char StyleAt(int position); char StyleAt(int position);
int ByteLength(); int ByteLength();
int Length(); int Length();
int Lines(); int Lines();
@@ -170,23 +189,23 @@ public:
int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
const char *InsertString(int position, char *s, int insertLength); const char *InsertString(int position, char *s, int insertLength);
void InsertCharStyle(int position, char ch, char style); void InsertCharStyle(int position, char ch, char style);
// Setting styles for positions outside the range of the buffer is safe and has no effect. /// Setting styles for positions outside the range of the buffer is safe and has no effect.
// True is returned if the style of a character changed. /// @return true if the style of a character is changed.
bool SetStyleAt(int position, char style, char mask='\377'); bool SetStyleAt(int position, char style, char mask='\377');
bool SetStyleFor(int position, int length, char style, char mask); bool SetStyleFor(int position, int length, char style, char mask);
const char *DeleteChars(int position, int deleteLength); const char *DeleteChars(int position, int deleteLength);
bool IsReadOnly(); bool IsReadOnly();
void SetReadOnly(bool set); void SetReadOnly(bool set);
// The save point is a marker in the undo stack where the container has stated that /// The save point is a marker in the undo stack where the container has stated that
// the buffer was saved. Undo and redo can move over the save point. /// the buffer was saved. Undo and redo can move over the save point.
void SetSavePoint(); void SetSavePoint();
bool IsSavePoint(); bool IsSavePoint();
// Line marker functions /// Line marker functions
int AddMark(int line, int markerNum); int AddMark(int line, int markerNum);
void DeleteMark(int line, int markerNum); void DeleteMark(int line, int markerNum);
void DeleteMarkFromHandle(int markerHandle); void DeleteMarkFromHandle(int markerHandle);
@@ -194,7 +213,7 @@ public:
void DeleteAllMarks(int markerNum); void DeleteAllMarks(int markerNum);
int LineFromHandle(int markerHandle); int LineFromHandle(int markerHandle);
// Without undo /// Actions without undo
void BasicInsertString(int position, char *s, int insertLength); void BasicInsertString(int position, char *s, int insertLength);
void BasicDeleteChars(int position, int deleteLength); void BasicDeleteChars(int position, int deleteLength);
@@ -203,9 +222,9 @@ public:
void BeginUndoAction(); void BeginUndoAction();
void EndUndoAction(); void EndUndoAction();
void DeleteUndoHistory(); void DeleteUndoHistory();
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// called that many times. Similarly for redo. /// called that many times. Similarly for redo.
bool CanUndo(); bool CanUndo();
int StartUndo(); int StartUndo();
const Action &GetUndoStep() const; const Action &GetUndoStep() const;
@@ -214,14 +233,14 @@ public:
int StartRedo(); int StartRedo();
const Action &GetRedoStep() const; const Action &GetRedoStep() const;
void PerformRedoStep(); void PerformRedoStep();
int SetLineState(int line, int state); int SetLineState(int line, int state);
int GetLineState(int line); int GetLineState(int line);
int GetMaxLineState(); int GetMaxLineState();
int SetLevel(int line, int level); int SetLevel(int line, int level);
int GetLevel(int line); int GetLevel(int line);
void ClearLevels(); void ClearLevels();
}; };
#define CELL_SIZE 2 #define CELL_SIZE 2

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// ContractionState.cxx - manages visibility of lines for folding /** @file ContractionState.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages visibility of lines for folding.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include "Platform.h" #include "Platform.h"

View File

@@ -1,15 +1,19 @@
// Scintilla source code edit control // Scintilla source code edit control
// ContractionState.h - manages visibility of lines for folding /** @file ContractionState.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages visibility of lines for folding.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef CONTRACTIONSTATE_H #ifndef CONTRACTIONSTATE_H
#define CONTRACTIONSTATE_H #define CONTRACTIONSTATE_H
/**
*/
class OneLine { class OneLine {
public: public:
int displayLine; // position within set of visible lines int displayLine; ///< Position within set of visible lines
int docLine; // inverse of displayLine int docLine; ///< Inverse of @a displayLine
bool visible; bool visible;
bool expanded; bool expanded;
@@ -17,6 +21,8 @@ public:
virtual ~OneLine() {} virtual ~OneLine() {}
}; };
/**
*/
class ContractionState { class ContractionState {
void Grow(int sizeNew); void Grow(int sizeNew);
enum { growSize = 4000 }; enum { growSize = 4000 };
@@ -26,6 +32,7 @@ class ContractionState {
int size; int size;
mutable bool valid; mutable bool valid;
void MakeValid() const; void MakeValid() const;
public: public:
ContractionState(); ContractionState();
virtual ~ContractionState(); virtual ~ContractionState();

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// Document.cxx - text document that handles notifications, DBCS, styling, words and end of line /** @file Document.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Text document that handles notifications, DBCS, styling, words and end of line.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -14,6 +16,12 @@
#include "SVector.h" #include "SVector.h"
#include "CellBuffer.h" #include "CellBuffer.h"
#include "Document.h" #include "Document.h"
#include "RESearch.h"
// This is ASCII specific but is safe with chars >= 0x80
inline bool isspacechar(unsigned char ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
Document::Document() { Document::Document() {
refCount = 0; refCount = 0;
@@ -25,7 +33,6 @@ Document::Document() {
dbcsCodePage = 0; dbcsCodePage = 0;
stylingBits = 5; stylingBits = 5;
stylingBitsMask = 0x1F; stylingBitsMask = 0x1F;
stylingPos = 0;
stylingMask = 0; stylingMask = 0;
for (int ch = 0; ch < 256; ch++) { for (int ch = 0; ch < 256; ch++) {
wordchars[ch] = isalnum(ch) || ch == '_'; wordchars[ch] = isalnum(ch) || ch == '_';
@@ -36,8 +43,14 @@ Document::Document() {
tabInChars = 8; tabInChars = 8;
indentInChars = 0; indentInChars = 0;
useTabs = true; useTabs = true;
tabIndents = true;
backspaceUnindents = false;
watchers = 0; watchers = 0;
lenWatchers = 0; lenWatchers = 0;
matchesValid = false;
pre = 0;
substituted = 0;
} }
Document::~Document() { Document::~Document() {
@@ -47,6 +60,10 @@ Document::~Document() {
delete []watchers; delete []watchers;
watchers = 0; watchers = 0;
lenWatchers = 0; lenWatchers = 0;
delete pre;
pre = 0;
delete []substituted;
substituted = 0;
} }
// Increase reference count and return its previous value. // Increase reference count and return its previous value.
@@ -68,27 +85,27 @@ void Document::SetSavePoint() {
NotifySavePoint(true); NotifySavePoint(true);
} }
int Document::AddMark(int line, int markerNum) { int Document::AddMark(int line, int markerNum) {
int prev = cb.AddMark(line, markerNum); int prev = cb.AddMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
return prev; return prev;
} }
void Document::DeleteMark(int line, int markerNum) { void Document::DeleteMark(int line, int markerNum) {
cb.DeleteMark(line, markerNum); cb.DeleteMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
} }
void Document::DeleteMarkFromHandle(int markerHandle) { void Document::DeleteMarkFromHandle(int markerHandle) {
cb.DeleteMarkFromHandle(markerHandle); cb.DeleteMarkFromHandle(markerHandle);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
} }
void Document::DeleteAllMarks(int markerNum) { void Document::DeleteAllMarks(int markerNum) {
cb.DeleteAllMarks(markerNum); cb.DeleteAllMarks(markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
} }
@@ -131,10 +148,11 @@ int Document::VCHomePosition(int position) {
return startText; return startText;
} }
int Document::SetLevel(int line, int level) { int Document::SetLevel(int line, int level) {
int prev = cb.SetLevel(line, level); int prev = cb.SetLevel(line, level);
if (prev != level) { if (prev != level) {
DocModification mh(SC_MOD_CHANGEFOLD, LineStart(line), 0, 0, 0); DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
LineStart(line), 0, 0, 0);
mh.line = line; mh.line = line;
mh.foldLevelNow = level; mh.foldLevelNow = level;
mh.foldLevelPrev = prev; mh.foldLevelPrev = prev;
@@ -146,7 +164,7 @@ int Document::SetLevel(int line, int level) {
static bool IsSubordinate(int levelStart, int levelTry) { static bool IsSubordinate(int levelStart, int levelTry) {
if (levelTry & SC_FOLDLEVELWHITEFLAG) if (levelTry & SC_FOLDLEVELWHITEFLAG)
return true; return true;
else else
return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK); return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK);
} }
@@ -155,16 +173,16 @@ int Document::GetLastChild(int lineParent, int level) {
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK; level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
int maxLine = LinesTotal(); int maxLine = LinesTotal();
int lineMaxSubord = lineParent; int lineMaxSubord = lineParent;
while (lineMaxSubord < maxLine-1) { while (lineMaxSubord < maxLine - 1) {
EnsureStyledTo(LineStart(lineMaxSubord+2)); EnsureStyledTo(LineStart(lineMaxSubord + 2));
if (!IsSubordinate(level, GetLevel(lineMaxSubord+1))) if (!IsSubordinate(level, GetLevel(lineMaxSubord + 1)))
break; break;
lineMaxSubord++; lineMaxSubord++;
} }
if (lineMaxSubord > lineParent) { if (lineMaxSubord > lineParent) {
if (level > (GetLevel(lineMaxSubord+1) & SC_FOLDLEVELNUMBERMASK)) { if (level > (GetLevel(lineMaxSubord + 1) & SC_FOLDLEVELNUMBERMASK)) {
// Have chewed up some whitespace that belongs to a parent so seek back // Have chewed up some whitespace that belongs to a parent so seek back
if ((lineMaxSubord > lineParent) && (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG)) { if (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG) {
lineMaxSubord--; lineMaxSubord--;
} }
} }
@@ -174,15 +192,15 @@ int Document::GetLastChild(int lineParent, int level) {
int Document::GetFoldParent(int line) { int Document::GetFoldParent(int line) {
int level = GetLevel(line); int level = GetLevel(line);
int lineLook = line-1; int lineLook = line - 1;
while ((lineLook > 0) && ( while ((lineLook > 0) && (
(!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) || (!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) ||
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level)) ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level))
) { ) {
lineLook--; lineLook--;
} }
if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) && if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) &&
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) { ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) {
return lineLook; return lineLook;
} else { } else {
return -1; return -1;
@@ -241,12 +259,12 @@ int Document::LenChar(int pos) {
if (ch < 0x80) if (ch < 0x80)
return 1; return 1;
int len = 2; int len = 2;
if (ch >= (0x80+0x40+0x20)) if (ch >= (0x80 + 0x40 + 0x20))
len = 3; len = 3;
int lengthDoc = Length(); int lengthDoc = Length();
if ((pos + len) > lengthDoc) if ((pos + len) > lengthDoc)
return lengthDoc-pos; return lengthDoc -pos;
else else
return len; return len;
} else if (IsDBCS(pos)) { } else if (IsDBCS(pos)) {
return 2; return 2;
@@ -292,7 +310,7 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
// ch is a trail byte // ch is a trail byte
if (moveDir > 0) if (moveDir > 0)
pos++; pos++;
else else
pos--; pos--;
ch = static_cast<unsigned char>(cb.CharAt(pos)); ch = static_cast<unsigned char>(cb.CharAt(pos));
} }
@@ -314,6 +332,7 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
//Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-"); //Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
} }
if (atLeadByte) { if (atLeadByte) {
// Position is between a lead byte and a trail byte // Position is between a lead byte and a trail byte
if (moveDir > 0) if (moveDir > 0)
@@ -338,9 +357,9 @@ void Document::ModifiedAt(int pos) {
// Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number // Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
void Document::DeleteChars(int pos, int len) { void Document::DeleteChars(int pos, int len) {
if ((pos + len) > Length()) if ((pos + len) > Length())
return; return ;
if (cb.IsReadOnly() && enteredReadOnlyCount==0) { if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
enteredReadOnlyCount++; enteredReadOnlyCount++;
NotifyModifyAttempt(); NotifyModifyAttempt();
enteredReadOnlyCount--; enteredReadOnlyCount--;
@@ -349,28 +368,31 @@ void Document::DeleteChars(int pos, int len) {
enteredCount++; enteredCount++;
if (!cb.IsReadOnly()) { if (!cb.IsReadOnly()) {
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_BEFOREDELETE | SC_PERFORMED_USER, SC_MOD_BEFOREDELETE | SC_PERFORMED_USER,
pos, len, pos, len,
0, 0)); 0, 0));
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
const char *text = cb.DeleteChars(pos*2, len * 2); const char *text = cb.DeleteChars(pos * 2, len * 2);
if (startSavePoint && cb.IsCollectingUndo()) if (startSavePoint && cb.IsCollectingUndo())
NotifySavePoint(!startSavePoint); NotifySavePoint(!startSavePoint);
ModifiedAt(pos); if ((pos < Length()) || (pos == 0))
ModifiedAt(pos);
else
ModifiedAt(pos-1);
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_DELETETEXT | SC_PERFORMED_USER, SC_MOD_DELETETEXT | SC_PERFORMED_USER,
pos, len, pos, len,
LinesTotal() - prevLinesTotal, text)); LinesTotal() - prevLinesTotal, text));
} }
enteredCount--; enteredCount--;
} }
} }
void Document::InsertStyledString(int position, char *s, int insertLength) { void Document::InsertStyledString(int position, char *s, int insertLength) {
if (cb.IsReadOnly() && enteredReadOnlyCount==0) { if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
enteredReadOnlyCount++; enteredReadOnlyCount++;
NotifyModifyAttempt(); NotifyModifyAttempt();
enteredReadOnlyCount--; enteredReadOnlyCount--;
@@ -379,10 +401,10 @@ void Document::InsertStyledString(int position, char *s, int insertLength) {
enteredCount++; enteredCount++;
if (!cb.IsReadOnly()) { if (!cb.IsReadOnly()) {
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER, SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
position / 2, insertLength / 2, position / 2, insertLength / 2,
0, 0)); 0, 0));
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
const char *text = cb.InsertString(position, s, insertLength); const char *text = cb.InsertString(position, s, insertLength);
@@ -390,10 +412,10 @@ void Document::InsertStyledString(int position, char *s, int insertLength) {
NotifySavePoint(!startSavePoint); NotifySavePoint(!startSavePoint);
ModifiedAt(position / 2); ModifiedAt(position / 2);
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_INSERTTEXT | SC_PERFORMED_USER, SC_MOD_INSERTTEXT | SC_PERFORMED_USER,
position / 2, insertLength / 2, position / 2, insertLength / 2,
LinesTotal() - prevLinesTotal, text)); LinesTotal() - prevLinesTotal, text));
} }
enteredCount--; enteredCount--;
} }
@@ -406,21 +428,21 @@ int Document::Undo() {
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
int steps = cb.StartUndo(); int steps = cb.StartUndo();
//Platform::DebugPrintf("Steps=%d\n", steps); //Platform::DebugPrintf("Steps=%d\n", steps);
for (int step=0; step<steps; step++) { for (int step = 0; step < steps; step++) {
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
const Action &action = cb.GetUndoStep(); const Action &action = cb.GetUndoStep();
if (action.at == removeAction) { if (action.at == removeAction) {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action)); SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action));
} else { } else {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action));
} }
cb.PerformUndoStep(); cb.PerformUndoStep();
int cellPosition = action.position / 2; int cellPosition = action.position / 2;
ModifiedAt(cellPosition); ModifiedAt(cellPosition);
newPos = cellPosition; newPos = cellPosition;
int modFlags = SC_PERFORMED_UNDO; int modFlags = SC_PERFORMED_UNDO;
// With undo, an insertion action becomes a deletion notification // With undo, an insertion action becomes a deletion notification
if (action.at == removeAction) { if (action.at == removeAction) {
@@ -429,12 +451,12 @@ int Document::Undo() {
} else { } else {
modFlags |= SC_MOD_DELETETEXT; modFlags |= SC_MOD_DELETETEXT;
} }
if (step == steps-1) if (step == steps - 1)
modFlags |= SC_LASTSTEPINUNDOREDO; modFlags |= SC_LASTSTEPINUNDOREDO;
NotifyModified(DocModification(modFlags, cellPosition, action.lenData, NotifyModified(DocModification(modFlags, cellPosition, action.lenData,
LinesTotal() - prevLinesTotal, action.data)); LinesTotal() - prevLinesTotal, action.data));
} }
bool endSavePoint = cb.IsSavePoint(); bool endSavePoint = cb.IsSavePoint();
if (startSavePoint != endSavePoint) if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint); NotifySavePoint(endSavePoint);
@@ -449,20 +471,20 @@ int Document::Redo() {
enteredCount++; enteredCount++;
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
int steps = cb.StartRedo(); int steps = cb.StartRedo();
for (int step=0; step<steps; step++) { for (int step = 0; step < steps; step++) {
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
const Action &action = cb.GetRedoStep(); const Action &action = cb.GetRedoStep();
if (action.at == insertAction) { if (action.at == insertAction) {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action));
} else { } else {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action));
} }
cb.PerformRedoStep(); cb.PerformRedoStep();
ModifiedAt(action.position / 2); ModifiedAt(action.position / 2);
newPos = action.position / 2; newPos = action.position / 2;
int modFlags = SC_PERFORMED_REDO; int modFlags = SC_PERFORMED_REDO;
if (action.at == insertAction) { if (action.at == insertAction) {
newPos += action.lenData; newPos += action.lenData;
@@ -470,13 +492,13 @@ int Document::Redo() {
} else { } else {
modFlags |= SC_MOD_DELETETEXT; modFlags |= SC_MOD_DELETETEXT;
} }
if (step == steps-1) if (step == steps - 1)
modFlags |= SC_LASTSTEPINUNDOREDO; modFlags |= SC_LASTSTEPINUNDOREDO;
NotifyModified( NotifyModified(
DocModification(modFlags, action.position / 2, action.lenData, DocModification(modFlags, action.position / 2, action.lenData,
LinesTotal() - prevLinesTotal, action.data)); LinesTotal() - prevLinesTotal, action.data));
} }
bool endSavePoint = cb.IsSavePoint(); bool endSavePoint = cb.IsSavePoint();
if (startSavePoint != endSavePoint) if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint); NotifySavePoint(endSavePoint);
@@ -526,7 +548,7 @@ int Document::DelCharBack(int pos) {
DeleteChars(pos - 2, 2); DeleteChars(pos - 2, 2);
return pos - 2; return pos - 2;
} else if (SC_CP_UTF8 == dbcsCodePage) { } else if (SC_CP_UTF8 == dbcsCodePage) {
int startChar = MovePositionOutsideChar(pos-1, -1, false); int startChar = MovePositionOutsideChar(pos - 1, -1, false);
DeleteChars(startChar, pos - startChar); DeleteChars(startChar, pos - startChar);
return startChar; return startChar;
} else if (IsDBCS(pos - 1)) { } else if (IsDBCS(pos - 1)) {
@@ -568,13 +590,13 @@ int Document::GetLineIndentation(int line) {
if ((line >= 0) && (line < LinesTotal())) { if ((line >= 0) && (line < LinesTotal())) {
int lineStart = LineStart(line); int lineStart = LineStart(line);
int length = Length(); int length = Length();
for (int i=lineStart;i<length;i++) { for (int i = lineStart;i < length;i++) {
char ch = cb.CharAt(i); char ch = cb.CharAt(i);
if (ch == ' ') if (ch == ' ')
indent++; indent++;
else if (ch == '\t') else if (ch == '\t')
indent = NextTab(indent, tabInChars); indent = NextTab(indent, tabInChars);
else else
return indent; return indent;
} }
} }
@@ -596,8 +618,8 @@ void Document::SetLineIndentation(int line, int indent) {
} }
int Document::GetLineIndentPosition(int line) { int Document::GetLineIndentPosition(int line) {
if (line < 0) if (line < 0)
return 0; return 0;
int pos = LineStart(line); int pos = LineStart(line);
int length = Length(); int length = Length();
while ((pos < length) && isindentchar(cb.CharAt(pos))) { while ((pos < length) && isindentchar(cb.CharAt(pos))) {
@@ -610,7 +632,7 @@ int Document::GetColumn(int pos) {
int column = 0; int column = 0;
int line = LineFromPosition(pos); int line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) { if ((line >= 0) && (line < LinesTotal())) {
for (int i=LineStart(line);i<pos;i++) { for (int i = LineStart(line);i < pos;i++) {
char ch = cb.CharAt(i); char ch = cb.CharAt(i);
if (ch == '\t') if (ch == '\t')
column = NextTab(column, tabInChars); column = NextTab(column, tabInChars);
@@ -640,7 +662,7 @@ void Document::ConvertLineEnds(int eolModeSet) {
BeginUndoAction(); BeginUndoAction();
for (int pos = 0; pos < Length(); pos++) { for (int pos = 0; pos < Length(); pos++) {
if (cb.CharAt(pos) == '\r') { if (cb.CharAt(pos) == '\r') {
if (cb.CharAt(pos+1) == '\n') { if (cb.CharAt(pos + 1) == '\n') {
if (eolModeSet != SC_EOL_CRLF) { if (eolModeSet != SC_EOL_CRLF) {
DeleteChars(pos, 2); DeleteChars(pos, 2);
if (eolModeSet == SC_EOL_CR) if (eolModeSet == SC_EOL_CR)
@@ -677,7 +699,7 @@ void Document::ConvertLineEnds(int eolModeSet) {
} }
bool Document::IsWordChar(unsigned char ch) { bool Document::IsWordChar(unsigned char ch) {
if ((SC_CP_UTF8 == dbcsCodePage) && (ch >0x80)) if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80))
return true; return true;
return wordchars[ch]; return wordchars[ch];
} }
@@ -697,19 +719,19 @@ int Document::NextWordStart(int pos, int delta) {
if (delta < 0) { if (delta < 0) {
while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t')) while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))
pos--; pos--;
if (isspace(cb.CharAt(pos - 1))) { // Back up to previous line if (isspacechar(cb.CharAt(pos - 1))) { // Back up to previous line
while (pos > 0 && isspace(cb.CharAt(pos - 1))) while (pos > 0 && isspacechar(cb.CharAt(pos - 1)))
pos--; pos--;
} else { } else {
bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1)); bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1));
while (pos > 0 && !isspace(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1)))) while (pos > 0 && !isspacechar(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1))))
pos--; pos--;
} }
} else { } else {
bool startAtWordChar = IsWordChar(cb.CharAt(pos)); bool startAtWordChar = IsWordChar(cb.CharAt(pos));
while (pos < (Length()) && isspace(cb.CharAt(pos))) while (pos < (Length()) && isspacechar(cb.CharAt(pos)))
pos++; pos++;
while (pos < (Length()) && !isspace(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos)))) while (pos < (Length()) && !isspacechar(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos))))
pos++; pos++;
while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t')) while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))
pos++; pos++;
@@ -717,6 +739,10 @@ int Document::NextWordStart(int pos, int delta) {
return pos; return pos;
} }
/**
* Check that the character before the given position
* is not a word character.
*/
bool Document::IsWordStartAt(int pos) { bool Document::IsWordStartAt(int pos) {
if (pos > 0) { if (pos > 0) {
return !IsWordChar(CharAt(pos - 1)); return !IsWordChar(CharAt(pos - 1));
@@ -724,6 +750,10 @@ bool Document::IsWordStartAt(int pos) {
return true; return true;
} }
/**
* Check that the character after the given position
* is not a word character.
*/
bool Document::IsWordEndAt(int pos) { bool Document::IsWordEndAt(int pos) {
if (pos < Length() - 1) { if (pos < Length() - 1) {
return !IsWordChar(CharAt(pos)); return !IsWordChar(CharAt(pos));
@@ -731,74 +761,233 @@ bool Document::IsWordEndAt(int pos) {
return true; return true;
} }
/**
* Check that the given range is delimited by
* non word characters.
*/
bool Document::IsWordAt(int start, int end) { bool Document::IsWordAt(int start, int end) {
return IsWordStartAt(start) && IsWordEndAt(end); return IsWordStartAt(start) && IsWordEndAt(end);
} }
// Find text in document, supporting both forward and backward // The comparison and case changing functions here assume ASCII
// searches (just pass minPos > maxPos to do a backward search) // or extended ASCII such as the normal Windows code page.
// Has not been tested with backwards DBCS searches yet.
long Document::FindText(int minPos, int maxPos, const char *s,
bool caseSensitive, bool word, bool wordStart) {
bool forward = minPos <= maxPos;
int increment = forward ? 1 : -1;
// Range endpoints should not be inside DBCS characters, but just in case, move them. static inline char MakeUpperCase(char ch) {
int startPos = MovePositionOutsideChar(minPos, increment, false); if (ch < 'a' || ch > 'z')
int endPos = MovePositionOutsideChar(maxPos, increment, false); return ch;
else
// Compute actual search ranges needed return static_cast<char>(ch - 'a' + 'A');
int lengthFind = strlen(s); }
int endSearch = endPos;
if (startPos <= endPos) { static inline char MakeLowerCase(char ch) {
endSearch = endPos - lengthFind + 1; if (ch < 'A' || ch > 'Z')
} return ch;
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind); else
char firstChar = s[0]; return static_cast<char>(ch - 'A' + 'a');
if (!caseSensitive) }
firstChar = static_cast<char>(toupper(firstChar));
int pos = startPos; // Define a way for the Regular Expression code to access the document
while (forward ? (pos < endSearch) : (pos >= endSearch)) { class DocumentIndexer : public CharacterIndexer {
char ch = CharAt(pos); Document *pdoc;
if (caseSensitive) { int end;
if (ch == firstChar) { public:
bool found = true; DocumentIndexer(Document *pdoc_, int end_) :
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) { pdoc(pdoc_), end(end_) {}
ch = CharAt(pos + posMatch);
if (ch != s[posMatch]) virtual char CharAt(int index) {
found = false; if (index < 0 || index >= end)
} return 0;
if (found) { else
if ((!word && !wordStart) || return pdoc->CharAt(index);
word && IsWordAt(pos, pos + lengthFind) || }
wordStart && IsWordStartAt(pos)) };
return pos;
} /**
} * Find text in document, supporting both forward and backward
* searches (just pass minPos > maxPos to do a backward search)
* Has not been tested with backwards DBCS searches yet.
*/
long Document::FindText(int minPos, int maxPos, const char *s,
bool caseSensitive, bool word, bool wordStart, bool regExp,
int *length) {
if (regExp) {
if (!pre)
pre = new RESearch();
if (!pre)
return -1;
int startPos;
int endPos;
if (minPos <= maxPos) {
startPos = minPos;
endPos = maxPos;
} else { } else {
if (toupper(ch) == firstChar) { startPos = maxPos;
bool found = true; endPos = minPos;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) { }
ch = CharAt(pos + posMatch);
if (toupper(ch) != toupper(s[posMatch])) // Range endpoints should not be inside DBCS characters, but just in case, move them.
found = false; startPos = MovePositionOutsideChar(startPos, 1, false);
} endPos = MovePositionOutsideChar(endPos, 1, false);
if (found) {
if (!(word && wordStart) || const char *errmsg = pre->Compile(s, *length, caseSensitive);
word && IsWordAt(pos, pos + lengthFind) || if (errmsg) {
wordStart && IsWordStartAt(pos)) return -1;
return pos; }
} // Find a variable in a property file: \$(\([A-Za-z0-9_.]+\))
// Replace first '.' with '-' in each property file variable reference:
// Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\))
// Replace: $(\1-\2)
int lineRangeStart = LineFromPosition(startPos);
int lineRangeEnd = LineFromPosition(endPos);
if ((startPos >= LineEnd(lineRangeStart)) && (lineRangeStart < lineRangeEnd)) {
// the start position is at end of line or between line end characters.
lineRangeStart++;
startPos = LineStart(lineRangeStart);
}
int pos = -1;
int lenRet = 0;
char searchEnd = s[*length - 1];
if (*length == 1) {
// These produce empty selections so nudge them on if needed
if (s[0] == '^') {
if (startPos == LineStart(lineRangeStart))
startPos++;
} else if (s[0] == '$') {
if ((startPos == LineEnd(lineRangeStart)) && (lineRangeStart < lineRangeEnd))
startPos = LineStart(lineRangeStart + 1);
}
lineRangeStart = LineFromPosition(startPos);
lineRangeEnd = LineFromPosition(endPos);
}
for (int line = lineRangeStart; line <= lineRangeEnd; line++) {
int startOfLine = LineStart(line);
int endOfLine = LineEnd(line);
if (line == lineRangeStart) {
if ((startPos != startOfLine) && (s[0] == '^'))
continue; // Can't match start of line if start position after start of line
startOfLine = startPos;
}
if (line == lineRangeEnd) {
if ((endPos != endOfLine) && (searchEnd == '$'))
continue; // Can't match end of line if end position before end of line
endOfLine = endPos;
}
DocumentIndexer di(this, endOfLine);
int success = pre->Execute(di, startOfLine, endOfLine);
if (success) {
pos = pre->bopat[0];
lenRet = pre->eopat[0] - pre->bopat[0];
break;
} }
} }
pos += increment; *length = lenRet;
if (dbcsCodePage) { return pos;
// Ensure trying to match from start of character
pos = MovePositionOutsideChar(pos, increment, false); } else {
bool forward = minPos <= maxPos;
int increment = forward ? 1 : -1;
// Range endpoints should not be inside DBCS characters, but just in case, move them.
int startPos = MovePositionOutsideChar(minPos, increment, false);
int endPos = MovePositionOutsideChar(maxPos, increment, false);
// Compute actual search ranges needed
int lengthFind = *length;
if (lengthFind == -1)
lengthFind = strlen(s);
int endSearch = endPos;
if (startPos <= endPos) {
endSearch = endPos - lengthFind + 1;
}
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind);
char firstChar = s[0];
if (!caseSensitive)
firstChar = static_cast<char>(MakeUpperCase(firstChar));
int pos = startPos;
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
char ch = CharAt(pos);
if (caseSensitive) {
if (ch == firstChar) {
bool found = true;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
ch = CharAt(pos + posMatch);
if (ch != s[posMatch])
found = false;
}
if (found) {
if ((!word && !wordStart) ||
word && IsWordAt(pos, pos + lengthFind) ||
wordStart && IsWordStartAt(pos))
return pos;
}
}
} else {
if (MakeUpperCase(ch) == firstChar) {
bool found = true;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
ch = CharAt(pos + posMatch);
if (MakeUpperCase(ch) != MakeUpperCase(s[posMatch]))
found = false;
}
if (found) {
if ((!word && !wordStart) ||
word && IsWordAt(pos, pos + lengthFind) ||
wordStart && IsWordStartAt(pos))
return pos;
}
}
}
pos += increment;
if (dbcsCodePage) {
// Ensure trying to match from start of character
pos = MovePositionOutsideChar(pos, increment, false);
}
} }
} }
//Platform::DebugPrintf("Not found\n"); //Platform::DebugPrintf("Not found\n");
return - 1; return -1;
}
const char *Document::SubstituteByPosition(const char *text, int *length) {
if (!pre)
return 0;
delete []substituted;
substituted = 0;
DocumentIndexer di(this, Length());
if (!pre->GrabMatches(di))
return 0;
unsigned int lenResult = 0;
for (int i = 0; i < *length; i++) {
if ((text[i] == '\\') && (text[i + 1] >= '1' && text[i + 1] <= '9')) {
unsigned int patNum = text[i + 1] - '0';
lenResult += pre->eopat[patNum] - pre->bopat[patNum];
i++;
} else {
lenResult++;
}
}
substituted = new char[lenResult + 1];
if (!substituted)
return 0;
char *o = substituted;
for (int j = 0; j < *length; j++) {
if ((text[j] == '\\') && (text[j + 1] >= '1' && text[j + 1] <= '9')) {
unsigned int patNum = text[j + 1] - '0';
unsigned int len = pre->eopat[patNum] - pre->bopat[patNum];
if (pre->pat[patNum]) // Will be null if try for a match that did not occur
memcpy(o, pre->pat[patNum], len);
o += len;
j++;
} else {
*o++ = text[j];
}
}
*o = '\0';
*length = lenResult;
return substituted;
} }
int Document::LinesTotal() { int Document::LinesTotal() {
@@ -806,18 +995,18 @@ int Document::LinesTotal() {
} }
void Document::ChangeCase(Range r, bool makeUpperCase) { void Document::ChangeCase(Range r, bool makeUpperCase) {
for (int pos=r.start; pos<r.end; pos++) { for (int pos = r.start; pos < r.end; pos++) {
char ch = CharAt(pos); char ch = CharAt(pos);
if (dbcsCodePage && IsDBCS(pos)) { if (dbcsCodePage && IsDBCS(pos)) {
pos += LenChar(pos); pos += LenChar(pos);
} else { } else {
if (makeUpperCase) { if (makeUpperCase) {
if (islower(ch)) { if (islower(ch)) {
ChangeChar(pos, static_cast<char>(toupper(ch))); ChangeChar(pos, static_cast<char>(MakeUpperCase(ch)));
} }
} else { } else {
if (isupper(ch)) { if (isupper(ch)) {
ChangeChar(pos, static_cast<char>(tolower(ch))); ChangeChar(pos, static_cast<char>(MakeLowerCase(ch)));
} }
} }
} }
@@ -844,28 +1033,27 @@ void Document::SetWordChars(unsigned char *chars) {
void Document::SetStylingBits(int bits) { void Document::SetStylingBits(int bits) {
stylingBits = bits; stylingBits = bits;
stylingBitsMask = 0; stylingBitsMask = 0;
for (int bit=0; bit<stylingBits; bit++) { for (int bit = 0; bit < stylingBits; bit++) {
stylingBitsMask <<= 1; stylingBitsMask <<= 1;
stylingBitsMask |= 1; stylingBitsMask |= 1;
} }
} }
void Document::StartStyling(int position, char mask) { void Document::StartStyling(int position, char mask) {
stylingPos = position;
stylingMask = mask; stylingMask = mask;
endStyled = position;
} }
void Document::SetStyleFor(int length, char style) { void Document::SetStyleFor(int length, char style) {
if (enteredCount == 0) { if (enteredCount == 0) {
enteredCount++; enteredCount++;
int prevEndStyled = endStyled; int prevEndStyled = endStyled;
if (cb.SetStyleFor(stylingPos, length, style, stylingMask)) { if (cb.SetStyleFor(endStyled, length, style, stylingMask)) {
DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
prevEndStyled, length); prevEndStyled, length);
NotifyModified(mh); NotifyModified(mh);
} }
stylingPos += length; endStyled += length;
endStyled = stylingPos;
enteredCount--; enteredCount--;
} }
} }
@@ -875,15 +1063,14 @@ void Document::SetStyles(int length, char *styles) {
enteredCount++; enteredCount++;
int prevEndStyled = endStyled; int prevEndStyled = endStyled;
bool didChange = false; bool didChange = false;
for (int iPos = 0; iPos < length; iPos++, stylingPos++) { for (int iPos = 0; iPos < length; iPos++, endStyled++) {
if (cb.SetStyleAt(stylingPos, styles[iPos], stylingMask)) { if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
didChange = true; didChange = true;
} }
} }
endStyled = stylingPos;
if (didChange) { if (didChange) {
DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
prevEndStyled, endStyled - prevEndStyled); prevEndStyled, endStyled - prevEndStyled);
NotifyModified(mh); NotifyModified(mh);
} }
enteredCount--; enteredCount--;
@@ -958,3 +1145,85 @@ void Document::NotifyModified(DocModification mh) {
watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData); watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData);
} }
} }
bool Document::IsWordPartSeparator(char ch) {
return ispunct(ch) && IsWordChar(ch);
}
int Document::WordPartLeft(int pos) {
if (pos > 0) {
--pos;
char startChar = cb.CharAt(pos);
if (IsWordPartSeparator(startChar)) {
while (pos > 0 && IsWordPartSeparator(cb.CharAt(pos))) {
--pos;
}
}
if (pos > 0) {
startChar = cb.CharAt(pos);
--pos;
if (islower(startChar)) {
while (pos > 0 && islower(cb.CharAt(pos)))
--pos;
if (!isupper(cb.CharAt(pos)) && !islower(cb.CharAt(pos)))
++pos;
} else if (isupper(startChar)) {
while (pos > 0 && isupper(cb.CharAt(pos)))
--pos;
if (!isupper(cb.CharAt(pos)))
++pos;
} else if (isdigit(startChar)) {
while (pos > 0 && isdigit(cb.CharAt(pos)))
--pos;
if (!isdigit(cb.CharAt(pos)))
++pos;
} else if (ispunct(startChar)) {
while (pos > 0 && ispunct(cb.CharAt(pos)))
--pos;
if (!ispunct(cb.CharAt(pos)))
++pos;
} else if (isspacechar(startChar)) {
while (pos > 0 && isspacechar(cb.CharAt(pos)))
--pos;
if (!isspacechar(cb.CharAt(pos)))
++pos;
}
}
}
return pos;
}
int Document::WordPartRight(int pos) {
char startChar = cb.CharAt(pos);
int length = Length();
if (IsWordPartSeparator(startChar)) {
while (pos < length && IsWordPartSeparator(cb.CharAt(pos)))
++pos;
startChar = cb.CharAt(pos);
}
if (islower(startChar)) {
while (pos < length && islower(cb.CharAt(pos)))
++pos;
} else if (isupper(startChar)) {
if (islower(cb.CharAt(pos + 1))) {
++pos;
while (pos < length && islower(cb.CharAt(pos)))
++pos;
} else {
while (pos < length && isupper(cb.CharAt(pos)))
++pos;
}
if (islower(cb.CharAt(pos)) && isupper(cb.CharAt(pos - 1)))
--pos;
} else if (isdigit(startChar)) {
while (pos < length && isdigit(cb.CharAt(pos)))
++pos;
} else if (ispunct(startChar)) {
while (pos < length && ispunct(cb.CharAt(pos)))
++pos;
} else if (isspacechar(startChar)) {
while (pos < length && isspacechar(cb.CharAt(pos)))
++pos;
}
return pos;
}

View File

@@ -1,36 +1,42 @@
// Scintilla source code edit control // Scintilla source code edit control
// Document.h - text document that handles notifications, DBCS, styling, words and end of line /** @file Document.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Text document that handles notifications, DBCS, styling, words and end of line.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef DOCUMENT_H #ifndef DOCUMENT_H
#define DOCUMENT_H #define DOCUMENT_H
// A Position is a position within a document between two characters or at the beginning or end. /**
// Sometimes used as a character index where it identifies the character after the position. * A Position is a position within a document between two characters or at the beginning or end.
* Sometimes used as a character index where it identifies the character after the position.
*/
typedef int Position; typedef int Position;
const Position invalidPosition = -1; const Position invalidPosition = -1;
// The range class represents a range of text in a document. /**
// The two values are not sorted as one end may be more significant than the other * The range class represents a range of text in a document.
// as is the case for the selection where the end position is the position of the caret. * The two values are not sorted as one end may be more significant than the other
// If either position is invalidPosition then the range is invalid and most operations will fail. * as is the case for the selection where the end position is the position of the caret.
* If either position is invalidPosition then the range is invalid and most operations will fail.
*/
class Range { class Range {
public: public:
Position start; Position start;
Position end; Position end;
Range(Position pos=0) : Range(Position pos=0) :
start(pos), end(pos) { start(pos), end(pos) {
}; };
Range(Position start_, Position end_) : Range(Position start_, Position end_) :
start(start_), end(end_) { start(start_), end(end_) {
}; };
bool Valid() const { bool Valid() const {
return (start != invalidPosition) && (end != invalidPosition); return (start != invalidPosition) && (end != invalidPosition);
} }
bool Contains(Position pos) const { bool Contains(Position pos) const {
if (start < end) { if (start < end) {
return (pos >= start && pos <= end); return (pos >= start && pos <= end);
@@ -38,11 +44,11 @@ public:
return (pos <= start && pos >= end); return (pos <= start && pos >= end);
} }
} }
bool Contains(Range other) const { bool Contains(Range other) const {
return Contains(other.start) && Contains(other.end); return Contains(other.start) && Contains(other.end);
} }
bool Overlaps(Range other) const { bool Overlaps(Range other) const {
return return
Contains(other.start) || Contains(other.start) ||
@@ -54,11 +60,14 @@ public:
class DocWatcher; class DocWatcher;
class DocModification; class DocModification;
class RESearch;
/**
*/
class Document { class Document {
public: public:
// Used to pair watcher pointer with user data /** Used to pair watcher pointer with user data. */
class WatcherWithUserData { class WatcherWithUserData {
public: public:
DocWatcher *watcher; DocWatcher *watcher;
@@ -68,37 +77,42 @@ public:
userData = 0; userData = 0;
} }
}; };
private: private:
int refCount; int refCount;
CellBuffer cb; CellBuffer cb;
bool wordchars[256]; bool wordchars[256];
int stylingPos;
char stylingMask; char stylingMask;
int endStyled; int endStyled;
int enteredCount; int enteredCount;
int enteredReadOnlyCount; int enteredReadOnlyCount;
WatcherWithUserData *watchers; WatcherWithUserData *watchers;
int lenWatchers; int lenWatchers;
bool matchesValid;
RESearch *pre;
char *substituted;
public: public:
int stylingBits; int stylingBits;
int stylingBitsMask; int stylingBitsMask;
int eolMode; int eolMode;
// dbcsCodePage can also be SC_CP_UTF8 to enable UTF-8 mode /// Can also be SC_CP_UTF8 to enable UTF-8 mode
int dbcsCodePage; int dbcsCodePage;
int tabInChars; int tabInChars;
int indentInChars; int indentInChars;
bool useTabs; bool useTabs;
bool tabIndents;
bool backspaceUnindents;
Document(); Document();
virtual ~Document(); virtual ~Document();
int AddRef(); int AddRef();
int Release(); int Release();
int LineFromPosition(int pos); int LineFromPosition(int pos);
int ClampPositionIntoDocument(int pos); int ClampPositionIntoDocument(int pos);
bool IsCrLf(int pos); bool IsCrLf(int pos);
@@ -165,12 +179,13 @@ public:
int NextWordStart(int pos, int delta); int NextWordStart(int pos, int delta);
int Length() { return cb.Length(); } int Length() { return cb.Length(); }
long FindText(int minPos, int maxPos, const char *s, long FindText(int minPos, int maxPos, const char *s,
bool caseSensitive, bool word, bool wordStart); bool caseSensitive, bool word, bool wordStart, bool regExp, int *length);
long FindText(int iMessage, unsigned long wParam, long lParam); long FindText(int iMessage, unsigned long wParam, long lParam);
const char *SubstituteByPosition(const char *text, int *length);
int LinesTotal(); int LinesTotal();
void ChangeCase(Range r, bool makeUpperCase); void ChangeCase(Range r, bool makeUpperCase);
void SetWordChars(unsigned char *chars); void SetWordChars(unsigned char *chars);
void SetStylingBits(int bits); void SetStylingBits(int bits);
void StartStyling(int position, char mask); void StartStyling(int position, char mask);
@@ -182,12 +197,16 @@ public:
int SetLineState(int line, int state) { return cb.SetLineState(line, state); } int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); } int GetLineState(int line) { return cb.GetLineState(line); }
int GetMaxLineState() { return cb.GetMaxLineState(); } int GetMaxLineState() { return cb.GetMaxLineState(); }
bool AddWatcher(DocWatcher *watcher, void *userData); bool AddWatcher(DocWatcher *watcher, void *userData);
bool RemoveWatcher(DocWatcher *watcher, void *userData); bool RemoveWatcher(DocWatcher *watcher, void *userData);
const WatcherWithUserData *GetWatchers() const { return watchers; } const WatcherWithUserData *GetWatchers() const { return watchers; }
int GetLenWatchers() const { return lenWatchers; } int GetLenWatchers() const { return lenWatchers; }
bool IsWordPartSeparator(char ch);
int WordPartLeft(int pos);
int WordPartRight(int pos);
private: private:
bool IsDBCS(int pos); bool IsDBCS(int pos);
bool IsWordChar(unsigned char ch); bool IsWordChar(unsigned char ch);
@@ -195,24 +214,26 @@ private:
bool IsWordEndAt(int pos); bool IsWordEndAt(int pos);
bool IsWordAt(int start, int end); bool IsWordAt(int start, int end);
void ModifiedAt(int pos); void ModifiedAt(int pos);
void NotifyModifyAttempt(); void NotifyModifyAttempt();
void NotifySavePoint(bool atSavePoint); void NotifySavePoint(bool atSavePoint);
void NotifyModified(DocModification mh); void NotifyModified(DocModification mh);
int IndentSize() { return indentInChars ? indentInChars : tabInChars; } int IndentSize() { return indentInChars ? indentInChars : tabInChars; }
}; };
// To optimise processing of document modifications by DocWatchers, a hint is passed indicating the /**
// scope of the change. * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the
// If the DocWatcher is a document view then this can be used to optimise screen updating. * scope of the change.
* If the DocWatcher is a document view then this can be used to optimise screen updating.
*/
class DocModification { class DocModification {
public: public:
int modificationType; int modificationType;
int position; int position;
int length; int length;
int linesAdded; // Negative if lines deleted int linesAdded; /**< Negative if lines deleted. */
const char *text; // Only valid for changes to text, not for changes to style const char *text; /**< Only valid for changes to text, not for changes to style. */
int line; int line;
int foldLevelNow; int foldLevelNow;
int foldLevelPrev; int foldLevelPrev;
@@ -239,12 +260,14 @@ public:
foldLevelPrev(0) {} foldLevelPrev(0) {}
}; };
// A class that wants to receive notifications from a Document must be derived from DocWatcher /**
// and implement the notification methods. It can then be added to the watcher list with AddWatcher. * A class that wants to receive notifications from a Document must be derived from DocWatcher
* and implement the notification methods. It can then be added to the watcher list with AddWatcher.
*/
class DocWatcher { class DocWatcher {
public: public:
virtual ~DocWatcher() {} virtual ~DocWatcher() {}
virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0; virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0;
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0; virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0; virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;

View File

@@ -1,11 +1,13 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// Accessor.cxx - rapid easy access to contents of a Scintilla /** @file DocumentAccessor.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include "Platform.h" #include "Platform.h"
@@ -21,12 +23,12 @@
DocumentAccessor::~DocumentAccessor() { DocumentAccessor::~DocumentAccessor() {
} }
#if PLAT_WIN #if PLAT_WIN
bool DocumentAccessor::InternalIsLeadByte(char ch) { bool DocumentAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage) if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the // For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte. // same so none is considered a lead byte.
return false; return false;
else else
return IsDBCSLeadByteEx(codePage, ch); return IsDBCSLeadByteEx(codePage, ch);
} }
@@ -36,7 +38,7 @@ bool DocumentAccessor::InternalIsLeadByte(char ch) {
bool DocumentAccessor::InternalIsLeadByte(char) { bool DocumentAccessor::InternalIsLeadByte(char) {
return false; return false;
} }
#endif #endif
void DocumentAccessor::Fill(int position) { void DocumentAccessor::Fill(int position) {
if (lenDoc == -1) if (lenDoc == -1)
@@ -70,10 +72,10 @@ int DocumentAccessor::LevelAt(int line) {
return pdoc->GetLevel(line); return pdoc->GetLevel(line);
} }
int DocumentAccessor::Length() { int DocumentAccessor::Length() {
if (lenDoc == -1) if (lenDoc == -1)
lenDoc = pdoc->Length(); lenDoc = pdoc->Length();
return lenDoc; return lenDoc;
} }
int DocumentAccessor::GetLineState(int line) { int DocumentAccessor::GetLineState(int line) {
@@ -132,12 +134,12 @@ void DocumentAccessor::Flush() {
int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) { int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
int end = Length(); int end = Length();
int spaceFlags = 0; int spaceFlags = 0;
// Determines the indentation level of the current line and also checks for consistent // Determines the indentation level of the current line and also checks for consistent
// indentation compared to the previous line. // indentation compared to the previous line.
// Indentation is judged consistent when the indentation whitespace of each line lines // Indentation is judged consistent when the indentation whitespace of each line lines
// the same or the indentation of one line is a prefix of the other. // the same or the indentation of one line is a prefix of the other.
int pos = LineStart(line); int pos = LineStart(line);
char ch = (*this)[pos]; char ch = (*this)[pos];
int indent = 0; int indent = 0;
@@ -164,11 +166,12 @@ int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnI
} }
ch = (*this)[++pos]; ch = (*this)[++pos];
} }
*flags = spaceFlags; *flags = spaceFlags;
indent += SC_FOLDLEVELBASE; indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment... // if completely empty line or the start of a comment...
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) ) if ((ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') ||
(pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
return indent | SC_FOLDLEVELWHITEFLAG; return indent | SC_FOLDLEVELWHITEFLAG;
else else
return indent; return indent;

View File

@@ -1,16 +1,24 @@
// DocumentAccessor.h - implementation of BufferAccess and StylingAccess on a Scintilla rapid easy access to contents of a Scintilla // Scintilla source code edit control
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> /** @file DocumentAccessor.h
** Implementation of BufferAccess and StylingAccess on a Scintilla
** rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
class Document; class Document;
/**
*/
class DocumentAccessor : public Accessor { class DocumentAccessor : public Accessor {
// Private so DocumentAccessor objects can not be copied // Private so DocumentAccessor objects can not be copied
DocumentAccessor(const DocumentAccessor &source) : Accessor(), props(source.props) {} DocumentAccessor(const DocumentAccessor &source) : Accessor(), props(source.props) {}
DocumentAccessor &operator=(const DocumentAccessor &) { return *this; } DocumentAccessor &operator=(const DocumentAccessor &) { return *this; }
protected: protected:
Document *pdoc; Document *pdoc;
PropSet &props; PropSet &props;
WindowID id;
int lenDoc; int lenDoc;
char styleBuf[bufferSize]; char styleBuf[bufferSize];
@@ -21,9 +29,10 @@ protected:
bool InternalIsLeadByte(char ch); bool InternalIsLeadByte(char ch);
void Fill(int position); void Fill(int position);
public: public:
DocumentAccessor(Document *pdoc_, PropSet &props_) : DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), Accessor(), pdoc(pdoc_), props(props_), id(id_),
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) { lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
} }
~DocumentAccessor(); ~DocumentAccessor();
@@ -38,6 +47,10 @@ public:
int GetPropertyInt(const char *key, int defaultValue=0) { int GetPropertyInt(const char *key, int defaultValue=0) {
return props.GetInt(key, defaultValue); return props.GetInt(key, defaultValue);
} }
char *GetProperties() {
return props.ToString();
}
WindowID GetWindow() { return id; }
void StartAt(unsigned int start, char chMask=31); void StartAt(unsigned int start, char chMask=31);
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,15 @@
// Scintilla source code edit control // Scintilla source code edit control
// Editor.h - defines the main editor class /** @file Editor.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the main editor class.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef EDITOR_H #ifndef EDITOR_H
#define EDITOR_H #define EDITOR_H
/**
*/
class Caret { class Caret {
public: public:
bool active; bool active;
@@ -15,8 +19,9 @@ public:
Caret(); Caret();
}; };
/**
*/
class Timer { class Timer {
public: public:
bool ticking; bool ticking;
int ticksToWait; int ticksToWait;
@@ -26,15 +31,18 @@ public:
Timer(); Timer();
}; };
/**
*/
class LineLayout { class LineLayout {
public: public:
// Drawing is only performed for maxLineLength characters on each line. /// Drawing is only performed for @a maxLineLength characters on each line.
enum {maxLineLength = 4000}; enum {maxLineLength = 4000};
int numCharsInLine; int numCharsInLine;
int xHighlightGuide; int xHighlightGuide;
bool highlightColumn; bool highlightColumn;
int selStart; int selStart;
int selEnd; int selEnd;
bool containsCaret;
int edgeColumn; int edgeColumn;
char chars[maxLineLength+1]; char chars[maxLineLength+1];
char styles[maxLineLength+1]; char styles[maxLineLength+1];
@@ -42,35 +50,40 @@ public:
int positions[maxLineLength+1]; int positions[maxLineLength+1];
}; };
/**
*/
class Editor : public DocWatcher { class Editor : public DocWatcher {
// Private so Editor objects can not be copied // Private so Editor objects can not be copied
Editor(const Editor &) : DocWatcher() {} Editor(const Editor &) : DocWatcher() {}
Editor &operator=(const Editor &) { return *this; } Editor &operator=(const Editor &) { return *this; }
protected: // ScintillaBase subclass needs access to much of Editor protected: // ScintillaBase subclass needs access to much of Editor
// On GTK+, Scintilla is a container widget holding two scroll bars and a drawing area /** On GTK+, Scintilla is a container widget holding two scroll bars
// whereas on Windows there is just one window with both scroll bars turned on. * whereas on Windows there is just one window with both scroll bars turned on. */
// Therefore, on GTK+ the following are separate windows but only one window on Windows. Window wMain; ///< The Scintilla parent window
Window wMain; // The Scintilla parent window
Window wDraw; // The text drawing area
// Style resources may be expensive to allocate so are cached between uses. /** Style resources may be expensive to allocate so are cached between uses.
// When a style attribute is changed, this cache is flushed. * When a style attribute is changed, this cache is flushed. */
bool stylesValid; bool stylesValid;
ViewStyle vs; ViewStyle vs;
Palette palette; Palette palette;
int printMagnification; int printMagnification;
int printColourMode; int printColourMode;
int cursorMode;
bool hasFocus;
bool hideSelection; bool hideSelection;
bool inOverstrike; bool inOverstrike;
int errorStatus;
// In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to bool mouseDownCaptures;
// the screen. This avoids flashing but is about 30% slower.
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
* the screen. This avoids flashing but is about 30% slower. */
bool bufferedDraw; bool bufferedDraw;
int xOffset; // Horizontal scrolled amount in pixels int xOffset; ///< Horizontal scrolled amount in pixels
int xCaretMargin; // Ensure this many pixels visible on both sides of caret int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
bool horizontalScrollBarVisible; bool horizontalScrollBarVisible;
Surface pixmapLine; Surface pixmapLine;
@@ -80,15 +93,20 @@ protected: // ScintillaBase subclass needs access to much of Editor
Surface pixmapIndentGuideHighlight; Surface pixmapIndentGuideHighlight;
// Intellimouse support - currently only implemented for Windows // Intellimouse support - currently only implemented for Windows
unsigned int ucWheelScrollLines; unsigned int ucWheelScrollLines;
int cWheelDelta; //wheel delta from roll int cWheelDelta; ///< Wheel delta from roll
KeyMap kmap; KeyMap kmap;
Caret caret; Caret caret;
Timer timer; Timer timer;
Timer autoScrollTimer;
enum { autoScrollDelay = 200 };
Point lastClick; Point lastClick;
unsigned int lastClickTime; unsigned int lastClickTime;
int dwellDelay;
int ticksToDwell;
bool dwelling;
enum { selChar, selWord, selLine } selectionType; enum { selChar, selWord, selLine } selectionType;
Point ptMouseLast; Point ptMouseLast;
bool firstExpose; bool firstExpose;
@@ -101,6 +119,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
int originalAnchorPos; int originalAnchorPos;
int currentPos; int currentPos;
int anchor; int anchor;
int targetStart;
int targetEnd;
int searchFlags;
int topLine; int topLine;
int posTopLine; int posTopLine;
@@ -128,6 +149,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
int caretPolicy; int caretPolicy;
int caretSlop; int caretSlop;
int visiblePolicy;
int visibleSlop;
int searchAnchor; int searchAnchor;
int displayPopupMenu; int displayPopupMenu;
@@ -152,15 +176,16 @@ protected: // ScintillaBase subclass needs access to much of Editor
void RefreshStyleData(); void RefreshStyleData();
void DropGraphics(); void DropGraphics();
PRectangle GetClientRectangle(); virtual PRectangle GetClientRectangle();
PRectangle GetTextRectangle(); PRectangle GetTextRectangle();
int LinesOnScreen(); int LinesOnScreen();
int LinesToScroll(); int LinesToScroll();
int MaxScrollPos(); int MaxScrollPos();
Point LocationFromPosition(unsigned int pos); Point LocationFromPosition(int pos);
int XFromPosition(unsigned int pos); int XFromPosition(int pos);
int PositionFromLocation(Point pt); int PositionFromLocation(Point pt);
int PositionFromLocationClose(Point pt);
int PositionFromLineX(int line, int x); int PositionFromLineX(int line, int x);
int LineFromLocation(Point pt); int LineFromLocation(Point pt);
void SetTopLine(int topLineNew); void SetTopLine(int topLineNew);
@@ -187,11 +212,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void ScrollText(int linesToMove); virtual void ScrollText(int linesToMove);
void HorizontalScrollTo(int xPos); void HorizontalScrollTo(int xPos);
void MoveCaretInsideView(); void MoveCaretInsideView();
void EnsureCaretVisible(bool useMargin=true); void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
void ShowCaretAtCurrentPosition(); void ShowCaretAtCurrentPosition();
void DropCaret(); void DropCaret();
void InvalidateCaret(); void InvalidateCaret();
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
void PaintSelMargin(Surface *surface, PRectangle &rc); void PaintSelMargin(Surface *surface, PRectangle &rc);
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll); void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll);
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
@@ -214,6 +240,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void Cut(); void Cut();
void PasteRectangular(int pos, const char *ptr, int len); void PasteRectangular(int pos, const char *ptr, int len);
virtual void Copy() = 0; virtual void Copy() = 0;
virtual bool CanPaste();
virtual void Paste() = 0; virtual void Paste() = 0;
void Clear(); void Clear();
void SelectAll(); void SelectAll();
@@ -227,14 +254,16 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void NotifyFocus(bool focus); virtual void NotifyFocus(bool focus);
virtual void NotifyParent(SCNotification scn) = 0; virtual void NotifyParent(SCNotification scn) = 0;
virtual void NotifyStyleToNeeded(int endStyleNeeded); virtual void NotifyStyleToNeeded(int endStyleNeeded);
void NotifyChar(char ch); void NotifyChar(int ch);
void NotifyMove(int position); void NotifyMove(int position);
void NotifySavePoint(bool isSavePoint); void NotifySavePoint(bool isSavePoint);
void NotifyModifyAttempt(); void NotifyModifyAttempt();
virtual void NotifyDoubleClick(Point pt, bool shift); virtual void NotifyDoubleClick(Point pt, bool shift);
void NotifyUpdateUI(); void NotifyUpdateUI();
void NotifyPainted();
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
void NotifyNeedShown(int pos, int len); void NotifyNeedShown(int pos, int len);
void NotifyDwelling(Point pt, bool state);
void NotifyModifyAttempt(Document *document, void *userData); void NotifyModifyAttempt(Document *document, void *userData);
void NotifySavePoint(Document *document, void *userData, bool atSavePoint); void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
@@ -253,7 +282,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void CancelModes(); virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage); virtual int KeyCommand(unsigned int iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/); virtual int KeyDefault(int /* key */, int /*modifiers*/);
int KeyDown(int key, bool shift, bool ctrl, bool alt); int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0);
int GetWhitespaceVisible(); int GetWhitespaceVisible();
void SetWhitespaceVisible(int view); void SetWhitespaceVisible(int view);
@@ -263,6 +292,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
long FindText(unsigned int iMessage, unsigned long wParam, long lParam); long FindText(unsigned int iMessage, unsigned long wParam, long lParam);
void SearchAnchor(); void SearchAnchor();
long SearchText(unsigned int iMessage, unsigned long wParam, long lParam); long SearchText(unsigned int iMessage, unsigned long wParam, long lParam);
long SearchInTarget(const char *text, int length);
void GoToLine(int lineNo); void GoToLine(int lineNo);
char *CopyRange(int start, int end); char *CopyRange(int start, int end);
@@ -270,13 +300,16 @@ protected: // ScintillaBase subclass needs access to much of Editor
char *CopySelectionRange(); char *CopySelectionRange();
void CopySelectionIntoDrag(); void CopySelectionIntoDrag();
void SetDragPosition(int newPos); void SetDragPosition(int newPos);
void DisplayCursor(Window::Cursor c);
virtual void StartDrag(); virtual void StartDrag();
void DropAt(int position, const char *value, bool moving, bool rectangular); void DropAt(int position, const char *value, bool moving, bool rectangular);
// PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after. /** PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
// Before means either before any line of selection or before selection on its line, with a similar meaning to after * Before means either before any line of selection or before selection on its line, with a similar meaning to after. */
int PositionInSelection(int pos); int PositionInSelection(int pos);
bool PointInSelection(Point pt); bool PointInSelection(Point pt);
bool PointInSelMargin(Point pt); bool PointInSelMargin(Point pt);
void LineSelection(int lineCurrent_, int lineAnchor_);
void DwellEnd(bool mouseMoved);
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
void ButtonMove(Point pt); void ButtonMove(Point pt);
void ButtonUp(Point pt, unsigned int curTime, bool ctrl); void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
@@ -285,6 +318,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void SetTicking(bool on) = 0; virtual void SetTicking(bool on) = 0;
virtual void SetMouseCapture(bool on) = 0; virtual void SetMouseCapture(bool on) = 0;
virtual bool HaveMouseCapture() = 0; virtual bool HaveMouseCapture() = 0;
void SetFocusState(bool focusState);
void CheckForChangeOutsidePaint(Range r); void CheckForChangeOutsidePaint(Range r);
int BraceMatch(int position, int maxReStyle); int BraceMatch(int position, int maxReStyle);
@@ -294,13 +328,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
void Expand(int &line, bool doExpand); void Expand(int &line, bool doExpand);
void ToggleContraction(int line); void ToggleContraction(int line);
void EnsureLineVisible(int line); void EnsureLineVisible(int lineDoc, bool enforcePolicy);
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
virtual long DefWndProc(unsigned int iMessage, unsigned long wParam, long lParam) = 0; virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
public: public:
// Public so scintilla_send_message can use it // Public so scintilla_send_message can use it
virtual long WndProc(unsigned int iMessage, unsigned long wParam, long lParam); virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
// Public so scintilla_set_id can use it // Public so scintilla_set_id can use it
int ctrlID; int ctrlID;
}; };

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// Indicator.cxx - defines the style of indicators which are text decorations such as underlining /** @file Indicator.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the style of indicators which are text decorations such as underlining.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include "Platform.h" #include "Platform.h"

View File

@@ -1,11 +1,15 @@
// Scintilla source code edit control // Scintilla source code edit control
// Indicator.h - defines the style of indicators which are text decorations such as underlining /** @file Indicator.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the style of indicators which are text decorations such as underlining.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef INDICATOR_H #ifndef INDICATOR_H
#define INDICATOR_H #define INDICATOR_H
/**
*/
class Indicator { class Indicator {
public: public:
int style; int style;

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// KeyMap.cxx - defines a mapping between keystrokes and commands /** @file KeyMap.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines a mapping between keystrokes and commands.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include "Platform.h" #include "Platform.h"
@@ -71,10 +73,14 @@ KeyToCommand KeyMap::MapDefault[] = {
{SCK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND}, {SCK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND},
{SCK_LEFT, SCI_CTRL, SCI_WORDLEFT}, {SCK_LEFT, SCI_CTRL, SCI_WORDLEFT},
{SCK_LEFT, SCI_CSHIFT, SCI_WORDLEFTEXTEND}, {SCK_LEFT, SCI_CSHIFT, SCI_WORDLEFTEXTEND},
{SCK_LEFT, SCI_ALT, SCI_WORDPARTLEFT},
{SCK_LEFT, SCI_ASHIFT, SCI_WORDPARTLEFTEXTEND},
{SCK_RIGHT, SCI_NORM, SCI_CHARRIGHT}, {SCK_RIGHT, SCI_NORM, SCI_CHARRIGHT},
{SCK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND}, {SCK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND},
{SCK_RIGHT, SCI_CTRL, SCI_WORDRIGHT}, {SCK_RIGHT, SCI_CTRL, SCI_WORDRIGHT},
{SCK_RIGHT, SCI_CSHIFT, SCI_WORDRIGHTEXTEND}, {SCK_RIGHT, SCI_CSHIFT, SCI_WORDRIGHTEXTEND},
{SCK_RIGHT, SCI_ALT, SCI_WORDPARTRIGHT},
{SCK_RIGHT, SCI_ASHIFT, SCI_WORDPARTRIGHTEXTEND},
{SCK_HOME, SCI_NORM, SCI_VCHOME}, {SCK_HOME, SCI_NORM, SCI_VCHOME},
{SCK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND}, {SCK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND},
{SCK_HOME, SCI_CTRL, SCI_DOCUMENTSTART}, {SCK_HOME, SCI_CTRL, SCI_DOCUMENTSTART},
@@ -90,6 +96,7 @@ KeyToCommand KeyMap::MapDefault[] = {
{SCK_DELETE, SCI_NORM, SCI_CLEAR}, {SCK_DELETE, SCI_NORM, SCI_CLEAR},
{SCK_DELETE, SCI_SHIFT, SCI_CUT}, {SCK_DELETE, SCI_SHIFT, SCI_CUT},
{SCK_DELETE, SCI_CTRL, SCI_DELWORDRIGHT}, {SCK_DELETE, SCI_CTRL, SCI_DELWORDRIGHT},
{SCK_DELETE, SCI_CSHIFT, SCI_DELLINERIGHT},
{SCK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE}, {SCK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE},
{SCK_INSERT, SCI_SHIFT, SCI_PASTE}, {SCK_INSERT, SCI_SHIFT, SCI_PASTE},
{SCK_INSERT, SCI_CTRL, SCI_COPY}, {SCK_INSERT, SCI_CTRL, SCI_COPY},
@@ -98,6 +105,7 @@ KeyToCommand KeyMap::MapDefault[] = {
{SCK_BACK, SCI_SHIFT, SCI_DELETEBACK}, {SCK_BACK, SCI_SHIFT, SCI_DELETEBACK},
{SCK_BACK, SCI_CTRL, SCI_DELWORDLEFT}, {SCK_BACK, SCI_CTRL, SCI_DELWORDLEFT},
{SCK_BACK, SCI_ALT, SCI_UNDO}, {SCK_BACK, SCI_ALT, SCI_UNDO},
{SCK_BACK, SCI_CSHIFT, SCI_DELLINELEFT},
{'Z', SCI_CTRL, SCI_UNDO}, {'Z', SCI_CTRL, SCI_UNDO},
{'Y', SCI_CTRL, SCI_REDO}, {'Y', SCI_CTRL, SCI_REDO},
{'X', SCI_CTRL, SCI_CUT}, {'X', SCI_CTRL, SCI_CUT},

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// KeyMap.h - defines a mapping between keystrokes and commands /** @file KeyMap.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines a mapping between keystrokes and commands.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef KEYTOCOMMAND_H #ifndef KEYTOCOMMAND_H
@@ -13,6 +15,8 @@
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT) #define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT) #define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
/**
*/
class KeyToCommand { class KeyToCommand {
public: public:
int key; int key;
@@ -20,11 +24,14 @@ public:
unsigned int msg; unsigned int msg;
}; };
/**
*/
class KeyMap { class KeyMap {
KeyToCommand *kmap; KeyToCommand *kmap;
int len; int len;
int alloc; int alloc;
static KeyToCommand MapDefault[]; static KeyToCommand MapDefault[];
public: public:
KeyMap(); KeyMap();
~KeyMap(); ~KeyMap();

View File

@@ -1,13 +1,15 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// KeyWords.cxx - colourise for particular languages /** @file KeyWords.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Colourise for particular languages.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -18,28 +20,137 @@
#include "SciLexer.h" #include "SciLexer.h"
LexerModule *LexerModule::base = 0; LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
LexerModule::LexerModule(int language_, LexerFunction fn_) : LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
language(language_), fn(fn_) { const char *languageName_, LexerFunction fnFolder_) :
language(language_),
languageName(languageName_),
fnLexer(fnLexer_),
fnFolder(fnFolder_) {
next = base; next = base;
base = this; base = this;
if (language == SCLEX_AUTOMATIC) {
language = nextLanguage;
nextLanguage++;
}
} }
void LexerModule::Colourise(unsigned int startPos, int lengthDoc, int initStyle, LexerModule *LexerModule::Find(int language) {
int language, WordList *keywordlists[], Accessor &styler) {
LexerModule *lm = base; LexerModule *lm = base;
while (lm) { while (lm) {
if (lm->language == language) { if (lm->language == language) {
lm->fn(startPos, lengthDoc, initStyle, keywordlists, styler); return lm;
return;
} }
lm = lm->next; lm = lm->next;
} }
// Unknown language return 0;
// Null language means all style bytes are 0 so just mark the end - no need to fill in. }
if (lengthDoc > 0) {
styler.StartAt(startPos + lengthDoc - 1); LexerModule *LexerModule::Find(const char *languageName) {
styler.StartSegment(startPos + lengthDoc - 1); if (languageName) {
styler.ColourTo(startPos + lengthDoc - 1, 0); LexerModule *lm = base;
while (lm) {
if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
return lm;
}
lm = lm->next;
}
}
return 0;
}
void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) {
if (fnLexer)
fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
}
void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) {
if (fnFolder) {
int lineCurrent = styler.GetLine(startPos);
// Move back one line in case deletion wrecked current line fold state
if (lineCurrent > 0) {
lineCurrent--;
int newStartPos = styler.LineStart(lineCurrent);
lengthDoc += startPos - newStartPos;
startPos = newStartPos;
initStyle = 0;
if (startPos > 0) {
initStyle = styler.StyleAt(startPos - 1);
}
}
fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);
} }
} }
static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[],
Accessor &styler) {
// Null language means all style bytes are 0 so just mark the end - no need to fill in.
if (length > 0) {
styler.StartAt(startPos + length - 1);
styler.StartSegment(startPos + length - 1);
styler.ColourTo(startPos + length - 1, 0);
}
}
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
#ifdef __vms
// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// them away. (eric@sourcegear.com)
// Taken from wxWindow's stc.cpp. Walter.
int wxForceScintillaLexers(void) {
extern LexerModule lmAda;
extern LexerModule lmAVE;
extern LexerModule lmConf;
extern LexerModule lmDiff;
extern LexerModule lmLatex;
extern LexerModule lmPascal;
extern LexerModule lmCPP;
extern LexerModule lmHTML;
extern LexerModule lmXML;
extern LexerModule lmProps;
extern LexerModule lmErrorList;
extern LexerModule lmMake;
extern LexerModule lmBatch;
extern LexerModule lmPerl;
extern LexerModule lmPython;
extern LexerModule lmSQL;
extern LexerModule lmVB;
extern LexerModule lmRuby;
if (
&lmAda
&& &lmAVE
&& &lmConf
&& &lmDiff
&& &lmLatex
&& &lmPascal
&& &lmCPP
&& &lmHTML
&& &lmXML
&& &lmProps
&& &lmErrorList
&& &lmMake
&& &lmBatch
&& &lmPerl
&& &lmPython
&& &lmSQL
&& &lmVB
&& &lmRuby
)
{
return 1;
}
else
{
return 0;
}
}
#endif

View File

@@ -0,0 +1,188 @@
// SciTE - Scintilla based Text Editor
/** @file LexAVE.cxx
** Lexer for Avenue.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void ColouriseAveDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold");
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
int state = initStyle;
if (state == SCE_AVE_STRINGEOL) // Does not leak onto next line
state = SCE_AVE_DEFAULT;
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
int visibleChars = 0;
styler.StartSegment(startPos);
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
// End of line
if (state == SCE_AVE_STRINGEOL) {
styler.ColourTo(i, state);
state = SCE_AVE_DEFAULT;
}
if (fold) {
int lev = levelPrev;
if (visibleChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
levelPrev = levelCurrent;
}
visibleChars = 0;
}
if (!isspace(ch))
visibleChars++;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
i += 1;
continue;
}
if (state == SCE_AVE_DEFAULT) {
if (iswordstart(ch) || (ch == '.') ) {
styler.ColourTo(i-1, state);
state = SCE_AVE_IDENTIFIER;
} else if (ch == '\'') {
styler.ColourTo(i-1, state);
state = SCE_AVE_COMMENT;
} else if (ch == '\"') {
styler.ColourTo(i-1, state);
state = SCE_AVE_STRING;
} else if (ch == '#') {
styler.ColourTo(i-1, state);
state = SCE_AVE_ENUM;
} else if (isoperator(ch) ) {
styler.ColourTo(i-1, state);
styler.ColourTo(i, SCE_AVE_OPERATOR);
}
}
else if (state == SCE_AVE_COMMENT) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state);
state = SCE_AVE_DEFAULT;
}
}
else if (state == SCE_AVE_ENUM) {
if (isoperator(ch) || ch == ' ' || ch == '\'' || ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state);
state = SCE_AVE_DEFAULT;
}
}
else if (state == SCE_AVE_STRING) {
if (ch == '\"') {
if (chNext == '\"') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
} else
{
styler.ColourTo(i, state);
state = SCE_AVE_DEFAULT;
}
} else if (chNext == '\r' || chNext == '\n') {
styler.ColourTo(i-1, SCE_AVE_STRINGEOL);
state = SCE_AVE_STRINGEOL;
}
}
if ((state == SCE_AVE_IDENTIFIER)) {
if (!iswordchar(ch) || ch == '.' ) {
char s[100];
unsigned int start = styler.GetStartSegment();
unsigned int end = i - 1;
for (unsigned int ii = 0; ii < end - start + 1 && ii < 30; ii++) {
s[ii] = static_cast<char>(tolower(styler[start + ii]));
s[ii + 1] = '\0';
}
char chAttr = SCE_AVE_IDENTIFIER;
if (isdigit(s[0]))
chAttr = SCE_AVE_NUMBER;
else {
if ((strcmp(s, "for") == 0) || (strcmp(s, "if") == 0) || (strcmp(s, "while") == 0))
{
levelCurrent +=1;
chAttr = SCE_AVE_STATEMENT;
}
if (strcmp(s, "end") == 0)
{
levelCurrent -=1;
chAttr = SCE_AVE_STATEMENT;
}
if ( (strcmp(s, "then") == 0) || (strcmp(s, "else") == 0) || (strcmp(s, "break") == 0) ||
(strcmp(s, "each") == 0) ||
(strcmp(s, "exit") == 0) || (strcmp(s, "continue") == 0) || (strcmp(s, "return") == 0) ||
(strcmp(s, "by") == 0) || (strcmp(s, "in") == 0) || (strcmp(s, "elseif") == 0))
{
chAttr = SCE_AVE_STATEMENT;
}
if ((strcmp(s, "av") == 0) || (strcmp(s, "self") == 0))
{
chAttr = SCE_AVE_KEYWORD;
}
if (keywords.InList(s))
{
chAttr = SCE_AVE_WORD;
}
}
styler.ColourTo(end, chAttr);
state = SCE_AVE_DEFAULT;
if (ch == '\'') {
state = SCE_AVE_COMMENT;
} else if (ch == '\"') {
state = SCE_AVE_STRING;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_AVE_OPERATOR);
}
}
}
}
styler.ColourTo(lengthDoc - 1, state);
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
if (fold) {
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
}
}
LexerModule lmAVE(SCLEX_AVE, ColouriseAveDoc, "ave");

View File

@@ -0,0 +1,198 @@
// SciTE - Scintilla based Text Editor
// LexAda.cxx - lexer for Ada95
// by Tahir Karaca <tahir@bigfoot.de>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
inline void classifyWordAda(unsigned int start, unsigned int end,
WordList &keywords, Accessor &styler) {
static const unsigned KEWORD_LEN_MAX = 30;
char wordLower[KEWORD_LEN_MAX + 1];
unsigned i;
for(i = 0; ( i < KEWORD_LEN_MAX ) && ( i < end - start + 1 ); i++) {
wordLower[i] = static_cast<char>(tolower(styler[start + i]));
}
wordLower[i] = '\0';
// int levelChange = 0;
char chAttr = SCE_ADA_IDENTIFIER;
if (keywords.InList(wordLower)) {
chAttr = SCE_ADA_WORD;
// Folding doesn't work this way since the semantics of some keywords depends
// on the current context.
// E.g. - "cond1 and THEN cond2" <-> "if ... THEN ..."
// - "procedure X IS ... end X;" <-> "procedure X IS new Y;"
// if (strcmp(wordLower, "is") == 0 || strcmp(wordLower, "then") == 0)
// levelChange=1;
// else if (strcmp(wordLower, "end") == 0)
// levelChange=-1;
}
styler.ColourTo(end, chAttr);
// return levelChange;
}
inline bool isAdaOperator(char ch) {
if (ch == '&' || ch == '\'' || ch == '(' || ch == ')' ||
ch == '*' || ch == '+' || ch == ',' || ch == '-' ||
ch == '.' || ch == '/' || ch == ':' || ch == ';' ||
ch == '<' || ch == '=' || ch == '>')
return true;
return false;
}
inline void styleTokenBegin(char beginChar, unsigned int pos, int &state,
Accessor &styler) {
if (isalpha(beginChar)) {
styler.ColourTo(pos-1, state);
state = SCE_ADA_IDENTIFIER;
} else if (isdigit(beginChar)) {
styler.ColourTo(pos-1, state);
state = SCE_ADA_NUMBER;
} else if (beginChar == '-' && styler.SafeGetCharAt(pos + 1) == '-') {
styler.ColourTo(pos-1, state);
state = SCE_ADA_COMMENT;
} else if (beginChar == '\"') {
styler.ColourTo(pos-1, state);
state = SCE_ADA_STRING;
} else if (beginChar == '\'' && styler.SafeGetCharAt(pos + 2) == '\'') {
styler.ColourTo(pos-1, state);
state = SCE_ADA_CHARACTER;
} else if (isAdaOperator(beginChar)) {
styler.ColourTo(pos-1, state);
styler.ColourTo(pos, SCE_ADA_OPERATOR);
}
}
static void ColouriseAdaDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
// bool fold = styler.GetPropertyInt("fold");
// int lineCurrent = styler.GetLine(startPos);
// int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
// int levelCurrent = levelPrev;
int state = initStyle;
if (state == SCE_ADA_STRINGEOL) // Does not leak onto next line
state = SCE_ADA_DEFAULT;
char chNext = styler[startPos];
const unsigned int lengthDoc = startPos + length;
//int visibleChars = 0;
styler.StartSegment(startPos);
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
if (state == SCE_ADA_STRINGEOL) {
styler.ColourTo(i, state);
state = SCE_ADA_DEFAULT;
}
// if (fold) {
// int lev = levelPrev;
// if (visibleChars == 0)
// lev |= SC_FOLDLEVELWHITEFLAG;
// if ((levelCurrent > levelPrev) && (visibleChars > 0))
// lev |= SC_FOLDLEVELHEADERFLAG;
// styler.SetLevel(lineCurrent, lev);
// lineCurrent++;
// levelPrev = levelCurrent;
// }
//visibleChars = 0;
}
//if (!isspacechar(ch))
// visibleChars++;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
i += 1;
continue;
}
if (state == SCE_ADA_DEFAULT) {
styleTokenBegin(ch, i, state, styler);
} else if (state == SCE_ADA_IDENTIFIER) {
if (!iswordchar(ch)) {
classifyWordAda(styler.GetStartSegment(),
i - 1,
keywords,
styler);
state = SCE_ADA_DEFAULT;
styleTokenBegin(ch, i, state, styler);
}
} else if (state == SCE_ADA_COMMENT) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state);
state = SCE_ADA_DEFAULT;
}
} else if (state == SCE_ADA_STRING) {
if (ch == '"' ) {
if( chNext == '"' ) {
i++;
chNext = styler.SafeGetCharAt(i + 1);
} else {
styler.ColourTo(i, state);
state = SCE_ADA_DEFAULT;
}
} else if (chNext == '\r' || chNext == '\n') {
styler.ColourTo(i-1, SCE_ADA_STRINGEOL);
state = SCE_ADA_STRINGEOL;
}
} else if (state == SCE_ADA_CHARACTER) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, SCE_ADA_STRINGEOL);
state = SCE_ADA_STRINGEOL;
} else if (ch == '\'' && styler.SafeGetCharAt(i - 2) == '\'') {
styler.ColourTo(i, state);
state = SCE_ADA_DEFAULT;
}
} else if (state == SCE_ADA_NUMBER) {
if ( !( isdigit(ch) || ch == '.' || ch == '_' || ch == '#'
|| ch == 'A' || ch == 'B' || ch == 'C' || ch == 'D'
|| ch == 'E' || ch == 'F'
|| ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd'
|| ch == 'e' || ch == 'f' ) ) {
styler.ColourTo(i-1, SCE_ADA_NUMBER);
state = SCE_ADA_DEFAULT;
styleTokenBegin(ch, i, state, styler);
}
}
}
styler.ColourTo(lengthDoc - 1, state);
// // Fill in the real level of the next line, keeping the current flags as they will be filled in later
// if (fold) {
// int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
// styler.SetLevel(lineCurrent, levelPrev | flagsNext);
// }
}
LexerModule lmAda(SCLEX_ADA, ColouriseAdaDoc, "ada");

View File

@@ -1,13 +1,15 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// LexCPP.cxx - lexer for C++, C, Java, and Javascript /** @file LexCPP.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Lexer for C++, C, Java, and Javascript.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -17,246 +19,370 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { static bool IsOKBeforeRE(int ch) {
char s[100]; return (ch == '(') || (ch == '=') || (ch == ',');
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
}
bool wordIsUUID = false;
char chAttr = SCE_C_IDENTIFIER;
if (isdigit(s[0]) || (s[0] == '.'))
chAttr = SCE_C_NUMBER;
else {
if (keywords.InList(s)) {
chAttr = SCE_C_WORD;
wordIsUUID = strcmp(s, "uuid") == 0;
}
}
styler.ColourTo(end, chAttr);
return wordIsUUID;
} }
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], static void getRange(unsigned int start,
Accessor &styler) { unsigned int end,
Accessor &styler,
char *s,
unsigned int len) {
unsigned int i = 0;
while ((i < end - start + 1) && (i < len-1)) {
s[i] = styler[start + i];
i++;
}
s[i] = '\0';
}
inline bool IsASpace(int ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
inline bool IsAWordChar(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
inline bool IsAWordStart(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
inline bool IsADigit(int ch) {
return (ch >= '0') && (ch <= '9');
}
// All languages handled so far can treat all characters >= 0x80 as one class
// which just continues the current token or starts an identifier if in default.
// DBCS treated specially as the second character can be < 0x80 and hence
// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
class ColouriseContext {
Accessor &styler;
int lengthDoc;
int currentPos;
ColouriseContext& operator=(const ColouriseContext&) {
return *this;
}
public:
bool atEOL;
int state;
int chPrev;
int ch;
int chNext;
ColouriseContext(unsigned int startPos, int length,
int initStyle, Accessor &styler_) :
styler(styler_),
lengthDoc(startPos + length),
currentPos(startPos),
atEOL(false),
state(initStyle),
chPrev(0),
ch(0),
chNext(0) {
styler.StartAt(startPos);
styler.StartSegment(startPos);
int pos = currentPos;
ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
if (styler.IsLeadByte(static_cast<char>(ch))) {
pos++;
ch = ch << 8;
ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
}
chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
if (styler.IsLeadByte(static_cast<char>(chNext))) {
chNext = chNext << 8;
chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
}
atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
}
void Complete() {
styler.ColourTo(currentPos - 1, state);
}
bool More() {
return currentPos <= lengthDoc;
}
void Forward() {
// A lot of this is repeated from the constructor - TODO: merge code
chPrev = ch;
currentPos++;
if (ch >= 0x100)
currentPos++;
ch = chNext;
chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
if (styler.IsLeadByte(static_cast<char>(chNext))) {
chNext = chNext << 8;
chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
}
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
// End of line
atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
}
void ChangeState(int state_) {
state = state_;
}
void SetState(int state_) {
styler.ColourTo(currentPos - 1, state);
state = state_;
}
void ForwardSetState(int state_) {
Forward();
styler.ColourTo(currentPos - 1, state);
state = state_;
}
void GetCurrent(char *s, int len) {
getRange(styler.GetStartSegment(), currentPos - 1, styler, s, len);
}
int LengthCurrent() {
return currentPos - styler.GetStartSegment();
}
bool Match(char ch0) {
return ch == ch0;
}
bool Match(char ch0, char ch1) {
return (ch == ch0) && (chNext == ch1);
}
bool Match(const char *s) {
if (ch != *s)
return false;
s++;
if (chNext != *s)
return false;
s++;
for (int n=2; *s; n++) {
if (*s != styler.SafeGetCharAt(currentPos+n))
return false;
s++;
}
return true;
}
};
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0]; WordList &keywords = *keywordlists[0];
WordList &keywords2 = *keywordlists[1];
styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold");
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor"); bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
if (initStyle == SCE_C_STRINGEOL) // Does not leak onto next line
initStyle = SCE_C_DEFAULT;
int chPrevNonWhite = ' ';
int visibleChars = 0;
bool lastWordWasUUID = false;
ColouriseContext cc(startPos, length, initStyle, styler);
for (; cc.More(); cc.Forward()) {
if (cc.state == SCE_C_STRINGEOL) {
if (cc.atEOL) {
cc.SetState(SCE_C_DEFAULT);
}
} else if (cc.state == SCE_C_OPERATOR) {
cc.SetState(SCE_C_DEFAULT);
} else if (cc.state == SCE_C_NUMBER) {
if (!IsAWordChar(cc.ch)) {
cc.SetState(SCE_C_DEFAULT);
}
} else if (cc.state == SCE_C_IDENTIFIER) {
if (!IsAWordChar(cc.ch) || (cc.ch == '.')) {
char s[100];
cc.GetCurrent(s, sizeof(s));
if (keywords.InList(s)) {
lastWordWasUUID = strcmp(s, "uuid") == 0;
cc.ChangeState(SCE_C_WORD);
} else if (keywords2.InList(s)) {
cc.ChangeState(SCE_C_WORD2);
}
cc.SetState(SCE_C_DEFAULT);
}
} if (cc.state == SCE_C_PREPROCESSOR) {
if (stylingWithinPreprocessor) {
if (IsASpace(cc.ch)) {
cc.SetState(SCE_C_DEFAULT);
}
} else {
if (cc.atEOL && (cc.chPrev != '\\')) {
cc.SetState(SCE_C_DEFAULT);
}
}
} else if (cc.state == SCE_C_COMMENT) {
if (cc.Match('*', '/')) {
cc.Forward();
cc.ForwardSetState(SCE_C_DEFAULT);
}
} else if (cc.state == SCE_C_COMMENTDOC) {
if (cc.Match('*', '/')) {
cc.Forward();
cc.ForwardSetState(SCE_C_DEFAULT);
}
} else if (cc.state == SCE_C_COMMENTLINE || cc.state == SCE_C_COMMENTLINEDOC) {
if (cc.ch == '\r' || cc.ch == '\n') {
cc.SetState(SCE_C_DEFAULT);
}
} else if (cc.state == SCE_C_STRING) {
if (cc.ch == '\\') {
if (cc.chNext == '\"' || cc.chNext == '\'' || cc.chNext == '\\') {
cc.Forward();
}
} else if (cc.ch == '\"') {
cc.ForwardSetState(SCE_C_DEFAULT);
} else if ((cc.atEOL) && (cc.chPrev != '\\')) {
cc.ChangeState(SCE_C_STRINGEOL);
}
} else if (cc.state == SCE_C_CHARACTER) {
if ((cc.ch == '\r' || cc.ch == '\n') && (cc.chPrev != '\\')) {
cc.ChangeState(SCE_C_STRINGEOL);
} else if (cc.ch == '\\') {
if (cc.chNext == '\"' || cc.chNext == '\'' || cc.chNext == '\\') {
cc.Forward();
}
} else if (cc.ch == '\'') {
cc.ForwardSetState(SCE_C_DEFAULT);
}
} else if (cc.state == SCE_C_REGEX) {
if (cc.ch == '\r' || cc.ch == '\n' || cc.ch == '/') {
cc.ForwardSetState(SCE_C_DEFAULT);
} else if (cc.ch == '\\') {
// Gobble up the quoted character
if (cc.chNext == '\\' || cc.chNext == '/') {
cc.Forward();
}
}
} else if (cc.state == SCE_C_VERBATIM) {
if (cc.ch == '\"') {
if (cc.chNext == '\"') {
cc.Forward();
} else {
cc.ForwardSetState(SCE_C_DEFAULT);
}
}
} else if (cc.state == SCE_C_UUID) {
if (cc.ch == '\r' || cc.ch == '\n' || cc.ch == ')') {
cc.SetState(SCE_C_DEFAULT);
}
}
if (cc.state == SCE_C_DEFAULT) {
if (cc.Match('@', '\"')) {
cc.SetState(SCE_C_VERBATIM);
cc.Forward();
} else if (IsADigit(cc.ch) || (cc.ch == '.' && IsADigit(cc.chNext))) {
if (lastWordWasUUID) {
cc.SetState(SCE_C_UUID);
lastWordWasUUID = false;
} else {
cc.SetState(SCE_C_NUMBER);
}
} else if (IsAWordStart(cc.ch) || (cc.ch == '@')) {
if (lastWordWasUUID) {
cc.SetState(SCE_C_UUID);
lastWordWasUUID = false;
} else {
cc.SetState(SCE_C_IDENTIFIER);
}
} else if (cc.Match('/', '*')) {
if (cc.Match("/**") || cc.Match("/*!")) // Support of Qt/Doxygen doc. style
cc.SetState(SCE_C_COMMENTDOC);
else
cc.SetState(SCE_C_COMMENT);
cc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (cc.Match('/', '/')) {
if (cc.Match("///") || cc.Match("//!")) // Support of Qt/Doxygen doc. style
cc.SetState(SCE_C_COMMENTLINEDOC);
else
cc.SetState(SCE_C_COMMENTLINE);
} else if (cc.ch == '/' && IsOKBeforeRE(chPrevNonWhite)) {
cc.SetState(SCE_C_REGEX);
} else if (cc.ch == '\"') {
cc.SetState(SCE_C_STRING);
} else if (cc.ch == '\'') {
cc.SetState(SCE_C_CHARACTER);
} else if (cc.ch == '#' && visibleChars == 0) {
// Preprocessor commands are alone on their line
cc.SetState(SCE_C_PREPROCESSOR);
// Skip whitespace between # and preprocessor word
do {
cc.Forward();
} while (IsASpace(cc.ch) && cc.More());
} else if (isoperator(static_cast<char>(cc.ch))) {
cc.SetState(SCE_C_OPERATOR);
}
}
if (cc.atEOL) {
// Reset states to begining of colourise so no surprises
// if different sets of lines lexed.
chPrevNonWhite = ' ';
visibleChars = 0;
lastWordWasUUID = false;
}
if (!IsASpace(cc.ch)) {
chPrevNonWhite = cc.ch;
visibleChars++;
}
}
cc.Complete();
}
static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment");
bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev; int levelCurrent = levelPrev;
int state = initStyle;
if (state == SCE_C_STRINGEOL) // Does not leak onto next line
state = SCE_C_DEFAULT;
char chPrev = ' ';
char chNext = styler[startPos]; char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length; int styleNext = styler.StyleAt(startPos);
int visibleChars = 0; int style = initStyle;
styler.StartSegment(startPos); for (unsigned int i = startPos; i < endPos; i++) {
bool lastWordWasUUID = false;
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext; char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { style = styleNext;
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) styleNext = styler.StyleAt(i + 1);
// Avoid triggering two times on Dos/Win bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
// End of line if (foldComment &&
if (state == SCE_C_STRINGEOL) { (style == SCE_C_COMMENT || style == SCE_C_COMMENTDOC)) {
styler.ColourTo(i, state); if (style != stylePrev) {
state = SCE_C_DEFAULT; levelCurrent++;
} else if ((style != styleNext) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelCurrent--;
} }
if (fold) { }
int lev = levelPrev; if (style == SCE_C_OPERATOR) {
if (visibleChars == 0) if (ch == '{') {
lev |= SC_FOLDLEVELWHITEFLAG; levelCurrent++;
if ((levelCurrent > levelPrev) && (visibleChars > 0)) } else if (ch == '}') {
lev |= SC_FOLDLEVELHEADERFLAG; levelCurrent--;
}
}
if (atEOL) {
int lev = levelPrev;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev); styler.SetLevel(lineCurrent, lev);
lineCurrent++;
levelPrev = levelCurrent;
} }
lineCurrent++;
levelPrev = levelCurrent;
visibleChars = 0; visibleChars = 0;
} }
if (!isspace(ch)) if (!isspacechar(ch))
visibleChars++; visibleChars++;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_C_DEFAULT) {
if (ch == '@' && chNext == '\"') {
styler.ColourTo(i-1, state);
state = SCE_C_VERBATIM;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
} else if (iswordstart(ch) || (ch == '@')) {
styler.ColourTo(i-1, state);
if (lastWordWasUUID) {
state = SCE_C_UUID;
lastWordWasUUID = false;
} else {
state = SCE_C_IDENTIFIER;
}
} else if (ch == '/' && chNext == '*') {
styler.ColourTo(i-1, state);
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i-1, state);
state = SCE_C_STRING;
} else if (ch == '\'') {
styler.ColourTo(i-1, state);
state = SCE_C_CHARACTER;
} else if (ch == '#' && visibleChars == 1) {
// Preprocessor commands are alone on their line
styler.ColourTo(i-1, state);
state = SCE_C_PREPROCESSOR;
// Skip whitespace between # and preprocessor word
do {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
} while (isspace(ch) && (i < lengthDoc));
} else if (isoperator(ch)) {
styler.ColourTo(i-1, state);
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
} else if (state == SCE_C_IDENTIFIER) {
if (!iswordchar(ch)) {
lastWordWasUUID = classifyWordCpp(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_C_DEFAULT;
if (ch == '/' && chNext == '*') {
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_C_STRING;
} else if (ch == '\'') {
state = SCE_C_CHARACTER;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
}
} else {
if (state == SCE_C_PREPROCESSOR) {
if (stylingWithinPreprocessor) {
if (isspace(ch)) {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
} else {
if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENT) {
if (ch == '/' && chPrev == '*') {
if (((i > styler.GetStartSegment() + 2) || (
(initStyle == SCE_C_COMMENT) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTDOC) {
if (ch == '/' && chPrev == '*') {
if (((i > styler.GetStartSegment() + 2) || (
(initStyle == SCE_C_COMMENTDOC) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_STRING) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
} else if (chNext == '\r' || chNext == '\n') {
styler.ColourTo(i-1, SCE_C_STRINGEOL);
state = SCE_C_STRINGEOL;
}
} else if (state == SCE_C_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, SCE_C_STRINGEOL);
state = SCE_C_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_VERBATIM) {
if (ch == '\"') {
if (chNext == '\"') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
} else {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_UUID) {
if (ch == '\r' || ch == '\n' || ch == ')') {
styler.ColourTo(i-1, state);
if (ch == ')')
styler.ColourTo(i, SCE_C_OPERATOR);
state = SCE_C_DEFAULT;
}
}
}
chPrev = ch;
} }
styler.ColourTo(lengthDoc - 1, state);
// Fill in the real level of the next line, keeping the current flags as they will be filled in later // Fill in the real level of the next line, keeping the current flags as they will be filled in later
if (fold) { int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext);
//styler.SetLevel(lineCurrent, levelCurrent | flagsNext);
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
}
} }
LexerModule lmCPP(SCLEX_CPP, ColouriseCppDoc); LexerModule lmCPP(SCLEX_CPP, ColouriseCppDoc, "cpp", FoldCppDoc);
LexerModule lmTCL(SCLEX_TCL, ColouriseCppDoc, "tcl", FoldCppDoc);

View File

@@ -0,0 +1,177 @@
// Scintilla source code edit control
/** @file LexConf.cxx
** Lexer for Apache Configuration Files.
**
** First working version contributed by Ahmad Zawawi <zeus_go64@hotmail.com> on October 28, 2000.
** i created this lexer because i needed something pretty when dealing
** when Apache Configuration files...
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
{
int state = SCE_CONF_DEFAULT;
char chNext = styler[startPos];
int lengthDoc = startPos + length;
// create a buffer large enough to take the largest chunk...
char *buffer = new char[length];
int bufferCount = 0;
// this assumes that we have 2 keyword list in conf.properties
WordList &directives = *keywordLists[0];
WordList &params = *keywordLists[1];
// go through all provided text segment
// using the hand-written state machine shown below
styler.StartAt(startPos);
styler.StartSegment(startPos);
for (int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
i++;
continue;
}
switch(state) {
case SCE_CONF_DEFAULT:
if( ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ') {
// whitespace is simply ignored here...
styler.ColourTo(i,SCE_CONF_DEFAULT);
break;
} else if( ch == '#' ) {
// signals the start of a comment...
state = SCE_CONF_COMMENT;
styler.ColourTo(i,SCE_CONF_COMMENT);
} else if( ch == '.' /*|| ch == '/'*/) {
// signals the start of a file...
state = SCE_CONF_EXTENSION;
styler.ColourTo(i,SCE_CONF_EXTENSION);
} else if( ch == '"') {
state = SCE_CONF_STRING;
styler.ColourTo(i,SCE_CONF_STRING);
} else if( ispunct(ch) ) {
// signals an operator...
// no state jump necessary for this
// simple case...
styler.ColourTo(i,SCE_CONF_OPERATOR);
} else if( isalpha(ch) ) {
// signals the start of an identifier
bufferCount = 0;
buffer[bufferCount++] = static_cast<char>(tolower(ch));
state = SCE_CONF_IDENTIFIER;
} else if( isdigit(ch) ) {
// signals the start of a number
bufferCount = 0;
buffer[bufferCount++] = ch;
//styler.ColourTo(i,SCE_CONF_NUMBER);
state = SCE_CONF_NUMBER;
} else {
// style it the default style..
styler.ColourTo(i,SCE_CONF_DEFAULT);
}
break;
case SCE_CONF_COMMENT:
// if we find a newline here,
// we simply go to default state
// else continue to work on it...
if( ch == '\n' || ch == '\r' ) {
state = SCE_CONF_DEFAULT;
} else {
styler.ColourTo(i,SCE_CONF_COMMENT);
}
break;
case SCE_CONF_EXTENSION:
// if we find a non-alphanumeric char,
// we simply go to default state
// else we're still dealing with an extension...
if( isalnum(ch) || (ch == '_') ||
(ch == '-') || (ch == '$') ||
(ch == '/') || (ch == '.') || (ch == '*') )
{
styler.ColourTo(i,SCE_CONF_EXTENSION);
} else {
state = SCE_CONF_DEFAULT;
chNext = styler[i--];
}
break;
case SCE_CONF_STRING:
// if we find the end of a string char, we simply go to default state
// else we're still dealing with an string...
if( (ch == '"' && styler.SafeGetCharAt(i-1)!='\\') || (ch == '\n') || (ch == '\r') ) {
state = SCE_CONF_DEFAULT;
}
styler.ColourTo(i,SCE_CONF_STRING);
break;
case SCE_CONF_IDENTIFIER:
// stay in CONF_IDENTIFIER state until we find a non-alphanumeric
if( isalnum(ch) || (ch == '_') || (ch == '-') || (ch == '/') || (ch == '$') || (ch == '.') || (ch == '*')) {
buffer[bufferCount++] = static_cast<char>(tolower(ch));
} else {
state = SCE_CONF_DEFAULT;
buffer[bufferCount] = '\0';
// check if the buffer contains a keyword, and highlight it if it is a keyword...
if(directives.InList(buffer)) {
styler.ColourTo(i-1,SCE_CONF_DIRECTIVE );
} else if(params.InList(buffer)) {
styler.ColourTo(i-1,SCE_CONF_PARAMETER );
} else if(strchr(buffer,'/') || strchr(buffer,'.')) {
styler.ColourTo(i-1,SCE_CONF_EXTENSION);
} else {
styler.ColourTo(i-1,SCE_CONF_DEFAULT);
}
// push back the faulty character
chNext = styler[i--];
}
break;
case SCE_CONF_NUMBER:
// stay in CONF_NUMBER state until we find a non-numeric
if( isdigit(ch) || ch == '.') {
buffer[bufferCount++] = ch;
} else {
state = SCE_CONF_DEFAULT;
buffer[bufferCount] = '\0';
// Colourize here...
if( strchr(buffer,'.') ) {
// it is an IP address...
styler.ColourTo(i-1,SCE_CONF_IP);
} else {
// normal number
styler.ColourTo(i-1,SCE_CONF_NUMBER);
}
// push back a character
chNext = styler[i--];
}
break;
}
}
}
LexerModule lmConf(SCLEX_CONF, ColouriseConfDoc, "conf");

View File

@@ -0,0 +1,321 @@
// Scintilla source code edit control
/** @file LexEiffel.cxx
** Lexer for Eiffel.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <fcntl.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
inline bool isEiffelOperator(unsigned int ch) {
// '.' left out as it is used to make up numbers
return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' ||
ch == '(' || ch == ')' || ch == '=' ||
ch == '{' || ch == '}' || ch == '~' ||
ch == '[' || ch == ']' || ch == ';' ||
ch == '<' || ch == '>' || ch == ',' ||
ch == '.' || ch == '^' || ch == '%' || ch == ':' ||
ch == '!' || ch == '@' || ch == '?';
}
static void getRangeLowered(unsigned int start,
unsigned int end,
Accessor &styler,
char *s,
unsigned int len) {
unsigned int i = 0;
while ((i < end - start + 1) && (i < len-1)) {
s[i] = static_cast<char>(tolower(styler[start + i]));
i++;
}
s[i] = '\0';
}
inline bool IsASpace(unsigned int ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
inline bool IsAWordChar(unsigned int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
inline bool IsAWordStart(unsigned int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
inline bool IsADigit(unsigned int ch) {
return (ch >= '0') && (ch <= '9');
}
// All languages handled so far can treat all characters >= 0x80 as one class
// which just continues the current token or starts an identifier if in default.
// DBCS treated specially as the second character can be < 0x80 and hence
// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
class xColouriseContext {
Accessor &styler;
int lengthDoc;
int currentPos;
xColouriseContext& operator=(const xColouriseContext&) {
return *this;
}
public:
int state;
unsigned int chPrev;
unsigned int ch;
unsigned int chNext;
xColouriseContext(unsigned int startPos, int length,
int initStyle, Accessor &styler_) :
styler(styler_),
lengthDoc(startPos + length),
currentPos(startPos),
state(initStyle),
chPrev(0),
ch(0),
chNext(0) {
styler.StartAt(startPos);
styler.StartSegment(startPos);
int pos = currentPos;
ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
if (styler.IsLeadByte(static_cast<char>(ch))) {
pos++;
ch = ch << 8;
ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
}
chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
if (styler.IsLeadByte(static_cast<char>(chNext))) {
chNext = chNext << 8;
chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
}
}
void Complete() {
styler.ColourTo(currentPos - 1, state);
}
bool More() {
return currentPos <= lengthDoc;
}
void Forward() {
chPrev = ch;
currentPos++;
if (ch >= 0x100)
currentPos++;
ch = chNext;
chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
if (styler.IsLeadByte(static_cast<char>(chNext))) {
chNext = chNext << 8;
chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
}
}
void ChangeState(int state_) {
state = state_;
}
void SetState(int state_) {
styler.ColourTo(currentPos - 1, state);
state = state_;
}
void GetCurrentLowered(char *s, int len) {
getRangeLowered(styler.GetStartSegment(), currentPos - 1, styler, s, len);
}
};
static void ColouriseEiffelDoc(unsigned int startPos,
int length,
int initStyle,
WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
xColouriseContext lc(startPos, length, initStyle, styler);
for (; lc.More(); lc.Forward()) {
if (lc.state == SCE_EIFFEL_STRINGEOL) {
if (lc.ch != '\r' && lc.ch != '\n') {
lc.SetState(SCE_EIFFEL_DEFAULT);
}
} else if (lc.state == SCE_EIFFEL_OPERATOR) {
lc.SetState(SCE_EIFFEL_DEFAULT);
} else if (lc.state == SCE_EIFFEL_WORD) {
if (!IsAWordChar(lc.ch)) {
char s[100];
lc.GetCurrentLowered(s, sizeof(s));
if (!keywords.InList(s)) {
lc.ChangeState(SCE_EIFFEL_IDENTIFIER);
}
lc.SetState(SCE_EIFFEL_DEFAULT);
}
} else if (lc.state == SCE_EIFFEL_NUMBER) {
if (!IsAWordChar(lc.ch)) {
lc.SetState(SCE_EIFFEL_DEFAULT);
}
} else if (lc.state == SCE_EIFFEL_COMMENTLINE) {
if (lc.ch == '\r' || lc.ch == '\n') {
lc.SetState(SCE_EIFFEL_DEFAULT);
}
} else if (lc.state == SCE_EIFFEL_STRING) {
if (lc.ch == '%') {
lc.Forward();
} else if (lc.ch == '\"') {
lc.Forward();
lc.SetState(SCE_EIFFEL_DEFAULT);
}
} else if (lc.state == SCE_EIFFEL_CHARACTER) {
if (lc.ch == '\r' || lc.ch == '\n') {
lc.SetState(SCE_EIFFEL_STRINGEOL);
} else if (lc.ch == '%') {
lc.Forward();
} else if (lc.ch == '\'') {
lc.Forward();
lc.SetState(SCE_EIFFEL_DEFAULT);
}
}
if (lc.state == SCE_EIFFEL_DEFAULT) {
if (lc.ch == '-' && lc.chNext == '-') {
lc.SetState(SCE_EIFFEL_COMMENTLINE);
} else if (lc.ch == '\"') {
lc.SetState(SCE_EIFFEL_STRING);
} else if (lc.ch == '\'') {
lc.SetState(SCE_EIFFEL_CHARACTER);
} else if (IsADigit(lc.ch) || (lc.ch == '.')) {
lc.SetState(SCE_EIFFEL_NUMBER);
} else if (IsAWordStart(lc.ch)) {
lc.SetState(SCE_EIFFEL_WORD);
} else if (isEiffelOperator(lc.ch)) {
lc.SetState(SCE_EIFFEL_OPERATOR);
}
}
}
lc.Complete();
}
static bool IsEiffelComment(Accessor &styler, int pos, int len) {
return len>1 && styler[pos]=='-' && styler[pos+1]=='-';
}
static void FoldEiffelDocIndent(unsigned int startPos, int length, int,
WordList *[], Accessor &styler) {
int lengthDoc = startPos + length;
// Backtrack to previous line in case need to fix its fold status
int lineCurrent = styler.GetLine(startPos);
if (startPos > 0) {
if (lineCurrent > 0) {
lineCurrent--;
startPos = styler.LineStart(lineCurrent);
}
}
int spaceFlags = 0;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsEiffelComment);
char chNext = styler[startPos];
for (int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsEiffelComment);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
// Line after is blank so check the next - maybe should continue further?
int spaceFlags2 = 0;
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsEiffelComment);
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
}
indentCurrent = indentNext;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
}
}
}
static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* initStyle */, WordList *[],
Accessor &styler) {
unsigned int lengthDoc = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
int stylePrev = 0;
int styleNext = styler.StyleAt(startPos);
// lastDeferred should be determined by looking back to last keyword in case
// the "deferred" is on a line before "class"
bool lastDeferred = false;
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if ((stylePrev != SCE_EIFFEL_WORD) && (style == SCE_EIFFEL_WORD)) {
char s[20];
unsigned int j = 0;
while ((j < (sizeof(s) - 1)) && (iswordchar(styler[i + j]))) {
s[j] = styler[i + j];
j++;
}
s[j] = '\0';
if (
(strcmp(s, "check") == 0) ||
(strcmp(s, "debug") == 0) ||
(strcmp(s, "deferred") == 0) ||
(strcmp(s, "do") == 0) ||
(strcmp(s, "from") == 0) ||
(strcmp(s, "if") == 0) ||
(strcmp(s, "inspect") == 0) ||
(strcmp(s, "once") == 0)
)
levelCurrent++;
if (!lastDeferred && (strcmp(s, "class") == 0))
levelCurrent++;
if (strcmp(s, "end") == 0)
levelCurrent--;
lastDeferred = strcmp(s, "deferred") == 0;
}
if (atEOL) {
int lev = levelPrev;
if (visibleChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
levelPrev = levelCurrent;
visibleChars = 0;
}
if (!isspacechar(ch))
visibleChars++;
stylePrev = style;
}
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
}
LexerModule lmEiffel(SCLEX_EIFFEL, ColouriseEiffelDoc, "eiffel", FoldEiffelDocIndent);
LexerModule lmEiffelkw(SCLEX_EIFFELKW, ColouriseEiffelDoc, "eiffelkw", FoldEiffelDocKeyWords);

View File

@@ -1,13 +1,15 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// LexHTML.cxx - lexer for HTML /** @file LexHTML.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Lexer for HTML.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -32,6 +34,8 @@ static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigne
s[i + 1] = '\0'; s[i + 1] = '\0';
} }
//Platform::DebugPrintf("Scripting indicator [%s]\n", s); //Platform::DebugPrintf("Scripting indicator [%s]\n", s);
if (strstr(s, "src")) // External script
return eScriptNone;
if (strstr(s, "vbs")) if (strstr(s, "vbs"))
return eScriptVBS; return eScriptVBS;
if (strstr(s, "pyth")) if (strstr(s, "pyth"))
@@ -63,7 +67,6 @@ static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, u
return iResult; return iResult;
} }
//static int ScriptOfState(int state,int defaultScript)
static int ScriptOfState(int state) { static int ScriptOfState(int state) {
int scriptLanguage; int scriptLanguage;
@@ -71,7 +74,7 @@ static int ScriptOfState(int state) {
scriptLanguage = eScriptPython; scriptLanguage = eScriptPython;
} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) { } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
scriptLanguage = eScriptVBS; scriptLanguage = eScriptVBS;
} else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_STRINGEOL)) { } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
scriptLanguage = eScriptJS; scriptLanguage = eScriptJS;
} else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) { } else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
scriptLanguage = eScriptPHP; scriptLanguage = eScriptPHP;
@@ -90,7 +93,7 @@ static int statePrintForState(int state, int inScriptType) {
StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_PYTHON); StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_PYTHON);
} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) { } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_VBS); StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_VBS);
} else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_STRINGEOL)) { } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_JS); StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_JS);
} else { } else {
StateToPrint = state; StateToPrint = state;
@@ -106,7 +109,7 @@ static int stateForPrintState(int StateToPrint) {
state = StateToPrint - SCE_HA_PYTHON; state = StateToPrint - SCE_HA_PYTHON;
} else if ((StateToPrint >= SCE_HBA_START) && (StateToPrint <= SCE_HBA_STRINGEOL)) { } else if ((StateToPrint >= SCE_HBA_START) && (StateToPrint <= SCE_HBA_STRINGEOL)) {
state = StateToPrint - SCE_HA_VBS; state = StateToPrint - SCE_HA_VBS;
} else if ((StateToPrint >= SCE_HJA_START) && (StateToPrint <= SCE_HJA_STRINGEOL)) { } else if ((StateToPrint >= SCE_HJA_START) && (StateToPrint <= SCE_HJA_REGEX)) {
state = StateToPrint - SCE_HA_JS; state = StateToPrint - SCE_HA_JS;
} else { } else {
state = StateToPrint; state = StateToPrint;
@@ -117,7 +120,51 @@ static int stateForPrintState(int StateToPrint) {
static inline bool IsNumber(unsigned int start, Accessor &styler) { static inline bool IsNumber(unsigned int start, Accessor &styler) {
return isdigit(styler[start]) || (styler[start] == '.') || return isdigit(styler[start]) || (styler[start] == '.') ||
(styler[start] == '-') || (styler[start] == '#'); (styler[start] == '-') || (styler[start] == '#');
}
static inline bool isStringState(int state) {
bool bResult;
switch (state) {
case SCE_HJ_DOUBLESTRING:
case SCE_HJ_SINGLESTRING:
case SCE_HJA_DOUBLESTRING:
case SCE_HJA_SINGLESTRING:
case SCE_HB_STRING:
case SCE_HBA_STRING:
case SCE_HP_STRING:
case SCE_HPA_STRING:
case SCE_HPHP_HSTRING:
case SCE_HPHP_SIMPLESTRING:
bResult = true;
break;
default :
bResult = false;
break;
}
return bResult;
}
// not really well done, since it's only comments that should lex the %> and <%
static inline bool isCommentASPState(int state) {
bool bResult;
switch (state) {
case SCE_HJ_COMMENT:
case SCE_HJ_COMMENTLINE:
case SCE_HJ_COMMENTDOC:
case SCE_HB_COMMENTLINE:
case SCE_HP_COMMENTLINE:
case SCE_HPHP_COMMENT:
case SCE_HPHP_COMMENTLINE:
bResult = true;
break;
default :
bResult = false;
break;
}
return bResult;
} }
static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
@@ -152,27 +199,28 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
s[i++] = static_cast<char>(tolower(ch)); s[i++] = static_cast<char>(tolower(ch));
} }
s[i] = '\0'; s[i] = '\0';
bool isScript = false;
char chAttr = SCE_H_TAGUNKNOWN; char chAttr = SCE_H_TAGUNKNOWN;
if (s[0] == '!' && s[1] == '-' && s[2] == '-') { //Comment if (s[0] == '!' && s[1] == '-' && s[2] == '-') { //Comment
chAttr = SCE_H_COMMENT; chAttr = SCE_H_COMMENT;
} else if (strcmp(s, "![cdata[") == 0) { // In lower case because already converted } else if (strcmp(s, "![cdata[") == 0) { // In lower case because already converted
chAttr = SCE_H_CDATA; chAttr = SCE_H_CDATA;
} else if (s[0] == '!') {
chAttr = SCE_H_SGML;
} else if (s[0] == '/') { // Closing tag } else if (s[0] == '/') { // Closing tag
if (keywords.InList(s + 1)) if (keywords.InList(s + 1))
chAttr = SCE_H_TAG; chAttr = SCE_H_TAG;
} else { } else {
if (keywords.InList(s)) { if (keywords.InList(s)) {
chAttr = SCE_H_TAG; chAttr = SCE_H_TAG;
} isScript = 0 == strcmp(s, "script");
if (0 == strcmp(s, "script")) {
chAttr = SCE_H_SCRIPT;
} }
} }
if ((chAttr == SCE_H_TAGUNKNOWN) && !keywords) if ((chAttr == SCE_H_TAGUNKNOWN) && !keywords)
// No keywords -> all are known // No keywords -> all are known
chAttr = SCE_H_TAG; chAttr = SCE_H_TAG;
styler.ColourTo(end, chAttr); styler.ColourTo(end, chAttr);
return chAttr; return isScript ? SCE_H_SCRIPT : chAttr;
} }
static void classifyWordHTJS(unsigned int start, unsigned int end, static void classifyWordHTJS(unsigned int start, unsigned int end,
@@ -295,6 +343,17 @@ static bool isLineEnd(char ch) {
return ch == '\r' || ch == '\n'; return ch == '\r' || ch == '\n';
} }
static bool isOKBeforeRE(char ch) {
return (ch == '(') || (ch == '=') || (ch == ',');
}
static bool isPHPStringState(int state) {
return
(state == SCE_HPHP_HSTRING) ||
(state == SCE_HPHP_SIMPLESTRING) ||
(state == SCE_HPHP_HSTRING_VARIABLE);
}
static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) { Accessor &styler) {
@@ -313,8 +372,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
// If inside a tag, it may be a script tag, so reread from the start to ensure any language tags are seen // If inside a tag, it may be a script tag, so reread from the start to ensure any language tags are seen
if (InTagState(state)) { if (InTagState(state)) {
while ((startPos > 1) && (InTagState(styler.StyleAt(startPos - 1)))) { while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) {
startPos--; startPos--;
length++;
} }
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
} }
@@ -324,25 +384,36 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) if (lineCurrent > 0)
lineState = styler.GetLineState(lineCurrent); lineState = styler.GetLineState(lineCurrent);
int inScriptType = (lineState >> 0) & 0x03; // 2 bits int inScriptType = (lineState >> 0) & 0x03; // 2 bits of scripting type
int defaultScript = (lineState >> 4) & 0x0F; // 4 bits bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
int beforePreProc = (lineState >> 8) & 0xFF; // 8 bits bool tagClosing = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
int defaultScript = (lineState >> 4) & 0x0F; // 4 bits of script name
int beforePreProc = (lineState >> 8) & 0xFF; // 8 bits of state
// int scriptLanguage = ScriptOfState(state,defaultScript);
int scriptLanguage = ScriptOfState(state); int scriptLanguage = ScriptOfState(state);
bool fold = styler.GetPropertyInt("fold"); bool fold = styler.GetPropertyInt("fold");
bool foldHTML = styler.GetPropertyInt("fold.html",0);
bool foldCompact = styler.GetPropertyInt("fold.compact",1);
fold = foldHTML && fold;
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev; int levelCurrent = levelPrev;
int visibleChars = 0; int visibleChars;
visibleChars = 0;
char chPrev = ' '; char chPrev = ' ';
char ch = ' '; char ch = ' ';
char chPrevNonWhite = ' ';
styler.StartSegment(startPos); styler.StartSegment(startPos);
int lengthDoc = startPos + length; int lengthDoc = startPos + length;
for (int i = startPos; i < lengthDoc; i++) { for (int i = startPos; i < lengthDoc; i++) {
char chPrev2 = chPrev; char chPrev2 = chPrev;
chPrev = ch; chPrev = ch;
if (ch != ' ' && ch != '\t')
chPrevNonWhite = ch;
ch = styler[i]; ch = styler[i];
char chNext = styler.SafeGetCharAt(i + 1); char chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2); char chNext2 = styler.SafeGetCharAt(i + 2);
@@ -354,40 +425,44 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
continue; continue;
} }
if (fold && !isspace(ch)) if ((!isspacechar(ch) || !foldCompact) && fold)
visibleChars++; visibleChars++;
// decide what is the current state to print (depending of the script tag)
StateToPrint = statePrintForState(state, inScriptType);
// handle script folding // handle script folding
if (fold) { if (fold) {
switch (scriptLanguage) { switch (scriptLanguage) {
case eScriptJS: case eScriptJS:
case eScriptPHP: case eScriptPHP:
//not currently supported case eScriptVBS: //not currently supported case eScriptVBS:
if ((state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENTLINE) && (state != SCE_HJ_COMMENT) && (state != SCE_HJ_COMMENTLINE) && (state != SCE_HJ_COMMENTDOC)) { if ((state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENTLINE) && (state != SCE_HJ_COMMENT) && (state != SCE_HJ_COMMENTLINE) && (state != SCE_HJ_COMMENTDOC)) {
if ((ch == '{') || (ch == '}')) { if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1; levelCurrent += (ch == '{') ? 1 : -1;
} }
} }
break; break;
case eScriptPython: case eScriptPython:
if (state != SCE_HP_COMMENTLINE) { if (state != SCE_HP_COMMENTLINE) {
if ((ch == ':') && ((chNext == '\n') || (chNext == '\r' && chNext2 == '\n'))) { if ((ch == ':') && ((chNext == '\n') || (chNext == '\r' && chNext2 == '\n'))) {
levelCurrent++; levelCurrent++;
} else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) { } else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) {
// check if the number of tabs is lower than the level // check if the number of tabs is lower than the level
int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8; int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8;
for (int j = 0;Findlevel > 0;j++) { for (int j = 0;Findlevel > 0;j++) {
char chTmp = styler.SafeGetCharAt(i + j + 1); char chTmp = styler.SafeGetCharAt(i + j + 1);
if (chTmp == '\t') { if (chTmp == '\t') {
Findlevel -= 8; Findlevel -= 8;
} else if (chTmp == ' ') { } else if (chTmp == ' ') {
Findlevel--; Findlevel--;
} else break; } else break;
} }
if (Findlevel > 0) { if (Findlevel > 0) {
levelCurrent -= Findlevel / 8; levelCurrent -= Findlevel / 8;
if (Findlevel % 8) levelCurrent--; if (Findlevel % 8) levelCurrent--;
} }
} }
} }
@@ -395,9 +470,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
} }
// decide what is the current state to print (depending of the script tag)
StateToPrint = statePrintForState(state, inScriptType);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win // Avoid triggering two times on Dos/Win
@@ -408,13 +480,16 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
lev |= SC_FOLDLEVELWHITEFLAG; lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0)) if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG; lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev); styler.SetLevel(lineCurrent, lev);
visibleChars = 0; visibleChars = 0;
levelPrev = levelCurrent; levelPrev = levelCurrent;
} }
lineCurrent++; lineCurrent++;
styler.SetLineState(lineCurrent, styler.SetLineState(lineCurrent,
((inScriptType & 0x03) << 0) | ((inScriptType & 0x03) << 0) |
((tagOpened & 0x01) << 2) |
((tagClosing & 0x01) << 3) |
((defaultScript & 0x0F) << 4) | ((defaultScript & 0x0F) << 4) |
((beforePreProc & 0xFF) << 8)); ((beforePreProc & 0xFF) << 8));
} }
@@ -428,7 +503,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
case SCE_H_SINGLESTRING: case SCE_H_SINGLESTRING:
case SCE_HJ_COMMENT: case SCE_HJ_COMMENT:
case SCE_HJ_COMMENTDOC: case SCE_HJ_COMMENTDOC:
case SCE_HJ_COMMENTLINE: // SCE_HJ_COMMENTLINE removed as this is a common thing done to hide
// the end of script marker from some JS interpreters.
//case SCE_HJ_COMMENTLINE:
case SCE_HJ_DOUBLESTRING: case SCE_HJ_DOUBLESTRING:
case SCE_HJ_SINGLESTRING: case SCE_HJ_SINGLESTRING:
case SCE_HB_STRING: case SCE_HB_STRING:
@@ -438,19 +515,24 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
break; break;
default : default :
// maybe we should check here if it's a tag and if it's SCRIPT // maybe we should check here if it's a tag and if it's SCRIPT
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
state = SCE_H_TAGUNKNOWN; state = SCE_H_TAGUNKNOWN;
inScriptType = eHtml; inScriptType = eHtml;
scriptLanguage = eScriptNone; scriptLanguage = eScriptNone;
i += 2; i += 2;
// unfold closing script
levelCurrent--;
continue; continue;
} }
} }
///////////////////////////////////// /////////////////////////////////////
// handle the start of PHP pre-processor = Non-HTML // handle the start of PHP pre-processor = Non-HTML
else if ((ch == '<') && (chNext == '?')) { else if ((state != SCE_H_ASPAT) &&
!isPHPStringState(state) &&
(state != SCE_HPHP_COMMENT) &&
(ch == '<') &&
(chNext == '?')) {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
beforePreProc = state; beforePreProc = state;
scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP); scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP);
@@ -465,11 +547,17 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
inScriptType = eNonHtmlScriptPreProc; inScriptType = eNonHtmlScriptPreProc;
else else
inScriptType = eNonHtmlPreProc; inScriptType = eNonHtmlPreProc;
// fold whole script
levelCurrent++;
if (scriptLanguage == eScriptXML)
levelCurrent--; // no folding of the XML first tag (all XML-like tags in this case)
// should be better
ch = styler.SafeGetCharAt(i);
continue; continue;
} }
// handle the start of ASP pre-processor = Non-HTML // handle the start of ASP pre-processor = Non-HTML
else if ((ch == '<') && (chNext == '%')) { else if (!isCommentASPState(state) && (ch == '<') && (chNext == '%')) {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
beforePreProc = state; beforePreProc = state;
if (inScriptType == eNonHtmlScript) if (inScriptType == eNonHtmlScript)
@@ -480,25 +568,40 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
if (chNext2 == '@') { if (chNext2 == '@') {
i += 2; // place as if it was the second next char treated i += 2; // place as if it was the second next char treated
state = SCE_H_ASPAT; state = SCE_H_ASPAT;
} else if ((chNext2 == '-') && (styler.SafeGetCharAt(i + 3) == '-')) {
styler.ColourTo(i + 3, SCE_H_ASP);
state = SCE_H_XCCOMMENT;
scriptLanguage = eScriptVBS;
continue;
} else { } else {
if (chNext2 == '=') { if (chNext2 == '=') {
i += 2; // place as if it was the second next char treated i += 2; // place as if it was the second next char treated
} } else {
else {
i++; // place as if it was the next char treated i++; // place as if it was the next char treated
} }
state = StateForScript(defaultScript); state = StateForScript(defaultScript);
} }
scriptLanguage = eScriptVBS;
styler.ColourTo(i, SCE_H_ASP); styler.ColourTo(i, SCE_H_ASP);
// fold whole script
levelCurrent++;
// should be better
ch = styler.SafeGetCharAt(i);
continue; continue;
} }
// handle the end of a pre-processor = Non-HTML // handle the end of a pre-processor = Non-HTML
else if (((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && ((ch == '?') || (ch == '%')) && (chNext == '>')) { else if (
((inScriptType == eNonHtmlPreProc)
|| (inScriptType == eNonHtmlScriptPreProc)) && (
((scriptLanguage == eScriptPHP) && (ch == '?') && !isPHPStringState(state) && (state != SCE_HPHP_COMMENT)) ||
((scriptLanguage != eScriptNone) && !isStringState(state) &&
(ch == '%'))
) && (chNext == '>')) {
if (state == SCE_H_ASPAT) { if (state == SCE_H_ASPAT) {
defaultScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, defaultScript); defaultScript = segIsScriptingIndicator(styler,
styler.GetStartSegment(), i - 1, defaultScript);
} }
// Bounce out of any ASP mode // Bounce out of any ASP mode
switch (state) { switch (state) {
@@ -514,6 +617,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
case SCE_HPHP_WORD: case SCE_HPHP_WORD:
classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler); classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler);
break; break;
case SCE_H_XCCOMMENT:
styler.ColourTo(i - 1, state);
break;
default : default :
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
break; break;
@@ -531,6 +637,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
else else
inScriptType = eHtml; inScriptType = eHtml;
scriptLanguage = eScriptNone; scriptLanguage = eScriptNone;
// unfold all scripting languages
levelCurrent--;
continue; continue;
} }
///////////////////////////////////// /////////////////////////////////////
@@ -538,10 +646,21 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
switch (state) { switch (state) {
case SCE_H_DEFAULT: case SCE_H_DEFAULT:
if (ch == '<') { if (ch == '<') {
// in HTML, fold on tag open and unfold on tag close
tagOpened = true;
if (chNext == '/') {
tagClosing = true;
} else {
tagClosing = false;
}
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
if (chNext == '!' && chNext2 == '-' && styler.SafeGetCharAt(i + 3) == '-') if (chNext == '!' && chNext2 == '-' && styler.SafeGetCharAt(i + 3) == '-') {
// should be better
i += 3;
levelCurrent++;
state = SCE_H_COMMENT; state = SCE_H_COMMENT;
else } else
state = SCE_H_TAGUNKNOWN; state = SCE_H_TAGUNKNOWN;
} else if (ch == '&') { } else if (ch == '&') {
styler.ColourTo(i - 1, SCE_H_DEFAULT); styler.ColourTo(i - 1, SCE_H_DEFAULT);
@@ -550,14 +669,26 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
break; break;
case SCE_H_COMMENT: case SCE_H_COMMENT:
if ((ch == '>') && (chPrev == '-') && (chPrev2 == '-')) { if ((ch == '>') && (chPrev == '-') && (chPrev2 == '-')) {
// unfold HTML comment
levelCurrent--;
styler.ColourTo(i, StateToPrint); styler.ColourTo(i, StateToPrint);
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
tagOpened = false;
} }
break; break;
case SCE_H_CDATA: case SCE_H_CDATA:
if ((ch == '>') && (chPrev == ']') && (chPrev2 == ']')) { if ((ch == '>') && (chPrev == ']') && (chPrev2 == ']')) {
styler.ColourTo(i, StateToPrint); styler.ColourTo(i, StateToPrint);
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
tagOpened = false;
}
break;
case SCE_H_SGML:
if (ch == '>') {
levelCurrent--;
styler.ColourTo(i, StateToPrint);
state = SCE_H_DEFAULT;
tagOpened = false;
} }
break; break;
case SCE_H_ENTITY: case SCE_H_ENTITY:
@@ -571,7 +702,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
break; break;
case SCE_H_TAGUNKNOWN: case SCE_H_TAGUNKNOWN:
if (!ishtmlwordchar(ch) && ch != '/' && ch != '-' && ch != '[') { if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {
int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler); int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler);
if (eClass == SCE_H_SCRIPT) { if (eClass == SCE_H_SCRIPT) {
inScriptType = eNonHtmlScript; inScriptType = eNonHtmlScript;
@@ -579,17 +710,38 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
eClass = SCE_H_TAG; eClass = SCE_H_TAG;
} }
if (ch == '>') { if (ch == '>') {
styler.ColourTo(i, SCE_H_TAG); styler.ColourTo(i, eClass);
if (inScriptType == eNonHtmlScript) { if (inScriptType == eNonHtmlScript) {
state = StateForScript(scriptLanguage); state = StateForScript(scriptLanguage);
} else { } else {
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
} }
} else { tagOpened = false;
if (eClass == SCE_H_CDATA) { if (tagClosing)
state = SCE_H_CDATA; levelCurrent--;
else
levelCurrent++;
tagClosing = false;
} else if (ch == '/' && chNext == '>') {
if (eClass == SCE_H_TAGUNKNOWN) {
styler.ColourTo(i + 1, SCE_H_TAGUNKNOWN);
} else { } else {
state = SCE_H_OTHER; styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i + 1, SCE_H_TAGEND);
}
i++;
ch = chNext;
state = SCE_H_DEFAULT;
tagOpened = false;
} else {
if (eClass != SCE_H_TAGUNKNOWN) {
if (eClass == SCE_H_CDATA) {
state = SCE_H_CDATA;
} else if (eClass == SCE_H_SGML) {
state = SCE_H_SGML;
} else {
state = SCE_H_OTHER;
}
} }
} }
} }
@@ -597,7 +749,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
case SCE_H_ATTRIBUTE: case SCE_H_ATTRIBUTE:
if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') { if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
if (inScriptType == eNonHtmlScript) { if (inScriptType == eNonHtmlScript) {
int scriptLanguagePrev = scriptLanguage;
scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage); scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
if ((scriptLanguagePrev != scriptLanguage) && (scriptLanguage == eScriptNone))
inScriptType = eHtml;
} }
classifyAttribHTML(styler.GetStartSegment(), i - 1, keywords, styler); classifyAttribHTML(styler.GetStartSegment(), i - 1, keywords, styler);
if (ch == '>') { if (ch == '>') {
@@ -607,6 +762,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else { } else {
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
} }
tagOpened = false;
if (tagClosing)
levelCurrent--;
else
levelCurrent++;
tagClosing = false;
} else if (ch == '=') { } else if (ch == '=') {
styler.ColourTo(i, SCE_H_OTHER); styler.ColourTo(i, SCE_H_OTHER);
state = SCE_H_VALUE; state = SCE_H_VALUE;
@@ -624,6 +785,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else { } else {
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
} }
tagOpened = false;
if (tagClosing)
levelCurrent--;
else
levelCurrent++;
tagClosing = false;
} else if (ch == '\"') { } else if (ch == '\"') {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
state = SCE_H_DOUBLESTRING; state = SCE_H_DOUBLESTRING;
@@ -639,6 +806,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
i++; i++;
ch = chNext; ch = chNext;
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
tagOpened = false;
} else if (ch == '?' && chNext == '>') { } else if (ch == '?' && chNext == '>') {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i + 1, SCE_H_XMLEND); styler.ColourTo(i + 1, SCE_H_XMLEND);
@@ -688,6 +856,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else { } else {
state = SCE_H_DEFAULT; state = SCE_H_DEFAULT;
} }
tagOpened = false;
if (tagClosing)
levelCurrent--;
else
levelCurrent++;
tagClosing = false;
} else { } else {
state = SCE_H_OTHER; state = SCE_H_OTHER;
} }
@@ -709,6 +883,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if (ch == '/' && chNext == '/') { } else if (ch == '/' && chNext == '/') {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_COMMENTLINE; state = SCE_HJ_COMMENTLINE;
} else if (ch == '/' && isOKBeforeRE(chPrevNonWhite)) {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_REGEX;
} else if (ch == '\"') { } else if (ch == '\"') {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_DOUBLESTRING; state = SCE_HJ_DOUBLESTRING;
@@ -781,8 +958,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if (ch == '\"') { } else if (ch == '\"') {
styler.ColourTo(i, statePrintForState(SCE_HJ_DOUBLESTRING, inScriptType)); styler.ColourTo(i, statePrintForState(SCE_HJ_DOUBLESTRING, inScriptType));
state = SCE_HJ_DEFAULT; state = SCE_HJ_DEFAULT;
i++;
ch = chNext;
} else if ((inScriptType == eNonHtmlScript) && (ch == '-') && (chNext == '-') && (chNext2 == '>')) { } else if ((inScriptType == eNonHtmlScript) && (ch == '-') && (chNext == '-') && (chNext2 == '>')) {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_COMMENTLINE; state = SCE_HJ_COMMENTLINE;
@@ -800,8 +975,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if (ch == '\'') { } else if (ch == '\'') {
styler.ColourTo(i, statePrintForState(SCE_HJ_SINGLESTRING, inScriptType)); styler.ColourTo(i, statePrintForState(SCE_HJ_SINGLESTRING, inScriptType));
state = SCE_HJ_DEFAULT; state = SCE_HJ_DEFAULT;
i++;
ch = chNext;
} else if ((inScriptType == eNonHtmlScript) && (ch == '-') && (chNext == '-') && (chNext2 == '>')) { } else if ((inScriptType == eNonHtmlScript) && (ch == '-') && (chNext == '-') && (chNext2 == '>')) {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_COMMENTLINE; state = SCE_HJ_COMMENTLINE;
@@ -820,6 +993,19 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJ_DEFAULT; state = SCE_HJ_DEFAULT;
} }
break; break;
case SCE_HJ_REGEX:
if (ch == '\r' || ch == '\n' || ch == '/') {
styler.ColourTo(i, StateToPrint);
state = SCE_HJ_DEFAULT;
} else if (ch == '\\') {
// Gobble up the quoted character
if (chNext == '\\' || chNext == '/') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
break;
case SCE_HB_DEFAULT: case SCE_HB_DEFAULT:
case SCE_HB_START: case SCE_HB_START:
if (iswordstart(ch)) { if (iswordstart(ch)) {
@@ -837,7 +1023,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HB_COMMENTLINE; state = SCE_HB_COMMENTLINE;
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i, SCE_HB_DEFAULT); styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType));
state = SCE_HB_DEFAULT; state = SCE_HB_DEFAULT;
} else if ((ch == ' ') || (ch == '\t')) { } else if ((ch == ' ') || (ch == '\t')) {
if (state == SCE_HB_START) { if (state == SCE_HB_START) {
@@ -865,8 +1051,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
if (ch == '\"') { if (ch == '\"') {
styler.ColourTo(i, StateToPrint); styler.ColourTo(i, StateToPrint);
state = SCE_HB_DEFAULT; state = SCE_HB_DEFAULT;
i++;
ch = chNext;
} else if (ch == '\r' || ch == '\n') { } else if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
state = SCE_HB_STRINGEOL; state = SCE_HB_STRINGEOL;
@@ -1023,6 +1207,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HPHP_SIMPLESTRING; state = SCE_HPHP_SIMPLESTRING;
} else if (ch == '$') { } else if (ch == '$') {
state = SCE_HPHP_VARIABLE; state = SCE_HPHP_VARIABLE;
} else if (isoperator(ch)) {
state = SCE_HPHP_OPERATOR;
} else { } else {
state = SCE_HPHP_DEFAULT; state = SCE_HPHP_DEFAULT;
} }
@@ -1031,13 +1217,19 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
case SCE_HPHP_NUMBER: case SCE_HPHP_NUMBER:
if (!isdigit(ch)) { if (!isdigit(ch)) {
styler.ColourTo(i - 1, SCE_HPHP_NUMBER); styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
state = SCE_HPHP_DEFAULT; if (isoperator(ch))
state =SCE_HPHP_OPERATOR;
else
state = SCE_HPHP_DEFAULT;
} }
break; break;
case SCE_HPHP_VARIABLE: case SCE_HPHP_VARIABLE:
if (!iswordstart(ch)) { if (!iswordstart(ch)) {
styler.ColourTo(i - 1, SCE_HPHP_VARIABLE); styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
state = SCE_HPHP_DEFAULT; if (isoperator(ch))
state =SCE_HPHP_OPERATOR;
else
state = SCE_HPHP_DEFAULT;
} }
break; break;
case SCE_HPHP_COMMENT: case SCE_HPHP_COMMENT:
@@ -1054,20 +1246,34 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
break; break;
case SCE_HPHP_HSTRING: case SCE_HPHP_HSTRING:
if (ch == '\\') { if (ch == '\\') {
// skip the next char // skip the next char
i++; i++;
} else if (ch == '$') {
styler.ColourTo(i-1, StateToPrint);
state = SCE_HPHP_HSTRING_VARIABLE;
} else if (ch == '\"') { } else if (ch == '\"') {
styler.ColourTo(i, StateToPrint); styler.ColourTo(i, StateToPrint);
state = SCE_HPHP_DEFAULT; state = SCE_HPHP_DEFAULT;
} }
break; break;
case SCE_HPHP_SIMPLESTRING: case SCE_HPHP_SIMPLESTRING:
if (ch == '\'') { if (ch == '\\') {
// skip the next char
i++;
} else if (ch == '\'') {
styler.ColourTo(i, StateToPrint); styler.ColourTo(i, StateToPrint);
state = SCE_HPHP_DEFAULT; state = SCE_HPHP_DEFAULT;
} }
break; break;
case SCE_HPHP_DEFAULT: case SCE_HPHP_HSTRING_VARIABLE:
if (!iswordstart(ch)) {
styler.ColourTo(i-1, StateToPrint);
i--; // strange but it works
state = SCE_HPHP_HSTRING;
}
break;
case SCE_HPHP_OPERATOR:
case SCE_HPHP_DEFAULT:
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
if (isdigit(ch)) { if (isdigit(ch)) {
state = SCE_HPHP_NUMBER; state = SCE_HPHP_NUMBER;
@@ -1087,15 +1293,20 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HPHP_SIMPLESTRING; state = SCE_HPHP_SIMPLESTRING;
} else if (ch == '$') { } else if (ch == '$') {
state = SCE_HPHP_VARIABLE; state = SCE_HPHP_VARIABLE;
} else if (isoperator(ch)) {
state = SCE_HPHP_OPERATOR;
} else if ((state == SCE_HPHP_OPERATOR) && (isspacechar(ch))) {
state = SCE_HPHP_DEFAULT;
} }
break; break;
///////////// end - PHP state handling ///////////// end - PHP state handling
} }
// Some of the above terminated their lexeme but since the same character starts
// the same class again, only reenter if non empty segment.
bool nonEmptySegment = i >= static_cast<int>(styler.GetStartSegment());
if (state == SCE_HB_DEFAULT) { // One of the above succeeded if (state == SCE_HB_DEFAULT) { // One of the above succeeded
if (ch == '\"') { if ((ch == '\"') && (nonEmptySegment)) {
state = SCE_HB_STRING; state = SCE_HB_STRING;
} else if (ch == '\'') { } else if (ch == '\'') {
state = SCE_HB_COMMENTLINE; state = SCE_HB_COMMENTLINE;
@@ -1105,7 +1316,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, SCE_HB_DEFAULT); styler.ColourTo(i, SCE_HB_DEFAULT);
} }
} else if (state == SCE_HBA_DEFAULT) { // One of the above succeeded } else if (state == SCE_HBA_DEFAULT) { // One of the above succeeded
if (ch == '\"') { if ((ch == '\"') && (nonEmptySegment)) {
state = SCE_HBA_STRING; state = SCE_HBA_STRING;
} else if (ch == '\'') { } else if (ch == '\'') {
state = SCE_HBA_COMMENTLINE; state = SCE_HBA_COMMENTLINE;
@@ -1122,14 +1333,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJ_COMMENT; state = SCE_HJ_COMMENT;
} else if (ch == '/' && chNext == '/') { } else if (ch == '/' && chNext == '/') {
state = SCE_HJ_COMMENTLINE; state = SCE_HJ_COMMENTLINE;
} else if (ch == '\"') { } else if ((ch == '\"') && (nonEmptySegment)) {
state = SCE_HJ_DOUBLESTRING; state = SCE_HJ_DOUBLESTRING;
} else if (ch == '\'') { } else if ((ch == '\'') && (nonEmptySegment)) {
state = SCE_HJ_SINGLESTRING; state = SCE_HJ_SINGLESTRING;
} else if (iswordstart(ch)) { } else if (iswordstart(ch)) {
state = SCE_HJ_WORD; state = SCE_HJ_WORD;
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
styler.ColourTo(i, SCE_HJ_SYMBOLS); styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType));
} }
} }
} }
@@ -1140,12 +1351,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
// Fill in the real level of the next line, keeping the current flags as they will be filled in later // Fill in the real level of the next line, keeping the current flags as they will be filled in later
if (fold) { if (fold) {
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
//styler.SetLevel(lineCurrent, levelCurrent | flagsNext);
styler.SetLevel(lineCurrent, levelPrev | flagsNext); styler.SetLevel(lineCurrent, levelPrev | flagsNext);
} }
} }
LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc); LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc); LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");

View File

@@ -0,0 +1,195 @@
// Scintilla source code edit control
/** @file LexLisp.cxx
** Lexer for Lisp.
** Written by Alexey Yutkin.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
inline bool isLispoperator(char ch) {
if (isascii(ch) && isalnum(ch))
return false;
if (ch == '\'' || ch == '(' || ch == ')' )
return true;
return false;
}
inline bool isLispwordstart(char ch) {
return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) &&
ch != '\n' && ch != '\r' && ch != '\"';
}
static void classifyWordLisp(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
PLATFORM_ASSERT(end >= start);
char s[100];
unsigned int i;
bool digit_flag = true;
for (i = 0; (i < end - start + 1) && (i < 99); i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
if (!isdigit(s[i]) && (s[i] != '.')) digit_flag = false;
}
char chAttr = SCE_LISP_IDENTIFIER;
if(digit_flag) chAttr = SCE_LISP_NUMBER;
else {
if (keywords.InList(s)) {
chAttr = SCE_LISP_KEYWORD;
}
}
styler.ColourTo(end, chAttr);
return;
}
static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
int state = initStyle;
if (state == SCE_LISP_STRINGEOL) // Does not leak onto next line
state = SCE_LISP_DEFAULT;
char chPrev = ' ';
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
styler.StartSegment(startPos);
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (atEOL) {
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
// End of line
if (state == SCE_LISP_STRINGEOL) {
styler.ColourTo(i, state);
state = SCE_LISP_DEFAULT;
}
}
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_LISP_DEFAULT) {
if (isLispwordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_LISP_IDENTIFIER;
}
else if (ch == ';') {
styler.ColourTo(i - 1, state);
state = SCE_LISP_COMMENT;
}
else if (isLispoperator(ch) || ch=='\'') {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_LISP_OPERATOR);
}
else if (ch == '\"') {
state = SCE_LISP_STRING;
}
} else if (state == SCE_LISP_IDENTIFIER) {
if (!isLispwordstart(ch)) {
classifyWordLisp(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_LISP_DEFAULT;
} /*else*/
if (isLispoperator(ch) || ch=='\'') {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_LISP_OPERATOR);
}
} else {
if (state == SCE_LISP_COMMENT) {
if (atEOL) {
styler.ColourTo(i - 1, state);
state = SCE_LISP_DEFAULT;
}
} else if (state == SCE_LISP_STRING) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_LISP_DEFAULT;
} else if ((chNext == '\r' || chNext == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, SCE_LISP_STRINGEOL);
state = SCE_LISP_STRINGEOL;
}
}
}
chPrev = ch;
}
styler.ColourTo(lengthDoc - 1, state);
}
static void FoldLispDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[],
Accessor &styler) {
unsigned int lengthDoc = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (style == SCE_LISP_OPERATOR) {
if (ch == '(') {
levelCurrent++;
} else if (ch == ')') {
levelCurrent--;
}
}
if (atEOL) {
int lev = levelPrev;
if (visibleChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
levelPrev = levelCurrent;
visibleChars = 0;
}
if (!isspacechar(ch))
visibleChars++;
}
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
}
LexerModule lmLISP(SCLEX_LISP, ColouriseLispDoc, "lisp", FoldLispDoc);

View File

@@ -1,5 +1,10 @@
// LexLua.cxx - lexer for Lua language // Scintilla source code edit control
// Written by Paul Winwood /** @file LexLua.cxx
** Lexer for Lua language.
**
** Written by Paul Winwood.
** Folder by Alexey Yutkin.
**/
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -16,283 +21,261 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
static void classifyWordLua(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) inline bool isLuaOperator(char ch) {
{ if (isalnum(ch))
char s[100]; return false;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); // '.' left out as it is used to make up numbers
if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) ch == '(' || ch == ')' || ch == '=' ||
{ ch == '{' || ch == '}' || ch == '~' ||
s[i] = styler[start + i]; ch == '[' || ch == ']' || ch == ';' ||
s[i + 1] = '\0'; ch == '<' || ch == '>' || ch == ',' ||
} ch == '.' || ch == '^' || ch == '%' || ch == ':')
return true;
char chAttr = SCE_LUA_IDENTIFIER; return false;
if (wordIsNumber)
chAttr = SCE_LUA_NUMBER;
else
{
if (keywords.InList(s))
{
chAttr = SCE_LUA_WORD;
}
}
styler.ColourTo(end, chAttr);
} }
static void ColouriseLuaDoc(unsigned int startPos, static void classifyWordLua(unsigned int start,
int length, unsigned int end,
int initStyle, WordList &keywords,
WordList *keywordlists[], Accessor &styler) {
Accessor &styler) char s[100];
{ bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
WordList &keywords = *keywordlists[0]; for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
}
styler.StartAt(startPos); char chAttr = SCE_LUA_IDENTIFIER;
styler.GetLine(startPos);
int state = initStyle; if (wordIsNumber)
char chPrev = ' '; chAttr = SCE_LUA_NUMBER;
char chNext = styler[startPos]; else {
unsigned int lengthDoc = startPos + length; if (keywords.InList(s)) {
bool firstChar = true; chAttr = SCE_LUA_WORD;
int literalString = 0; }
}
styler.StartSegment(startPos); styler.ColourTo(end, chAttr);
for (unsigned int i = startPos; i <= lengthDoc; i++)
{
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if (styler.IsLeadByte(ch))
{
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_LUA_STRINGEOL)
{
if (ch != '\r' && ch != '\n')
{
styler.ColourTo(i-1, state);
state = SCE_LUA_DEFAULT;
}
}
if (state == SCE_LUA_LITERALSTRING && ch == '[' && chNext == '[')
{
literalString++;
}
else
if (state == SCE_LUA_DEFAULT)
{
if (ch == '-' && chNext == '-')
{
styler.ColourTo(i-1, state);
state = SCE_LUA_COMMENTLINE;
}
else
if (ch == '[' && chNext == '[')
{
state = SCE_LUA_LITERALSTRING;
literalString = 1;
}
else
if (iswordstart(ch))
{
styler.ColourTo(i-1, state);
state = SCE_LUA_WORD;
}
else
if (ch == '\"')
{
styler.ColourTo(i-1, state);
state = SCE_LUA_STRING;
}
else
if (ch == '\'')
{
styler.ColourTo(i-1, state);
state = SCE_LUA_CHARACTER;
}
else
if (ch == '$' && firstChar)
{
styler.ColourTo(i-1, state);
state = SCE_LUA_PREPROCESSOR;
}
else
if (isoperator(ch))
{
styler.ColourTo(i-1, state);
styler.ColourTo(i, SCE_LUA_OPERATOR);
}
}
else
if (state == SCE_LUA_WORD)
{
if (!iswordchar(ch))
{
classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_LUA_DEFAULT;
if (ch == '[' && chNext == '[')
{
literalString = 1;
state = SCE_LUA_LITERALSTRING;
}
else
if (ch == '-' && chNext == '-')
{
state = SCE_LUA_COMMENTLINE;
}
else
if (ch == '\"')
{
state = SCE_LUA_STRING;
}
else
if (ch == '\'')
{
state = SCE_LUA_CHARACTER;
}
else
if (ch == '$' && firstChar)
{
state = SCE_LUA_PREPROCESSOR;
}
else
if (isoperator(ch))
{
styler.ColourTo(i, SCE_LUA_OPERATOR);
}
}
}
else
{
if (state == SCE_LUA_LITERALSTRING)
{
if (ch == ']' && (chPrev == ']') && (--literalString == 0))
{
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
}
}
else
if (state == SCE_LUA_PREPROCESSOR)
{
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
{
styler.ColourTo(i-1, state);
state = SCE_LUA_DEFAULT;
}
}
else
if (state == SCE_LUA_COMMENTLINE)
{
if (ch == '\r' || ch == '\n')
{
styler.ColourTo(i-1, state);
state = SCE_LUA_DEFAULT;
}
}
else
if (state == SCE_LUA_STRING)
{
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
{
styler.ColourTo(i-1, state);
state = SCE_LUA_STRINGEOL;
}
else
if (ch == '\\')
{
if (chNext == '\"' || chNext == '\\')
{
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
else
if (ch == '\"')
{
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
else
if (state == SCE_LUA_CHARACTER)
{
if ((ch == '\r' || ch == '\n') && (chPrev != '\\'))
{
styler.ColourTo(i-1, state);
state = SCE_LUA_STRINGEOL;
}
else
if (ch == '\\')
{
if (chNext == '\'' || chNext == '\\')
{
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
else
if (ch == '\'')
{
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
if (state == SCE_LUA_DEFAULT)
{
if (ch == '-' && chNext == '-')
{
state = SCE_LUA_COMMENTLINE;
}
else
if (ch == '\"')
{
state = SCE_LUA_STRING;
}
else
if (ch == '\'')
{
state = SCE_LUA_CHARACTER;
}
else
if (ch == '$' && firstChar)
{
state = SCE_LUA_PREPROCESSOR;
}
else
if (iswordstart(ch))
{
state = SCE_LUA_WORD;
}
else
if (isoperator(ch))
{
styler.ColourTo(i, SCE_LUA_OPERATOR);
}
}
}
chPrev = ch;
firstChar = (ch == '\r' || ch == '\n');
}
styler.ColourTo(lengthDoc - 1, state);
} }
LexerModule lmLua(SCLEX_LUA, ColouriseLuaDoc); static void ColouriseLuaDoc(unsigned int startPos,
int length,
int initStyle,
WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
styler.GetLine(startPos);
int state = initStyle;
char chPrev = ' ';
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
bool firstChar = true;
/* Must initialize the literalString level, if we are inside such a string.
* Note: this isn't enough, because literal strings can be nested,
* we should go back to see at what level we are...
*/
int literalString = (initStyle == SCE_LUA_LITERALSTRING) ? 1 : 0;
styler.StartSegment(startPos);
for (unsigned int i = startPos; i <= lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_LUA_STRINGEOL) {
if (ch != '\r' && ch != '\n') {
styler.ColourTo(i - 1, state);
state = SCE_LUA_DEFAULT;
}
}
if (state == SCE_LUA_LITERALSTRING && ch == '[' && chNext == '[') {
literalString++;
} else if (state == SCE_LUA_DEFAULT) {
if (ch == '-' && chNext == '-') {
styler.ColourTo(i - 1, state);
state = SCE_LUA_COMMENTLINE;
} else if (ch == '[' && chNext == '[') {
state = SCE_LUA_LITERALSTRING;
literalString = 1;
} else if (ch == '\"') {
styler.ColourTo(i - 1, state);
state = SCE_LUA_STRING;
} else if (ch == '\'') {
styler.ColourTo(i - 1, state);
state = SCE_LUA_CHARACTER;
} else if (ch == '$' && firstChar) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_PREPROCESSOR;
} else if (ch == '#' && firstChar) // Should be only on the first line of the file! Cannot be tested here
{
styler.ColourTo(i - 1, state);
state = SCE_LUA_COMMENTLINE;
} else if (isLuaOperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_LUA_OPERATOR);
} else if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_WORD;
}
} else if (state == SCE_LUA_WORD) {
if (!iswordchar(ch)) {
classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_LUA_DEFAULT;
if (ch == '[' && chNext == '[') {
literalString = 1;
state = SCE_LUA_LITERALSTRING;
} else if (ch == '-' && chNext == '-') {
state = SCE_LUA_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_LUA_STRING;
} else if (ch == '\'') {
state = SCE_LUA_CHARACTER;
} else if (ch == '$' && firstChar) {
state = SCE_LUA_PREPROCESSOR;
} else if (isLuaOperator(ch)) {
styler.ColourTo(i, SCE_LUA_OPERATOR);
}
} else if (ch == '.' && chNext == '.') {
classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
styler.ColourTo(i, SCE_LUA_OPERATOR);
state = SCE_LUA_DEFAULT;
}
} else {
if (state == SCE_LUA_LITERALSTRING) {
if (ch == ']' && (chPrev == ']') && (--literalString == 0)) {
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
}
} else if (state == SCE_LUA_PREPROCESSOR) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_DEFAULT;
}
} else if (state == SCE_LUA_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_LUA_DEFAULT;
}
} else if (state == SCE_LUA_STRING) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_LUA_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
if (state == SCE_LUA_DEFAULT) {
if (ch == '-' && chNext == '-') {
state = SCE_LUA_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_LUA_STRING;
} else if (ch == '\'') {
state = SCE_LUA_CHARACTER;
} else if (ch == '$' && firstChar) {
state = SCE_LUA_PREPROCESSOR;
} else if (iswordstart(ch)) {
state = SCE_LUA_WORD;
} else if (isLuaOperator(ch)) {
styler.ColourTo(i, SCE_LUA_OPERATOR);
}
}
}
chPrev = ch;
firstChar = (ch == '\r' || ch == '\n');
}
styler.ColourTo(lengthDoc - 1, state);
}
static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[],
Accessor &styler) {
unsigned int lengthDoc = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
char s[10];
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (style == SCE_LUA_WORD)
if ( ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') {
for (unsigned int j = 0; j < 8; j++) {
if (!iswordchar(styler[i + j])) break;
s[j] = styler[i + j];
s[j + 1] = '\0';
}
if ((strcmp(s, "then") == 0) || (strcmp(s, "do") == 0)
|| (strcmp(s, "function") == 0))
levelCurrent++;
if (strcmp(s, "end") == 0) levelCurrent--;
}
if (atEOL) {
int lev = levelPrev;
if (visibleChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
levelPrev = levelCurrent;
visibleChars = 0;
}
if (!isspacechar(ch))
visibleChars++;
}
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
}
LexerModule lmLua(SCLEX_LUA, ColouriseLuaDoc, "lua", FoldLuaDoc);

View File

@@ -1,13 +1,16 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// LexOthers.cxx - lexers for properties files, batch files, make files and error lists /** @file LexOthers.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Lexers for batch files, diff results, properties files, make files and error lists.
** Also lexer for LaTeX documents.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -17,36 +20,135 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
static void ColouriseBatchLine(char *lineBuffer, int endLine, Accessor &styler) { static void ColouriseBatchLine(
if (0 == strncmp(lineBuffer, "REM", 3)) { char *lineBuffer,
styler.ColourTo(endLine, 1); unsigned int lengthLine,
} else if (0 == strncmp(lineBuffer, "rem", 3)) { unsigned int startLine,
styler.ColourTo(endLine, 1); unsigned int endPos,
} else if (0 == strncmp(lineBuffer, "SET", 3)) { WordList &keywords,
styler.ColourTo(endLine, 2); Accessor &styler) {
} else if (0 == strncmp(lineBuffer, "set", 3)) {
styler.ColourTo(endLine, 2);
} else if (lineBuffer[0] == ':') {
styler.ColourTo(endLine, 3);
} else {
styler.ColourTo(endLine, 0);
}
}
static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { unsigned int i = 0;
char lineBuffer[1024]; unsigned int state = SCE_BAT_DEFAULT;
styler.StartAt(startPos);
styler.StartSegment(startPos); while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip initial spaces
unsigned int linePos = 0; i++;
for (unsigned int i = startPos; i < startPos + length; i++) { }
lineBuffer[linePos++] = styler[i]; if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) { styler.ColourTo(startLine + i, SCE_BAT_HIDE);
ColouriseBatchLine(lineBuffer, i, styler); i++;
linePos = 0; while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip next spaces
i++;
} }
} }
if (linePos > 0) if (lineBuffer[i] == ':') {
ColouriseBatchLine(lineBuffer, startPos + length, styler); // Label
if (lineBuffer[i + 1] == ':') {
// :: is a fake label, similar to REM, see http://content.techweb.com/winmag/columns/explorer/2000/21.htm
styler.ColourTo(endPos, SCE_BAT_COMMENT);
} else { // Real label
styler.ColourTo(endPos, SCE_BAT_LABEL);
}
} else {
// Check if initial word is a keyword
char wordBuffer[21];
unsigned int wbl = 0, offset = i;
// Copy word in buffer
for (; offset < lengthLine && wbl < 20 &&
!isspacechar(lineBuffer[offset]); wbl++, offset++) {
wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
}
wordBuffer[wbl] = '\0';
// Check if it is a comment
if (CompareCaseInsensitive(wordBuffer, "rem") == 0) {
styler.ColourTo(endPos, SCE_BAT_COMMENT);
return ;
}
// Check if it is in the list
if (keywords.InList(wordBuffer)) {
styler.ColourTo(startLine + offset - 1, SCE_BAT_WORD); // Regular keyword
} else {
// Search end of word (can be a long path)
while (offset < lengthLine &&
!isspacechar(lineBuffer[offset])) {
offset++;
}
styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); // External command / program
}
// Remainder of the line: colourise the variables.
while (offset < lengthLine) {
if (state == SCE_BAT_DEFAULT && lineBuffer[offset] == '%') {
styler.ColourTo(startLine + offset - 1, state);
if (isdigit(lineBuffer[offset + 1])) {
styler.ColourTo(startLine + offset + 1, SCE_BAT_IDENTIFIER);
offset += 2;
} else if (lineBuffer[offset + 1] == '%' &&
!isspacechar(lineBuffer[offset + 2])) {
// Should be safe, as there is CRLF at the end of the line...
styler.ColourTo(startLine + offset + 2, SCE_BAT_IDENTIFIER);
offset += 3;
} else {
state = SCE_BAT_IDENTIFIER;
}
} else if (state == SCE_BAT_IDENTIFIER && lineBuffer[offset] == '%') {
styler.ColourTo(startLine + offset, state);
state = SCE_BAT_DEFAULT;
} else if (state == SCE_BAT_DEFAULT &&
(lineBuffer[offset] == '*' ||
lineBuffer[offset] == '?' ||
lineBuffer[offset] == '=' ||
lineBuffer[offset] == '<' ||
lineBuffer[offset] == '>' ||
lineBuffer[offset] == '|')) {
styler.ColourTo(startLine + offset - 1, state);
styler.ColourTo(startLine + offset, SCE_BAT_OPERATOR);
}
offset++;
}
// if (endPos > startLine + offset - 1) {
styler.ColourTo(endPos, SCE_BAT_DEFAULT); // Remainder of line, currently not lexed
// }
}
}
// ToDo: (not necessarily at beginning of line) GOTO, [IF] NOT, ERRORLEVEL
// IF [NO] (test) (command) -- test is EXIST (filename) | (string1)==(string2) | ERRORLEVEL (number)
// FOR %%(variable) IN (set) DO (command) -- variable is [a-zA-Z] -- eg for %%X in (*.txt) do type %%X
// ToDo: %n (parameters), %EnvironmentVariable% colourising
// ToDo: Colourise = > >> < | "
static void ColouriseBatchDoc(
unsigned int startPos,
int length,
int /*initStyle*/,
WordList *keywordlists[],
Accessor &styler) {
char lineBuffer[1024];
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0, startLine = startPos;
for (unsigned int i = startPos; i <= startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >=
sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
if (styler[i + 1] == '\n') {
lineBuffer[linePos++] = styler[++i];
}
lineBuffer[linePos] = '\0';
ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
linePos = 0;
startLine = i + 1;
}
}
if (linePos > 0) {
ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length,
keywords, styler);
}
} }
static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) { static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
@@ -89,25 +191,32 @@ static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[
ColouriseDiffLine(lineBuffer, startPos + length, styler); ColouriseDiffLine(lineBuffer, startPos + length, styler);
} }
static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, Accessor &styler) { static void ColourisePropsLine(
int i = 0; char *lineBuffer,
while (isspace(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces unsigned int lengthLine,
unsigned int startLine,
unsigned int endPos,
Accessor &styler) {
unsigned int i = 0;
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
i++; i++;
if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') { if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
styler.ColourTo(endPos, 1); styler.ColourTo(endPos, 1);
} else if (lineBuffer[i] == '[') { } else if (lineBuffer[i] == '[') {
styler.ColourTo(endPos, 2); styler.ColourTo(endPos, 2);
} else if (lineBuffer[i] == '@') { } else if (lineBuffer[i] == '@') {
styler.ColourTo(startLine+i, 4); styler.ColourTo(startLine + i, 4);
if (lineBuffer[++i] == '=') if (lineBuffer[++i] == '=')
styler.ColourTo(startLine+i, 3); styler.ColourTo(startLine + i, 3);
styler.ColourTo(endPos, 0); styler.ColourTo(endPos, 0);
} else { } else {
while (lineBuffer[i] != '=' && (i < lengthLine)) // Search the '=' character // Search for the '=' character
while (lineBuffer[i] != '=' && (i < lengthLine - 1))
i++; i++;
if (lineBuffer[i] == '=') { if (lineBuffer[i] == '=') {
styler.ColourTo(startLine+i-1, 0); styler.ColourTo(startLine + i - 1, 0);
styler.ColourTo(startLine+i, 3); styler.ColourTo(startLine + i, 3);
styler.ColourTo(endPos, 0); styler.ColourTo(endPos, 0);
} else { } else {
styler.ColourTo(endPos, 0); styler.ColourTo(endPos, 0);
@@ -119,31 +228,77 @@ static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *
char lineBuffer[1024]; char lineBuffer[1024];
styler.StartAt(startPos); styler.StartAt(startPos);
styler.StartSegment(startPos); styler.StartSegment(startPos);
unsigned int linePos = 0; unsigned int linePos = 0, startLine = startPos;
int startLine = startPos;
for (unsigned int i = startPos; i <= startPos + length; i++) { for (unsigned int i = startPos; i <= startPos + length; i++) {
lineBuffer[linePos++] = styler[i]; lineBuffer[linePos++] = styler[i];
if ((styler[i] == '\r' && styler.SafeGetCharAt(i+1) != '\n') || if ((styler[i] == '\r' && styler.SafeGetCharAt(i + 1) != '\n') ||
styler[i] == '\n' || styler[i] == '\n' ||
(linePos >= sizeof(lineBuffer) - 1)) { (linePos >= sizeof(lineBuffer) - 1)) {
lineBuffer[linePos] = '\0'; lineBuffer[linePos] = '\0';
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler); ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0; linePos = 0;
startLine = i+1; startLine = i + 1;
} }
} }
if (linePos > 0) if (linePos > 0)
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler); ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
} }
static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, Accessor &styler) { static void ColouriseMakeLine(
int i = 0; char *lineBuffer,
while (isspace(lineBuffer[i]) && (i < lengthLine)) unsigned int lengthLine,
unsigned int startLine,
unsigned int endPos,
Accessor &styler) {
unsigned int i = 0;
unsigned int lastNonSpace = 0;
unsigned int state = SCE_MAKE_DEFAULT;
bool bSpecial = false;
// Skip initial spaces
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) {
i++; i++;
if (lineBuffer[i] == '#' || lineBuffer[i] == '!') { }
styler.ColourTo(endPos, 1); if (lineBuffer[i] == '#') { // Comment
styler.ColourTo(endPos, SCE_MAKE_COMMENT);
return;
}
if (lineBuffer[i] == '!') { // Special directive
styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
return;
}
while (i < lengthLine) {
if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
styler.ColourTo(startLine + i - 1, state);
state = SCE_MAKE_IDENTIFIER;
} else if (state == SCE_MAKE_IDENTIFIER && lineBuffer[i] == ')') {
styler.ColourTo(startLine + i, state);
state = SCE_MAKE_DEFAULT;
}
if (!bSpecial) {
if (lineBuffer[i] == ':') {
styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
bSpecial = true; // Only react to the first ':' of the line
state = SCE_MAKE_DEFAULT;
} else if (lineBuffer[i] == '=') {
styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
bSpecial = true; // Only react to the first '=' of the line
state = SCE_MAKE_DEFAULT;
}
}
if (!isspacechar(lineBuffer[i])) {
lastNonSpace = i;
}
i++;
}
if (state == SCE_MAKE_IDENTIFIER) {
styler.ColourTo(endPos, SCE_MAKE_IDEOL); // Error, variable reference not ended
} else { } else {
styler.ColourTo(endPos, 0); styler.ColourTo(endPos, SCE_MAKE_DEFAULT);
} }
} }
@@ -151,22 +306,38 @@ static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[
char lineBuffer[1024]; char lineBuffer[1024];
styler.StartAt(startPos); styler.StartAt(startPos);
styler.StartSegment(startPos); styler.StartSegment(startPos);
unsigned int linePos = 0; unsigned int linePos = 0, startLine = startPos;
for (unsigned int i = startPos; i <= startPos + length; i++) { for (unsigned int i = startPos; i <= startPos + length; i++) {
lineBuffer[linePos++] = styler[i]; lineBuffer[linePos++] = styler[i];
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) { if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
ColouriseMakeLine(lineBuffer, linePos, i, styler); lineBuffer[linePos] = '\0';
ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0; linePos = 0;
startLine = i + 1;
} }
} }
if (linePos > 0) if (linePos > 0) {
ColouriseMakeLine(lineBuffer, linePos, startPos + length, styler); ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length, styler);
}
} }
static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, Accessor &styler) { static void ColouriseErrorListLine(
char *lineBuffer,
unsigned int lengthLine,
// unsigned int startLine,
unsigned int endPos,
Accessor &styler) {
if (lineBuffer[0] == '>') { if (lineBuffer[0] == '>') {
// Command or return status // Command or return status
styler.ColourTo(endPos, SCE_ERR_CMD); styler.ColourTo(endPos, SCE_ERR_CMD);
} else if (lineBuffer[0] == '!') {
styler.ColourTo(endPos, SCE_ERR_DIFF_CHANGED);
} else if (lineBuffer[0] == '+') {
styler.ColourTo(endPos, SCE_ERR_DIFF_ADDITION);
} else if (lineBuffer[0] == '-' && lineBuffer[1] == '-' && lineBuffer[2] == '-') {
styler.ColourTo(endPos, SCE_ERR_DIFF_MESSAGE);
} else if (lineBuffer[0] == '-') {
styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION);
} else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) { } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
styler.ColourTo(endPos, SCE_ERR_PYTHON); styler.ColourTo(endPos, SCE_ERR_PYTHON);
} else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) { } else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
@@ -175,18 +346,28 @@ static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos,
} else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) { } else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
// Borland warning message // Borland warning message
styler.ColourTo(endPos, SCE_ERR_BORLAND); styler.ColourTo(endPos, SCE_ERR_BORLAND);
} else if (strstr(lineBuffer, " at " ) && } else if (strstr(lineBuffer, "at line " ) &&
strstr(lineBuffer, " at " ) < lineBuffer+lengthLine && strstr(lineBuffer, "at line " ) < lineBuffer + lengthLine &&
strstr(lineBuffer, " line ") && strstr(lineBuffer, "file ") &&
strstr(lineBuffer, " line ") < lineBuffer+lengthLine) { strstr(lineBuffer, "file ") < lineBuffer + lengthLine) {
// Lua error message
styler.ColourTo(endPos, SCE_ERR_LUA);
} else if (strstr(lineBuffer, " at " ) &&
strstr(lineBuffer, " at " ) < lineBuffer + lengthLine &&
strstr(lineBuffer, " line ") &&
strstr(lineBuffer, " line ") < lineBuffer + lengthLine) {
// perl error message // perl error message
styler.ColourTo(endPos, SCE_ERR_PERL); styler.ColourTo(endPos, SCE_ERR_PERL);
} else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
strstr(lineBuffer, ":line ")) {
// A .NET traceback
styler.ColourTo(endPos, SCE_ERR_NET);
} else { } else {
// Look for <filename>:<line>:message // Look for <filename>:<line>:message
// Look for <filename>(line)message // Look for <filename>(line)message
// Look for <filename>(line,pos)message // Look for <filename>(line,pos)message
int state = 0; int state = 0;
for (int i = 0; i < lengthLine; i++) { for (unsigned int i = 0; i < lengthLine; i++) {
if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) { if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
state = 1; state = 1;
} else if (state == 0 && lineBuffer[i] == '(') { } else if (state == 0 && lineBuffer[i] == '(') {
@@ -240,15 +421,13 @@ static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordLi
} }
static int isSpecial(char s) { static int isSpecial(char s) {
return (s == '\\') || (s == ',') || (s == ';') || (s == '\'') || (s == ' ') || return (s == '\\') || (s == ',') || (s == ';') || (s == '\'') || (s == ' ') ||
(s == '\"') || (s == '`') || (s == '^') || (s == '~'); (s == '\"') || (s == '`') || (s == '^') || (s == '~');
} }
static int isTag(int start, Accessor &styler) { static int isTag(int start, Accessor &styler) {
char s[6]; char s[6];
unsigned int i = 0, e=1; unsigned int i = 0, e = 1;
while (i < 5 && e) { while (i < 5 && e) {
s[i] = styler[start + i]; s[i] = styler[start + i];
i++; i++;
@@ -259,7 +438,7 @@ static int isTag(int start, Accessor &styler) {
} }
static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle, static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) { WordList *[], Accessor &styler) {
styler.StartAt(startPos); styler.StartAt(startPos);
@@ -277,75 +456,74 @@ static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
i++; i++;
continue; continue;
} }
switch(state) { switch (state) {
case SCE_L_DEFAULT : case SCE_L_DEFAULT :
switch(ch) { switch (ch) {
case '\\' : case '\\' :
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
if (isSpecial(styler[i + 1])) { if (isSpecial(styler[i + 1])) {
styler.ColourTo(i + 1, SCE_L_COMMAND); styler.ColourTo(i + 1, SCE_L_COMMAND);
i++; i++;
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
} } else {
else { if (isTag(i + 1, styler))
if (isTag(i+1, styler)) state = SCE_L_TAG;
state = SCE_L_TAG; else
else state = SCE_L_COMMAND;
state = SCE_L_COMMAND;
}
break;
case '$' :
styler.ColourTo(i - 1, state);
state = SCE_L_MATH;
if (chNext == '$') {
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
break;
case '%' :
styler.ColourTo(i - 1, state);
state = SCE_L_COMMENT;
break;
} }
break; break;
case SCE_L_COMMAND : case '$' :
if (chNext == '[' || chNext == '{' || chNext == '}' || styler.ColourTo(i - 1, state);
chNext == ' ' || chNext == '\r' || chNext == '\n') { state = SCE_L_MATH;
styler.ColourTo(i, state); if (chNext == '$') {
state = SCE_L_DEFAULT;
i++; i++;
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
} }
break;
case SCE_L_TAG :
if (ch == '}') {
styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
}
break; break;
case SCE_L_MATH : case '%' :
if (ch == '$') { styler.ColourTo(i - 1, state);
if (chNext == '$') { state = SCE_L_COMMENT;
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
}
break; break;
case SCE_L_COMMENT : }
if (ch == '\r' || ch == '\n') { break;
styler.ColourTo(i - 1, state); case SCE_L_COMMAND :
state = SCE_L_DEFAULT; if (chNext == '[' || chNext == '{' || chNext == '}' ||
chNext == ' ' || chNext == '\r' || chNext == '\n') {
styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
break;
case SCE_L_TAG :
if (ch == '}') {
styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
}
break;
case SCE_L_MATH :
if (ch == '$') {
if (chNext == '$') {
i++;
chNext = styler.SafeGetCharAt(i + 1);
} }
} styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
}
break;
case SCE_L_COMMENT :
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_L_DEFAULT;
}
}
} }
styler.ColourTo(lengthDoc, state); styler.ColourTo(lengthDoc, state);
} }
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc); LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch");
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc); LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff");
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc); LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props");
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc); LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile");
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc); LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist");
LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc); LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex");

View File

@@ -0,0 +1,222 @@
// Scintilla source code edit control
/** @file LexPascal.cxx
** Lexer for Pascal.
** Written by Laurent le Tynevez
**/
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static int classifyWordPascal(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char s[100];
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = static_cast<char>(tolower(styler[start + i]));
s[i + 1] = '\0';
}
int lev= 0;
char chAttr = SCE_C_IDENTIFIER;
if (isdigit(s[0]) || (s[0] == '.')){
chAttr = SCE_C_NUMBER;
}
else {
if (keywords.InList(s)) {
chAttr = SCE_C_WORD;
if (strcmp(s, "begin") == 0 || strcmp(s, "object") == 0)
lev=1;
else if (strcmp(s, "end") == 0)
lev=-1;
}
}
styler.ColourTo(end, chAttr);
return lev;
}
static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold");
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
int state = initStyle;
if (state == SCE_C_STRINGEOL) // Does not leak onto next line
state = SCE_C_DEFAULT;
char chPrev = ' ';
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
int visibleChars = 0;
styler.StartSegment(startPos);
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
// End of line
if (state == SCE_C_STRINGEOL) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
if (fold) {
int lev = levelPrev;
if (visibleChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
levelPrev = levelCurrent;
}
visibleChars = 0;
}
if (!isspacechar(ch))
visibleChars++;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_C_DEFAULT) {
if (iswordstart(ch) || (ch == '@')) {
styler.ColourTo(i-1, state);
state = SCE_C_IDENTIFIER;
} else if (ch == '{' && chNext != '$' && chNext != '&') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENT;
} else if (ch == '(' && chNext == '*'
&& styler.SafeGetCharAt(i + 2) != '$'
&& styler.SafeGetCharAt(i + 2) != '&') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENTDOC;
} else if (ch == '/' && chNext == '/') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i-1, state);
state = SCE_C_STRING;
} else if (ch == '\'') {
styler.ColourTo(i-1, state);
state = SCE_C_CHARACTER;
} else if (ch == '{' && (chNext == '$' || chNext=='&') && visibleChars == 1) {
styler.ColourTo(i-1, state);
state = SCE_C_PREPROCESSOR;
} else if (isoperator(ch)) {
styler.ColourTo(i-1, state);
styler.ColourTo(i, SCE_C_OPERATOR);
}
} else if (state == SCE_C_IDENTIFIER) {
if (!iswordchar(ch)) {
int levelChange = classifyWordPascal(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_C_DEFAULT;
chNext = styler.SafeGetCharAt(i + 1);
if (ch == '{' && chNext != '$' && chNext != '&') {
state = SCE_C_COMMENT;
} else if (ch == '(' && chNext == '*'
&& styler.SafeGetCharAt(i + 2) != '$'
&& styler.SafeGetCharAt(i + 2) != '&') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENTDOC;
} else if (ch == '/' && chNext == '/') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_C_STRING;
} else if (ch == '\'') {
state = SCE_C_CHARACTER;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
}
levelCurrent+=levelChange;
}
} else {
if (state == SCE_C_PREPROCESSOR) {
if (ch=='}'){
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
} else {
if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENT) {
if (ch == '}' ) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_COMMENTDOC) {
if (ch == ')' && chPrev == '*') {
if (((i > styler.GetStartSegment() + 2) || (
(initStyle == SCE_C_COMMENTDOC) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_STRING) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
} else if (chNext == '\r' || chNext == '\n') {
styler.ColourTo(i-1, SCE_C_STRINGEOL);
state = SCE_C_STRINGEOL;
}
} else if (state == SCE_C_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, SCE_C_STRINGEOL);
state = SCE_C_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
}
chPrev = ch;
}
styler.ColourTo(lengthDoc - 1, state);
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
if (fold) {
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
}
}
LexerModule lmPascal(SCLEX_PASCAL, ColourisePascalDoc, "pascal");

View File

@@ -1,13 +1,15 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// LexPerl.cxx - lexer for subset of Perl /** @file LexPerl.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Lexer for subset of Perl.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -17,7 +19,18 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
inline bool isPerlOperator(char ch) { static inline bool isEOLChar(char ch) {
return (ch == '\r') || (ch == '\n');
}
static bool isSingleCharOp(char ch) {
char strCharSet[2];
strCharSet[0] = ch;
strCharSet[1] = '\0';
return (NULL != strstr("rwxoRWXOezsfdlpSbctugkTBMAC", strCharSet));
}
static inline bool isPerlOperator(char ch) {
if (isalnum(ch)) if (isalnum(ch))
return false; return false;
// '.' left out as it is used to make up numbers // '.' left out as it is used to make up numbers
@@ -49,7 +62,7 @@ static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keyw
return chAttr; return chAttr;
} }
static bool isEndVar(char ch) { static inline bool isEndVar(char ch) {
return !isalnum(ch) && ch != '#' && ch != '$' && return !isalnum(ch) && ch != '#' && ch != '$' &&
ch != '_' && ch != '\''; ch != '_' && ch != '\'';
} }
@@ -85,32 +98,86 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
// Lexer for perl often has to backtrack to start of current style to determine // Lexer for perl often has to backtrack to start of current style to determine
// which characters are being used as quotes, how deeply nested is the // which characters are being used as quotes, how deeply nested is the
// start position and what the termination string is for here documents // start position and what the termination string is for here documents
WordList &keywords = *keywordlists[0]; WordList &keywords = *keywordlists[0];
class HereDocCls {
public:
int State; // 0: '<<' encountered
// 1: collect the delimiter
// 2: here doc text (lines after the delimiter)
char Quote; // the char after '<<'
bool Quoted; // true if Quote in ('\'','"','`')
int DelimiterLength; // strlen(Delimiter)
char Delimiter[256]; // the Delimiter, 256: sizeof PL_tokenbuf
HereDocCls() {
State = 0;
DelimiterLength = 0;
Delimiter[0] = '\0';
}
};
HereDocCls HereDoc; // TODO: FIFO for stacked here-docs
class QuoteCls {
public:
int Rep;
int Count;
char Up;
char Down;
QuoteCls() {
this->New(1);
}
void New(int r) {
Rep = r;
Count = 0;
Up = '\0';
Down = '\0';
}
void Open(char u) {
Count++;
Up = u;
Down = opposite(Up);
}
};
QuoteCls Quote;
char sooked[100]; char sooked[100];
int quotes = 0;
char quoteDown = 'd';
char quoteUp = 'd';
int quoteRep = 1;
int sookedpos = 0; int sookedpos = 0;
bool preferRE = true; bool preferRE = true;
sooked[sookedpos] = '\0'; sooked[sookedpos] = '\0';
int state = initStyle; int state = initStyle;
int lengthDoc = startPos + length; unsigned int lengthDoc = startPos + length;
// If in a long distance lexical state, seek to the beginning to find quote characters // If in a long distance lexical state, seek to the beginning to find quote characters
if (state == SCE_PL_HERE || state == SCE_PL_REGEX || if (state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX) {
state == SCE_PL_REGSUBST || state == SCE_PL_LONGQUOTE) { while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_PL_HERE_DELIM)) {
startPos--;
}
startPos = styler.LineStart(styler.GetLine(startPos));
state = styler.StyleAt(startPos - 1);
}
if ( state == SCE_PL_STRING_Q
|| state == SCE_PL_STRING_QQ
|| state == SCE_PL_STRING_QX
|| state == SCE_PL_STRING_QR
|| state == SCE_PL_STRING_QW
|| state == SCE_PL_REGEX
|| state == SCE_PL_REGSUBST
) {
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) { while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
startPos--; startPos--;
} }
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
} }
styler.StartAt(startPos); styler.StartAt(startPos);
char chPrev = styler.SafeGetCharAt(startPos - 1); char chPrev = styler.SafeGetCharAt(startPos - 1);
if (startPos == 0)
chPrev = '\n';
char chNext = styler[startPos]; char chNext = styler[startPos];
styler.StartSegment(startPos); styler.StartSegment(startPos);
for (int i = startPos; i < lengthDoc; i++) {
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext; char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2); char chNext2 = styler.SafeGetCharAt(i + 2);
@@ -121,41 +188,81 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
i += 1; i += 1;
continue; continue;
} }
if ((chPrev == '\r' && ch == '\n')) { // skip on DOS/Windows
chPrev = ch;
continue;
}
if (HereDoc.State == 1 && isEOLChar(ch)) {
// Begin of here-doc (the line after the here-doc delimiter):
HereDoc.State = 2;
styler.ColourTo(i - 1, state);
if (HereDoc.Quoted) {
if (state == SCE_PL_HERE_DELIM) {
// Missing quote at end of string! We are stricter than perl.
state = SCE_PL_ERROR;
} else {
switch (HereDoc.Quote) {
case '\'':
state = SCE_PL_HERE_Q ;
break;
case '"':
state = SCE_PL_HERE_QQ;
break;
case '`':
state = SCE_PL_HERE_QX;
break;
}
}
} else {
switch (HereDoc.Quote) {
case '\\':
state = SCE_PL_HERE_Q ;
break;
default :
state = SCE_PL_HERE_QQ;
}
}
}
if (state == SCE_PL_DEFAULT) { if (state == SCE_PL_DEFAULT) {
if (iswordstart(ch)) { if (iswordstart(ch)) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
if (ch == 's' && !isalnum(chNext)) { if (ch == 's' && !isalnum(chNext)) {
state = SCE_PL_REGSUBST; state = SCE_PL_REGSUBST;
quotes = 0; Quote.New(2);
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 2;
} else if (ch == 'm' && !isalnum(chNext)) { } else if (ch == 'm' && !isalnum(chNext)) {
state = SCE_PL_REGEX; state = SCE_PL_REGEX;
quotes = 0; Quote.New(1);
quoteUp = '\0'; } else if (ch == 'q' && !isalnum(chNext)) {
quoteDown = '\0'; state = SCE_PL_STRING_Q;
quoteRep = 1; Quote.New(1);
} else if (ch == 'y' && !isalnum(chNext)) {
state = SCE_PL_REGSUBST;
Quote.New(2);
} else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) { } else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) {
state = SCE_PL_REGSUBST; state = SCE_PL_REGSUBST;
quotes = 0; Quote.New(2);
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 2;
i++; i++;
chNext = chNext2; chNext = chNext2;
} else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) { } else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) {
state = SCE_PL_LONGQUOTE; if (chNext == 'q') state = SCE_PL_STRING_QQ;
else if (chNext == 'x') state = SCE_PL_STRING_QX;
else if (chNext == 'r') state = SCE_PL_STRING_QR;
else if (chNext == 'w') state = SCE_PL_STRING_QW;
i++; i++;
chNext = chNext2; chNext = chNext2;
quotes = 0; Quote.New(1);
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 1;
} else { } else {
state = SCE_PL_WORD; state = SCE_PL_WORD;
preferRE = false; preferRE = false;
if ((!iswordchar(chNext) && chNext != '\'')
|| (chNext == '.' && chNext2 == '.')) {
// We need that if length of word == 1!
// This test is copied from the SCE_PL_WORD handler.
classifyWordPerl(styler.GetStartSegment(), i, keywords, styler);
state = SCE_PL_DEFAULT;
}
} }
} else if (ch == '#') { } else if (ch == '#') {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
@@ -163,6 +270,8 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
} else if (ch == '\"') { } else if (ch == '\"') {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_STRING; state = SCE_PL_STRING;
Quote.New(1);
Quote.Open(ch);
} else if (ch == '\'') { } else if (ch == '\'') {
if (chPrev == '&') { if (chPrev == '&') {
// Archaic call // Archaic call
@@ -170,22 +279,24 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
} else { } else {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_CHARACTER; state = SCE_PL_CHARACTER;
Quote.New(1);
Quote.Open(ch);
} }
} else if (ch == '`') { } else if (ch == '`') {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_BACKTICKS; state = SCE_PL_BACKTICKS;
Quote.New(1);
Quote.Open(ch);
} else if (ch == '$') { } else if (ch == '$') {
preferRE = false; preferRE = false;
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
if (isalnum(chNext) || chNext == '#' || chNext == '$' || chNext == '_') { if ((chNext == '{') || isspacechar(chNext)) {
state = SCE_PL_SCALAR;
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_SCALAR); styler.ColourTo(i, SCE_PL_SCALAR);
i++;
ch = ' ';
chNext = ' ';
} else { } else {
styler.ColourTo(i, SCE_PL_SCALAR); state = SCE_PL_SCALAR;
i++;
ch = chNext;
chNext = chNext2;
} }
} else if (ch == '@') { } else if (ch == '@') {
preferRE = false; preferRE = false;
@@ -204,12 +315,10 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') { if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
state = SCE_PL_HASH; state = SCE_PL_HASH;
} else if (chNext != '{' && chNext != '[') { } else if (chNext == '{') {
styler.ColourTo(i, SCE_PL_HASH); styler.ColourTo(i, SCE_PL_HASH);
i++;
ch = ' ';
} else { } else {
styler.ColourTo(i, SCE_PL_HASH); styler.ColourTo(i, SCE_PL_OPERATOR);
} }
} else if (ch == '*') { } else if (ch == '*') {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
@@ -217,25 +326,29 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
} else if (ch == '/' && preferRE) { } else if (ch == '/' && preferRE) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_REGEX; state = SCE_PL_REGEX;
quoteUp = '/'; Quote.New(1);
quoteDown = '/'; Quote.Open(ch);
quotes = 1;
quoteRep = 1;
} else if (ch == '<' && chNext == '<') { } else if (ch == '<' && chNext == '<') {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_HERE; state = SCE_PL_HERE_DELIM;
i++; HereDoc.State = 0;
ch = chNext; } else if (ch == '='
chNext = chNext2; && isalpha(chNext)
quotes = 0; && (isEOLChar(chPrev))) {
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (ch == '=' && (chPrev == '\r' || chPrev == '\n') && isalpha(chNext)) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_POD; state = SCE_PL_POD;
quotes = 0;
sookedpos = 0; sookedpos = 0;
sooked[sookedpos] = '\0'; sooked[sookedpos] = '\0';
} else if (ch == '-'
&& isSingleCharOp(chNext)
&& !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i + 1, SCE_PL_WORD);
state = SCE_PL_DEFAULT;
preferRE = false;
i += 2;
ch = chNext2;
chNext = chNext2 = styler.SafeGetCharAt(i + 1);
} else if (isPerlOperator(ch)) { } else if (isPerlOperator(ch)) {
if (ch == ')' || ch == ']') if (ch == ')' || ch == ']')
preferRE = false; preferRE = false;
@@ -245,7 +358,10 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(i, SCE_PL_OPERATOR); styler.ColourTo(i, SCE_PL_OPERATOR);
} }
} else if (state == SCE_PL_WORD) { } else if (state == SCE_PL_WORD) {
if (!iswordchar(ch) && ch != '\'') { // Archaic Perl has quotes inside names if ((!iswordchar(chNext) && chNext != '\'')
|| (chNext == '.' && chNext2 == '.')) {
// ".." is always an operator if preceded by a SCE_PL_WORD.
// Archaic Perl has quotes inside names
if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) { if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) {
styler.ColourTo(i, SCE_PL_DATASECTION); styler.ColourTo(i, SCE_PL_DATASECTION);
state = SCE_PL_DATASECTION; state = SCE_PL_DATASECTION;
@@ -253,95 +369,106 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(i, SCE_PL_DATASECTION); styler.ColourTo(i, SCE_PL_DATASECTION);
state = SCE_PL_DATASECTION; state = SCE_PL_DATASECTION;
} else { } else {
if (classifyWordPerl(styler.GetStartSegment(), i - 1, keywords, styler) == SCE_PL_WORD) if (classifyWordPerl(styler.GetStartSegment(), i, keywords, styler) == SCE_PL_WORD)
preferRE = true; preferRE = true;
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
if (ch == '#') { ch = ' ';
state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_PL_STRING;
} else if (ch == '\'') {
state = SCE_PL_CHARACTER;
} else if (ch == '<' && chNext == '<') {
state = SCE_PL_HERE;
quotes = 0;
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (isPerlOperator(ch)) {
if (ch == ')' || ch == ']')
preferRE = false;
else
preferRE = true;
styler.ColourTo(i, SCE_PL_OPERATOR);
state = SCE_PL_DEFAULT;
}
} }
} }
} else { } else {
if (state == SCE_PL_COMMENTLINE) { if (state == SCE_PL_COMMENTLINE) {
if (ch == '\r' || ch == '\n') { if (isEOLChar(ch)) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
} }
} else if (state == SCE_PL_HERE) { } else if (state == SCE_PL_HERE_DELIM) {
if ((isalnum(ch) || ch == '_') && quotes < 2) { //
sooked[sookedpos++] = ch; // From perldata.pod:
sooked[sookedpos] = '\0'; // ------------------
if (quotes == 0) // A line-oriented form of quoting is based on the shell ``here-doc''
quotes = 1; // syntax.
} else { // Following a << you specify a string to terminate the quoted material,
quotes++; // and all lines following the current line down to the terminating
// string are the value of the item.
// The terminating string may be either an identifier (a word),
// or some quoted text.
// If quoted, the type of quotes you use determines the treatment of
// the text, just as in regular quoting.
// An unquoted identifier works like double quotes.
// There must be no space between the << and the identifier.
// (If you put a space it will be treated as a null identifier,
// which is valid, and matches the first empty line.)
// The terminating string must appear by itself (unquoted and with no
// surrounding whitespace) on the terminating line.
//
if (HereDoc.State == 0) { // '<<' encountered
HereDoc.State = 1;
HereDoc.Quote = chNext;
HereDoc.Quoted = false;
HereDoc.DelimiterLength = 0;
HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
if (chNext == '\'' || chNext == '"' || chNext == '`') { // a quoted here-doc delimiter
i++;
ch = chNext;
chNext = chNext2;
HereDoc.Quoted = true;
} else if (chNext == '\\') { // ref?
i++;
ch = chNext;
chNext = chNext2;
} else if (isalnum(chNext) || chNext == '_') { // an unquoted here-doc delimiter
}
else if (isspacechar(chNext)) { // deprecated here-doc delimiter || TODO: left shift operator
}
else { // TODO: ???
}
} else if (HereDoc.State == 1) { // collect the delimiter
if (HereDoc.Quoted) { // a quoted here-doc delimiter
if (ch == HereDoc.Quote) { // closing quote => end of delimiter
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = chNext2;
} else {
if (ch == '\\' && chNext == HereDoc.Quote) { // escaped quote
i++;
ch = chNext;
chNext = chNext2;
}
HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
}
} else { // an unquoted here-doc delimiter
if (isalnum(ch) || ch == '_') {
HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch;
HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
} else {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
}
if (HereDoc.DelimiterLength >= static_cast<int>(sizeof(HereDoc.Delimiter)) - 1) {
styler.ColourTo(i - 1, state);
state = SCE_PL_ERROR;
}
} }
if ((quotes > 1) && } else if (HereDoc.State == 2) {
(chPrev == '\n' || chPrev == '\r') && // state == SCE_PL_HERE_Q || state == SCE_PL_HERE_QQ || state == SCE_PL_HERE_QX
isMatch(styler, lengthDoc, i, sooked)) { if (isEOLChar(chPrev) && isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) {
i += sookedpos; i += HereDoc.DelimiterLength;
chNext = styler.SafeGetCharAt(i); chNext = styler.SafeGetCharAt(i);
if (chNext == '\n' || chNext == '\r') { if (isEOLChar(chNext)) {
styler.ColourTo(i - 1, SCE_PL_HERE); styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
HereDoc.State = 0;
} }
ch = chNext; ch = chNext;
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
} }
} else if (state == SCE_PL_STRING) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_CHARACTER) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_BACKTICKS) {
if (ch == '`') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_POD) { } else if (state == SCE_PL_POD) {
if (ch == '=' && (chPrev == '\r' || chPrev == '\n')) { if (ch == '=' && isEOLChar(chPrev)) {
if (isMatch(styler, lengthDoc, i, "=cut")) { if (isMatch(styler, lengthDoc, i, "=cut")) {
styler.ColourTo(i - 1 + 4, state); styler.ColourTo(i - 1 + 4, state);
i += 4; i += 4;
@@ -352,7 +479,12 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
} }
} else if (state == SCE_PL_SCALAR) { } else if (state == SCE_PL_SCALAR) {
if (isEndVar(ch)) { if (isEndVar(ch)) {
styler.ColourTo(i - 1, state); if (i == (styler.GetStartSegment() + 1)) {
// Special variable: $(, $_ etc.
styler.ColourTo(i, state);
} else {
styler.ColourTo(i - 1, state);
}
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
} }
} else if (state == SCE_PL_ARRAY) { } else if (state == SCE_PL_ARRAY) {
@@ -370,36 +502,36 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
} }
} else if (state == SCE_PL_REF) { } else if (state == SCE_PL_REGEX
if (isEndVar(ch)) { || state == SCE_PL_STRING_QR
styler.ColourTo(i - 1, state); ) {
state = SCE_PL_DEFAULT; if (!Quote.Up && !isspacechar(ch)) {
} Quote.Open(ch);
} else if (state == SCE_PL_REGEX) { } else if (ch == '\\' && Quote.Up != '\\') {
if (!quoteUp && !isspace(ch)) { // SG: Is it save to skip *every* escaped char?
quoteUp = ch; i++;
quoteDown = opposite(ch); ch = chNext;
quotes++; chNext = styler.SafeGetCharAt(i + 1);
} else { } else {
if (ch == quoteDown && chPrev != '\\') { if (ch == Quote.Down /*&& chPrev != '\\'*/) {
quotes--; Quote.Count--;
if (quotes == 0) { if (Quote.Count == 0) {
quoteRep--; Quote.Rep--;
if (quoteUp == quoteDown) { if (Quote.Up == Quote.Down) {
quotes++; Quote.Count++;
} }
} }
if (!isalpha(chNext)) { if (!isalpha(chNext)) {
if (quoteRep <= 0) { if (Quote.Rep <= 0) {
styler.ColourTo(i, state); styler.ColourTo(i, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
ch = ' '; ch = ' ';
} }
} }
} else if (ch == quoteUp && chPrev != '\\') { } else if (ch == Quote.Up /*&& chPrev != '\\'*/) {
quotes++; Quote.Count++;
} else if (!isalpha(chNext)) { } else if (!isalpha(chNext)) {
if (quoteRep <= 0) { if (Quote.Rep <= 0) {
styler.ColourTo(i, state); styler.ColourTo(i, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
ch = ' '; ch = ' ';
@@ -407,12 +539,15 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
} }
} }
} else if (state == SCE_PL_REGSUBST) { } else if (state == SCE_PL_REGSUBST) {
if (!quoteUp && !isspace(ch)) { if (!Quote.Up && !isspacechar(ch)) {
quoteUp = ch; Quote.Open(ch);
quoteDown = opposite(ch); } else if (ch == '\\' && Quote.Up != '\\') {
quotes++; // SG: Is it save to skip *every* escaped char?
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
} else { } else {
if (quotes == 0 && quoteRep == 1) { if (Quote.Count == 0 && Quote.Rep == 1) {
/* We matched something like s(...) or tr{...} /* We matched something like s(...) or tr{...}
* and are looking for the next matcher characters, * and are looking for the next matcher characters,
* which could be either bracketed ({...}) or non-bracketed * which could be either bracketed ({...}) or non-bracketed
@@ -420,68 +555,76 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
* *
* Number-signs are problematic. If they occur after * Number-signs are problematic. If they occur after
* the close of the first part, treat them like * the close of the first part, treat them like
* a quoteUp char, even if they actually start comments. * a Quote.Up char, even if they actually start comments.
* *
* If we find an alnum, we end the regsubst, and punt. * If we find an alnum, we end the regsubst, and punt.
* *
* Eric Promislow ericp@activestate.com Aug 9,2000 * Eric Promislow ericp@activestate.com Aug 9,2000
*/ */
if (isspace(ch)) { if (isspacechar(ch)) {
// Keep going // Keep going
} else if (isalnum(ch)) { }
else if (isalnum(ch)) {
styler.ColourTo(i, state); styler.ColourTo(i, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
ch = ' '; ch = ' ';
} else { } else {
quoteUp = ch; Quote.Open(ch);
quoteDown = opposite(ch);
quotes++;
} }
} else if (ch == quoteDown && chPrev != '\\') { } else if (ch == Quote.Down /*&& chPrev != '\\'*/) {
quotes--; Quote.Count--;
if (quotes == 0) { if (Quote.Count == 0) {
quoteRep--; Quote.Rep--;
} }
if (!isalpha(chNext)) { if (!isalpha(chNext)) {
if (quoteRep <= 0) { if (Quote.Rep <= 0) {
styler.ColourTo(i, state); styler.ColourTo(i, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
ch = ' '; ch = ' ';
} }
} }
if (quoteUp == quoteDown) { if (Quote.Up == Quote.Down) {
quotes++; Quote.Count++;
} }
} else if (ch == quoteUp && chPrev != '\\') { } else if (ch == Quote.Up /*&& chPrev != '\\'*/) {
quotes++; Quote.Count++;
} else if (!isalpha(chNext)) { } else if (!isalpha(chNext)) {
if (quoteRep <= 0) { if (Quote.Rep <= 0) {
styler.ColourTo(i, state); styler.ColourTo(i, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
ch = ' '; ch = ' ';
} }
} }
} }
} else if (state == SCE_PL_LONGQUOTE) { } else if (state == SCE_PL_STRING_Q
if (!quoteDown && !isspace(ch)) { || state == SCE_PL_STRING_QQ
quoteUp = ch; || state == SCE_PL_STRING_QX
quoteDown = opposite(quoteUp); || state == SCE_PL_STRING_QW
quotes++; || state == SCE_PL_STRING
} else if (ch == quoteDown) { || state == SCE_PL_CHARACTER
quotes--; || state == SCE_PL_BACKTICKS
if (quotes == 0) { ) {
quoteRep--; if (!Quote.Down && !isspacechar(ch)) {
if (quoteRep <= 0) { Quote.Open(ch);
} else if (ch == '\\' && Quote.Up != '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
} else if (ch == Quote.Down) {
Quote.Count--;
if (Quote.Count == 0) {
Quote.Rep--;
if (Quote.Rep <= 0) {
styler.ColourTo(i, state); styler.ColourTo(i, state);
state = SCE_PL_DEFAULT; state = SCE_PL_DEFAULT;
ch = ' '; ch = ' ';
} }
if (quoteUp == quoteDown) { if (Quote.Up == Quote.Down) {
quotes++; Quote.Count++;
} }
} }
} else if (ch == quoteUp) { } else if (ch == Quote.Up) {
quotes++; Quote.Count++;
} }
} }
@@ -490,19 +633,30 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
state = SCE_PL_COMMENTLINE; state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') { } else if (ch == '\"') {
state = SCE_PL_STRING; state = SCE_PL_STRING;
Quote.New(1);
Quote.Open(ch);
} else if (ch == '\'') { } else if (ch == '\'') {
state = SCE_PL_CHARACTER; state = SCE_PL_CHARACTER;
Quote.New(1);
Quote.Open(ch);
} else if (iswordstart(ch)) { } else if (iswordstart(ch)) {
state = SCE_PL_WORD; state = SCE_PL_WORD;
preferRE = false; preferRE = false;
} else if (isoperator(ch)) { } else if (isPerlOperator(ch)) {
if (ch == ')' || ch == ']')
preferRE = false;
else
preferRE = true;
styler.ColourTo(i, SCE_PL_OPERATOR); styler.ColourTo(i, SCE_PL_OPERATOR);
} }
} }
} }
if (state == SCE_PL_ERROR) {
break;
}
chPrev = ch; chPrev = ch;
} }
styler.ColourTo(lengthDoc, state); styler.ColourTo(lengthDoc, state);
} }
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc); LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl");

View File

@@ -1,13 +1,15 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// LexPython.cxx - lexer for Python /** @file LexPython.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Lexer for Python.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -17,6 +19,32 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
/* Returns true if the "as" word that begins at start follows an import statement */
static bool IsImportAs(unsigned int start, Accessor &styler) {
unsigned int i;
unsigned int j;
char s[10];
/* Find any import before start but after any statement terminator or quote */
i = start;
while (i > 0) {
char ch = styler[i - 1];
if (ch == '\n' || ch == '\r' || ch == ';' || ch == '\'' || ch == '"' || ch == '`')
break;
if (ch == 't' && i > 5) {
for (j = 0; j < 6; j++)
s[j] = styler[(i - 6) + j];
s[j] = '\0';
if (strcmp(s, "import") == 0)
return true;
}
i--;
}
return false;
}
static void ClassifyWordPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) { static void ClassifyWordPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
char s[100]; char s[100];
bool wordIsNumber = isdigit(styler[start]); bool wordIsNumber = isdigit(styler[start]);
@@ -33,6 +61,8 @@ static void ClassifyWordPy(unsigned int start, unsigned int end, WordList &keywo
chAttr = SCE_P_NUMBER; chAttr = SCE_P_NUMBER;
else if (keywords.InList(s)) else if (keywords.InList(s))
chAttr = SCE_P_WORD; chAttr = SCE_P_WORD;
else if (strcmp(s, "as") == 0 && IsImportAs(start, styler))
chAttr = SCE_P_WORD;
// make sure that dot-qualifiers inside the word are lexed correct // make sure that dot-qualifiers inside the word are lexed correct
else for (unsigned int i = 0; i < end - start + 1; i++) { else for (unsigned int i = 0; i < end - start + 1; i++) {
if (styler[start + i] == '.') { if (styler[start + i] == '.') {
@@ -48,50 +78,107 @@ static bool IsPyComment(Accessor &styler, int pos, int len) {
return len>0 && styler[pos]=='#'; return len>0 && styler[pos]=='#';
} }
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, static bool IsPyStringStart(char ch, char chNext, char chNext2) {
if (ch == '\'' || ch == '"')
return true;
if (ch == 'u' || ch == 'U') {
if (chNext == '"' || chNext == '\'')
return true;
if ((chNext == 'r' || chNext == 'R') && (chNext2 == '"' || chNext2 == '\''))
return true;
}
if ((ch == 'r' || ch == 'R') && (chNext == '"' || chNext == '\''))
return true;
return false;
}
static bool IsPyWordStart(char ch, char chNext, char chNext2) {
return (iswordchar(ch) && !IsPyStringStart(ch, chNext, chNext2));
}
/* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
char ch = styler.SafeGetCharAt(i);
char chNext = styler.SafeGetCharAt(i + 1);
// Advance beyond r, u, or ur prefix, but bail if there are any unexpected chars
if (ch == 'r' || ch == 'R') {
i++;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
}
else if (ch == 'u' || ch == 'U') {
if (chNext == 'r' || chNext == 'R')
i += 2;
else
i += 1;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
}
if (ch != '"' && ch != '\'') {
*nextIndex = i + 1;
return SCE_P_DEFAULT;
}
if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) {
*nextIndex = i + 3;
if (ch == '"')
return SCE_P_TRIPLEDOUBLE;
else
return SCE_P_TRIPLE;
} else {
*nextIndex = i + 1;
if (ch == '"')
return SCE_P_STRING;
else
return SCE_P_CHARACTER;
}
}
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) { WordList *keywordlists[], Accessor &styler) {
int lengthDoc = startPos + length; int lengthDoc = startPos + length;
// Backtrack to previous line in case need to fix its fold status or tab whinging // Backtrack to previous line in case need to fix its tab whinging
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
if (startPos > 0) { if (startPos > 0) {
if (lineCurrent > 0) { if (lineCurrent > 0) {
lineCurrent--; startPos = styler.LineStart(lineCurrent-1);
startPos = styler.LineStart(lineCurrent);
if (startPos == 0) if (startPos == 0)
initStyle = SCE_P_DEFAULT; initStyle = SCE_P_DEFAULT;
else else
initStyle = styler.StyleAt(startPos-1); initStyle = styler.StyleAt(startPos-1);
} }
} }
// Python uses a different mask because bad indentation is marked by oring with 32 // Python uses a different mask because bad indentation is marked by oring with 32
styler.StartAt(startPos, 127); styler.StartAt(startPos, 127);
WordList &keywords = *keywordlists[0]; WordList &keywords = *keywordlists[0];
bool fold = styler.GetPropertyInt("fold");
int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level"); int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
char prevWord[200]; char prevWord[200];
prevWord[0] = '\0'; prevWord[0] = '\0';
if (length == 0) if (length == 0)
return ; return ;
int spaceFlags = 0;
int state = initStyle & 31; int state = initStyle & 31;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment); int nextIndex = 0;
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
indentCurrent |= SC_FOLDLEVELWHITEFLAG;
char chPrev = ' '; char chPrev = ' ';
char chPrev2 = ' '; char chPrev2 = ' ';
char chNext = styler[startPos]; char chNext = styler[startPos];
styler.StartSegment(startPos); styler.StartSegment(startPos);
bool atStartLine = true; bool atStartLine = true;
int spaceFlags = 0;
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
for (int i = startPos; i < lengthDoc; i++) { for (int i = startPos; i < lengthDoc; i++) {
if (atStartLine) { if (atStartLine) {
char chBad = static_cast<char>(64); char chBad = static_cast<char>(64);
char chGood = static_cast<char>(0); char chGood = static_cast<char>(0);
@@ -108,40 +195,19 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
styler.SetFlags(chFlags, static_cast<char>(state)); styler.SetFlags(chFlags, static_cast<char>(state));
atStartLine = false; atStartLine = false;
} }
char ch = chNext; char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2); char chNext2 = styler.SafeGetCharAt(i + 2);
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) { if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) { if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
// Perform colourisation of white space and triple quoted strings at end of each line to allow // Perform colourisation of white space and triple quoted strings at end of each line to allow
// tab marking to work inside white space and triple quoted strings // tab marking to work inside white space and triple quoted strings
styler.ColourTo(i, state); styler.ColourTo(i, state);
} }
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsPyComment);
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
indentNext |= SC_FOLDLEVELWHITEFLAG;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
// Line after is blank so check the next - maybe should continue further?
int spaceFlags2 = 0;
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsPyComment);
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
}
indentCurrent = indentNext;
if (fold) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++; lineCurrent++;
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
atStartLine = true; atStartLine = true;
} }
@@ -160,33 +226,20 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
} }
} }
if (state == SCE_P_DEFAULT) { if (state == SCE_P_DEFAULT) {
if (iswordstart(ch)) { if (IsPyWordStart(ch, chNext, chNext2)) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = SCE_P_WORD; state = SCE_P_WORD;
} else if (ch == '#') { } else if (ch == '#') {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE; state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (ch == '\"') { } else if (IsPyStringStart(ch, chNext, chNext2)) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
if (chNext == '\"' && chNext2 == '\"') { state = GetPyStringState(styler, i, &nextIndex);
i += 2; if (nextIndex != i + 1) {
state = SCE_P_TRIPLEDOUBLE; i = nextIndex - 1;
ch = ' '; ch = ' ';
chPrev = ' '; chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_STRING;
}
} else if (ch == '\'') {
styler.ColourTo(i - 1, state);
if (chNext == '\'' && chNext2 == '\'') {
i += 2;
state = SCE_P_TRIPLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_CHARACTER;
} }
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
styler.ColourTo(i - 1, state); styler.ColourTo(i - 1, state);
@@ -198,25 +251,14 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
state = SCE_P_DEFAULT; state = SCE_P_DEFAULT;
if (ch == '#') { if (ch == '#') {
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE; state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (ch == '\"') { } else if (IsPyStringStart(ch, chNext, chNext2)) {
if (chNext == '\"' && chNext2 == '\"') { styler.ColourTo(i - 1, state);
i += 2; state = GetPyStringState(styler, i, &nextIndex);
state = SCE_P_TRIPLEDOUBLE; if (nextIndex != i + 1) {
i = nextIndex - 1;
ch = ' '; ch = ' ';
chPrev = ' '; chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_STRING;
}
} else if (ch == '\'') {
if (chNext == '\'' && chNext2 == '\'') {
i += 2;
state = SCE_P_TRIPLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_CHARACTER;
} }
} else if (isoperator(ch)) { } else if (isoperator(ch)) {
styler.ColourTo(i, SCE_P_OPERATOR); styler.ColourTo(i, SCE_P_OPERATOR);
@@ -278,4 +320,131 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
} }
} }
LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc); static bool IsCommentLine(int line, Accessor &styler) {
int pos = styler.LineStart(line);
int eol_pos = styler.LineStart(line+1) - 1;
for (int i = pos; i < eol_pos; i++) {
char ch = styler[i];
if (ch == '#')
return true;
else if (ch != ' ' && ch != '\t')
return false;
}
return false;
}
static bool IsQuoteLine(int line, Accessor &styler) {
int style = styler.StyleAt(styler.LineStart(line)) & 31;
return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
}
static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
WordList *[], Accessor &styler) {
int maxPos = startPos + length;
int maxLines = styler.GetLine(maxPos-1);
bool foldComment = styler.GetPropertyInt("fold.comment.python");
bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
// Backtrack to previous non-blank line so we can determine indent level
// for any white space lines (needed esp. within triple quoted strings)
// and so we can fix any preceding fold level (which is why we go back
// at least one line in all cases)
int spaceFlags = 0;
int lineCurrent = styler.GetLine(startPos);
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
while (lineCurrent > 0) {
lineCurrent--;
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) &&
(!IsCommentLine(lineCurrent, styler)) &&
(!IsQuoteLine(lineCurrent, styler)))
break;
}
int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
startPos = styler.LineStart(lineCurrent);
// Set up initial state
int prev_state = SCE_P_DEFAULT & 31;
if (lineCurrent >= 1)
prev_state = styler.StyleAt(startPos-1) & 31;
int prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
int prevComment = 0;
if (lineCurrent >= 1)
prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
// Process all characters to end of requested range or end of any triple quote
// or comment that hangs over the end of the range
while ((lineCurrent <= maxLines) || prevQuote || prevComment) {
// Gather info
int lev = indentCurrent;
int lineNext = lineCurrent + 1;
int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
int indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
int quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
int quote_start = (quote && !prevQuote);
int quote_continue = (quote && prevQuote);
int comment = foldComment && IsCommentLine(lineCurrent, styler);
int comment_start = (comment && !prevComment &&
IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
int comment_continue = (comment && prevComment);
if ((!quote || !prevQuote) && !comment)
indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
if (quote)
indentNext = indentCurrentLevel;
if (indentNext & SC_FOLDLEVELWHITEFLAG)
indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
if (quote_start) {
// Place fold point at start of triple quoted string
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (quote_continue || prevQuote) {
// Add level to rest of lines in the string
lev = lev + 1;
} else if (comment_start) {
// Place fold point at start of a block of comments
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (comment_continue) {
// Add level to rest of lines in the block
lev = lev + 1;
}
// Skip past any blank lines for next indent level info; we skip also comments
// starting in column 0 which effectively folds them into surrounding code
// rather than screwing up folding. Then set indent level on the lines
// we skipped to be same as maximum of current and next indent. This approach
// does a reasonable job of collapsing white space into surrounding code
// without getting confused by white space at the start of an indented level.
while (!quote &&
((indentNext & SC_FOLDLEVELWHITEFLAG) || styler[styler.LineStart(lineNext)] == '#') &&
(lineNext < maxLines)) {
int level = Platform::Maximum(indentCurrent, indentNext);
if (indentNext & SC_FOLDLEVELWHITEFLAG)
level = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
styler.SetLevel(lineNext, level);
lineNext++;
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
}
// Set fold header on non-quote/non-comment line
if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
lev |= SC_FOLDLEVELHEADERFLAG;
}
// Keep track of triple quote and block comment state of previous line
prevQuote = quote;
prevComment = comment_start || comment_continue;
// Set fold level for this line and move to next line
styler.SetLevel(lineCurrent, lev);
indentCurrent = indentNext;
lineCurrent = lineNext;
}
// Make sure last line indent level is set too
styler.SetLevel(lineCurrent, indentCurrent);
}
LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc);

View File

@@ -0,0 +1,355 @@
// Scintilla source code edit control
/** @file LexRuby.cxx
** Lexer for Ruby.
**/
// Copyright 2001- by Clemens Wyss <wys@helbling.ch>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
char s[100];
bool wordIsNumber = isdigit(styler[start]);
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
}
char chAttr = SCE_P_IDENTIFIER;
if (0 == strcmp(prevWord, "class"))
chAttr = SCE_P_CLASSNAME;
else if (0 == strcmp(prevWord, "module"))
chAttr = SCE_P_CLASSNAME;
else if (0 == strcmp(prevWord, "def"))
chAttr = SCE_P_DEFNAME;
else if (wordIsNumber)
chAttr = SCE_P_NUMBER;
else if (keywords.InList(s))
chAttr = SCE_P_WORD;
// make sure that dot-qualifiers inside the word are lexed correct
else for (unsigned int i = 0; i < end - start + 1; i++) {
if (styler[start + i] == '.') {
styler.ColourTo(start + i - 1, chAttr);
styler.ColourTo(start + i, SCE_P_OPERATOR);
}
}
styler.ColourTo(end, chAttr);
strcpy(prevWord, s);
}
static bool IsRbComment(Accessor &styler, int pos, int len) {
return len>0 && styler[pos]=='#';
}
static bool IsRbStringStart(char ch, char chNext, char chNext2) {
if (ch == '\'' || ch == '"')
return true;
if (ch == 'u' || ch == 'U') {
if (chNext == '"' || chNext == '\'')
return true;
if ((chNext == 'r' || chNext == 'R') && (chNext2 == '"' || chNext2 == '\''))
return true;
}
if ((ch == 'r' || ch == 'R') && (chNext == '"' || chNext == '\''))
return true;
return false;
}
static bool IsRbWordStart(char ch, char chNext, char chNext2) {
return (iswordchar(ch) && !IsRbStringStart(ch, chNext, chNext2));
}
/* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
static int GetRbStringState(Accessor &styler, int i, int *nextIndex) {
char ch = styler.SafeGetCharAt(i);
char chNext = styler.SafeGetCharAt(i + 1);
// Advance beyond r, u, or ur prefix, but bail if there are any unexpected chars
if (ch == 'r' || ch == 'R') {
i++;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
}
else if (ch == 'u' || ch == 'U') {
if (chNext == 'r' || chNext == 'R')
i += 2;
else
i += 1;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
}
if (ch != '"' && ch != '\'') {
*nextIndex = i + 1;
return SCE_P_DEFAULT;
}
if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) {
*nextIndex = i + 3;
if (ch == '"')
return SCE_P_TRIPLEDOUBLE;
else
return SCE_P_TRIPLE;
} else {
*nextIndex = i + 1;
if (ch == '"')
return SCE_P_STRING;
else
return SCE_P_CHARACTER;
}
}
static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
int lengthDoc = startPos + length;
// Backtrack to previous line in case need to fix its tab whinging
if (startPos > 0) {
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) {
startPos = styler.LineStart(lineCurrent-1);
if (startPos == 0)
initStyle = SCE_P_DEFAULT;
else
initStyle = styler.StyleAt(startPos-1);
}
}
// Ruby uses a different mask because bad indentation is marked by oring with 32
styler.StartAt(startPos, 127);
WordList &keywords = *keywordlists[0];
int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
char prevWord[200];
prevWord[0] = '\0';
if (length == 0)
return ;
int state = initStyle & 31;
int nextIndex = 0;
char chPrev = ' ';
char chPrev2 = ' ';
char chNext = styler[startPos];
styler.StartSegment(startPos);
bool atStartLine = true;
int spaceFlags = 0;
for (int i = startPos; i < lengthDoc; i++) {
if (atStartLine) {
char chBad = static_cast<char>(64);
char chGood = static_cast<char>(0);
char chFlags = chGood;
if (whingeLevel == 1) {
chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
} else if (whingeLevel == 2) {
chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood;
} else if (whingeLevel == 3) {
chFlags = (spaceFlags & wsSpace) ? chBad : chGood;
} else if (whingeLevel == 4) {
chFlags = (spaceFlags & wsTab) ? chBad : chGood;
}
styler.SetFlags(chFlags, static_cast<char>(state));
atStartLine = false;
}
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2);
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
// Perform colourisation of white space and triple quoted strings at end of each line to allow
// tab marking to work inside white space and triple quoted strings
styler.ColourTo(i, state);
}
atStartLine = true;
}
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
chPrev2 = ' ';
i += 1;
continue;
}
if (state == SCE_P_STRINGEOL) {
if (ch != '\r' && ch != '\n') {
styler.ColourTo(i - 1, state);
state = SCE_P_DEFAULT;
}
}
if (state == SCE_P_DEFAULT) {
if (IsRbWordStart(ch, chNext, chNext2)) {
styler.ColourTo(i - 1, state);
state = SCE_P_WORD;
} else if (ch == '#') {
styler.ColourTo(i - 1, state);
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (ch == '=' && chNext == 'b') {
// =begin indicates the start of a comment (doc) block
if(styler.SafeGetCharAt(i + 2) == 'e' && styler.SafeGetCharAt(i + 3) == 'g' && styler.SafeGetCharAt(i + 4) == 'i' && styler.SafeGetCharAt(i + 5) == 'n') {
styler.ColourTo(i - 1, state);
state = SCE_P_TRIPLEDOUBLE; //SCE_C_COMMENT;
}
} else if (IsRbStringStart(ch, chNext, chNext2)) {
styler.ColourTo(i - 1, state);
state = GetRbStringState(styler, i, &nextIndex);
if (nextIndex != i + 1) {
i = nextIndex - 1;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (isoperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_P_OPERATOR);
}
} else if (state == SCE_P_WORD) {
if (!iswordchar(ch)) {
ClassifyWordRb(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
state = SCE_P_DEFAULT;
if (ch == '#') {
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (IsRbStringStart(ch, chNext, chNext2)) {
styler.ColourTo(i - 1, state);
state = GetRbStringState(styler, i, &nextIndex);
if (nextIndex != i + 1) {
i = nextIndex - 1;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_P_OPERATOR);
}
}
} else {
if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_STRING) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_P_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_P_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_TRIPLE) {
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_TRIPLEDOUBLE) {
// =end terminates the comment block
if (ch == 'd' && chPrev == 'n' && chPrev2 == 'e') {
if (styler.SafeGetCharAt(i - 3) == '=') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
}
}
}
chPrev2 = chPrev;
chPrev = ch;
}
if (state == SCE_P_WORD) {
ClassifyWordRb(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
} else {
styler.ColourTo(lengthDoc, state);
}
}
static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
int lengthDoc = startPos + length;
// Backtrack to previous line in case need to fix its fold status
int lineCurrent = styler.GetLine(startPos);
if (startPos > 0) {
if (lineCurrent > 0) {
lineCurrent--;
startPos = styler.LineStart(lineCurrent);
if (startPos == 0)
initStyle = SCE_P_DEFAULT;
else
initStyle = styler.StyleAt(startPos-1);
}
}
int state = initStyle & 31;
int spaceFlags = 0;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsRbComment);
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
indentCurrent |= SC_FOLDLEVELWHITEFLAG;
char chNext = styler[startPos];
for (int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styler.StyleAt(i) & 31;
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsRbComment);
if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE))
indentNext |= SC_FOLDLEVELWHITEFLAG;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
// Line after is blank so check the next - maybe should continue further?
int spaceFlags2 = 0;
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsRbComment);
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
}
indentCurrent = indentNext;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
}
}
}
LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc);

View File

@@ -1,13 +1,15 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// LexSQL.cxx - lexer for SQL /** @file LexSQL.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Lexer for SQL.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -38,7 +40,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
int initStyle, WordList *keywordlists[], Accessor &styler) { int initStyle, WordList *keywordlists[], Accessor &styler) {
WordList &keywords = *keywordlists[0]; WordList &keywords = *keywordlists[0];
styler.StartAt(startPos); styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold"); bool fold = styler.GetPropertyInt("fold");
@@ -153,4 +155,4 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
styler.ColourTo(lengthDoc - 1, state); styler.ColourTo(lengthDoc - 1, state);
} }
LexerModule lmSQL(SCLEX_SQL, ColouriseSQLDoc); LexerModule lmSQL(SCLEX_SQL, ColouriseSQLDoc, "sql");

View File

@@ -1,13 +1,15 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// LexVB.cxx - lexer for Visual Basic and VBScript /** @file LexVB.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Lexer for Visual Basic and VBScript.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "Platform.h" #include "Platform.h"
@@ -43,11 +45,15 @@ static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywor
return SCE_C_DEFAULT; return SCE_C_DEFAULT;
} }
static bool IsVBComment(Accessor &styler, int pos, int len) {
return len>0 && styler[pos]=='\'';
}
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) { WordList *keywordlists[], Accessor &styler) {
WordList &keywords = *keywordlists[0]; WordList &keywords = *keywordlists[0];
styler.StartAt(startPos); styler.StartAt(startPos);
int visibleChars = 0; int visibleChars = 0;
@@ -73,7 +79,7 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
} }
visibleChars = 0; visibleChars = 0;
} }
if (!isspace(ch)) if (!isspacechar(ch))
visibleChars++; visibleChars++;
if (state == SCE_C_DEFAULT) { if (state == SCE_C_DEFAULT) {
@@ -136,4 +142,56 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(lengthDoc, state); styler.ColourTo(lengthDoc, state);
} }
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc); static void FoldVBDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
int lengthDoc = startPos + length;
// Backtrack to previous line in case need to fix its fold status
int lineCurrent = styler.GetLine(startPos);
if (startPos > 0) {
if (lineCurrent > 0) {
lineCurrent--;
startPos = styler.LineStart(lineCurrent);
if (startPos == 0)
initStyle = SCE_P_DEFAULT;
else
initStyle = styler.StyleAt(startPos-1);
}
}
int state = initStyle & 31;
int spaceFlags = 0;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsVBComment);
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
indentCurrent |= SC_FOLDLEVELWHITEFLAG;
char chNext = styler[startPos];
for (int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styler.StyleAt(i) & 31;
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsVBComment);
if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE))
indentNext |= SC_FOLDLEVELWHITEFLAG;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
// Line after is blank so check the next - maybe should continue further?
int spaceFlags2 = 0;
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsVBComment);
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
}
indentCurrent = indentNext;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
}
}
}
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc, "vb", FoldVBDoc);

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// LineMarker.cxx - defines the look of a line marker in the margin /** @file LineMarker.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the look of a line marker in the margin .
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include "Platform.h" #include "Platform.h"
@@ -8,13 +10,49 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "LineMarker.h" #include "LineMarker.h"
void LineMarker::Draw(Surface *surface, PRectangle &rc) { static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
PRectangle rc;
rc.left = centreX - armSize;
rc.top = centreY - armSize;
rc.right = centreX + armSize + 1;
rc.bottom = centreY + armSize + 1;
surface->RectangleDraw(rc, back, fore);
}
static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
PRectangle rcCircle;
rcCircle.left = centreX - armSize;
rcCircle.top = centreY - armSize;
rcCircle.right = centreX + armSize + 1;
rcCircle.bottom = centreY + armSize + 1;
surface->Ellipse(rcCircle, back, fore);
}
static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore);
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
void LineMarker::Draw(Surface *surface, PRectangle &rcWhole) {
// Restrict most shapes a bit
PRectangle rc = rcWhole;
rc.top++;
rc.bottom--;
int minDim = Platform::Minimum(rc.Width(), rc.Height()); int minDim = Platform::Minimum(rc.Width(), rc.Height());
minDim--; // Ensure does not go beyond edge minDim--; // Ensure does not go beyond edge
int centreX = (rc.right + rc.left) / 2; int centreX = (rc.right + rc.left) / 2;
int centreY = (rc.bottom + rc.top) / 2; int centreY = (rc.bottom + rc.top) / 2;
int dimOn2 = minDim / 2; int dimOn2 = minDim / 2;
int dimOn4 = minDim / 4; int dimOn4 = minDim / 4;
int blobSize = dimOn2-1;
int armSize = dimOn2-2;
if (rc.Width() > (rc.Height() * 2)) { if (rc.Width() > (rc.Height() * 2)) {
// Wide column is line number so move to left to try to avoid overlapping number // Wide column is line number so move to left to try to avoid overlapping number
centreX = rc.left + dimOn2 + 1; centreX = rc.left + dimOn2 + 1;
@@ -50,7 +88,6 @@ void LineMarker::Draw(Surface *surface, PRectangle &rc) {
fore.allocated, back.allocated); fore.allocated, back.allocated);
} else if (markType == SC_MARK_PLUS) { } else if (markType == SC_MARK_PLUS) {
int armSize = dimOn2-2;
Point pts[] = { Point pts[] = {
Point(centreX - armSize, centreY - 1), Point(centreX - armSize, centreY - 1),
Point(centreX - 1, centreY - 1), Point(centreX - 1, centreY - 1),
@@ -69,7 +106,6 @@ void LineMarker::Draw(Surface *surface, PRectangle &rc) {
fore.allocated, back.allocated); fore.allocated, back.allocated);
} else if (markType == SC_MARK_MINUS) { } else if (markType == SC_MARK_MINUS) {
int armSize = dimOn2-2;
Point pts[] = { Point pts[] = {
Point(centreX - armSize, centreY - 1), Point(centreX - armSize, centreY - 1),
Point(centreX + armSize, centreY -1), Point(centreX + armSize, centreY -1),
@@ -86,8 +122,114 @@ void LineMarker::Draw(Surface *surface, PRectangle &rc) {
rcSmall.right = rc.right - 1; rcSmall.right = rc.right - 1;
rcSmall.bottom = rc.bottom - 2; rcSmall.bottom = rc.bottom - 2;
surface->RectangleDraw(rcSmall, fore.allocated, back.allocated); surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
} else if (markType == SC_MARK_EMPTY) { } else if (markType == SC_MARK_EMPTY) {
// An invisible marker so don't draw anything // An invisible marker so don't draw anything
} else if (markType == SC_MARK_VLINE) {
surface->PenColour(back.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_LCORNER) {
surface->PenColour(back.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2);
surface->LineTo(rc.right - 2, rc.top + dimOn2);
} else if (markType == SC_MARK_TCORNER) {
surface->PenColour(back.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rcWhole.bottom);
surface->MoveTo(centreX, rc.top + dimOn2);
surface->LineTo(rc.right - 2, rc.top + dimOn2);
} else if (markType == SC_MARK_LCORNERCURVE) {
surface->PenColour(back.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2-3);
surface->LineTo(centreX+3, rc.top + dimOn2);
surface->LineTo(rc.right - 1, rc.top + dimOn2);
} else if (markType == SC_MARK_TCORNERCURVE) {
surface->PenColour(back.allocated);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rcWhole.bottom);
surface->MoveTo(centreX, rc.top + dimOn2-3);
surface->LineTo(centreX+3, rc.top + dimOn2);
surface->LineTo(rc.right - 1, rc.top + dimOn2);
} else if (markType == SC_MARK_BOXPLUS) {
surface->PenColour(back.allocated);
DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
} else if (markType == SC_MARK_BOXPLUSCONNECTED) {
surface->PenColour(back.allocated);
DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
} else if (markType == SC_MARK_BOXMINUS) {
surface->PenColour(back.allocated);
DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_BOXMINUSCONNECTED) {
surface->PenColour(back.allocated);
DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
} else if (markType == SC_MARK_CIRCLEPLUS) {
DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
surface->PenColour(back.allocated);
DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
} else if (markType == SC_MARK_CIRCLEPLUSCONNECTED) {
DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
surface->PenColour(back.allocated);
DrawPlus(surface, centreX, centreY, blobSize, back.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
} else if (markType == SC_MARK_CIRCLEMINUS) {
DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
surface->PenColour(back.allocated);
DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) {
DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated);
surface->PenColour(back.allocated);
DrawMinus(surface, centreX, centreY, blobSize, back.allocated);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
} else { // SC_MARK_SHORTARROW } else { // SC_MARK_SHORTARROW
Point pts[] = { Point pts[] = {
Point(centreX, centreY + dimOn2), Point(centreX, centreY + dimOn2),

View File

@@ -1,11 +1,15 @@
// Scintilla source code edit control // Scintilla source code edit control
// LineMarker.h - defines the look of a line marker in the margin /** @file LineMarker.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the look of a line marker in the margin .
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef LINEMARKER_H #ifndef LINEMARKER_H
#define LINEMARKER_H #define LINEMARKER_H
/**
*/
class LineMarker { class LineMarker {
public: public:
int markType; int markType;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,865 @@
// Scintilla source code edit control
/** @file RESearch.cxx
** Regular expression search library.
**/
/*
* regex - Regular expression pattern matching and replacement
*
* By: Ozan S. Yigit (oz)
* Dept. of Computer Science
* York University
*
* Original code available from http://www.cs.yorku.ca/~oz/
* Translation to C++ by Neil Hodgson neilh@scintilla.org
* Removed all use of register.
* Converted to modern function prototypes.
* Put all global/static variables into an object so this code can be
* used from multiple threads etc.
*
* These routines are the PUBLIC DOMAIN equivalents of regex
* routines as found in 4.nBSD UN*X, with minor extensions.
*
* These routines are derived from various implementations found
* in software tools books, and Conroy's grep. They are NOT derived
* from licensed/restricted software.
* For more interesting/academic/complicated implementations,
* see Henry Spencer's regexp routines, or GNU Emacs pattern
* matching module.
*
* Modification history:
*
* $Log$
* Revision 1.1 2001/09/01 03:05:24 RD
* Upgraded to version 1.39 of Scintilla, and upated wxStyledTextCtrl
* accordingly.
*
* Revision 1.6 2001/04/29 13:32:10 nyamatongwe
* Addition of new target methods - versions of ReplaceTarget that take counted
* strings to allow for nulls, SearchInTarget and Get/SetSearchFlags to use a
* series of calls rather than a structure.
* Handling of \000 in search and replace.
* Handling of /escapes within character ranges of regular expressions.
* Some handling of bare ^ and $ regular expressions.
*
* Revision 1.5 2001/04/20 07:36:09 nyamatongwe
* Removed DEBUG code that failed to compile on GTK+.
*
* Revision 1.4 2001/04/13 03:52:13 nyamatongwe
* Added URL to find original code to comments.
*
* Revision 1.3 2001/04/06 12:24:21 nyamatongwe
* Made regular expression searching work on a line by line basis, made ^ and
* $ work, made [set] work, and added a case insensitive option.
*
* Revision 1.2 2001/04/05 01:58:04 nyamatongwe
* Replace target functionality to make find and replace operations faster
* by diminishing screen updates and allow for \d patterns in the replacement
* text.
*
* Revision 1.1 2001/04/04 12:52:44 nyamatongwe
* Moved to public domain regular expresion implementation.
*
* Revision 1.4 1991/10/17 03:56:42 oz
* miscellaneous changes, small cleanups etc.
*
* Revision 1.3 1989/04/01 14:18:09 oz
* Change all references to a dfa: this is actually an nfa.
*
* Revision 1.2 88/08/28 15:36:04 oz
* Use a complement bitmap to represent NCL.
* This removes the need to have seperate
* code in the PMatch case block - it is
* just CCL code now.
*
* Use the actual CCL code in the CLO
* section of PMatch. No need for a recursive
* PMatch call.
*
* Use a bitmap table to set char bits in an
* 8-bit chunk.
*
* Interfaces:
* RESearch::Compile: compile a regular expression into a NFA.
*
* char *RESearch::Compile(s)
* char *s;
*
* RESearch::Execute: execute the NFA to match a pattern.
*
* int RESearch::Execute(s)
* char *s;
*
* RESearch::ModifyWord change RESearch::Execute's understanding of what a "word"
* looks like (for \< and \>) by adding into the
* hidden word-syntax table.
*
* void RESearch::ModifyWord(s)
* char *s;
*
* RESearch::Substitute: substitute the matched portions in a new string.
*
* int RESearch::Substitute(src, dst)
* char *src;
* char *dst;
*
* re_fail: failure routine for RESearch::Execute.
*
* void re_fail(msg, op)
* char *msg;
* char op;
*
* Regular Expressions:
*
* [1] char matches itself, unless it is a special
* character (metachar): . \ [ ] * + ^ $
*
* [2] . matches any character.
*
* [3] \ matches the character following it, except
* when followed by a left or right round bracket,
* a digit 1 to 9 or a left or right angle bracket.
* (see [7], [8] and [9])
* It is used as an escape character for all
* other meta-characters, and itself. When used
* in a set ([4]), it is treated as an ordinary
* character.
*
* [4] [set] matches one of the characters in the set.
* If the first character in the set is "^",
* it matches a character NOT in the set, i.e.
* complements the set. A shorthand S-E is
* used to specify a set of characters S upto
* E, inclusive. The special characters "]" and
* "-" have no special meaning if they appear
* as the first chars in the set.
* examples: match:
*
* [a-z] any lowercase alpha
*
* [^]-] any char except ] and -
*
* [^A-Z] any char except uppercase
* alpha
*
* [a-zA-Z] any alpha
*
* [5] * any regular expression form [1] to [4], followed by
* closure char (*) matches zero or more matches of
* that form.
*
* [6] + same as [5], except it matches one or more.
*
* [7] a regular expression in the form [1] to [10], enclosed
* as \(form\) matches what form matches. The enclosure
* creates a set of tags, used for [8] and for
* pattern substution. The tagged forms are numbered
* starting from 1.
*
* [8] a \ followed by a digit 1 to 9 matches whatever a
* previously tagged regular expression ([7]) matched.
*
* [9] \< a regular expression starting with a \< construct
* \> and/or ending with a \> construct, restricts the
* pattern matching to the beginning of a word, and/or
* the end of a word. A word is defined to be a character
* string beginning and/or ending with the characters
* A-Z a-z 0-9 and _. It must also be preceded and/or
* followed by any character outside those mentioned.
*
* [10] a composite regular expression xy where x and y
* are in the form [1] to [10] matches the longest
* match of x followed by a match for y.
*
* [11] ^ a regular expression starting with a ^ character
* $ and/or ending with a $ character, restricts the
* pattern matching to the beginning of the line,
* or the end of line. [anchors] Elsewhere in the
* pattern, ^ and $ are treated as ordinary characters.
*
*
* Acknowledgements:
*
* HCR's Hugh Redelmeier has been most helpful in various
* stages of development. He convinced me to include BOW
* and EOW constructs, originally invented by Rob Pike at
* the University of Toronto.
*
* References:
* Software tools Kernighan & Plauger
* Software tools in Pascal Kernighan & Plauger
* Grep [rsx-11 C dist] David Conroy
* ed - text editor Un*x Programmer's Manual
* Advanced editing on Un*x B. W. Kernighan
* RegExp routines Henry Spencer
*
* Notes:
*
* This implementation uses a bit-set representation for character
* classes for speed and compactness. Each character is represented
* by one bit in a 128-bit block. Thus, CCL always takes a
* constant 16 bytes in the internal nfa, and RESearch::Execute does a single
* bit comparison to locate the character in the set.
*
* Examples:
*
* pattern: foo*.*
* compile: CHR f CHR o CLO CHR o END CLO ANY END END
* matches: fo foo fooo foobar fobar foxx ...
*
* pattern: fo[ob]a[rz]
* compile: CHR f CHR o CCL bitset CHR a CCL bitset END
* matches: fobar fooar fobaz fooaz
*
* pattern: foo\\+
* compile: CHR f CHR o CHR o CHR \ CLO CHR \ END END
* matches: foo\ foo\\ foo\\\ ...
*
* pattern: \(foo\)[1-3]\1 (same as foo[1-3]foo)
* compile: BOT 1 CHR f CHR o CHR o EOT 1 CCL bitset REF 1 END
* matches: foo1foo foo2foo foo3foo
*
* pattern: \(fo.*\)-\1
* compile: BOT 1 CHR f CHR o CLO ANY END EOT 1 CHR - REF 1 END
* matches: foo-foo fo-fo fob-fob foobar-foobar ...
*/
#include "RESearch.h"
#define OKP 1
#define NOP 0
#define CHR 1
#define ANY 2
#define CCL 3
#define BOL 4
#define EOL 5
#define BOT 6
#define EOT 7
#define BOW 8
#define EOW 9
#define REF 10
#define CLO 11
#define END 0
/*
* The following defines are not meant to be changeable.
* They are for readability only.
*/
#define BLKIND 0170
#define BITIND 07
#define ASCIIB 0177
const char bitarr[] = {1,2,4,8,16,32,64,'\200'};
#define badpat(x) (*nfa = END, x)
RESearch::RESearch() {
Init();
}
RESearch::~RESearch() {
Clear();
}
void RESearch::Init() {
sta = NOP; /* status of lastpat */
bol = 0;
for (int i=0; i<MAXTAG; i++)
pat[i] = 0;
for (int j=0; j<BITBLK; j++)
bittab[j] = 0;
}
void RESearch::Clear() {
for (int i=0; i<MAXTAG; i++) {
delete []pat[i];
pat[i] = 0;
bopat[i] = NOTFOUND;
eopat[i] = NOTFOUND;
}
}
bool RESearch::GrabMatches(CharacterIndexer &ci) {
bool success = true;
for (unsigned int i=0; i<MAXTAG; i++) {
if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
unsigned int len = eopat[i] - bopat[i];
pat[i] = new char[len + 1];
if (pat[i]) {
for (unsigned int j=0; j<len; j++)
pat[i][j] = ci.CharAt(bopat[i] + j);
pat[i][len] = '\0';
} else {
success = false;
}
}
}
return success;
}
void RESearch::ChSet(char c) {
bittab[((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND];
}
void RESearch::ChSetWithCase(char c, bool caseSensitive) {
if (caseSensitive) {
ChSet(c);
} else {
if ((c >= 'a') && (c <= 'z')) {
ChSet(c);
ChSet(static_cast<char>(c - 'a' + 'A'));
} else if ((c >= 'A') && (c <= 'Z')) {
ChSet(c);
ChSet(static_cast<char>(c - 'A' + 'a'));
} else {
ChSet(c);
}
}
}
const char escapeValue(char ch) {
switch (ch) {
case 'a': return '\a';
case 'b': return '\b';
case 'f': return '\f';
case 'n': return '\n';
case 'r': return '\r';
case 't': return '\t';
case 'v': return '\v';
}
return 0;
}
const char *RESearch::Compile(const char *pat, int length, bool caseSensitive) {
char *mp=nfa; /* nfa pointer */
char *lp; /* saved pointer.. */
char *sp=nfa; /* another one.. */
int tagi = 0; /* tag stack index */
int tagc = 1; /* actual tag count */
int n;
char mask; /* xor mask -CCL/NCL */
int c1, c2;
if (!pat || !length)
if (sta)
return 0;
else
return badpat("No previous regular expression");
sta = NOP;
const char *p=pat; /* pattern pointer */
for (int i=0; i<length; i++, p++) {
lp = mp;
switch(*p) {
case '.': /* match any char.. */
*mp++ = ANY;
break;
case '^': /* match beginning.. */
if (p == pat)
*mp++ = BOL;
else {
*mp++ = CHR;
*mp++ = *p;
}
break;
case '$': /* match endofline.. */
if (!*(p+1))
*mp++ = EOL;
else {
*mp++ = CHR;
*mp++ = *p;
}
break;
case '[': /* match char class..*/
*mp++ = CCL;
i++;
if (*++p == '^') {
mask = '\377';
i++;
p++;
} else
mask = 0;
if (*p == '-') { /* real dash */
i++;
ChSet(*p++);
}
if (*p == ']') { /* real brace */
i++;
ChSet(*p++);
}
while (*p && *p != ']') {
if (*p == '-' && *(p+1) && *(p+1) != ']') {
i++;
p++;
c1 = *(p-2) + 1;
i++;
c2 = *p++;
while (c1 <= c2) {
ChSetWithCase(static_cast<char>(c1++), caseSensitive);
}
} else if (*p == '\\' && *(p+1)) {
i++;
p++;
char escape = escapeValue(*p);
if (escape)
ChSetWithCase(escape, caseSensitive);
else
ChSetWithCase(*p, caseSensitive);
i++;
p++;
} else {
i++;
ChSetWithCase(*p++, caseSensitive);
}
}
if (!*p)
return badpat("Missing ]");
for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
*mp++ = static_cast<char>(mask ^ bittab[n]);
break;
case '*': /* match 0 or more.. */
case '+': /* match 1 or more.. */
if (p == pat)
return badpat("Empty closure");
lp = sp; /* previous opcode */
if (*lp == CLO) /* equivalence.. */
break;
switch(*lp) {
case BOL:
case BOT:
case EOT:
case BOW:
case EOW:
case REF:
return badpat("Illegal closure");
default:
break;
}
if (*p == '+')
for (sp = mp; lp < sp; lp++)
*mp++ = *lp;
*mp++ = END;
*mp++ = END;
sp = mp;
while (--mp > lp)
*mp = mp[-1];
*mp = CLO;
mp = sp;
break;
case '\\': /* tags, backrefs .. */
i++;
switch(*++p) {
case '(':
if (tagc < MAXTAG) {
tagstk[++tagi] = tagc;
*mp++ = BOT;
*mp++ = static_cast<char>(tagc++);
}
else
return badpat("Too many \\(\\) pairs");
break;
case ')':
if (*sp == BOT)
return badpat("Null pattern inside \\(\\)");
if (tagi > 0) {
*mp++ = static_cast<char>(EOT);
*mp++ = static_cast<char>(tagstk[tagi--]);
}
else
return badpat("Unmatched \\)");
break;
case '<':
*mp++ = BOW;
break;
case '>':
if (*sp == BOW)
return badpat("Null pattern inside \\<\\>");
*mp++ = EOW;
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
n = *p-'0';
if (tagi > 0 && tagstk[tagi] == n)
return badpat("Cyclical reference");
if (tagc > n) {
*mp++ = static_cast<char>(REF);
*mp++ = static_cast<char>(n);
}
else
return badpat("Undetermined reference");
break;
case 'a':
case 'b':
case 'n':
case 'f':
case 'r':
case 't':
case 'v':
*mp++ = CHR;
*mp++ = escapeValue(*p);
break;
default:
*mp++ = CHR;
*mp++ = *p;
}
break;
default : /* an ordinary char */
if (caseSensitive) {
*mp++ = CHR;
*mp++ = *p;
} else {
*mp++ = CCL;
mask = 0;
ChSetWithCase(*p, false);
for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
*mp++ = static_cast<char>(mask ^ bittab[n]);
}
break;
}
sp = lp;
}
if (tagi > 0)
return badpat("Unmatched \\(");
*mp = END;
sta = OKP;
return 0;
}
/*
* RESearch::Execute:
* execute nfa to find a match.
*
* special cases: (nfa[0])
* BOL
* Match only once, starting from the
* beginning.
* CHR
* First locate the character without
* calling PMatch, and if found, call
* PMatch for the remaining string.
* END
* RESearch::Compile failed, poor luser did not
* check for it. Fail fast.
*
* If a match is found, bopat[0] and eopat[0] are set
* to the beginning and the end of the matched fragment,
* respectively.
*
*/
int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
char c;
int ep = NOTFOUND;
char *ap = nfa;
bol = lp;
failure = 0;
Clear();
switch(*ap) {
case BOL: /* anchored: match from BOL only */
ep = PMatch(ci, lp, endp, ap);
break;
case EOL: /* just searching for end of line normal path doesn't work */
if (*(ap+1) == END) {
lp = endp;
ep = lp;
break;
} else {
return 0;
}
case CHR: /* ordinary char: locate it fast */
c = *(ap+1);
while ((lp < endp) && (ci.CharAt(lp) != c))
lp++;
if (lp >= endp) /* if EOS, fail, else fall thru. */
return 0;
default: /* regular matching all the way. */
while (lp < endp) {
ep = PMatch(ci, lp, endp, ap);
if (ep != NOTFOUND)
break;
lp++;
}
break;
case END: /* munged automaton. fail always */
return 0;
}
if (ep == NOTFOUND)
return 0;
bopat[0] = lp;
eopat[0] = ep;
return 1;
}
/*
* PMatch: internal routine for the hard part
*
* This code is partly snarfed from an early grep written by
* David Conroy. The backref and tag stuff, and various other
* innovations are by oz.
*
* special case optimizations: (nfa[n], nfa[n+1])
* CLO ANY
* We KNOW .* will match everything upto the
* end of line. Thus, directly go to the end of
* line, without recursive PMatch calls. As in
* the other closure cases, the remaining pattern
* must be matched by moving backwards on the
* string recursively, to find a match for xy
* (x is ".*" and y is the remaining pattern)
* where the match satisfies the LONGEST match for
* x followed by a match for y.
* CLO CHR
* We can again scan the string forward for the
* single char and at the point of failure, we
* execute the remaining nfa recursively, same as
* above.
*
* At the end of a successful match, bopat[n] and eopat[n]
* are set to the beginning and end of subpatterns matched
* by tagged expressions (n = 1 to 9).
*
*/
extern void re_fail(char *,char);
/*
* character classification table for word boundary operators BOW
* and EOW. the reason for not using ctype macros is that we can
* let the user add into our own table. see RESearch::ModifyWord. This table
* is not in the bitset form, since we may wish to extend it in the
* future for other character classifications.
*
* TRUE for 0-9 A-Z a-z _
*/
static char chrtyp[MAXCHR] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 1, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 0, 0, 0, 0
};
#define inascii(x) (0177&(x))
#define iswordc(x) chrtyp[inascii(x)]
#define isinset(x,y) ((x)[((y)&BLKIND)>>3] & bitarr[(y)&BITIND])
/*
* skip values for CLO XXX to skip past the closure
*/
#define ANYSKIP 2 /* [CLO] ANY END ... */
#define CHRSKIP 3 /* [CLO] CHR chr END ... */
#define CCLSKIP 18 /* [CLO] CCL 16bytes END ... */
int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) {
int op, c, n;
int e; /* extra pointer for CLO */
int bp; /* beginning of subpat.. */
int ep; /* ending of subpat.. */
int are; /* to save the line ptr. */
while ((op = *ap++) != END)
switch(op) {
case CHR:
if (ci.CharAt(lp++) != *ap++)
return NOTFOUND;
break;
case ANY:
if (lp++ >= endp)
return NOTFOUND;
break;
case CCL:
c = ci.CharAt(lp++);
if (!isinset(ap,c))
return NOTFOUND;
ap += BITBLK;
break;
case BOL:
if (lp != bol)
return NOTFOUND;
break;
case EOL:
if (lp < endp)
return NOTFOUND;
break;
case BOT:
bopat[*ap++] = lp;
break;
case EOT:
eopat[*ap++] = lp;
break;
case BOW:
if (lp!=bol && iswordc(ci.CharAt(lp-1)) || !iswordc(ci.CharAt(lp)))
return NOTFOUND;
break;
case EOW:
if (lp==bol || !iswordc(ci.CharAt(lp-1)) || iswordc(ci.CharAt(lp)))
return NOTFOUND;
break;
case REF:
n = *ap++;
bp = bopat[n];
ep = eopat[n];
while (bp < ep)
if (ci.CharAt(bp++) != ci.CharAt(lp++))
return NOTFOUND;
break;
case CLO:
are = lp;
switch(*ap) {
case ANY:
while (lp < endp)
lp++;
n = ANYSKIP;
break;
case CHR:
c = *(ap+1);
while ((lp < endp) && (c == ci.CharAt(lp)))
lp++;
n = CHRSKIP;
break;
case CCL:
while ((lp < endp) && isinset(ap+1,ci.CharAt(lp)))
lp++;
n = CCLSKIP;
break;
default:
failure = true;
//re_fail("closure: bad nfa.", *ap);
return NOTFOUND;
}
ap += n;
while (lp >= are) {
if ((e = PMatch(ci, lp, endp, ap)) != NOTFOUND)
return e;
--lp;
}
return NOTFOUND;
default:
//re_fail("RESearch::Execute: bad nfa.", static_cast<char>(op));
return NOTFOUND;
}
return lp;
}
/*
* RESearch::ModifyWord:
* add new characters into the word table to change RESearch::Execute's
* understanding of what a word should look like. Note that we
* only accept additions into the word definition.
*
* If the string parameter is 0 or null string, the table is
* reset back to the default containing A-Z a-z 0-9 _. [We use
* the compact bitset representation for the default table]
*/
static char deftab[16] = {
0, 0, 0, 0, 0, 0, '\377', 003, '\376', '\377', '\377', '\207',
'\376', '\377', '\377', 007
};
void RESearch::ModifyWord(char *s) {
int i;
if (!s || !*s) {
for (i = 0; i < MAXCHR; i++)
if (!isinset(deftab,i))
iswordc(i) = 0;
}
else
while(*s)
iswordc(*s++) = 1;
}
/*
* RESearch::Substitute:
* substitute the matched portions of the src in dst.
*
* & substitute the entire matched pattern.
*
* \digit substitute a subpattern, with the given tag number.
* Tags are numbered from 1 to 9. If the particular
* tagged subpattern does not exist, null is substituted.
*/
int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) {
char c;
int pin;
int bp;
int ep;
if (!*src || !bopat[0])
return 0;
while ((c = *src++) != 0) {
switch(c) {
case '&':
pin = 0;
break;
case '\\':
c = *src++;
if (c >= '0' && c <= '9') {
pin = c - '0';
break;
}
default:
*dst++ = c;
continue;
}
if ((bp = bopat[pin]) != 0 && (ep = eopat[pin]) != 0) {
while (ci.CharAt(bp) && bp < ep)
*dst++ = ci.CharAt(bp++);
if (bp < ep)
return 0;
}
}
*dst = (char) 0;
return 1;
}

View File

@@ -0,0 +1,60 @@
// Scintilla source code edit control
/** @file RESearch.h
** Interface to the regular expression search library.
**/
// Written by Neil Hodgson <neilh@scintilla.org>
// Based on the work of Ozan S. Yigit.
// This file is in the public domain.
#ifndef RESEARCH_H
#define RESEARCH_H
/*
* The following defines are not meant to be changeable.
* They are for readability only.
*/
#define MAXCHR 128
#define CHRBIT 8
#define BITBLK MAXCHR/CHRBIT
class CharacterIndexer {
public:
virtual char CharAt(int index)=0;
};
class RESearch {
public:
RESearch();
~RESearch();
void Init();
void Clear();
bool GrabMatches(CharacterIndexer &ci);
void ChSet(char c);
void ChSetWithCase(char c, bool caseSensitive);
const char *Compile(const char *pat, int length, bool caseSensitive);
int Execute(CharacterIndexer &ci, int lp, int endp);
void ModifyWord(char *s);
int Substitute(CharacterIndexer &ci, char *src, char *dst);
enum {MAXTAG=10};
enum {MAXNFA=2048};
enum {NOTFOUND=-1};
int bopat[MAXTAG];
int eopat[MAXTAG];
char *pat[MAXTAG];
private:
int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
int bol;
int tagstk[MAXTAG]; /* subpat tag stack..*/
char nfa[MAXNFA]; /* automaton.. */
int sta;
char bittab[BITBLK]; /* bit table for CCL */
/* pre-set bits... */
int failure;
};
#endif

View File

@@ -1,26 +1,31 @@
// Scintilla source code edit control // Scintilla source code edit control
// SVector.h - a simple expandable vector /** @file SVector.h
// Copyright 1998-1999 by Neil Hodgson <neilh@hare.net.au> ** A simple expandable vector.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@hare.net.au>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef SVECTOR_H #ifndef SVECTOR_H
#define SVECTOR_H #define SVECTOR_H
// A simple expandable integer vector. /**
// Storage not allocated for elements until an element is used. * A simple expandable integer vector.
// This makes it very lightweight unless used so is a good match for optional features. * Storage not allocated for elements until an element is used.
* This makes it very lightweight unless used so is a good match for optional features.
*/
class SVector { class SVector {
int *v; enum { allocSize = 4000 };
unsigned int size; // Number of elements allocated
unsigned int len; // Number of elements in vector
bool allocFailure; // A memory allocation call has failed
// Internally allocate more elements than the user wants to avoid int *v; ///< The vector
// thrashng the memory allocator unsigned int size; ///< Number of elements allocated
unsigned int len; ///< Number of elements used in vector
bool allocFailure; ///< A memory allocation call has failed
/** Internally allocate more elements than the user wants
* to avoid thrashing the memory allocator. */
void SizeTo(int newSize) { void SizeTo(int newSize) {
if (newSize < 4000) if (newSize < allocSize)
newSize += 4000; newSize += allocSize;
else else
newSize = (newSize * 3) / 2; newSize = (newSize * 3) / 2;
int* newv = new int[newSize]; int* newv = new int[newSize];
@@ -50,6 +55,7 @@ public:
~SVector() { ~SVector() {
Free(); Free();
} }
/// Constructor from another vector.
SVector(const SVector &other) { SVector(const SVector &other) {
allocFailure = false; allocFailure = false;
v = 0; v = 0;
@@ -64,6 +70,7 @@ public:
} }
} }
} }
/// Copy constructor.
SVector &operator=(const SVector &other) { SVector &operator=(const SVector &other) {
if (this != &other) { if (this != &other) {
delete []v; delete []v;
@@ -82,6 +89,9 @@ public:
} }
return *this; return *this;
} }
/** @brief Accessor.
* Allows to access values from the list, and grows it if accessing
* outside the current bounds. The returned value in this case is 0. */
int &operator[](unsigned int i) { int &operator[](unsigned int i) {
if (i >= len) { if (i >= len) {
if (i >= size) { if (i >= size) {
@@ -91,12 +101,15 @@ public:
} }
return v[i]; return v[i];
} }
/// Reset vector.
void Free() { void Free() {
delete []v; delete []v;
v = 0; v = 0;
size = 0; size = 0;
len = 0; len = 0;
} }
/** @brief Grow vector size.
* Doesn't allow a vector to be shrinked. */
void SetLength(unsigned int newLength) { void SetLength(unsigned int newLength) {
if (newLength > len) { if (newLength > len) {
if (newLength >= size) { if (newLength >= size) {
@@ -105,6 +118,7 @@ public:
} }
len = newLength; len = newLength;
} }
/// Get the current length (number of used elements) of the vector.
int Length() const { int Length() const {
return len; return len;
} }

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// ScintillaBase.cxx - an enhanced subclass of Editor with calltips, autocomplete and context menu /** @file ScintillaBase.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** An enhanced subclass of Editor with calltips, autocomplete and context menu.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -15,7 +17,6 @@
#ifdef SCI_LEXER #ifdef SCI_LEXER
#include "SciLexer.h" #include "SciLexer.h"
#include "Accessor.h" #include "Accessor.h"
#include "WindowAccessor.h"
#include "DocumentAccessor.h" #include "DocumentAccessor.h"
#include "KeyWords.h" #include "KeyWords.h"
#endif #endif
@@ -34,22 +35,25 @@
#include "ScintillaBase.h" #include "ScintillaBase.h"
ScintillaBase::ScintillaBase() { ScintillaBase::ScintillaBase() {
#ifdef SCI_LEXER listType = 0;
#ifdef SCI_LEXER
lexLanguage = SCLEX_CONTAINER; lexLanguage = SCLEX_CONTAINER;
for (int wl=0;wl<numWordLists;wl++) lexCurrent = 0;
for (int wl = 0;wl < numWordLists;wl++)
keyWordLists[wl] = new WordList; keyWordLists[wl] = new WordList;
keyWordLists[numWordLists] = 0;
#endif #endif
} }
ScintillaBase::~ScintillaBase() { ScintillaBase::~ScintillaBase() {
#ifdef SCI_LEXER #ifdef SCI_LEXER
for (int wl=0;wl<numWordLists;wl++) for (int wl = 0;wl < numWordLists;wl++)
delete keyWordLists[wl]; delete keyWordLists[wl];
#endif #endif
} }
void ScintillaBase::Finalise() { void ScintillaBase::Finalise() {
Editor::Finalise(); Editor::Finalise();
popup.Destroy(); popup.Destroy();
} }
@@ -70,10 +74,12 @@ void ScintillaBase::Command(int cmdId) {
switch (cmdId) { switch (cmdId) {
case idAutoComplete: // Nothing to do case idAutoComplete: // Nothing to do
break; break;
case idCallTip: // Nothing to do case idCallTip: // Nothing to do
break; break;
case idcmdUndo: case idcmdUndo:
@@ -170,7 +176,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
//Platform::DebugPrintf("AutoComplete %s\n", list); //Platform::DebugPrintf("AutoComplete %s\n", list);
ct.CallTipCancel(); ct.CallTipCancel();
if (ac.chooseSingle) { if (ac.chooseSingle && (listType == 0)) {
if (list && !strchr(list, ac.GetSeparator())) { if (list && !strchr(list, ac.GetSeparator())) {
if (ac.ignoreCase) { if (ac.ignoreCase) {
SetEmptySelection(currentPos - lenEntered); SetEmptySelection(currentPos - lenEntered);
@@ -183,13 +189,13 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
pdoc->InsertString(currentPos, list + lenEntered); pdoc->InsertString(currentPos, list + lenEntered);
SetEmptySelection(currentPos + strlen(list + lenEntered)); SetEmptySelection(currentPos + strlen(list + lenEntered));
} }
return; return ;
} }
} }
ac.Start(wDraw, idAutoComplete, currentPos, lenEntered); ac.Start(wMain, idAutoComplete, currentPos, lenEntered);
PRectangle rcClient = GetClientRectangle(); PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(currentPos-lenEntered); Point pt = LocationFromPosition(currentPos - lenEntered);
int heightLB = 100; int heightLB = 100;
int widthLB = 100; int widthLB = 100;
@@ -200,8 +206,8 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
} }
PRectangle rcac; PRectangle rcac;
rcac.left = pt.x - 5; rcac.left = pt.x - 5;
if (pt.y >= rcClient.bottom - heightLB && // Wont fit below. if (pt.y >= rcClient.bottom - heightLB && // Wont fit below.
pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above. pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
rcac.top = pt.y - heightLB; rcac.top = pt.y - heightLB;
if (rcac.top < 0) { if (rcac.top < 0) {
heightLB += rcac.top; heightLB += rcac.top;
@@ -225,8 +231,8 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
// Make an allowance for large strings in list // Make an allowance for large strings in list
rcList.left = pt.x - 5; rcList.left = pt.x - 5;
rcList.right = rcList.left + widthLB; rcList.right = rcList.left + widthLB;
if (pt.y >= rcClient.bottom - heightLB && // Wont fit below. if (pt.y >= rcClient.bottom - heightLB && // Wont fit below.
pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above. pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
rcList.top = pt.y - heightAlloced; rcList.top = pt.y - heightAlloced;
} else { } else {
rcList.top = pt.y + vs.lineHeight; rcList.top = pt.y + vs.lineHeight;
@@ -236,7 +242,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
ac.Show(); ac.Show();
if (lenEntered != 0) { if (lenEntered != 0) {
AutoCompleteMoveToCurrentWord(); AutoCompleteMoveToCurrentWord();
} }
} }
void ScintillaBase::AutoCompleteCancel() { void ScintillaBase::AutoCompleteCancel() {
@@ -278,44 +284,45 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
ac.lb.GetValue(item, selected, sizeof(selected)); ac.lb.GetValue(item, selected, sizeof(selected));
} }
ac.Cancel(); ac.Cancel();
if (ac.ignoreCase) { if (listType > 0) {
if (currentPos != ac.posStart) { userListSelected = selected;
pdoc->DeleteChars(ac.posStart, currentPos - ac.posStart); SCNotification scn;
} scn.nmhdr.code = SCN_USERLISTSELECTION;
SetEmptySelection(ac.posStart - ac.startLen); scn.message = 0;
pdoc->DeleteChars(ac.posStart - ac.startLen, ac.startLen); scn.wParam = listType;
if (item != -1) { scn.lParam = 0;
SString piece = selected; scn.text = userListSelected.c_str();
if (fillUp) NotifyParent(scn);
piece += fillUp; return ;
pdoc->InsertString(currentPos, piece.c_str()); }
SetEmptySelection(currentPos + piece.length());
} Position firstPos = ac.posStart - ac.startLen;
} else { if (currentPos < firstPos)
if (currentPos != ac.posStart) { return ;
pdoc->DeleteChars(ac.posStart, currentPos - ac.posStart); if (currentPos != firstPos) {
} pdoc->DeleteChars(firstPos, currentPos - firstPos);
SetEmptySelection(ac.posStart); }
if (item != -1) { SetEmptySelection(ac.posStart);
SString piece = selected + ac.startLen; if (item != -1) {
if (fillUp) SString piece = selected;
piece += fillUp; if (fillUp)
pdoc->InsertString(currentPos, piece.c_str()); piece += fillUp;
SetEmptySelection(currentPos + piece.length()); pdoc->InsertString(firstPos, piece.c_str());
} SetEmptySelection(firstPos + piece.length());
} }
} }
void ScintillaBase::ContextMenu(Point pt) { void ScintillaBase::ContextMenu(Point pt) {
bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
popup.CreatePopUp(); popup.CreatePopUp();
AddToPopUp("Undo", idcmdUndo, pdoc->CanUndo()); AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo());
AddToPopUp("Redo", idcmdRedo, pdoc->CanRedo()); AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo());
AddToPopUp(""); AddToPopUp("");
AddToPopUp("Cut", idcmdCut, currentPos != anchor); AddToPopUp("Cut", idcmdCut, writable && currentPos != anchor);
AddToPopUp("Copy", idcmdCopy, currentPos != anchor); AddToPopUp("Copy", idcmdCopy, currentPos != anchor);
AddToPopUp("Paste", idcmdPaste, WndProc(SCI_CANPASTE, 0, 0)); AddToPopUp("Paste", idcmdPaste, writable && WndProc(SCI_CANPASTE, 0, 0));
AddToPopUp("Delete", idcmdDelete, currentPos != anchor); AddToPopUp("Delete", idcmdDelete, writable && currentPos != anchor);
AddToPopUp(""); AddToPopUp("");
AddToPopUp("Select All", idcmdSelectAll); AddToPopUp("Select All", idcmdSelectAll);
popup.Show(pt, wMain); popup.Show(pt, wMain);
@@ -333,41 +340,67 @@ void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool
} }
#ifdef SCI_LEXER #ifdef SCI_LEXER
void ScintillaBase::SetLexer(uptr_t wParam) {
lexLanguage = wParam;
lexCurrent = LexerModule::Find(lexLanguage);
if (!lexCurrent)
lexCurrent = LexerModule::Find(SCLEX_NULL);
}
void ScintillaBase::SetLexerLanguage(const char *languageName) {
lexLanguage = SCLEX_CONTAINER;
lexCurrent = LexerModule::Find(languageName);
if (!lexCurrent)
lexCurrent = LexerModule::Find(SCLEX_NULL);
if (lexCurrent)
lexLanguage = lexCurrent->GetLanguage();
}
void ScintillaBase::Colourise(int start, int end) { void ScintillaBase::Colourise(int start, int end) {
int lengthDoc = Platform::SendScintilla(wMain.GetID(), SCI_GETLENGTH, 0, 0); int lengthDoc = pdoc->Length();
if (end == -1) if (end == -1)
end = lengthDoc; end = lengthDoc;
int len = end - start; int len = end - start;
PLATFORM_ASSERT(len >= 0);
PLATFORM_ASSERT(start + len <= lengthDoc);
//WindowAccessor styler(wMain.GetID(), props); //WindowAccessor styler(wMain.GetID(), props);
DocumentAccessor styler(pdoc, props); DocumentAccessor styler(pdoc, props, wMain.GetID());
int styleStart = 0; int styleStart = 0;
if (start > 0) if (start > 0)
styleStart = styler.StyleAt(start - 1); styleStart = styler.StyleAt(start - 1);
styler.SetCodePage(pdoc->dbcsCodePage); styler.SetCodePage(pdoc->dbcsCodePage);
LexerModule::Colourise(start, len, styleStart, lexLanguage, keyWordLists, styler); if (lexCurrent) { // Should always succeed as null lexer should always be available
styler.Flush(); lexCurrent->Lex(start, len, styleStart, keyWordLists, styler);
styler.Flush();
if (styler.GetPropertyInt("fold")) {
lexCurrent->Fold(start, len, styleStart, keyWordLists, styler);
styler.Flush();
}
}
} }
#endif #endif
void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) { void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
#ifdef SCI_LEXER #ifdef SCI_LEXER
if (lexLanguage != SCLEX_CONTAINER) { if (lexLanguage != SCLEX_CONTAINER) {
int endStyled = Platform::SendScintilla(wMain.GetID(), SCI_GETENDSTYLED, 0, 0); int endStyled = WndProc(SCI_GETENDSTYLED, 0, 0);
int lineEndStyled = Platform::SendScintilla(wMain.GetID(), SCI_LINEFROMPOSITION, endStyled, 0); int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);
endStyled = Platform::SendScintilla(wMain.GetID(), SCI_POSITIONFROMLINE, lineEndStyled, 0); endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);
Colourise(endStyled, endStyleNeeded); Colourise(endStyled, endStyleNeeded);
return; return ;
} }
#endif #endif
Editor::NotifyStyleToNeeded(endStyleNeeded); Editor::NotifyStyleToNeeded(endStyleNeeded);
} }
long ScintillaBase::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
switch (iMessage) { switch (iMessage) {
case SCI_AUTOCSHOW: case SCI_AUTOCSHOW:
listType = 0;
AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam)); AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam));
break; break;
@@ -395,15 +428,15 @@ long ScintillaBase::WndProc(unsigned int iMessage, unsigned long wParam, long lP
case SCI_AUTOCSTOPS: case SCI_AUTOCSTOPS:
ac.SetStopChars(reinterpret_cast<char *>(lParam)); ac.SetStopChars(reinterpret_cast<char *>(lParam));
break; break;
case SCI_AUTOCSELECT: case SCI_AUTOCSELECT:
ac.Select(reinterpret_cast<char *>(lParam)); ac.Select(reinterpret_cast<char *>(lParam));
break; break;
case SCI_AUTOCSETCANCELATSTART: case SCI_AUTOCSETCANCELATSTART:
ac.cancelAtStartPos = wParam; ac.cancelAtStartPos = wParam;
break; break;
case SCI_AUTOCGETCANCELATSTART: case SCI_AUTOCGETCANCELATSTART:
return ac.cancelAtStartPos; return ac.cancelAtStartPos;
@@ -417,20 +450,35 @@ long ScintillaBase::WndProc(unsigned int iMessage, unsigned long wParam, long lP
case SCI_AUTOCGETCHOOSESINGLE: case SCI_AUTOCGETCHOOSESINGLE:
return ac.chooseSingle; return ac.chooseSingle;
case SCI_AUTOCSETIGNORECASE: case SCI_AUTOCSETIGNORECASE:
ac.ignoreCase = wParam; ac.ignoreCase = wParam;
break; break;
case SCI_AUTOCGETIGNORECASE: case SCI_AUTOCGETIGNORECASE:
return ac.ignoreCase; return ac.ignoreCase;
case SCI_USERLISTSHOW:
listType = wParam;
AutoCompleteStart(0, reinterpret_cast<const char *>(lParam));
break;
case SCI_AUTOCSETAUTOHIDE:
ac.autoHide = wParam;
break;
case SCI_AUTOCGETAUTOHIDE:
return ac.autoHide;
case SCI_CALLTIPSHOW: { case SCI_CALLTIPSHOW: {
AutoCompleteCancel(); AutoCompleteCancel();
if (!ct.wCallTip.Created()) { if (!ct.wCallTip.Created()) {
PRectangle rc = ct.CallTipStart(currentPos, LocationFromPosition(wParam), Point pt = LocationFromPosition(wParam);
pt.y += vs.lineHeight;
PRectangle rc = ct.CallTipStart(currentPos, pt,
reinterpret_cast<char *>(lParam), reinterpret_cast<char *>(lParam),
vs.styles[STYLE_DEFAULT].fontName, vs.styles[STYLE_DEFAULT].size); vs.styles[STYLE_DEFAULT].fontName,
vs.styles[STYLE_DEFAULT].sizeZoomed);
// If the call-tip window would be out of the client // If the call-tip window would be out of the client
// space, adjust so it displays above the text. // space, adjust so it displays above the text.
PRectangle rcClient = GetClientRectangle(); PRectangle rcClient = GetClientRectangle();
@@ -441,7 +489,7 @@ long ScintillaBase::WndProc(unsigned int iMessage, unsigned long wParam, long lP
} }
// Now display the window. // Now display the window.
CreateCallTipWindow(rc); CreateCallTipWindow(rc);
ct.wCallTip.SetPositionRelative(rc, wDraw); ct.wCallTip.SetPositionRelative(rc, wMain);
ct.wCallTip.Show(); ct.wCallTip.Show();
} }
} }
@@ -465,31 +513,37 @@ long ScintillaBase::WndProc(unsigned int iMessage, unsigned long wParam, long lP
ct.colourBG = Colour(wParam); ct.colourBG = Colour(wParam);
InvalidateStyleRedraw(); InvalidateStyleRedraw();
break; break;
#ifdef SCI_LEXER #ifdef SCI_LEXER
case SCI_SETLEXER: case SCI_SETLEXER:
SetLexer(wParam);
lexLanguage = wParam; lexLanguage = wParam;
break; break;
case SCI_GETLEXER: case SCI_GETLEXER:
return lexLanguage; return lexLanguage;
case SCI_COLOURISE: case SCI_COLOURISE:
Colourise(wParam, lParam); Colourise(wParam, lParam);
Redraw(); Redraw();
break; break;
case SCI_SETPROPERTY: case SCI_SETPROPERTY:
props.Set(reinterpret_cast<const char *>(wParam), props.Set(reinterpret_cast<const char *>(wParam),
reinterpret_cast<const char *>(lParam)); reinterpret_cast<const char *>(lParam));
break; break;
case SCI_SETKEYWORDS: case SCI_SETKEYWORDS:
if (wParam < numWordLists) { if (wParam < numWordLists) {
keyWordLists[wParam]->Clear(); keyWordLists[wParam]->Clear();
keyWordLists[wParam]->Set(reinterpret_cast<const char *>(lParam)); keyWordLists[wParam]->Set(reinterpret_cast<const char *>(lParam));
} }
break; break;
case SCI_SETLEXERLANGUAGE:
SetLexerLanguage(reinterpret_cast<const char *>(lParam));
break;
#endif #endif
default: default:

View File

@@ -1,17 +1,22 @@
// Scintilla source code edit control // Scintilla source code edit control
// ScintillaBase.h - defines an enhanced subclass of Editor with calltips, autocomplete and context menu /** @file ScintillaBase.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef SCINTILLABASE_H #ifndef SCINTILLABASE_H
#define SCINTILLABASE_H #define SCINTILLABASE_H
/**
*/
class ScintillaBase : public Editor { class ScintillaBase : public Editor {
// Private so ScintillaBase objects can not be copied // Private so ScintillaBase objects can not be copied
ScintillaBase(const ScintillaBase &) : Editor() {} ScintillaBase(const ScintillaBase &) : Editor() {}
ScintillaBase &operator=(const ScintillaBase &) { return *this; } ScintillaBase &operator=(const ScintillaBase &) { return *this; }
protected: protected:
// Enumeration of commands and child windows /** Enumeration of commands and child windows. */
enum { enum {
idCallTip=1, idCallTip=1,
idAutoComplete=2, idAutoComplete=2,
@@ -30,11 +35,17 @@ protected:
CallTip ct; CallTip ct;
int listType; ///< 0 is an autocomplete list
SString userListSelected; ///< Receives listbox selected string
#ifdef SCI_LEXER #ifdef SCI_LEXER
int lexLanguage; int lexLanguage;
LexerModule *lexCurrent;
PropSet props; PropSet props;
enum {numWordLists=5}; enum {numWordLists=5};
WordList *keyWordLists[numWordLists]; WordList *keyWordLists[numWordLists+1];
void SetLexer(uptr_t wParam);
void SetLexerLanguage(const char *languageName);
void Colourise(int start, int end); void Colourise(int start, int end);
#endif #endif
@@ -67,7 +78,7 @@ protected:
virtual void NotifyStyleToNeeded(int endStyleNeeded); virtual void NotifyStyleToNeeded(int endStyleNeeded);
public: public:
// Public so scintilla_send_message can use it // Public so scintilla_send_message can use it
virtual long WndProc(unsigned int iMessage, unsigned long wParam, long lParam); virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
}; };
#endif #endif

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// Style.cxx - defines the font and colour style for a class of text /** @file Style.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the font and colour style for a class of text.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <string.h> #include <string.h>
@@ -12,15 +14,15 @@
Style::Style() { Style::Style() {
aliasOfDefaultFont = true; aliasOfDefaultFont = true;
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT, Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
false, false, false, false, true); false, false, false, false, caseMixed, true);
} }
Style::Style(const Style &source) { Style::Style(const Style &source) {
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
0, 0, 0, 0, 0, 0,
false, false, false, false, true); false, false, false, false, caseMixed, true);
fore.desired = source.fore.desired; fore.desired = source.fore.desired;
back.desired = source.back.desired; back.desired = source.back.desired;
characterSet = source.characterSet; characterSet = source.characterSet;
@@ -29,7 +31,8 @@ Style::Style(const Style &source) {
size = source.size; size = source.size;
eolFilled = source.eolFilled; eolFilled = source.eolFilled;
underline = source.underline; underline = source.underline;
visible = source.visible; caseForce = source.caseForce;
visible = source.visible;
} }
Style::~Style() { Style::~Style() {
@@ -42,10 +45,10 @@ Style::~Style() {
Style &Style::operator=(const Style &source) { Style &Style::operator=(const Style &source) {
if (this == &source) if (this == &source)
return *this; return * this;
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
0, 0, SC_CHARSET_DEFAULT, 0, 0, SC_CHARSET_DEFAULT,
false, false, false, false, true); false, false, false, false, caseMixed, true);
fore.desired = source.fore.desired; fore.desired = source.fore.desired;
back.desired = source.back.desired; back.desired = source.back.desired;
characterSet = source.characterSet; characterSet = source.characterSet;
@@ -54,13 +57,15 @@ Style &Style::operator=(const Style &source) {
size = source.size; size = source.size;
eolFilled = source.eolFilled; eolFilled = source.eolFilled;
underline = source.underline; underline = source.underline;
visible = source.visible; caseForce = source.caseForce;
visible = source.visible;
return *this; return *this;
} }
void Style::Clear(Colour fore_, Colour back_, int size_, void Style::Clear(Colour fore_, Colour back_, int size_,
const char *fontName_, int characterSet_, const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_, bool underline_, bool visible_) { bool bold_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_, bool visible_) {
fore.desired = fore_; fore.desired = fore_;
back.desired = back_; back.desired = back_;
characterSet = characterSet_; characterSet = characterSet_;
@@ -70,19 +75,35 @@ void Style::Clear(Colour fore_, Colour back_, int size_,
fontName = fontName_; fontName = fontName_;
eolFilled = eolFilled_; eolFilled = eolFilled_;
underline = underline_; underline = underline_;
visible = visible_; caseForce = caseForce_;
visible = visible_;
if (aliasOfDefaultFont) if (aliasOfDefaultFont)
font.SetID(0); font.SetID(0);
else else
font.Release(); font.Release();
aliasOfDefaultFont = false; aliasOfDefaultFont = false;
} }
void Style::ClearTo(const Style &source) {
Clear(
source.fore.desired,
source.back.desired,
source.size,
source.fontName,
source.characterSet,
source.bold,
source.italic,
source.eolFilled,
source.underline,
source.caseForce,
source.visible);
}
bool Style::EquivalentFontTo(const Style *other) const { bool Style::EquivalentFontTo(const Style *other) const {
if (bold != other->bold || if (bold != other->bold ||
italic != other->italic || italic != other->italic ||
size != other->size || size != other->size ||
characterSet != other->characterSet) characterSet != other->characterSet)
return false; return false;
if (fontName == other->fontName) if (fontName == other->fontName)
return true; return true;
@@ -94,17 +115,17 @@ bool Style::EquivalentFontTo(const Style *other) const {
} }
void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) { void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) {
int sizeZoomed = size + zoomLevel; sizeZoomed = size + zoomLevel;
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1 if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
sizeZoomed = 2; sizeZoomed = 2;
if (aliasOfDefaultFont) if (aliasOfDefaultFont)
font.SetID(0); font.SetID(0);
else else
font.Release(); font.Release();
int deviceHeight = surface.DeviceHeightFont(sizeZoomed); int deviceHeight = surface.DeviceHeightFont(sizeZoomed);
aliasOfDefaultFont = defaultStyle && aliasOfDefaultFont = defaultStyle &&
(EquivalentFontTo(defaultStyle) || !fontName); (EquivalentFontTo(defaultStyle) || !fontName);
if (aliasOfDefaultFont) { if (aliasOfDefaultFont) {
font.SetID(defaultStyle->font.GetID()); font.SetID(defaultStyle->font.GetID());
} else if (fontName) { } else if (fontName) {

View File

@@ -1,11 +1,15 @@
// Scintilla source code edit control // Scintilla source code edit control
// Style.h - defines the font and colour style for a class of text /** @file Style.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the font and colour style for a class of text.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef STYLE_H #ifndef STYLE_H
#define STYLE_H #define STYLE_H
/**
*/
class Style { class Style {
public: public:
ColourPair fore; ColourPair fore;
@@ -18,9 +22,12 @@ public:
int characterSet; int characterSet;
bool eolFilled; bool eolFilled;
bool underline; bool underline;
enum ecaseForced {caseMixed, caseUpper, caseLower};
ecaseForced caseForce;
bool visible; bool visible;
Font font; Font font;
int sizeZoomed;
unsigned int lineHeight; unsigned int lineHeight;
unsigned int ascent; unsigned int ascent;
unsigned int descent; unsigned int descent;
@@ -33,11 +40,13 @@ public:
~Style(); ~Style();
Style &operator=(const Style &source); Style &operator=(const Style &source);
void Clear(Colour fore_, Colour back_, void Clear(Colour fore_, Colour back_,
int size_, int size_,
const char *fontName_, int characterSet_, const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_, bool underline_, bool visible_); bool bold_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_, bool visible_);
void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const; bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle=0); void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0);
}; };
#endif #endif

View File

@@ -1,5 +1,8 @@
// UniConversion.h - functions to handle UFT-8 and UCS-2 strings // Scintilla source code edit control
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> /** @file UniConversion.cxx
** Functions to handle UFT-8 and UCS-2 strings.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>

View File

@@ -1,5 +1,8 @@
// UniConversion.h - functions to handle UFT-8 and UCS-2 strings // Scintilla source code edit control
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> /** @file UniConversion.h
** Functions to handle UFT-8 and UCS-2 strings.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen); unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen);

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// ViewStyle.cxx - store information on how the document is to be viewed /** @file ViewStyle.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Store information on how the document is to be viewed.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <string.h> #include <string.h>
@@ -13,7 +15,7 @@
#include "Style.h" #include "Style.h"
#include "ViewStyle.h" #include "ViewStyle.h"
MarginStyle::MarginStyle() : MarginStyle::MarginStyle() :
symbol(false), width(16), mask(0xffffffff), sensitive(false) { symbol(false), width(16), mask(0xffffffff), sensitive(false) {
} }
@@ -64,7 +66,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
for (int ind=0;ind<=INDIC_MAX;ind++) { for (int ind=0;ind<=INDIC_MAX;ind++) {
indicators[ind] = source.indicators[ind]; indicators[ind] = source.indicators[ind];
} }
selforeset = source.selforeset; selforeset = source.selforeset;
selforeground.desired = source.selforeground.desired; selforeground.desired = source.selforeground.desired;
selbackset = source.selbackset; selbackset = source.selbackset;
@@ -73,8 +75,11 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
selbar.desired = source.selbar.desired; selbar.desired = source.selbar.desired;
selbarlight.desired = source.selbarlight.desired; selbarlight.desired = source.selbarlight.desired;
caretcolour.desired = source.caretcolour.desired; caretcolour.desired = source.caretcolour.desired;
showCaretLineBackground = source.showCaretLineBackground;
caretLineBackground.desired = source.caretLineBackground.desired;
edgecolour.desired = source.edgecolour.desired; edgecolour.desired = source.edgecolour.desired;
edgeState = source.edgeState; edgeState = source.edgeState;
caretWidth = source.caretWidth;
leftMarginWidth = source.leftMarginWidth; leftMarginWidth = source.leftMarginWidth;
rightMarginWidth = source.rightMarginWidth; rightMarginWidth = source.rightMarginWidth;
for (int i=0;i < margins; i++) { for (int i=0;i < margins; i++) {
@@ -87,7 +92,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
viewWhitespace = source.viewWhitespace; viewWhitespace = source.viewWhitespace;
viewIndentationGuides = source.viewIndentationGuides; viewIndentationGuides = source.viewIndentationGuides;
viewEOL = source.viewEOL; viewEOL = source.viewEOL;
showMarkedLines = source.showMarkedLines; showMarkedLines = source.showMarkedLines;
} }
ViewStyle::~ViewStyle() { ViewStyle::~ViewStyle() {
@@ -96,7 +101,7 @@ ViewStyle::~ViewStyle() {
void ViewStyle::Init() { void ViewStyle::Init() {
fontNames.Clear(); fontNames.Clear();
ResetDefaultStyle(); ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE; indicators[0].style = INDIC_SQUIGGLE;
indicators[0].fore = Colour(0, 0x7f, 0); indicators[0].fore = Colour(0, 0x7f, 0);
indicators[1].style = INDIC_TT; indicators[1].style = INDIC_TT;
@@ -119,11 +124,13 @@ void ViewStyle::Init() {
selbarlight.desired = Platform::ChromeHighlight(); selbarlight.desired = Platform::ChromeHighlight();
styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0); styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0);
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome(); styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
//caretcolour.desired = Colour(0xff, 0, 0);
caretcolour.desired = Colour(0, 0, 0); caretcolour.desired = Colour(0, 0, 0);
showCaretLineBackground = false;
caretLineBackground.desired = Colour(0xff, 0xff, 0);
edgecolour.desired = Colour(0xc0, 0xc0, 0xc0); edgecolour.desired = Colour(0xc0, 0xc0, 0xc0);
edgeState = EDGE_NONE; edgeState = EDGE_NONE;
caretWidth = 1;
leftMarginWidth = 1; leftMarginWidth = 1;
rightMarginWidth = 1; rightMarginWidth = 1;
ms[0].symbol = false; ms[0].symbol = false;
@@ -172,6 +179,7 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
pal.WantFind(selbar, want); pal.WantFind(selbar, want);
pal.WantFind(selbarlight, want); pal.WantFind(selbarlight, want);
pal.WantFind(caretcolour, want); pal.WantFind(caretcolour, want);
pal.WantFind(caretLineBackground, want);
pal.WantFind(edgecolour, want); pal.WantFind(edgecolour, want);
} }
@@ -190,7 +198,7 @@ void ViewStyle::Refresh(Surface &surface) {
maxDescent = styles[i].descent; maxDescent = styles[i].descent;
} }
} }
lineHeight = maxAscent + maxDescent; lineHeight = maxAscent + maxDescent;
aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth; aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
spaceWidth = styles[STYLE_DEFAULT].spaceWidth; spaceWidth = styles[STYLE_DEFAULT].spaceWidth;
@@ -208,26 +216,16 @@ void ViewStyle::Refresh(Surface &surface) {
void ViewStyle::ResetDefaultStyle() { void ViewStyle::ResetDefaultStyle() {
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()), Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT, SC_CHARSET_DEFAULT,
false, false, false, false, true); false, false, false, false, Style::caseMixed, true);
} }
void ViewStyle::ClearStyles() { void ViewStyle::ClearStyles() {
// Reset all styles to be like the default style // Reset all styles to be like the default style
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) { for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
if (i != STYLE_DEFAULT) { if (i != STYLE_DEFAULT) {
styles[i].Clear( styles[i].ClearTo(styles[STYLE_DEFAULT]);
styles[STYLE_DEFAULT].fore.desired,
styles[STYLE_DEFAULT].back.desired,
styles[STYLE_DEFAULT].size,
styles[STYLE_DEFAULT].fontName,
styles[STYLE_DEFAULT].characterSet,
styles[STYLE_DEFAULT].bold,
styles[STYLE_DEFAULT].italic,
styles[STYLE_DEFAULT].eolFilled,
styles[STYLE_DEFAULT].underline,
styles[STYLE_DEFAULT].visible);
} }
} }
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome(); styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();

View File

@@ -1,11 +1,15 @@
// Scintilla source code edit control // Scintilla source code edit control
// ViewStyle.h - store information on how the document is to be viewed /** @file ViewStyle.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Store information on how the document is to be viewed.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef VIEWSTYLE_H #ifndef VIEWSTYLE_H
#define VIEWSTYLE_H #define VIEWSTYLE_H
/**
*/
class MarginStyle { class MarginStyle {
public: public:
bool symbol; bool symbol;
@@ -15,10 +19,13 @@ public:
MarginStyle(); MarginStyle();
}; };
/**
*/
class FontNames { class FontNames {
private: private:
char *names[STYLE_MAX + 1]; char *names[STYLE_MAX + 1];
int max; int max;
public: public:
FontNames(); FontNames();
~FontNames(); ~FontNames();
@@ -27,6 +34,9 @@ public:
}; };
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2}; enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
/**
*/
class ViewStyle { class ViewStyle {
public: public:
FontNames fontNames; FontNames fontNames;
@@ -45,12 +55,12 @@ public:
ColourPair selbackground2; ColourPair selbackground2;
ColourPair selbar; ColourPair selbar;
ColourPair selbarlight; ColourPair selbarlight;
// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
int leftMarginWidth; // Spacing margin on left of text
int rightMarginWidth; // Spacing margin on left of text
enum { margins=3 }; enum { margins=3 };
int leftMarginWidth; ///< Spacing margin on left of text
int rightMarginWidth; ///< Spacing margin on left of text
bool symbolMargin; bool symbolMargin;
int maskInLine; // Mask for markers to be put into text because there is nowhere for them to go in margin int maskInLine; ///< Mask for markers to be put into text because there is nowhere for them to go in margin
MarginStyle ms[margins]; MarginStyle ms[margins];
int fixedColumnWidth; int fixedColumnWidth;
int zoomLevel; int zoomLevel;
@@ -59,8 +69,11 @@ public:
bool viewEOL; bool viewEOL;
bool showMarkedLines; bool showMarkedLines;
ColourPair caretcolour; ColourPair caretcolour;
bool showCaretLineBackground;
ColourPair caretLineBackground;
ColourPair edgecolour; ColourPair edgecolour;
int edgeState; int edgeState;
int caretWidth;
ViewStyle(); ViewStyle();
ViewStyle(const ViewStyle &source); ViewStyle(const ViewStyle &source);

View File

@@ -1,6 +1,8 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// Accessor.cxx - rapid easy access to contents of a Scintilla /** @file WindowAccessor.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>

View File

@@ -28,31 +28,37 @@
int wxForceScintillaLexers(void) int wxForceScintillaLexers(void)
{ {
extern LexerModule lmAda;
extern LexerModule lmAVE;
extern LexerModule lmConf;
extern LexerModule lmCPP; extern LexerModule lmCPP;
extern LexerModule lmEiffel;
extern LexerModule lmHTML; extern LexerModule lmHTML;
extern LexerModule lmXML; extern LexerModule lmLISP;
extern LexerModule lmProps; extern LexerModule lmLua;
extern LexerModule lmErrorList; extern LexerModule lmBatch; // In LexOthers.cxx
extern LexerModule lmMake; extern LexerModule lmPascal;
extern LexerModule lmBatch;
extern LexerModule lmPerl; extern LexerModule lmPerl;
extern LexerModule lmPython; extern LexerModule lmPython;
extern LexerModule lmRuby;
extern LexerModule lmSQL; extern LexerModule lmSQL;
extern LexerModule lmVB; extern LexerModule lmVB;
if ( if ( &lmAda
&lmCPP && &lmAVE
&& &lmHTML && &lmConf
&& &lmXML && &lmCPP
&& &lmProps && &lmEiffel
&& &lmErrorList && &lmHTML
&& &lmMake && &lmLISP
&& &lmBatch && &lmLua
&& &lmPerl && &lmBatch
&& &lmPython && &lmPascal
&& &lmSQL && &lmPerl
&& &lmVB && &lmPython
) && &lmRuby
&& &lmSQL
&& &lmVB )
{ {
return 1; return 1;
} }
@@ -66,21 +72,27 @@ int wxForceScintillaLexers(void)
const wxChar* wxSTCNameStr = "stcwindow"; const wxChar* wxSTCNameStr = "stcwindow";
DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ) DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ) DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ) DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED ) DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
@@ -94,7 +106,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
#endif #endif
EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_CHAR (wxStyledTextCtrl::OnChar) EVT_CHAR (wxStyledTextCtrl::OnChar)
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
@@ -299,6 +311,12 @@ int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
return SendMsg(2022, pt.x, pt.y); return SendMsg(2022, pt.x, pt.y);
} }
// Find the position from a point within the window but return
// INVALID_POSITION if not close to text.
int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
return SendMsg(2023, x, y);
}
// Set caret to start of a line and ensure it is visible. // Set caret to start of a line and ensure it is visible.
void wxStyledTextCtrl::GotoLine(int line) { void wxStyledTextCtrl::GotoLine(int line) {
SendMsg(2024, line, 0); SendMsg(2024, line, 0);
@@ -335,9 +353,9 @@ int wxStyledTextCtrl::GetEndStyled() {
return SendMsg(2028, 0, 0); return SendMsg(2028, 0, 0);
} }
// Convert all line endings in the document to use the current mode. // Convert all line endings in the document to one mode.
void wxStyledTextCtrl::ConvertEOLs() { void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
SendMsg(2029, 0, 0); SendMsg(2029, eolMode, 0);
} }
// Retrieve the current end of line mode - one of CRLF, CR, or LF. // Retrieve the current end of line mode - one of CRLF, CR, or LF.
@@ -534,6 +552,11 @@ void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
SendMsg(2059, style, underline); SendMsg(2059, style, underline);
} }
// Set a style to be mixed case, or to force upper or lower case.
void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
SendMsg(2060, style, caseForce);
}
// Set the foreground colour of the selection and whether to use this setting. // Set the foreground colour of the selection and whether to use this setting.
void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
SendMsg(2067, useSetting, wxColourAsLong(fore)); SendMsg(2067, useSetting, wxColourAsLong(fore));
@@ -649,6 +672,27 @@ int wxStyledTextCtrl::GetMaxLineState() {
return SendMsg(2094, 0, 0); return SendMsg(2094, 0, 0);
} }
// Is the background of the line containing the caret in a different colour?
bool wxStyledTextCtrl::GetCaretLineVisible() {
return SendMsg(2095, 0, 0) != 0;
}
// Display the background of the line containing the caret in a different colour.
void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
SendMsg(2096, show, 0);
}
// Get the colour of the background of the line containing the caret.
wxColour wxStyledTextCtrl::GetCaretLineBack() {
long c = SendMsg(2097, 0, 0);
return wxColourFromLong(c);
}
// Set the colour of the background of the line containing the caret.
void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
SendMsg(2098, wxColourAsLong(back), 0);
}
// Display a auto-completion list. // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
@@ -734,6 +778,21 @@ bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
return SendMsg(2116, 0, 0) != 0; return SendMsg(2116, 0, 0) != 0;
} }
// Display a list of strings and send notification when user chooses one.
void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
SendMsg(2117, listType, (long)itemList.c_str());
}
// Set whether or not autocompletion is hidden automatically when nothing matches
void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
SendMsg(2118, autoHide, 0);
}
// Retrieve whether or not autocompletion is hidden automatically when nothing matches
bool wxStyledTextCtrl::AutoCompGetAutoHide() {
return SendMsg(2119, 0, 0) != 0;
}
// Set the number of spaces used for one level of indentation. // Set the number of spaces used for one level of indentation.
void wxStyledTextCtrl::SetIndent(int indentSize) { void wxStyledTextCtrl::SetIndent(int indentSize) {
SendMsg(2122, indentSize, 0); SendMsg(2122, indentSize, 0);
@@ -938,8 +997,8 @@ int wxStyledTextCtrl::GetLineCount() {
} }
// Sets the size in pixels of the left margin. // Sets the size in pixels of the left margin.
void wxStyledTextCtrl::SetMarginLeft(int width) { void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
SendMsg(2155, 0, width); SendMsg(2155, 0, pixelWidth);
} }
// Returns the size in pixels of the left margin. // Returns the size in pixels of the left margin.
@@ -948,8 +1007,8 @@ int wxStyledTextCtrl::GetMarginLeft() {
} }
// Sets the size in pixels of the right margin. // Sets the size in pixels of the right margin.
void wxStyledTextCtrl::SetMarginRight(int width) { void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
SendMsg(2157, 0, width); SendMsg(2157, 0, pixelWidth);
} }
// Returns the size in pixels of the right margin. // Returns the size in pixels of the right margin.
@@ -1105,6 +1164,76 @@ bool wxStyledTextCtrl::GetOvertype() {
return SendMsg(2187, 0, 0) != 0; return SendMsg(2187, 0, 0) != 0;
} }
// Set the width of the insert mode caret
void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
SendMsg(2188, pixelWidth, 0);
}
// Returns the width of the insert mode caret
int wxStyledTextCtrl::GetCaretWidth() {
return SendMsg(2189, 0, 0);
}
// Sets the position that starts the target which is used for updating the
// document without affecting the scroll position.
void wxStyledTextCtrl::SetTargetStart(int pos) {
SendMsg(2190, pos, 0);
}
// Get the position that starts the target.
int wxStyledTextCtrl::GetTargetStart() {
return SendMsg(2191, 0, 0);
}
// Sets the position that ends the target which is used for updating the
// document without affecting the scroll position.
void wxStyledTextCtrl::SetTargetEnd(int pos) {
SendMsg(2192, pos, 0);
}
// Get the position that ends the target.
int wxStyledTextCtrl::GetTargetEnd() {
return SendMsg(2193, 0, 0);
}
// Replace the target text with the argument text.
// Returns the length of the replacement text.
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
return SendMsg(2194, text.Len(), (long)text.c_str());
}
// Replace the target text with the argument text after \d processing.
// Looks for \d where d is between 1 and 9 and replaces these with the strings
// matched in the last search operation which were surrounded by \( and \).
// Returns the length of the replacement text including any change
// caused by processing the \d patterns.
int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
return SendMsg(2195, text.Len(), (long)text.c_str());
}
// Search for a counted string in the target and set the target to the found
// range.
// Returns length of range or -1 for failure in which case target is not moved.
int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
return SendMsg(2197, text.Len(), (long)text.c_str());
}
// Set the search flags used by SearchInTarget
void wxStyledTextCtrl::SetSearchFlags(int flags) {
SendMsg(2198, flags, 0);
}
// Get the search flags used by SearchInTarget
int wxStyledTextCtrl::GetSearchFlags() {
return SendMsg(2199, 0, 0);
}
// Show a call tip containing a definition near position pos. // Show a call tip containing a definition near position pos.
void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
SendMsg(2200, pos, (long)definition.c_str()); SendMsg(2200, pos, (long)definition.c_str());
@@ -1207,6 +1336,47 @@ void wxStyledTextCtrl::SetFoldFlags(int flags) {
SendMsg(2233, flags, 0); SendMsg(2233, flags, 0);
} }
// Ensure a particular line is visible by expanding any header line hiding it.
// Use the currently set visibility policy to determine which range to display.
void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
SendMsg(2234, line, 0);
}
// Sets whether a tab pressed when caret is within indentation indents
void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
SendMsg(2260, tabIndents, 0);
}
// Does a tab pressed when caret is within indentation indent?
bool wxStyledTextCtrl::GetTabIndents() {
return SendMsg(2261, 0, 0) != 0;
}
// Sets whether a backspace pressed when caret is within indentation unindents
void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
SendMsg(2262, bsUnIndents, 0);
}
// Does a backspace pressed when caret is within indentation unindent?
bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
return SendMsg(2263, 0, 0) != 0;
}
// Sets the time the mouse must sit still to generate a mouse dwell event
void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
SendMsg(2264, periodMilliseconds, 0);
}
// Retrieve the time the mouse must sit still to generate a mouse dwell event
int wxStyledTextCtrl::GetMouseDwellTime() {
return SendMsg(2265, 0, 0);
}
// Move the caret inside current view if it's not there already
void wxStyledTextCtrl::MoveCaretInsideView() {
SendMsg(2401, 0, 0);
}
// How many characters are on a line, not including end of line characters. // How many characters are on a line, not including end of line characters.
int wxStyledTextCtrl::LineLength(int line) { int wxStyledTextCtrl::LineLength(int line) {
return SendMsg(2350, line, 0); return SendMsg(2350, line, 0);
@@ -1244,7 +1414,7 @@ void* wxStyledTextCtrl::GetDocPointer() {
// Change the document object used. // Change the document object used.
void wxStyledTextCtrl::SetDocPointer(void* docPointer) { void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
SendMsg(2358, (long)docPointer); SendMsg(2358, 0, (long)docPointer);
} }
// Set which document modification events are sent to the container. // Set which document modification events are sent to the container.
@@ -1291,11 +1461,13 @@ void wxStyledTextCtrl::SearchAnchor() {
} }
// Find some text starting at the search anchor. // Find some text starting at the search anchor.
// Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
return SendMsg(2367, flags, (long)text.c_str()); return SendMsg(2367, flags, (long)text.c_str());
} }
// Find some text starting at the search anchor and moving backwards. // Find some text starting at the search anchor and moving backwards.
// Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
return SendMsg(2368, flags, (long)text.c_str()); return SendMsg(2368, flags, (long)text.c_str());
} }
@@ -1353,6 +1525,81 @@ int wxStyledTextCtrl::GetModEventMask() {
return SendMsg(2378, 0, 0); return SendMsg(2378, 0, 0);
} }
// Change internal focus flag
void wxStyledTextCtrl::SetFocus(bool focus) {
SendMsg(2380, focus, 0);
}
// Get internal focus flag
bool wxStyledTextCtrl::GetFocus() {
return SendMsg(2381, 0, 0) != 0;
}
// Change error status - 0 = OK
void wxStyledTextCtrl::SetStatus(int statusCode) {
SendMsg(2382, statusCode, 0);
}
// Get error status
int wxStyledTextCtrl::GetStatus() {
return SendMsg(2383, 0, 0);
}
// Set whether the mouse is captured when its button is pressed
void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
SendMsg(2384, captures, 0);
}
// Get whether mouse gets captured
bool wxStyledTextCtrl::GetMouseDownCaptures() {
return SendMsg(2385, 0, 0) != 0;
}
// Sets the cursor to one of the SC_CURSOR* values
void wxStyledTextCtrl::SetCursor(int cursorType) {
SendMsg(2386, cursorType, 0);
}
// Get cursor type
int wxStyledTextCtrl::GetCursor() {
return SendMsg(2387, 0, 0);
}
// Move to the previous change in capitalistion
void wxStyledTextCtrl::WordPartLeft() {
SendMsg(2390, 0, 0);
}
// Move to the previous change in capitalistion extending selection to new caret position.
void wxStyledTextCtrl::WordPartLeftExtend() {
SendMsg(2391, 0, 0);
}
// Move to the change next in capitalistion
void wxStyledTextCtrl::WordPartRight() {
SendMsg(2392, 0, 0);
}
// Move to the next change in capitalistion extending selection to new caret position.
void wxStyledTextCtrl::WordPartRightExtend() {
SendMsg(2393, 0, 0);
}
// Set the way the display area is determined when a particular line is to be moved to.
void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
SendMsg(2394, visiblePolicy, visibleSlop);
}
// Delete back from the current position to the start of the line
void wxStyledTextCtrl::DelLineLeft() {
SendMsg(2395, 0, 0);
}
// Delete forwards from the current position to the end of the line
void wxStyledTextCtrl::DelLineRight() {
SendMsg(2396, 0, 0);
}
// Start notifying the container of all key presses and commands. // Start notifying the container of all key presses and commands.
void wxStyledTextCtrl::StartRecord() { void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0); SendMsg(3001, 0, 0);
@@ -1388,6 +1635,11 @@ void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
SendMsg(4005, keywordSet, (long)keyWords.c_str()); SendMsg(4005, keywordSet, (long)keyWords.c_str());
} }
// Set the lexing language of the document based on string name.
void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
SendMsg(4006, 0, (long)language.c_str());
}
// END of generated section // END of generated section
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -1560,8 +1812,9 @@ void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
} }
void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
wxPoint pt = evt.GetPosition(); wxPoint pt = evt.GetPosition();
ScreenToClient(&pt.x, &pt.y);
m_swx->DoContextMenu(Point(pt.x, pt.y)); m_swx->DoContextMenu(Point(pt.x, pt.y));
} }
@@ -1569,7 +1822,8 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
m_swx->DoMouseWheel(evt.GetWheelRotation(), m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(), evt.GetWheelDelta(),
evt.GetLinesPerAction()); evt.GetLinesPerAction(),
evt.ControlDown());
} }
@@ -1588,10 +1842,14 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
long key = evt.KeyCode(); long key = evt.KeyCode();
key = toupper(key); //key = toupper(key); //**** ????
int processed = m_swx->DoKeyDown(key, evt.ShiftDown(), bool consumed = FALSE;
evt.ControlDown(), evt.AltDown()); int processed = m_swx->DoKeyDown(key,
if (! processed) evt.ShiftDown(),
evt.ControlDown(),
evt.AltDown(),
&consumed);
if (!processed && !consumed)
evt.Skip(); evt.Skip();
} }
@@ -1634,73 +1892,110 @@ void wxStyledTextCtrl::NotifyChange() {
void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
SCNotification& scn = *_scn; SCNotification& scn = *_scn;
int eventType = 0; wxStyledTextEvent evt(0, GetId());
evt.SetPosition(scn.position);
evt.SetKey(scn.ch);
evt.SetModifiers(scn.modifiers);
switch (scn.nmhdr.code) { switch (scn.nmhdr.code) {
case SCN_STYLENEEDED: case SCN_STYLENEEDED:
eventType = wxEVT_STC_STYLENEEDED; evt.SetEventType(wxEVT_STC_STYLENEEDED);
break; break;
case SCN_CHARADDED:
eventType = wxEVT_STC_CHARADDED;
break;
case SCN_UPDATEUI:
eventType = wxEVT_STC_UPDATEUI;
break;
case SCN_SAVEPOINTREACHED:
eventType = wxEVT_STC_SAVEPOINTREACHED;
break;
case SCN_SAVEPOINTLEFT:
eventType = wxEVT_STC_SAVEPOINTLEFT;
break;
case SCN_MODIFYATTEMPTRO:
eventType = wxEVT_STC_ROMODIFYATTEMPT;
break;
case SCN_DOUBLECLICK:
eventType = wxEVT_STC_DOUBLECLICK;
break;
case SCN_MODIFIED:
eventType = wxEVT_STC_MODIFIED;
break;
case SCN_KEY:
eventType = wxEVT_STC_KEY;
break;
case SCN_MACRORECORD:
eventType = wxEVT_STC_MACRORECORD;
break;
case SCN_MARGINCLICK:
eventType = wxEVT_STC_MARGINCLICK;
break;
case SCN_NEEDSHOWN:
eventType = wxEVT_STC_NEEDSHOWN;
break;
case SCN_POSCHANGED:
eventType = wxEVT_STC_POSCHANGED;
break;
}
if (eventType) {
wxStyledTextEvent evt(eventType, GetId());
evt.SetPosition(scn.position);
evt.SetKey(scn.ch);
evt.SetModifiers(scn.modifiers);
if (eventType == wxEVT_STC_MODIFIED) {
evt.SetModificationType(scn.modificationType);
if (scn.text)
evt.SetText(wxString(scn.text, scn.length));
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line);
evt.SetFoldLevelNow(scn.foldLevelNow);
evt.SetFoldLevelPrev(scn.foldLevelPrev);
}
if (eventType == wxEVT_STC_MARGINCLICK)
evt.SetMargin(scn.margin);
if (eventType == wxEVT_STC_MACRORECORD) {
evt.SetMessage(scn.message);
evt.SetWParam(scn.wParam);
evt.SetLParam(scn.lParam);
}
GetEventHandler()->ProcessEvent(evt); case SCN_CHARADDED:
evt.SetEventType(wxEVT_STC_CHARADDED);
break;
case SCN_SAVEPOINTREACHED:
evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
break;
case SCN_SAVEPOINTLEFT:
evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
break;
case SCN_MODIFYATTEMPTRO:
evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
break;
case SCN_KEY:
evt.SetEventType(wxEVT_STC_KEY);
break;
case SCN_DOUBLECLICK:
evt.SetEventType(wxEVT_STC_DOUBLECLICK);
break;
case SCN_UPDATEUI:
evt.SetEventType(wxEVT_STC_UPDATEUI);
break;
case SCN_MODIFIED:
evt.SetEventType(wxEVT_STC_MODIFIED);
evt.SetModificationType(scn.modificationType);
if (scn.text)
evt.SetText(wxString(scn.text, scn.length));
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line);
evt.SetFoldLevelNow(scn.foldLevelNow);
evt.SetFoldLevelPrev(scn.foldLevelPrev);
break;
case SCN_MACRORECORD:
evt.SetEventType(wxEVT_STC_MACRORECORD);
evt.SetMessage(scn.message);
evt.SetWParam(scn.wParam);
evt.SetLParam(scn.lParam);
break;
case SCN_MARGINCLICK:
evt.SetEventType(wxEVT_STC_MARGINCLICK);
evt.SetMargin(scn.margin);
break;
case SCN_NEEDSHOWN:
evt.SetEventType(wxEVT_STC_NEEDSHOWN);
evt.SetLength(scn.length);
break;
case SCN_POSCHANGED:
evt.SetEventType(wxEVT_STC_POSCHANGED);
break;
case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED);
break;
case SCN_USERLISTSELECTION:
evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
evt.SetListType(scn.listType);
evt.SetText(scn.text);
break;
case SCN_URIDROPPED:
evt.SetEventType(wxEVT_STC_URIDROPPED);
evt.SetText(scn.text);
break;
case SCN_DWELLSTART:
evt.SetEventType(wxEVT_STC_DWELLSTART);
evt.SetX(scn.x);
evt.SetY(scn.y);
break;
case SCN_DWELLEND:
evt.SetEventType(wxEVT_STC_DWELLEND);
evt.SetX(scn.x);
evt.SetY(scn.y);
break;
default:
return;
} }
GetEventHandler()->ProcessEvent(evt);
} }
@@ -1725,8 +2020,9 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
m_message = 0; m_message = 0;
m_wParam = 0; m_wParam = 0;
m_lParam = 0; m_lParam = 0;
m_listType = 0;
m_x = 0;
m_y = 0;
} }
bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
@@ -1754,7 +2050,9 @@ void wxStyledTextEvent::CopyObject(wxObject& obj) const {
o->m_wParam = m_wParam; o->m_wParam = m_wParam;
o->m_lParam = m_lParam; o->m_lParam = m_lParam;
o->m_listType = m_listType;
o->m_x = m_x;
o->m_y = m_y;
} }

View File

@@ -28,31 +28,37 @@
int wxForceScintillaLexers(void) int wxForceScintillaLexers(void)
{ {
extern LexerModule lmAda;
extern LexerModule lmAVE;
extern LexerModule lmConf;
extern LexerModule lmCPP; extern LexerModule lmCPP;
extern LexerModule lmEiffel;
extern LexerModule lmHTML; extern LexerModule lmHTML;
extern LexerModule lmXML; extern LexerModule lmLISP;
extern LexerModule lmProps; extern LexerModule lmLua;
extern LexerModule lmErrorList; extern LexerModule lmBatch; // In LexOthers.cxx
extern LexerModule lmMake; extern LexerModule lmPascal;
extern LexerModule lmBatch;
extern LexerModule lmPerl; extern LexerModule lmPerl;
extern LexerModule lmPython; extern LexerModule lmPython;
extern LexerModule lmRuby;
extern LexerModule lmSQL; extern LexerModule lmSQL;
extern LexerModule lmVB; extern LexerModule lmVB;
if ( if ( &lmAda
&lmCPP && &lmAVE
&& &lmHTML && &lmConf
&& &lmXML && &lmCPP
&& &lmProps && &lmEiffel
&& &lmErrorList && &lmHTML
&& &lmMake && &lmLISP
&& &lmBatch && &lmLua
&& &lmPerl && &lmBatch
&& &lmPython && &lmPascal
&& &lmSQL && &lmPerl
&& &lmVB && &lmPython
) && &lmRuby
&& &lmSQL
&& &lmVB )
{ {
return 1; return 1;
} }
@@ -66,21 +72,27 @@ int wxForceScintillaLexers(void)
const wxChar* wxSTCNameStr = "stcwindow"; const wxChar* wxSTCNameStr = "stcwindow";
DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ) DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ) DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ) DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED ) DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
@@ -94,7 +106,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
#endif #endif
EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_CHAR (wxStyledTextCtrl::OnChar) EVT_CHAR (wxStyledTextCtrl::OnChar)
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
@@ -350,8 +362,9 @@ void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
} }
void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
wxPoint pt = evt.GetPosition(); wxPoint pt = evt.GetPosition();
ScreenToClient(&pt.x, &pt.y);
m_swx->DoContextMenu(Point(pt.x, pt.y)); m_swx->DoContextMenu(Point(pt.x, pt.y));
} }
@@ -359,7 +372,8 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
m_swx->DoMouseWheel(evt.GetWheelRotation(), m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(), evt.GetWheelDelta(),
evt.GetLinesPerAction()); evt.GetLinesPerAction(),
evt.ControlDown());
} }
@@ -378,10 +392,14 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
long key = evt.KeyCode(); long key = evt.KeyCode();
key = toupper(key); //key = toupper(key); //**** ????
int processed = m_swx->DoKeyDown(key, evt.ShiftDown(), bool consumed = FALSE;
evt.ControlDown(), evt.AltDown()); int processed = m_swx->DoKeyDown(key,
if (! processed) evt.ShiftDown(),
evt.ControlDown(),
evt.AltDown(),
&consumed);
if (!processed && !consumed)
evt.Skip(); evt.Skip();
} }
@@ -424,73 +442,110 @@ void wxStyledTextCtrl::NotifyChange() {
void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
SCNotification& scn = *_scn; SCNotification& scn = *_scn;
int eventType = 0; wxStyledTextEvent evt(0, GetId());
evt.SetPosition(scn.position);
evt.SetKey(scn.ch);
evt.SetModifiers(scn.modifiers);
switch (scn.nmhdr.code) { switch (scn.nmhdr.code) {
case SCN_STYLENEEDED: case SCN_STYLENEEDED:
eventType = wxEVT_STC_STYLENEEDED; evt.SetEventType(wxEVT_STC_STYLENEEDED);
break; break;
case SCN_CHARADDED:
eventType = wxEVT_STC_CHARADDED;
break;
case SCN_UPDATEUI:
eventType = wxEVT_STC_UPDATEUI;
break;
case SCN_SAVEPOINTREACHED:
eventType = wxEVT_STC_SAVEPOINTREACHED;
break;
case SCN_SAVEPOINTLEFT:
eventType = wxEVT_STC_SAVEPOINTLEFT;
break;
case SCN_MODIFYATTEMPTRO:
eventType = wxEVT_STC_ROMODIFYATTEMPT;
break;
case SCN_DOUBLECLICK:
eventType = wxEVT_STC_DOUBLECLICK;
break;
case SCN_MODIFIED:
eventType = wxEVT_STC_MODIFIED;
break;
case SCN_KEY:
eventType = wxEVT_STC_KEY;
break;
case SCN_MACRORECORD:
eventType = wxEVT_STC_MACRORECORD;
break;
case SCN_MARGINCLICK:
eventType = wxEVT_STC_MARGINCLICK;
break;
case SCN_NEEDSHOWN:
eventType = wxEVT_STC_NEEDSHOWN;
break;
case SCN_POSCHANGED:
eventType = wxEVT_STC_POSCHANGED;
break;
}
if (eventType) {
wxStyledTextEvent evt(eventType, GetId());
evt.SetPosition(scn.position);
evt.SetKey(scn.ch);
evt.SetModifiers(scn.modifiers);
if (eventType == wxEVT_STC_MODIFIED) {
evt.SetModificationType(scn.modificationType);
if (scn.text)
evt.SetText(wxString(scn.text, scn.length));
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line);
evt.SetFoldLevelNow(scn.foldLevelNow);
evt.SetFoldLevelPrev(scn.foldLevelPrev);
}
if (eventType == wxEVT_STC_MARGINCLICK)
evt.SetMargin(scn.margin);
if (eventType == wxEVT_STC_MACRORECORD) {
evt.SetMessage(scn.message);
evt.SetWParam(scn.wParam);
evt.SetLParam(scn.lParam);
}
GetEventHandler()->ProcessEvent(evt); case SCN_CHARADDED:
evt.SetEventType(wxEVT_STC_CHARADDED);
break;
case SCN_SAVEPOINTREACHED:
evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
break;
case SCN_SAVEPOINTLEFT:
evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
break;
case SCN_MODIFYATTEMPTRO:
evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
break;
case SCN_KEY:
evt.SetEventType(wxEVT_STC_KEY);
break;
case SCN_DOUBLECLICK:
evt.SetEventType(wxEVT_STC_DOUBLECLICK);
break;
case SCN_UPDATEUI:
evt.SetEventType(wxEVT_STC_UPDATEUI);
break;
case SCN_MODIFIED:
evt.SetEventType(wxEVT_STC_MODIFIED);
evt.SetModificationType(scn.modificationType);
if (scn.text)
evt.SetText(wxString(scn.text, scn.length));
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line);
evt.SetFoldLevelNow(scn.foldLevelNow);
evt.SetFoldLevelPrev(scn.foldLevelPrev);
break;
case SCN_MACRORECORD:
evt.SetEventType(wxEVT_STC_MACRORECORD);
evt.SetMessage(scn.message);
evt.SetWParam(scn.wParam);
evt.SetLParam(scn.lParam);
break;
case SCN_MARGINCLICK:
evt.SetEventType(wxEVT_STC_MARGINCLICK);
evt.SetMargin(scn.margin);
break;
case SCN_NEEDSHOWN:
evt.SetEventType(wxEVT_STC_NEEDSHOWN);
evt.SetLength(scn.length);
break;
case SCN_POSCHANGED:
evt.SetEventType(wxEVT_STC_POSCHANGED);
break;
case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED);
break;
case SCN_USERLISTSELECTION:
evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
evt.SetListType(scn.listType);
evt.SetText(scn.text);
break;
case SCN_URIDROPPED:
evt.SetEventType(wxEVT_STC_URIDROPPED);
evt.SetText(scn.text);
break;
case SCN_DWELLSTART:
evt.SetEventType(wxEVT_STC_DWELLSTART);
evt.SetX(scn.x);
evt.SetY(scn.y);
break;
case SCN_DWELLEND:
evt.SetEventType(wxEVT_STC_DWELLEND);
evt.SetX(scn.x);
evt.SetY(scn.y);
break;
default:
return;
} }
GetEventHandler()->ProcessEvent(evt);
} }
@@ -515,8 +570,9 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
m_message = 0; m_message = 0;
m_wParam = 0; m_wParam = 0;
m_lParam = 0; m_lParam = 0;
m_listType = 0;
m_x = 0;
m_y = 0;
} }
bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
@@ -544,7 +600,9 @@ void wxStyledTextEvent::CopyObject(wxObject& obj) const {
o->m_wParam = m_wParam; o->m_wParam = m_wParam;
o->m_lParam = m_lParam; o->m_lParam = m_lParam;
o->m_listType = m_listType;
o->m_x = m_x;
o->m_y = m_y;
} }

View File

@@ -141,6 +141,10 @@ public:
// Scroll enough to make the given column visible // Scroll enough to make the given column visible
void ScrollToColumn(int column); void ScrollToColumn(int column);
// Send a message to Scintilla
long SendMsg(int msg, long wp=0, long lp=0);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -153,7 +157,7 @@ private:
void OnMouseLeftDown(wxMouseEvent& evt); void OnMouseLeftDown(wxMouseEvent& evt);
void OnMouseMove(wxMouseEvent& evt); void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt); void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt); void OnContextMenu(wxContextMenuEvent& evt);
void OnMouseWheel(wxMouseEvent& evt); void OnMouseWheel(wxMouseEvent& evt);
void OnChar(wxKeyEvent& evt); void OnChar(wxKeyEvent& evt);
void OnKeyDown(wxKeyEvent& evt); void OnKeyDown(wxKeyEvent& evt);
@@ -169,8 +173,6 @@ private:
void NotifyChange(); void NotifyChange();
void NotifyParent(SCNotification* scn); void NotifyParent(SCNotification* scn);
long SendMsg(int msg, long wp=0, long lp=0);
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxStyledTextCtrl) DECLARE_CLASS(wxStyledTextCtrl)
@@ -205,6 +207,9 @@ public:
void SetMessage(int val) { m_message = val; } void SetMessage(int val) { m_message = val; }
void SetWParam(int val) { m_wParam = val; } void SetWParam(int val) { m_wParam = val; }
void SetLParam(int val) { m_lParam = val; } void SetLParam(int val) { m_lParam = val; }
void SetListType(int val) { m_listType = val; }
void SetX(int val) { m_x = val; }
void SetY(int val) { m_y = val; }
int GetPosition() const { return m_position; } int GetPosition() const { return m_position; }
int GetKey() const { return m_key; } int GetKey() const { return m_key; }
@@ -220,6 +225,9 @@ public:
int GetMessage() const { return m_message; } int GetMessage() const { return m_message; }
int GetWParam() const { return m_wParam; } int GetWParam() const { return m_wParam; }
int GetLParam() const { return m_lParam; } int GetLParam() const { return m_lParam; }
int GetListType() const { return m_listType; }
int GetX() const { return m_x; }
int GetY() const { return m_y; }
bool GetShift() const; bool GetShift() const;
bool GetControl() const; bool GetControl() const;
@@ -248,42 +256,56 @@ private:
int m_message; // wxEVT_STC_MACRORECORD int m_message; // wxEVT_STC_MACRORECORD
int m_wParam; int m_wParam;
int m_lParam; int m_lParam;
int m_listType;
int m_x;
int m_y;
#endif #endif
}; };
#ifndef SWIG #ifndef SWIG
BEGIN_DECLARE_EVENT_TYPES() BEGIN_DECLARE_EVENT_TYPES()
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1653) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1653)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1654) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1654)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1655) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1655)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1656) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1656)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1658) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1658)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1659) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1659)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_PAINTED, 1664)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_USERLISTSELECTION, 1665)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668)
END_DECLARE_EVENT_TYPES() END_DECLARE_EVENT_TYPES()
#else #else
enum { enum {
wxEVT_STC_CHANGE, wxEVT_STC_CHANGE,
wxEVT_STC_STYLENEEDED, wxEVT_STC_STYLENEEDED,
wxEVT_STC_CHARADDED, wxEVT_STC_CHARADDED,
wxEVT_STC_UPDATEUI,
wxEVT_STC_SAVEPOINTREACHED, wxEVT_STC_SAVEPOINTREACHED,
wxEVT_STC_SAVEPOINTLEFT, wxEVT_STC_SAVEPOINTLEFT,
wxEVT_STC_ROMODIFYATTEMPT, wxEVT_STC_ROMODIFYATTEMPT,
wxEVT_STC_DOUBLECLICK,
wxEVT_STC_MODIFIED,
wxEVT_STC_KEY, wxEVT_STC_KEY,
wxEVT_STC_DOUBLECLICK,
wxEVT_STC_UPDATEUI,
wxEVT_STC_MODIFIED,
wxEVT_STC_MACRORECORD, wxEVT_STC_MACRORECORD,
wxEVT_STC_MARGINCLICK, wxEVT_STC_MARGINCLICK,
wxEVT_STC_NEEDSHOWN, wxEVT_STC_NEEDSHOWN,
wxEVT_STC_POSCHANGED wxEVT_STC_POSCHANGED,
wxEVT_STC_PAINTED,
wxEVT_STC_USERLISTSELECTION,
wxEVT_STC_URIDROPPED,
wxEVT_STC_DWELLSTART,
wxEVT_STC_DWELLEND,
}; };
#endif #endif
@@ -292,20 +314,26 @@ END_DECLARE_EVENT_TYPES()
#ifndef SWIG #ifndef SWIG
typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
#define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_PAINTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_PAINTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_USERLISTSELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_USERLISTSELECTION, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#endif #endif

View File

@@ -57,6 +57,28 @@
#define wxSTC_MARK_ARROWDOWN 6 #define wxSTC_MARK_ARROWDOWN 6
#define wxSTC_MARK_MINUS 7 #define wxSTC_MARK_MINUS 7
#define wxSTC_MARK_PLUS 8 #define wxSTC_MARK_PLUS 8
// Shapes used for outlining column
#define wxSTC_MARK_VLINE 9
#define wxSTC_MARK_LCORNER 10
#define wxSTC_MARK_TCORNER 11
#define wxSTC_MARK_BOXPLUS 12
#define wxSTC_MARK_BOXPLUSCONNECTED 13
#define wxSTC_MARK_BOXMINUS 14
#define wxSTC_MARK_BOXMINUSCONNECTED 15
#define wxSTC_MARK_LCORNERCURVE 16
#define wxSTC_MARK_TCORNERCURVE 17
#define wxSTC_MARK_CIRCLEPLUS 18
#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
#define wxSTC_MARK_CIRCLEMINUS 20
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
// Markers used for outlining column
#define wxSTC_MARKNUM_FOLDEREND 25
#define wxSTC_MARKNUM_FOLDEROPENMID 26
#define wxSTC_MARKNUM_FOLDERMIDTAIL 27
#define wxSTC_MARKNUM_FOLDERTAIL 28
#define wxSTC_MARKNUM_FOLDERSUB 29
#define wxSTC_MARKNUM_FOLDER 30 #define wxSTC_MARKNUM_FOLDER 30
#define wxSTC_MARKNUM_FOLDEROPEN 31 #define wxSTC_MARKNUM_FOLDEROPEN 31
#define wxSTC_MARGIN_SYMBOL 0 #define wxSTC_MARGIN_SYMBOL 0
@@ -90,6 +112,9 @@
#define wxSTC_CHARSET_ARABIC 178 #define wxSTC_CHARSET_ARABIC 178
#define wxSTC_CHARSET_VIETNAMESE 163 #define wxSTC_CHARSET_VIETNAMESE 163
#define wxSTC_CHARSET_THAI 222 #define wxSTC_CHARSET_THAI 222
#define wxSTC_CASE_MIXED 0
#define wxSTC_CASE_UPPER 1
#define wxSTC_CASE_LOWER 2
#define wxSTC_INDIC_MAX 7 #define wxSTC_INDIC_MAX 7
#define wxSTC_INDIC_PLAIN 0 #define wxSTC_INDIC_PLAIN 0
#define wxSTC_INDIC_SQUIGGLE 1 #define wxSTC_INDIC_SQUIGGLE 1
@@ -109,12 +134,15 @@
// PrintColourMode - force black text on white background for printing. // PrintColourMode - force black text on white background for printing.
#define wxSTC_PRINT_BLACKONWHITE 2 #define wxSTC_PRINT_BLACKONWHITE 2
#define wxSTC_FIND_DOWN 1
// PrintColourMode - text stays coloured, but all background is forced to be white for printing.
#define wxSTC_PRINT_COLOURONWHITE 3
// PrintColourMode - only the default-background is forced to be white for printing.
#define wxSTC_PRINT_COLOURONWHITEDEFAULTBG 4
#define wxSTC_FIND_WHOLEWORD 2 #define wxSTC_FIND_WHOLEWORD 2
#define wxSTC_FIND_MATCHCASE 4 #define wxSTC_FIND_MATCHCASE 4
#define wxSTC_FIND_WORDSTART 0x00100000 #define wxSTC_FIND_WORDSTART 0x00100000
// SCFIND_REGEXP is not yet implemented.
#define wxSTC_FIND_REGEXP 0x00200000 #define wxSTC_FIND_REGEXP 0x00200000
#define wxSTC_CMD_UNDO 2176 #define wxSTC_CMD_UNDO 2176
#define wxSTC_CMD_CUT 2177 #define wxSTC_CMD_CUT 2177
@@ -124,6 +152,7 @@
#define wxSTC_FOLDLEVELWHITEFLAG 0x1000 #define wxSTC_FOLDLEVELWHITEFLAG 0x1000
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000 #define wxSTC_FOLDLEVELHEADERFLAG 0x2000
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF #define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
#define wxSTC_TIME_FOREVER 10000000
#define wxSTC_CMD_LINEDOWN 2300 #define wxSTC_CMD_LINEDOWN 2300
#define wxSTC_CMD_LINEDOWNEXTEND 2301 #define wxSTC_CMD_LINEDOWNEXTEND 2301
#define wxSTC_CMD_LINEUP 2302 #define wxSTC_CMD_LINEUP 2302
@@ -173,15 +202,31 @@
#define wxSTC_EDGE_BACKGROUND 2 #define wxSTC_EDGE_BACKGROUND 2
// Show caret within N lines of edge when it's scrolled to view // Show caret within N lines of edge when it's scrolled to view
// If CARET_SLOP not set then centre caret on screen when it's
// scrolled to view
#define wxSTC_CARET_SLOP 0x01 #define wxSTC_CARET_SLOP 0x01
// Center caret on screen when it's scrolled to view // Value not used
#define wxSTC_CARET_CENTER 0x02 #define wxSTC_CARET_CENTER 0x02
// OR this with CARET_CENTER to reposition even when visible, or // If CARET_SLOP also set then reposition whenever outside slop border
// OR this with CARET_SLOP to reposition whenever outside slop border // If CARET_SLOP not set then recentre even when visible
#define wxSTC_CARET_STRICT 0x04 #define wxSTC_CARET_STRICT 0x04
// If CARET_XEVEN set then both left and right margins are given equal weight
// rather than favouring left following behaviour.
#define wxSTC_CARET_XEVEN 0x08
// If CARET_XJUMPS set then when caret reaches the margin the display jumps
// enough to leave the caret solidly within the display.
#define wxSTC_CARET_XJUMPS 0x10
#define wxSTC_CURSORNORMAL -1
#define wxSTC_CURSORWAIT 3
// Constants for use with SetVisiblePolicy, similar to SetCaretPolicy
#define wxSTC_VISIBLE_SLOP 0x01
#define wxSTC_VISIBLE_STRICT 0x04
// Notifications // Notifications
// Type of modification and the action which caused the modification // Type of modification and the action which caused the modification
// These are defined as a bit mask to make it easy to specify which notifications are wanted. // These are defined as a bit mask to make it easy to specify which notifications are wanted.
@@ -241,6 +286,19 @@
#define wxSTC_LEX_LATEX 14 #define wxSTC_LEX_LATEX 14
#define wxSTC_LEX_LUA 15 #define wxSTC_LEX_LUA 15
#define wxSTC_LEX_DIFF 16 #define wxSTC_LEX_DIFF 16
#define wxSTC_LEX_CONF 17
#define wxSTC_LEX_PASCAL 18
#define wxSTC_LEX_AVE 19
#define wxSTC_LEX_ADA 20
#define wxSTC_LEX_LISP 21
#define wxSTC_LEX_RUBY 22
#define wxSTC_LEX_EIFFEL 23
#define wxSTC_LEX_EIFFELKW 24
#define wxSTC_LEX_TCL 25
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1.
#define wxSTC_LEX_AUTOMATIC 1000
// Lexical states for SCLEX_PYTHON // Lexical states for SCLEX_PYTHON
#define wxSTC_P_DEFAULT 0 #define wxSTC_P_DEFAULT 0
@@ -273,6 +331,9 @@
#define wxSTC_C_IDENTIFIER 11 #define wxSTC_C_IDENTIFIER 11
#define wxSTC_C_STRINGEOL 12 #define wxSTC_C_STRINGEOL 12
#define wxSTC_C_VERBATIM 13 #define wxSTC_C_VERBATIM 13
#define wxSTC_C_REGEX 14
#define wxSTC_C_COMMENTLINEDOC 15
#define wxSTC_C_WORD2 16
// Lexical states for SCLEX_HTML, SCLEX_XML // Lexical states for SCLEX_HTML, SCLEX_XML
#define wxSTC_H_DEFAULT 0 #define wxSTC_H_DEFAULT 0
@@ -300,6 +361,12 @@
// More HTML // More HTML
#define wxSTC_H_VALUE 19 #define wxSTC_H_VALUE 19
// X-Code
#define wxSTC_H_XCCOMMENT 20
// SGML
#define wxSTC_H_SGML 21
// Embedded Javascript // Embedded Javascript
#define wxSTC_HJ_START 40 #define wxSTC_HJ_START 40
#define wxSTC_HJ_DEFAULT 41 #define wxSTC_HJ_DEFAULT 41
@@ -313,6 +380,7 @@
#define wxSTC_HJ_SINGLESTRING 49 #define wxSTC_HJ_SINGLESTRING 49
#define wxSTC_HJ_SYMBOLS 50 #define wxSTC_HJ_SYMBOLS 50
#define wxSTC_HJ_STRINGEOL 51 #define wxSTC_HJ_STRINGEOL 51
#define wxSTC_HJ_REGEX 52
// ASP Javascript // ASP Javascript
#define wxSTC_HJA_START 55 #define wxSTC_HJA_START 55
@@ -327,6 +395,7 @@
#define wxSTC_HJA_SINGLESTRING 64 #define wxSTC_HJA_SINGLESTRING 64
#define wxSTC_HJA_SYMBOLS 65 #define wxSTC_HJA_SYMBOLS 65
#define wxSTC_HJA_STRINGEOL 66 #define wxSTC_HJA_STRINGEOL 66
#define wxSTC_HJA_REGEX 67
// Embedded VBScript // Embedded VBScript
#define wxSTC_HB_START 70 #define wxSTC_HB_START 70
@@ -387,11 +456,12 @@
#define wxSTC_HPHP_VARIABLE 123 #define wxSTC_HPHP_VARIABLE 123
#define wxSTC_HPHP_COMMENT 124 #define wxSTC_HPHP_COMMENT 124
#define wxSTC_HPHP_COMMENTLINE 125 #define wxSTC_HPHP_COMMENTLINE 125
#define wxSTC_HPHP_STRINGEOL 126 #define wxSTC_HPHP_HSTRING_VARIABLE 126
#define wxSTC_HPHP_OPERATOR 127
// Lexical states for SCLEX_PERL // Lexical states for SCLEX_PERL
#define wxSTC_PL_DEFAULT 0 #define wxSTC_PL_DEFAULT 0
#define wxSTC_PL_HERE 1 #define wxSTC_PL_ERROR 1
#define wxSTC_PL_COMMENTLINE 2 #define wxSTC_PL_COMMENTLINE 2
#define wxSTC_PL_POD 3 #define wxSTC_PL_POD 3
#define wxSTC_PL_NUMBER 4 #define wxSTC_PL_NUMBER 4
@@ -406,12 +476,20 @@
#define wxSTC_PL_ARRAY 13 #define wxSTC_PL_ARRAY 13
#define wxSTC_PL_HASH 14 #define wxSTC_PL_HASH 14
#define wxSTC_PL_SYMBOLTABLE 15 #define wxSTC_PL_SYMBOLTABLE 15
#define wxSTC_PL_REF 16
#define wxSTC_PL_REGEX 17 #define wxSTC_PL_REGEX 17
#define wxSTC_PL_REGSUBST 18 #define wxSTC_PL_REGSUBST 18
#define wxSTC_PL_LONGQUOTE 19 #define wxSTC_PL_LONGQUOTE 19
#define wxSTC_PL_BACKTICKS 20 #define wxSTC_PL_BACKTICKS 20
#define wxSTC_PL_DATASECTION 21 #define wxSTC_PL_DATASECTION 21
#define wxSTC_PL_HERE_DELIM 22
#define wxSTC_PL_HERE_Q 23
#define wxSTC_PL_HERE_QQ 24
#define wxSTC_PL_HERE_QX 25
#define wxSTC_PL_STRING_Q 26
#define wxSTC_PL_STRING_QQ 27
#define wxSTC_PL_STRING_QX 28
#define wxSTC_PL_STRING_QR 29
#define wxSTC_PL_STRING_QW 30
// Lexical states for SCLEX_LATEX // Lexical states for SCLEX_LATEX
#define wxSTC_L_DEFAULT 0 #define wxSTC_L_DEFAULT 0
@@ -434,6 +512,8 @@
#define wxSTC_LUA_OPERATOR 10 #define wxSTC_LUA_OPERATOR 10
#define wxSTC_LUA_IDENTIFIER 11 #define wxSTC_LUA_IDENTIFIER 11
#define wxSTC_LUA_STRINGEOL 12 #define wxSTC_LUA_STRINGEOL 12
// Lexical states for SCLEX_ERRORLIST
#define wxSTC_ERR_DEFAULT 0 #define wxSTC_ERR_DEFAULT 0
#define wxSTC_ERR_PYTHON 1 #define wxSTC_ERR_PYTHON 1
#define wxSTC_ERR_GCC 2 #define wxSTC_ERR_GCC 2
@@ -441,6 +521,88 @@
#define wxSTC_ERR_CMD 4 #define wxSTC_ERR_CMD 4
#define wxSTC_ERR_BORLAND 5 #define wxSTC_ERR_BORLAND 5
#define wxSTC_ERR_PERL 6 #define wxSTC_ERR_PERL 6
#define wxSTC_ERR_NET 7
#define wxSTC_ERR_LUA 8
#define wxSTC_ERR_DIFF_CHANGED 10
#define wxSTC_ERR_DIFF_ADDITION 11
#define wxSTC_ERR_DIFF_DELETION 12
#define wxSTC_ERR_DIFF_MESSAGE 13
// Lexical states for SCLEX_BATCH
#define wxSTC_BAT_DEFAULT 0
#define wxSTC_BAT_COMMENT 1
#define wxSTC_BAT_WORD 2
#define wxSTC_BAT_LABEL 3
#define wxSTC_BAT_HIDE 4
#define wxSTC_BAT_COMMAND 5
#define wxSTC_BAT_IDENTIFIER 6
#define wxSTC_BAT_OPERATOR 7
// Lexical states for SCLEX_MAKEFILE
#define wxSTC_MAKE_DEFAULT 0
#define wxSTC_MAKE_COMMENT 1
#define wxSTC_MAKE_PREPROCESSOR 2
#define wxSTC_MAKE_IDENTIFIER 3
#define wxSTC_MAKE_OPERATOR 4
#define wxSTC_MAKE_TARGET 5
#define wxSTC_MAKE_IDEOL 9
// Lexical states for the SCLEX_CONF (Apache Configuration Files Lexer)
#define wxSTC_CONF_DEFAULT 0
#define wxSTC_CONF_COMMENT 1
#define wxSTC_CONF_NUMBER 2
#define wxSTC_CONF_IDENTIFIER 3
#define wxSTC_CONF_EXTENSION 4
#define wxSTC_CONF_PARAMETER 5
#define wxSTC_CONF_STRING 6
#define wxSTC_CONF_OPERATOR 7
#define wxSTC_CONF_IP 8
#define wxSTC_CONF_DIRECTIVE 9
// Avenue
#define wxSTC_AVE_DEFAULT 0
#define wxSTC_AVE_COMMENT 1
#define wxSTC_AVE_NUMBER 2
#define wxSTC_AVE_WORD 3
#define wxSTC_AVE_KEYWORD 4
#define wxSTC_AVE_STATEMENT 5
#define wxSTC_AVE_STRING 6
#define wxSTC_AVE_ENUM 7
#define wxSTC_AVE_STRINGEOL 8
#define wxSTC_AVE_IDENTIFIER 9
#define wxSTC_AVE_OPERATOR 10
// Lexical states for SCLEX_ADA
#define wxSTC_ADA_DEFAULT 0
#define wxSTC_ADA_COMMENT 1
#define wxSTC_ADA_NUMBER 2
#define wxSTC_ADA_WORD 3
#define wxSTC_ADA_STRING 4
#define wxSTC_ADA_CHARACTER 5
#define wxSTC_ADA_OPERATOR 6
#define wxSTC_ADA_IDENTIFIER 7
#define wxSTC_ADA_STRINGEOL 8
// Lexical states for SCLEX_LISP
#define wxSTC_LISP_DEFAULT 0
#define wxSTC_LISP_COMMENT 1
#define wxSTC_LISP_NUMBER 2
#define wxSTC_LISP_KEYWORD 3
#define wxSTC_LISP_STRING 6
#define wxSTC_LISP_STRINGEOL 8
#define wxSTC_LISP_IDENTIFIER 9
#define wxSTC_LISP_OPERATOR 10
// Lexical states for SCLEX_EIFFEL and SCLEX_EIFFELKW
#define wxSTC_EIFFEL_DEFAULT 0
#define wxSTC_EIFFEL_COMMENTLINE 1
#define wxSTC_EIFFEL_NUMBER 2
#define wxSTC_EIFFEL_WORD 3
#define wxSTC_EIFFEL_STRING 4
#define wxSTC_EIFFEL_CHARACTER 5
#define wxSTC_EIFFEL_OPERATOR 6
#define wxSTC_EIFFEL_IDENTIFIER 7
#define wxSTC_EIFFEL_STRINGEOL 8
// END of generated section // END of generated section
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -556,6 +718,10 @@ public:
// Find the position from a point within the window. // Find the position from a point within the window.
int PositionFromPoint(wxPoint pt); int PositionFromPoint(wxPoint pt);
// Find the position from a point within the window but return
// INVALID_POSITION if not close to text.
int PositionFromPointClose(int x, int y);
// Set caret to start of a line and ensure it is visible. // Set caret to start of a line and ensure it is visible.
void GotoLine(int line); void GotoLine(int line);
@@ -573,8 +739,8 @@ public:
// Retrieve the position of the last correctly styled character. // Retrieve the position of the last correctly styled character.
int GetEndStyled(); int GetEndStyled();
// Convert all line endings in the document to use the current mode. // Convert all line endings in the document to one mode.
void ConvertEOLs(); void ConvertEOLs(int eolMode);
// Retrieve the current end of line mode - one of CRLF, CR, or LF. // Retrieve the current end of line mode - one of CRLF, CR, or LF.
int GetEOLMode(); int GetEOLMode();
@@ -693,6 +859,9 @@ public:
// Set a style to be underlined or not. // Set a style to be underlined or not.
void StyleSetUnderline(int style, bool underline); void StyleSetUnderline(int style, bool underline);
// Set a style to be mixed case, or to force upper or lower case.
void StyleSetCase(int style, int caseForce);
// Set the foreground colour of the selection and whether to use this setting. // Set the foreground colour of the selection and whether to use this setting.
void SetSelForeground(bool useSetting, const wxColour& fore); void SetSelForeground(bool useSetting, const wxColour& fore);
@@ -763,6 +932,18 @@ public:
// Retrieve the last line number that has line state. // Retrieve the last line number that has line state.
int GetMaxLineState(); int GetMaxLineState();
// Is the background of the line containing the caret in a different colour?
bool GetCaretLineVisible();
// Display the background of the line containing the caret in a different colour.
void SetCaretLineVisible(bool show);
// Get the colour of the background of the line containing the caret.
wxColour GetCaretLineBack();
// Set the colour of the background of the line containing the caret.
void SetCaretLineBack(const wxColour& back);
// Display a auto-completion list. // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
@@ -816,6 +997,15 @@ public:
// Retrieve state of ignore case flag. // Retrieve state of ignore case flag.
bool AutoCompGetIgnoreCase(); bool AutoCompGetIgnoreCase();
// Display a list of strings and send notification when user chooses one.
void UserListShow(int listType, const wxString& itemList);
// Set whether or not autocompletion is hidden automatically when nothing matches
void AutoCompSetAutoHide(bool autoHide);
// Retrieve whether or not autocompletion is hidden automatically when nothing matches
bool AutoCompGetAutoHide();
// Set the number of spaces used for one level of indentation. // Set the number of spaces used for one level of indentation.
void SetIndent(int indentSize); void SetIndent(int indentSize);
@@ -923,13 +1113,13 @@ public:
int GetLineCount(); int GetLineCount();
// Sets the size in pixels of the left margin. // Sets the size in pixels of the left margin.
void SetMarginLeft(int width); void SetMarginLeft(int pixelWidth);
// Returns the size in pixels of the left margin. // Returns the size in pixels of the left margin.
int GetMarginLeft(); int GetMarginLeft();
// Sets the size in pixels of the right margin. // Sets the size in pixels of the right margin.
void SetMarginRight(int width); void SetMarginRight(int pixelWidth);
// Returns the size in pixels of the right margin. // Returns the size in pixels of the right margin.
int GetMarginRight(); int GetMarginRight();
@@ -1006,6 +1196,48 @@ public:
// Returns true if overtype mode is active otherwise false is returned. // Returns true if overtype mode is active otherwise false is returned.
bool GetOvertype(); bool GetOvertype();
// Set the width of the insert mode caret
void SetCaretWidth(int pixelWidth);
// Returns the width of the insert mode caret
int GetCaretWidth();
// Sets the position that starts the target which is used for updating the
// document without affecting the scroll position.
void SetTargetStart(int pos);
// Get the position that starts the target.
int GetTargetStart();
// Sets the position that ends the target which is used for updating the
// document without affecting the scroll position.
void SetTargetEnd(int pos);
// Get the position that ends the target.
int GetTargetEnd();
// Replace the target text with the argument text.
// Returns the length of the replacement text.
int ReplaceTarget(const wxString& text);
// Replace the target text with the argument text after \d processing.
// Looks for \d where d is between 1 and 9 and replaces these with the strings
// matched in the last search operation which were surrounded by \( and \).
// Returns the length of the replacement text including any change
// caused by processing the \d patterns.
int ReplaceTargetRE(const wxString& text);
// Search for a counted string in the target and set the target to the found
// range.
// Returns length of range or -1 for failure in which case target is not moved.
int SearchInTarget(const wxString& text);
// Set the search flags used by SearchInTarget
void SetSearchFlags(int flags);
// Get the search flags used by SearchInTarget
int GetSearchFlags();
// Show a call tip containing a definition near position pos. // Show a call tip containing a definition near position pos.
void CallTipShow(int pos, const wxString& definition); void CallTipShow(int pos, const wxString& definition);
@@ -1068,6 +1300,31 @@ public:
// Set some debugging options for folding // Set some debugging options for folding
void SetFoldFlags(int flags); void SetFoldFlags(int flags);
// Ensure a particular line is visible by expanding any header line hiding it.
// Use the currently set visibility policy to determine which range to display.
void EnsureVisibleEnforcePolicy(int line);
// Sets whether a tab pressed when caret is within indentation indents
void SetTabIndents(bool tabIndents);
// Does a tab pressed when caret is within indentation indent?
bool GetTabIndents();
// Sets whether a backspace pressed when caret is within indentation unindents
void SetBackSpaceUnIndents(bool bsUnIndents);
// Does a backspace pressed when caret is within indentation unindent?
bool GetBackSpaceUnIndents();
// Sets the time the mouse must sit still to generate a mouse dwell event
void SetMouseDwellTime(int periodMilliseconds);
// Retrieve the time the mouse must sit still to generate a mouse dwell event
int GetMouseDwellTime();
// Move the caret inside current view if it's not there already
void MoveCaretInsideView();
// How many characters are on a line, not including end of line characters. // How many characters are on a line, not including end of line characters.
int LineLength(int line); int LineLength(int line);
@@ -1119,9 +1376,11 @@ public:
void SearchAnchor(); void SearchAnchor();
// Find some text starting at the search anchor. // Find some text starting at the search anchor.
// Does not ensure the selection is visible.
int SearchNext(int flags, const wxString& text); int SearchNext(int flags, const wxString& text);
// Find some text starting at the search anchor and moving backwards. // Find some text starting at the search anchor and moving backwards.
// Does not ensure the selection is visible.
int SearchPrev(int flags, const wxString& text); int SearchPrev(int flags, const wxString& text);
// Set the way the line the caret is on is kept visible. // Set the way the line the caret is on is kept visible.
@@ -1157,6 +1416,51 @@ public:
// Get which document modification events are sent to the container. // Get which document modification events are sent to the container.
int GetModEventMask(); int GetModEventMask();
// Change internal focus flag
void SetFocus(bool focus);
// Get internal focus flag
bool GetFocus();
// Change error status - 0 = OK
void SetStatus(int statusCode);
// Get error status
int GetStatus();
// Set whether the mouse is captured when its button is pressed
void SetMouseDownCaptures(bool captures);
// Get whether mouse gets captured
bool GetMouseDownCaptures();
// Sets the cursor to one of the SC_CURSOR* values
void SetCursor(int cursorType);
// Get cursor type
int GetCursor();
// Move to the previous change in capitalistion
void WordPartLeft();
// Move to the previous change in capitalistion extending selection to new caret position.
void WordPartLeftExtend();
// Move to the change next in capitalistion
void WordPartRight();
// Move to the next change in capitalistion extending selection to new caret position.
void WordPartRightExtend();
// Set the way the display area is determined when a particular line is to be moved to.
void SetVisiblePolicy(int visiblePolicy, int visibleSlop);
// Delete back from the current position to the start of the line
void DelLineLeft();
// Delete forwards from the current position to the end of the line
void DelLineRight();
// Start notifying the container of all key presses and commands. // Start notifying the container of all key presses and commands.
void StartRecord(); void StartRecord();
@@ -1178,6 +1482,9 @@ public:
// Set up the key words used by the lexer. // Set up the key words used by the lexer.
void SetKeyWords(int keywordSet, const wxString& keyWords); void SetKeyWords(int keywordSet, const wxString& keyWords);
// Set the lexing language of the document based on string name.
void SetLexerLanguage(const wxString& language);
// END of generated section // END of generated section
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Others... // Others...
@@ -1243,6 +1550,10 @@ public:
// Scroll enough to make the given column visible // Scroll enough to make the given column visible
void ScrollToColumn(int column); void ScrollToColumn(int column);
// Send a message to Scintilla
long SendMsg(int msg, long wp=0, long lp=0);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -1255,7 +1566,7 @@ private:
void OnMouseLeftDown(wxMouseEvent& evt); void OnMouseLeftDown(wxMouseEvent& evt);
void OnMouseMove(wxMouseEvent& evt); void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt); void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt); void OnContextMenu(wxContextMenuEvent& evt);
void OnMouseWheel(wxMouseEvent& evt); void OnMouseWheel(wxMouseEvent& evt);
void OnChar(wxKeyEvent& evt); void OnChar(wxKeyEvent& evt);
void OnKeyDown(wxKeyEvent& evt); void OnKeyDown(wxKeyEvent& evt);
@@ -1271,8 +1582,6 @@ private:
void NotifyChange(); void NotifyChange();
void NotifyParent(SCNotification* scn); void NotifyParent(SCNotification* scn);
long SendMsg(int msg, long wp=0, long lp=0);
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxStyledTextCtrl) DECLARE_CLASS(wxStyledTextCtrl)
@@ -1307,6 +1616,9 @@ public:
void SetMessage(int val) { m_message = val; } void SetMessage(int val) { m_message = val; }
void SetWParam(int val) { m_wParam = val; } void SetWParam(int val) { m_wParam = val; }
void SetLParam(int val) { m_lParam = val; } void SetLParam(int val) { m_lParam = val; }
void SetListType(int val) { m_listType = val; }
void SetX(int val) { m_x = val; }
void SetY(int val) { m_y = val; }
int GetPosition() const { return m_position; } int GetPosition() const { return m_position; }
int GetKey() const { return m_key; } int GetKey() const { return m_key; }
@@ -1322,6 +1634,9 @@ public:
int GetMessage() const { return m_message; } int GetMessage() const { return m_message; }
int GetWParam() const { return m_wParam; } int GetWParam() const { return m_wParam; }
int GetLParam() const { return m_lParam; } int GetLParam() const { return m_lParam; }
int GetListType() const { return m_listType; }
int GetX() const { return m_x; }
int GetY() const { return m_y; }
bool GetShift() const; bool GetShift() const;
bool GetControl() const; bool GetControl() const;
@@ -1350,42 +1665,56 @@ private:
int m_message; // wxEVT_STC_MACRORECORD int m_message; // wxEVT_STC_MACRORECORD
int m_wParam; int m_wParam;
int m_lParam; int m_lParam;
int m_listType;
int m_x;
int m_y;
#endif #endif
}; };
#ifndef SWIG #ifndef SWIG
BEGIN_DECLARE_EVENT_TYPES() BEGIN_DECLARE_EVENT_TYPES()
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1653) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1653)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1654) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1654)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1655) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1655)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1656) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1656)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1658) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1658)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1659) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1659)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663) DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_PAINTED, 1664)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_USERLISTSELECTION, 1665)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667)
DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668)
END_DECLARE_EVENT_TYPES() END_DECLARE_EVENT_TYPES()
#else #else
enum { enum {
wxEVT_STC_CHANGE, wxEVT_STC_CHANGE,
wxEVT_STC_STYLENEEDED, wxEVT_STC_STYLENEEDED,
wxEVT_STC_CHARADDED, wxEVT_STC_CHARADDED,
wxEVT_STC_UPDATEUI,
wxEVT_STC_SAVEPOINTREACHED, wxEVT_STC_SAVEPOINTREACHED,
wxEVT_STC_SAVEPOINTLEFT, wxEVT_STC_SAVEPOINTLEFT,
wxEVT_STC_ROMODIFYATTEMPT, wxEVT_STC_ROMODIFYATTEMPT,
wxEVT_STC_DOUBLECLICK,
wxEVT_STC_MODIFIED,
wxEVT_STC_KEY, wxEVT_STC_KEY,
wxEVT_STC_DOUBLECLICK,
wxEVT_STC_UPDATEUI,
wxEVT_STC_MODIFIED,
wxEVT_STC_MACRORECORD, wxEVT_STC_MACRORECORD,
wxEVT_STC_MARGINCLICK, wxEVT_STC_MARGINCLICK,
wxEVT_STC_NEEDSHOWN, wxEVT_STC_NEEDSHOWN,
wxEVT_STC_POSCHANGED wxEVT_STC_POSCHANGED,
wxEVT_STC_PAINTED,
wxEVT_STC_USERLISTSELECTION,
wxEVT_STC_URIDROPPED,
wxEVT_STC_DWELLSTART,
wxEVT_STC_DWELLEND,
}; };
#endif #endif
@@ -1394,20 +1723,26 @@ END_DECLARE_EVENT_TYPES()
#ifndef SWIG #ifndef SWIG
typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
#define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), #define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_PAINTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_PAINTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_USERLISTSELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_USERLISTSELECTION, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
#endif #endif

View File

@@ -112,6 +112,8 @@ Font::~Font() {
} }
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) { void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
// TODO: what to do about the characterSet?
Release(); Release();
id = new wxFont(size, id = new wxFont(size,
wxDEFAULT, wxDEFAULT,
@@ -161,13 +163,11 @@ void Surface::Init() {
Release(); Release();
hdc = new wxMemoryDC(); hdc = new wxMemoryDC();
hdcOwned = true; hdcOwned = true;
// **** ::SetTextAlign(hdc, TA_BASELINE);
} }
void Surface::Init(SurfaceID hdc_) { void Surface::Init(SurfaceID hdc_) {
Release(); Release();
hdc = hdc_; hdc = hdc_;
// **** ::SetTextAlign(hdc, TA_BASELINE);
} }
void Surface::InitPixMap(int width, int height, Surface *surface_) { void Surface::InitPixMap(int width, int height, Surface *surface_) {
@@ -176,7 +176,6 @@ void Surface::InitPixMap(int width, int height, Surface *surface_) {
hdcOwned = true; hdcOwned = true;
bitmap = new wxBitmap(width, height); bitmap = new wxBitmap(width, height);
((wxMemoryDC*)hdc)->SelectObject(*bitmap); ((wxMemoryDC*)hdc)->SelectObject(*bitmap);
// **** ::SetTextAlign(hdc, TA_BASELINE);
} }
void Surface::PenColour(Colour fore) { void Surface::PenColour(Colour fore) {
@@ -353,7 +352,7 @@ int Surface::AverageCharWidth(Font &font) {
} }
int Surface::SetPalette(Palette *pal, bool inBackGround) { int Surface::SetPalette(Palette *pal, bool inBackGround) {
return 0; // **** figure out what to do with palettes... return 0;
} }
void Surface::SetClip(PRectangle rc) { void Surface::SetClip(PRectangle rc) {
@@ -697,6 +696,36 @@ void Platform::DebugPrintf(const char *format, ...) {
#endif #endif
} }
static bool assertionPopUps = true;
bool Platform::ShowAssertionPopUps(bool assertionPopUps_) {
bool ret = assertionPopUps;
assertionPopUps = assertionPopUps_;
return ret;
}
void Platform::Assert(const char *c, const char *file, int line) {
char buffer[2000];
sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
if (assertionPopUps) {
int idButton = wxMessageBox(buffer, "Assertion failure",
wxICON_HAND | wxOK);
// if (idButton == IDRETRY) {
// ::DebugBreak();
// } else if (idButton == IDIGNORE) {
// // all OK
// } else {
// abort();
// }
} else {
strcat(buffer, "\r\n");
Platform::DebugDisplay(buffer);
abort();
}
}
int Platform::Clamp(int val, int minVal, int maxVal) { int Platform::Clamp(int val, int minVal, int maxVal) {
if (val > maxVal) if (val > maxVal)
val = maxVal; val = maxVal;

View File

@@ -93,7 +93,6 @@ END_EVENT_TABLE()
ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
capturedMouse = false; capturedMouse = false;
wMain = win; wMain = win;
wDraw = win;
stc = win; stc = win;
wheelRotation = 0; wheelRotation = 0;
Initialise(); Initialise();
@@ -170,8 +169,8 @@ bool ScintillaWX::HaveMouseCapture() {
void ScintillaWX::ScrollText(int linesToMove) { void ScintillaWX::ScrollText(int linesToMove) {
int dy = vs.lineHeight * (linesToMove); int dy = vs.lineHeight * (linesToMove);
// TODO: calculate the rectangle to refreshed...
wMain.GetID()->ScrollWindow(0, dy); wMain.GetID()->ScrollWindow(0, dy);
wMain.GetID()->Update();
} }
void ScintillaWX::SetVerticalScrollPos() { void ScintillaWX::SetVerticalScrollPos() {
@@ -261,7 +260,7 @@ bool ScintillaWX::CanPaste() {
} }
void ScintillaWX::CreateCallTipWindow(PRectangle) { void ScintillaWX::CreateCallTipWindow(PRectangle) {
ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct); ct.wCallTip = new wxSTCCallTip(wMain.GetID(), -1, &ct);
ct.wDraw = ct.wCallTip; ct.wDraw = ct.wCallTip;
} }
@@ -365,17 +364,27 @@ void ScintillaWX::DoVScroll(int type, int pos) {
} }
void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction) { void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown) {
int topLineNew = topLine; int topLineNew = topLine;
int lines; int lines;
wheelRotation += rotation; if (ctrlDown) { // Zoom the fonts if Ctrl key down
lines = wheelRotation / delta; if (rotation < 0) {
wheelRotation -= lines * delta; KeyCommand(SCI_ZOOMIN);
if (lines != 0) { }
lines *= linesPerAction; else {
topLineNew -= lines; KeyCommand(SCI_ZOOMOUT);
ScrollTo(topLineNew); }
}
else { // otherwise just scroll the window
wheelRotation += rotation;
lines = wheelRotation / delta;
wheelRotation -= lines * delta;
if (lines != 0) {
lines *= linesPerAction;
topLineNew -= lines;
ScrollTo(topLineNew);
}
} }
} }
@@ -387,11 +396,11 @@ void ScintillaWX::DoSize(int width, int height) {
} }
void ScintillaWX::DoLoseFocus(){ void ScintillaWX::DoLoseFocus(){
DropCaret(); SetFocusState(false);
} }
void ScintillaWX::DoGainFocus(){ void ScintillaWX::DoGainFocus(){
ShowCaretAtCurrentPosition(); SetFocusState(true);
} }
void ScintillaWX::DoSysColourChange() { void ScintillaWX::DoSysColourChange() {
@@ -418,7 +427,7 @@ void ScintillaWX::DoAddChar(char ch) {
// AutoCompleteChanged(ch); // AutoCompleteChanged(ch);
} }
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) { int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
switch (key) { switch (key) {
case WXK_DOWN: key = SCK_DOWN; break; case WXK_DOWN: key = SCK_DOWN; break;
case WXK_UP: key = SCK_UP; break; case WXK_UP: key = SCK_UP; break;
@@ -442,7 +451,7 @@ int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
case WXK_SHIFT: key = 0; break; case WXK_SHIFT: key = 0; break;
} }
return KeyDown(key, shift, ctrl, alt); return KeyDown(key, shift, ctrl, alt, consumed);
} }

View File

@@ -119,9 +119,9 @@ public:
void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl); void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
void DoButtonMove(Point pt); void DoButtonMove(Point pt);
void DoMouseWheel(int rotation, int delta, int linesPerAction); void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown);
void DoAddChar(char ch); void DoAddChar(char ch);
int DoKeyDown(int key, bool shift, bool ctrl, bool alt); int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
void DoTick() { Tick(); } void DoTick() { Tick(); }
bool DoDropText(long x, long y, const wxString& data); bool DoDropText(long x, long y, const wxString& data);

View File

@@ -12,15 +12,15 @@
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
import sys, string, re import sys, string, re, os
from fileinput import FileInput from fileinput import FileInput
IFACE = './scintilla/include/Scintilla.iface' IFACE = os.path.abspath('./scintilla/include/Scintilla.iface')
H_TEMPLATE = './stc.h.in' H_TEMPLATE = os.path.abspath('./stc.h.in')
CPP_TEMPLATE = './stc.cpp.in' CPP_TEMPLATE = os.path.abspath('./stc.cpp.in')
H_DEST = '../../include/wx/stc/stc.h' H_DEST = os.path.abspath('../../include/wx/stc/stc.h')
CPP_DEST = './stc.cpp' CPP_DEST = os.path.abspath('./stc.cpp')
# Value prefixes to convert # Value prefixes to convert
@@ -215,6 +215,9 @@ methodOverrideMap = {
'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0), 'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0), 'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0), 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0), 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0), 'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
@@ -360,6 +363,38 @@ methodOverrideMap = {
'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0), 'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
'ReplaceTarget' : (0,
'int %s(const wxString& text);',
'''
int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str());
''',
0),
'ReplaceTargetRE' : (0,
'int %s(const wxString& text);',
'''
int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str());
''',
0),
'SearchInTarget' : (0,
'int %s(const wxString& text);',
'''
int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str());
''',
0),
# Remove all methods that are key commands since they can be # Remove all methods that are key commands since they can be
# executed with CmdKeyExecute # executed with CmdKeyExecute
'LineDown' : (None, 0, 0, 0), 'LineDown' : (None, 0, 0, 0),
@@ -417,7 +452,7 @@ methodOverrideMap = {
'SetDocPointer' : (0, 'SetDocPointer' : (0,
'void %s(void* docPointer);', 'void %s(void* docPointer);',
'''void %s(void* docPointer) { '''void %s(void* docPointer) {
SendMsg(%s, (long)docPointer);''', SendMsg(%s, 0, (long)docPointer);''',
0), 0),
'CreateDocument' : (0, 'CreateDocument' : (0,
@@ -685,4 +720,3 @@ if __name__ == '__main__':
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------

View File

@@ -3,5 +3,5 @@ scintilla/include directories from the Scintilla/SCiTE source
distribution. All other code needed to implement Scintilla on top of distribution. All other code needed to implement Scintilla on top of
wxWindows is located in the directory above this one. wxWindows is located in the directory above this one.
The current version of the Scintilla code is 1.32 The current version of the Scintilla code is 1.39

View File

@@ -1,6 +1,8 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// Accessor.h - rapid easy access to contents of a Scintilla /** @file Accessor.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8}; enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
@@ -9,12 +11,16 @@ class Accessor;
typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len); typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len);
// Interface to data in a Scintilla /**
* Interface to data in a Scintilla.
*/
class Accessor { class Accessor {
protected: protected:
enum {extremePosition=0x7FFFFFFF}; enum {extremePosition=0x7FFFFFFF};
// bufferSize is a trade off between time taken to copy the characters and retrieval overhead /** @a bufferSize is a trade off between time taken to copy the characters
// slopSize positions the buffer before the desired position in case there is some backtracking * and retrieval overhead.
* @a slopSize positions the buffer before the desired position
* in case there is some backtracking. */
enum {bufferSize=4000, slopSize=bufferSize/8}; enum {bufferSize=4000, slopSize=bufferSize/8};
char buf[bufferSize+1]; char buf[bufferSize+1];
int startPos; int startPos;
@@ -23,6 +29,7 @@ protected:
virtual bool InternalIsLeadByte(char ch)=0; virtual bool InternalIsLeadByte(char ch)=0;
virtual void Fill(int position)=0; virtual void Fill(int position)=0;
public: public:
Accessor() : startPos(extremePosition), endPos(0), codePage(0) {} Accessor() : startPos(extremePosition), endPos(0), codePage(0) {}
virtual ~Accessor() {} virtual ~Accessor() {}
@@ -32,8 +39,8 @@ public:
} }
return buf[position - startPos]; return buf[position - startPos];
} }
/** Safe version of operator[], returning a defined value for invalid position. */
char SafeGetCharAt(int position, char chDefault=' ') { char SafeGetCharAt(int position, char chDefault=' ') {
// Safe version of operator[], returning a defined value for invalid position
if (position < startPos || position >= endPos) { if (position < startPos || position >= endPos) {
Fill(position); Fill(position);
if (position < startPos || position >= endPos) { if (position < startPos || position >= endPos) {
@@ -57,6 +64,7 @@ public:
virtual int GetLineState(int line)=0; virtual int GetLineState(int line)=0;
virtual int SetLineState(int line, int state)=0; virtual int SetLineState(int line, int state)=0;
virtual int GetPropertyInt(const char *key, int defaultValue=0)=0; virtual int GetPropertyInt(const char *key, int defaultValue=0)=0;
virtual char *GetProperties()=0;
// Style setting // Style setting
virtual void StartAt(unsigned int start, char chMask=31)=0; virtual void StartAt(unsigned int start, char chMask=31)=0;
@@ -67,4 +75,3 @@ public:
virtual void SetLevel(int line, int level)=0; virtual void SetLevel(int line, int level)=0;
virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0; virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
}; };

View File

@@ -1,32 +1,59 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// KeyWords.h - colourise for particular languages /** @file KeyWords.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Colourise for particular languages.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler); WordList *keywordlists[], Accessor &styler);
/**
* A LexerModule is responsible for lexing and folding a particular language.
* The class maintains a list of LexerModules which can be searched to find a
* module appropriate to a particular language.
*/
class LexerModule { class LexerModule {
static LexerModule *base; protected:
LexerModule *next; LexerModule *next;
int language; int language;
LexerFunction fn; const char *languageName;
LexerFunction fnLexer;
LexerFunction fnFolder;
static LexerModule *base;
static int nextLanguage;
public: public:
LexerModule(int language_, LexerFunction fn_); LexerModule(int language_, LexerFunction fnLexer_,
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle, const char *languageName_=0, LexerFunction fnFolder_=0);
int language, WordList *keywordlists[], Accessor &styler); int GetLanguage() { return language; }
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler);
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler);
static LexerModule *Find(int language);
static LexerModule *Find(const char *languageName);
}; };
/**
* Check if a character is a space.
* This is ASCII specific but is safe with chars >= 0x80.
*/
inline bool isspacechar(unsigned char ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
inline bool iswordchar(char ch) { inline bool iswordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '_'; return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_');
} }
inline bool iswordstart(char ch) { inline bool iswordstart(char ch) {
return isalnum(ch) || ch == '_'; return isascii(ch) && (isalnum(ch) || ch == '_');
} }
inline bool isoperator(char ch) { inline bool isoperator(char ch) {
if (isalnum(ch)) if (isascii(ch) && isalnum(ch))
return false; return false;
// '.' left out as it is used to make up numbers // '.' left out as it is used to make up numbers
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
@@ -38,4 +65,3 @@ inline bool isoperator(char ch) {
return true; return true;
return false; return false;
} }

View File

@@ -1,18 +1,21 @@
// Scintilla source code edit control // Scintilla source code edit control
// Platform.h - interface to platform facilities /** @file Platform.h
// Also includes some basic utilities ** Interface to platform facilities. Also includes some basic utilities.
// Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> **/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PLATFORM_H #ifndef PLATFORM_H
#define PLATFORM_H #define PLATFORM_H
// PLAT_GTK = GTK+ on Linux, PLAT_WIN = Win32 API on Win32 OS // PLAT_GTK = GTK+ on Linux or Win32
// PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32
// PLAT_WIN = Win32 API on Win32 OS
// PLAT_WX is wxWindows on any supported platform // PLAT_WX is wxWindows on any supported platform
// Could also have PLAT_GTKWIN = GTK+ on Win32 OS in future
#define PLAT_GTK 0 #define PLAT_GTK 0
#define PLAT_GTK_WIN32 0
#define PLAT_WIN 0 #define PLAT_WIN 0
#define PLAT_WX 0 #define PLAT_WX 0
@@ -24,6 +27,11 @@
#undef PLAT_GTK #undef PLAT_GTK
#define PLAT_GTK 1 #define PLAT_GTK 1
#ifdef _MSC_VER
#undef PLAT_GTK_WIN32
#define PLAT_GTK_WIN32 1
#endif
#else #else
#undef PLAT_WIN #undef PLAT_WIN
#define PLAT_WIN 1 #define PLAT_WIN 1
@@ -34,6 +42,9 @@
// Include the main header for each platform // Include the main header for each platform
#if PLAT_GTK #if PLAT_GTK
#ifdef _MSC_VER
#pragma warning(disable: 4505 4514 4710 4800)
#endif
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#endif #endif
@@ -42,7 +53,7 @@
#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out #define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out
// Vassili Bourdo: shut up annoying Visual C++ warnings: // Vassili Bourdo: shut up annoying Visual C++ warnings:
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable: 4800 4244 4309) #pragma warning(disable: 4244 4309 4710 4800)
#endif #endif
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
@@ -80,23 +91,28 @@ typedef wxWindow* WindowID;
typedef wxMenu* MenuID; typedef wxMenu* MenuID;
#endif #endif
// Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably /**
* A geometric point class.
* Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably.
*/
class Point { class Point {
public: public:
int x; int x;
int y; int y;
Point(int x_=0, int y_=0) : x(x_), y(y_) { Point(int x_=0, int y_=0) : x(x_), y(y_) {
} }
// Other automatically defined methods (assignment, copy constructor, destructor) are fine // Other automatically defined methods (assignment, copy constructor, destructor) are fine
static Point FromLong(long lpoint); static Point FromLong(long lpoint);
}; };
// PRectangle is exactly the same as the Win32 RECT so can be used interchangeably /**
// PRectangles contain their top and left sides, but not their right and bottom sides * A geometric rectangle class.
* PRectangle is exactly the same as the Win32 RECT so can be used interchangeably.
* PRectangles contain their top and left sides, but not their right and bottom sides.
*/
class PRectangle { class PRectangle {
public: public:
int left; int left;
@@ -110,6 +126,10 @@ public:
// Other automatically defined methods (assignment, copy constructor, destructor) are fine // Other automatically defined methods (assignment, copy constructor, destructor) are fine
bool operator==(PRectangle &rc) {
return (rc.left == left) && (rc.right == right) &&
(rc.top == top) && (rc.bottom == bottom);
}
bool Contains(Point pt) { bool Contains(Point pt) {
return (pt.x >= left) && (pt.x <= right) && return (pt.x >= left) && (pt.x <= right) &&
(pt.y >= top) && (pt.y <= bottom); (pt.y >= top) && (pt.y <= bottom);
@@ -131,6 +151,9 @@ wxRect wxRectFromPRectangle(PRectangle prc);
PRectangle PRectangleFromwxRect(wxRect rc); PRectangle PRectangleFromwxRect(wxRect rc);
#endif #endif
/**
* A colour class.
*/
class Colour { class Colour {
ColourID co; ColourID co;
public: public:
@@ -141,15 +164,17 @@ public:
unsigned int GetRed(); unsigned int GetRed();
unsigned int GetGreen(); unsigned int GetGreen();
unsigned int GetBlue(); unsigned int GetBlue();
friend class Surface; friend class Surface;
friend class Palette; friend class Palette;
}; };
// Colour pairs hold a desired colour and the colour that the graphics engine /**
// allocates to approximate the desired colour. * Colour pairs hold a desired colour and the colour that the graphics engine
// To make palette management more automatic, ColourPairs could register at * allocates to approximate the desired colour.
// construction time with a palette management object. * To make palette management more automatic, ColourPairs could register at
* construction time with a palette management object.
*/
struct ColourPair { struct ColourPair {
Colour desired; Colour desired;
Colour allocated; Colour allocated;
@@ -162,6 +187,9 @@ struct ColourPair {
class Window; // Forward declaration for Palette class Window; // Forward declaration for Palette
/**
* Colour palette management.
*/
class Palette { class Palette {
int used; int used;
enum {numEntries = 100}; enum {numEntries = 100};
@@ -176,22 +204,27 @@ class Palette {
#endif #endif
public: public:
bool allowRealization; bool allowRealization;
Palette(); Palette();
~Palette(); ~Palette();
void Release(); void Release();
// This method either adds a colour to the list of wanted colours (want==true) /**
// or retrieves the allocated colour back to the ColourPair. * This method either adds a colour to the list of wanted colours (want==true)
// This is one method to make it easier to keep the code for wanting and retrieving in sync. * or retrieves the allocated colour back to the ColourPair.
* This is one method to make it easier to keep the code for wanting and retrieving in sync.
*/
void WantFind(ColourPair &cp, bool want); void WantFind(ColourPair &cp, bool want);
void Allocate(Window &w); void Allocate(Window &w);
friend class Surface; friend class Surface;
}; };
/**
* Font management.
*/
class Font { class Font {
protected: protected:
FontID id; FontID id;
@@ -214,7 +247,9 @@ public:
friend class Surface; friend class Surface;
}; };
// A surface abstracts a place to draw /**
* A surface abstracts a place to draw.
*/
class Surface { class Surface {
private: private:
bool unicodeMode; bool unicodeMode;
@@ -256,7 +291,7 @@ private:
public: public:
Surface(); Surface();
~Surface(); ~Surface();
void Init(); void Init();
void Init(SurfaceID hdc_); void Init(SurfaceID hdc_);
void InitPixMap(int width, int height, Surface *surface_); void InitPixMap(int width, int height, Surface *surface_);
@@ -287,7 +322,7 @@ public:
int ExternalLeading(Font &font_); int ExternalLeading(Font &font_);
int Height(Font &font_); int Height(Font &font_);
int AverageCharWidth(Font &font_); int AverageCharWidth(Font &font_);
int SetPalette(Palette *pal, bool inBackGround); int SetPalette(Palette *pal, bool inBackGround);
void SetClip(PRectangle rc); void SetClip(PRectangle rc);
void FlushCachedState(); void FlushCachedState();
@@ -297,8 +332,10 @@ public:
} }
}; };
// Class to hide the details of window manipulation /**
// Does not own the window which will normally have a longer life than this object * Class to hide the details of window manipulation.
* Does not own the window which will normally have a longer life than this object.
*/
class Window { class Window {
friend class ListBox; friend class ListBox;
protected: protected:
@@ -333,6 +370,9 @@ public:
#endif #endif
}; };
/**
* Listbox management.
*/
class ListBox : public Window { class ListBox : public Window {
#if PLAT_GTK #if PLAT_GTK
WindowID list; WindowID list;
@@ -360,6 +400,9 @@ public:
void Sort(); void Sort();
}; };
/**
* Menu management.
*/
class Menu { class Menu {
MenuID id; MenuID id;
public: public:
@@ -370,8 +413,10 @@ public:
void Show(Point pt, Window &w); void Show(Point pt, Window &w);
}; };
// Platform class used to retrieve system wide parameters such as double click speed /**
// and chrome colour. Not a creatable object, more of a module with several functions. * Platform class used to retrieve system wide parameters such as double click speed
* and chrome colour. Not a creatable object, more of a module with several functions.
*/
class Platform { class Platform {
// Private so Platform objects can not be copied // Private so Platform objects can not be copied
Platform(const Platform &) {} Platform(const Platform &) {}
@@ -390,7 +435,7 @@ public:
static bool IsKeyDown(int key); static bool IsKeyDown(int key);
static long SendScintilla( static long SendScintilla(
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0); WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
// These are utility functions not really tied to a platform // These are utility functions not really tied to a platform
static int Minimum(int a, int b); static int Minimum(int a, int b);
static int Maximum(int a, int b); static int Maximum(int a, int b);
@@ -405,7 +450,15 @@ public:
return static_cast<short>(x & 0xffff); return static_cast<short>(x & 0xffff);
} }
static void DebugPrintf(const char *format, ...); static void DebugPrintf(const char *format, ...);
static bool ShowAssertionPopUps(bool assertionPopUps_);
static void Assert(const char *c, const char *file, int line);
static int Clamp(int val, int minVal, int maxVal); static int Clamp(int val, int minVal, int maxVal);
}; };
#ifdef NDEBUG
#define PLATFORM_ASSERT(c) ((void)0)
#else
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif
#endif #endif

View File

@@ -1,138 +0,0 @@
#ifndef POSREGEXP_H
#define POSREGEXP_H
#define MatchesNum 0x10
enum EOps
{
ReBlockOps = 0x1000,
ReMul, // *
RePlus, // +
ReQuest, // ?
ReNGMul, // *?
ReNGPlus, // +?
ReNGQuest, // ??
ReRangeN, // {n,}
ReRangeNM, // {n,m}
ReNGRangeN, // {n,}?
ReNGRangeNM, // {n,m}?
ReOr, // |
ReBehind = 0x1100, // ?#n
ReNBehind = 0x1200, // ?~n
ReAhead = 0x1300, // ?=
ReNAhead = 0x1400, // ?!
ReSymbolOps = 0x2000,
ReEmpty,
ReSymb, // a b \W \s ...
ReEnum, // []
ReNEnum, // [^]
ReBrackets, // (...)
ReBkTrace = 0x2100, // \yN
ReBkBrack = 0x2200 // \N
};
enum ESymbols
{
ReAnyChr = 0x4000, // .
ReSoL, // ^
ReEoL, // $
ReDigit, // \d
ReNDigit, // \D
ReWordSymb, // \w
ReNWordSymb, // \W
ReWSpace, // \s
ReNWSpace, // \S
ReUCase, // \u
ReNUCase , // \l
ReWBound, // \b
ReNWBound, // \B
RePreNW, // \c
ReStart, // \m
ReEnd, // \M
ReChr = 0x0 // Char in Lower Byte
};
enum ETempSymb
{
ReTemp = 0x7000,
ReLBrack, ReRBrack,
ReEnumS, ReEnumE, ReNEnumS,
ReRangeS, ReRangeE, ReNGRangeE, ReFrToEnum
};
#define BackSlash '\\'
typedef union SCharData
{
int IArr[8];
char CArr[32];
void SetBit(unsigned char Bit);
void ClearBit(unsigned char Bit);
bool GetBit(unsigned char Bit);
} *PCharData;
typedef struct SRegInfo
{
SRegInfo();
~SRegInfo();
EOps Op;
union{
SRegInfo *Param;
int Symb;
PCharData ChrClass;
}un;
int s,e;
SRegInfo *Parent;
SRegInfo *Next;
} *PRegInfo;
typedef struct SMatches
{
int s[MatchesNum];
int e[MatchesNum];
int CurMatch;
} *PMatches;
typedef class PosRegExp
{
PRegInfo Info;
PMatches BkTrace;
bool NoCase,Extend,NoMoves;
bool Error;
int *Exprn;
int posParse;
int posEnd,posStart;
int posBkStr;
int FirstChar;
bool SetExprLow(const char *Expr);
bool SetStructs(PRegInfo &Info,int st,int end);
void Optimize();
bool CheckSymb(int Symb,bool Inc);
bool LowParse(PRegInfo Re);
bool LowParseRe(PRegInfo &Next);
bool LowCheckNext(PRegInfo Re);
bool ParseRe(int posStr);
bool QuickCheck();
public:
PMatches Matches;
int Ok, CurMatch;
void *param;
char (*CharAt)(int pos, void *param);
PosRegExp();
~PosRegExp();
bool isok();
bool SetNoMoves(bool Moves);
bool SetBkTrace(int posStr,PMatches Trace);
bool SetExpr(const char *Expr);
bool Parse(int posStr, int posStop, PMatches Mtch);
bool Parse(int posStr,int posSol, int posEol, PMatches Mtch, int Moves = -1);
bool Evaluate(char *Expr, int posStr, PMatches Mtch, char **Res);
} *PPosRegExp;
#endif /* POSREGEXP_H */

View File

@@ -1,188 +1,17 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// PropSet.h - a java style properties file module /** @file PropSet.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** A Java style properties file module.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PROPSET_H #ifndef PROPSET_H
#define PROPSET_H #define PROPSET_H
#include "SString.h"
bool EqualCaseInsensitive(const char *a, const char *b); bool EqualCaseInsensitive(const char *a, const char *b);
#if PLAT_WIN bool isprefix(const char *target, const char *prefix);
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
#ifdef __WXMSW__
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
// Define another string class.
// While it would be 'better' to use std::string, that doubles the executable size.
inline char *StringDup(const char *s, int len=-1) {
if (!s)
return 0;
if (len == -1)
len = strlen(s);
char *sNew = new char[len + 1];
if (sNew) {
strncpy(sNew, s, len);
sNew[len] = '\0';
}
return sNew;
}
class SString {
char *s;
int ssize;
public:
typedef const char* const_iterator;
typedef int size_type;
static size_type npos;
const char* begin(void) const {
return s;
}
const char* end(void) const {
return &s[ssize];
}
size_type size(void) const {
if (s)
return ssize;
else
return 0;
}
SString &assign(const char* sother, int size_ = -1) {
char *t = s;
s = StringDup(sother,size_);
ssize = (s) ? strlen(s) : 0;
delete []t;
return *this;
}
SString &assign(const SString& sother, int size_ = -1) {
return assign(sother.s,size_);
}
SString &assign(const_iterator ibeg, const_iterator iend) {
return assign(ibeg,iend - ibeg);
}
SString() {
s = 0;
ssize = 0;
}
SString(const SString &source) {
s = StringDup(source.s);
ssize = (s) ? strlen(s) : 0;
}
SString(const char *s_) {
s = StringDup(s_);
ssize = (s) ? strlen(s) : 0;
}
SString(int i) {
char number[100];
sprintf(number, "%0d", i);
s = StringDup(number);
ssize = (s) ? strlen(s) : 0;
}
~SString() {
delete []s;
s = 0;
ssize = 0;
}
SString &operator=(const SString &source) {
if (this != &source) {
delete []s;
s = StringDup(source.s);
ssize = (s) ? strlen(s) : 0;
}
return *this;
}
bool operator==(const SString &other) const {
if ((s == 0) && (other.s == 0))
return true;
if ((s == 0) || (other.s == 0))
return false;
return strcmp(s, other.s) == 0;
}
bool operator!=(const SString &other) const {
return !operator==(other);
}
bool operator==(const char *sother) const {
if ((s == 0) && (sother == 0))
return true;
if ((s == 0) || (sother == 0))
return false;
return strcmp(s, sother) == 0;
}
bool operator!=(const char *sother) const {
return !operator==(sother);
}
const char *c_str() const {
if (s)
return s;
else
return "";
}
int length() const {
if (s)
return strlen(s);
else
return 0;
}
char operator[](int i) const {
if (s)
return s[i];
else
return '\0';
}
SString &operator +=(const char *sother) {
return append(sother,-1);
}
SString &operator +=(const SString &sother) {
return append(sother.s,sother.ssize);
}
SString &operator +=(char ch) {
return append(&ch,1);
}
SString &append(const char* sother, int lenOther) {
int len = length();
if(lenOther < 0)
lenOther = strlen(sother);
char *sNew = new char[len + lenOther + 1];
if (sNew) {
if (s)
memcpy(sNew, s, len);
strncpy(&sNew[len], sother, lenOther);
sNew[len + lenOther] = '\0';
delete []s;
s = sNew;
ssize = (s) ? strlen(s) : 0;
}
return *this;
}
int value() const {
if (s)
return atoi(s);
else
return 0;
}
void substitute(char find, char replace) {
char *t = s;
while (t) {
t = strchr(t, find);
if (t)
*t = replace;
}
}
// I don't think this really belongs here -- Neil
void correctPath() {
#ifdef unix
substitute('\\', '/');
#else
substitute('/', '\\');
#endif
}
};
struct Property { struct Property {
unsigned int hash; unsigned int hash;
@@ -192,53 +21,66 @@ struct Property {
Property() : hash(0), key(0), val(0), next(0) {} Property() : hash(0), key(0), val(0), next(0) {}
}; };
/**
*/
class PropSet { class PropSet {
private: private:
enum { hashRoots=31 }; enum { hashRoots=31 };
Property *props[hashRoots]; Property *props[hashRoots];
Property *enumnext;
int enumhash;
public: public:
PropSet *superPS; PropSet *superPS;
PropSet(); PropSet();
~PropSet(); ~PropSet();
void Set(const char *key, const char *val); void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
void Set(char *keyval); void Set(const char *keyVal);
void SetMultiple(const char *s);
SString Get(const char *key); SString Get(const char *key);
SString GetExpanded(const char *key); SString GetExpanded(const char *key);
SString Expand(const char *withvars); SString Expand(const char *withVars);
int GetInt(const char *key, int defaultValue=0); int GetInt(const char *key, int defaultValue=0);
SString GetWild(const char *keybase, const char *filename); SString GetWild(const char *keybase, const char *filename);
SString GetNewExpand(const char *keybase, const char *filename); SString GetNewExpand(const char *keybase, const char *filename);
void Clear(); void Clear();
void ReadFromMemory(const char *data, int len, const char *directoryForImports=0); char *ToString(); // Caller must delete[] the return value
void Read(const char *filename, const char *directoryForImports); bool GetFirst(char **key, char **val);
bool GetNext(char **key, char **val);
}; };
/**
*/
class WordList { class WordList {
public: public:
// Each word contains at least one character - a empty word acts as sentinal at the end. // Each word contains at least one character - a empty word acts as sentinel at the end.
char **words; char **words;
char **wordsNoCase; char **wordsNoCase;
char *list; char *list;
int len; int len;
bool onlyLineEnds; // Delimited by any white space or only line ends bool onlyLineEnds; ///< Delimited by any white space or only line ends
bool sorted; bool sorted;
int starts[256]; int starts[256];
WordList(bool onlyLineEnds_ = false) : WordList(bool onlyLineEnds_ = false) :
words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {} words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {}
~WordList() { Clear(); } ~WordList() { Clear(); }
operator bool() { return words ? true : false; } operator bool() { return len ? true : false; }
const char *operator[](int ind) { return words[ind]; } char *operator[](int ind) { return words[ind]; }
void Clear(); void Clear();
void Set(const char *s); void Set(const char *s);
char *Allocate(int size); char *Allocate(int size);
void SetFromAllocated(); void SetFromAllocated();
bool InList(const char *s); bool InList(const char *s);
const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false); const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
char *GetNearestWords(const char *wordStart, int searchLen = -1, bool ignoreCase = false); char *GetNearestWords(const char *wordStart, int searchLen=-1,
bool ignoreCase=false, char otherSeparator='\0');
}; };
inline bool nonFuncChar(char ch) { inline bool nonFuncChar(char ch) {
return strchr("\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", ch) != NULL; return strchr("\t\n\r !\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", ch) != NULL;
} }
inline bool IsAlphabetic(unsigned int ch) {
return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
}
#endif #endif

View File

@@ -0,0 +1,255 @@
// SciTE - Scintilla based Text Editor
/** @file SString.h
** A simple string class.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef SSTRING_H
#define SSTRING_H
// These functions are implemented because each platform calls them something different
int CompareCaseInsensitive(const char *a, const char *b);
int CompareNCaseInsensitive(const char *a, const char *b, int len);
bool EqualCaseInsensitive(const char *a, const char *b);
// Define another string class.
// While it would be 'better' to use std::string, that doubles the executable size.
// An SString may contain embedded nul characters.
/**
* Duplicate a C string.
* Allocate memory of the given size, or big enough to fit the string if length isn't given;
* then copy the given string in the allocated memory.
* @return the pointer to the new string
*/
inline char *StringDup(
const char *s, ///< The string to duplicate
int len=-1) ///< The length of memory to allocate. Optional.
{
if (!s)
return 0;
if (len == -1)
len = strlen(s);
char *sNew = new char[len + 1];
if (sNew) {
strncpy(sNew, s, len);
sNew[len] = '\0';
}
return sNew;
}
/**
* @brief A simple string class.
* Hold the length of the string for quick operations,
* can have a buffer bigger than the string to avoid too many memory allocations and copies.
* May have embedded zeroes as a result of @a substitute, but rely too heavily on C string
* functions to allow reliable manipulations of these strings.
**/
class SString {
char *s; ///< The C string
int sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
int sLen; ///< The size of the string in s
int sizeGrowth; ///< Minimum growth size when appending strings
enum { sizeGrowthDefault = 64 };
public:
typedef int size_type;
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
}
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(source.s);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(s_);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(const char *s_, int first, int last) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(s_ + first, last - first);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(int i) : sizeGrowth(sizeGrowthDefault) {
char number[32];
sprintf(number, "%0d", i);
s = StringDup(number);
sSize = sLen = (s) ? strlen(s) : 0;
}
~SString() {
delete []s;
s = 0;
sSize = 0;
sLen = 0;
}
void clear(void) {
if (s) {
*s = '\0';
}
sLen = 0;
}
/** Size of buffer. */
size_type size(void) const { ///<
if (s)
return sSize;
else
return 0;
}
/** Size of string in buffer. */
int length() const {
return sLen;
}
SString &assign(const char* sOther, int sSize_ = -1) {
if (!sOther) {
sSize_ = 0;
}
if (sSize_ < 0) {
sSize_ = strlen(sOther);
}
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
if (s && sSize_) {
strncpy(s, sOther, sSize_);
}
s[sSize_] = '\0';
sLen = sSize_;
} else {
delete []s;
s = StringDup(sOther, sSize_);
if (s) {
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
sLen = strlen(s);
} else {
sSize = sLen = 0;
}
}
return *this;
}
SString &assign(const SString& sOther, int sSize_ = -1) {
return assign(sOther.s, sSize_);
}
SString &operator=(const char *source) {
return assign(source);
}
SString &operator=(const SString &source) {
if (this != &source) {
assign(source.c_str());
}
return *this;
}
bool operator==(const SString &sOther) const {
if ((s == 0) && (sOther.s == 0))
return true;
if ((s == 0) || (sOther.s == 0))
return false;
return strcmp(s, sOther.s) == 0;
}
bool operator!=(const SString &sOther) const {
return !operator==(sOther);
}
bool operator==(const char *sOther) const {
if ((s == 0) && (sOther == 0))
return true;
if ((s == 0) || (sOther == 0))
return false;
return strcmp(s, sOther) == 0;
}
bool operator!=(const char *sOther) const {
return !operator==(sOther);
}
bool contains(char ch) {
if (s && *s)
return strchr(s, ch) != 0;
else
return false;
}
void setsizegrowth(int sizeGrowth_) {
sizeGrowth = sizeGrowth_;
}
const char *c_str() const {
if (s)
return s;
else
return "";
}
/** Give ownership of buffer to caller which must use delete[] to free buffer. */
char *detach() {
char *sRet = s;
s = 0;
sSize = 0;
sLen = 0;
return sRet;
}
char operator[](int i) const {
if (s && i < sSize) // Or < sLen? Depends on the use, both are OK
return s[i];
else
return '\0';
}
SString &append(const char* sOther, int sLenOther=-1, char sep=0) {
if (sLenOther < 0)
sLenOther = strlen(sOther);
int lenSep = 0;
if (sLen && sep) // Only add a separator if not empty
lenSep = 1;
int lenNew = sLen + sLenOther + lenSep;
if (lenNew + 1 < sSize) {
// Conservative about growing the buffer: don't do it, unless really needed
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
s[sLen + sLenOther] = '\0';
sLen += sLenOther;
} else {
// Grow the buffer bigger than really needed, to have room for other appends
char *sNew = new char[lenNew + sizeGrowth + 1];
if (sNew) {
if (s) {
memcpy(sNew, s, sLen);
delete []s;
}
s = sNew;
sSize = lenNew + sizeGrowth;
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
sNew[sLen + sLenOther] = '\0';
sLen += sLenOther;
}
}
return *this;
}
SString &operator +=(const char *sOther) {
return append(sOther, -1);
}
SString &operator +=(const SString &sOther) {
return append(sOther.s, sOther.sSize);
}
SString &operator +=(char ch) {
return append(&ch, 1);
}
SString &appendwithseparator(const char* sOther, char sep) {
return append(sOther, strlen(sOther), sep);
}
int value() const {
if (s)
return atoi(s);
else
return 0;
}
void substitute(char find, char replace) {
char *t = s;
while (t) {
t = strchr(t, find);
if (t) {
*t = replace;
t++;
}
}
}
};
#endif

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// SciLexer - interface to the added lexer functions in the SciLexer version of the edit control /** @file SciLexer.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Interface to the added lexer functions in the SciLexer version of the edit control.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -29,6 +31,16 @@
#define SCLEX_LATEX 14 #define SCLEX_LATEX 14
#define SCLEX_LUA 15 #define SCLEX_LUA 15
#define SCLEX_DIFF 16 #define SCLEX_DIFF 16
#define SCLEX_CONF 17
#define SCLEX_PASCAL 18
#define SCLEX_AVE 19
#define SCLEX_ADA 20
#define SCLEX_LISP 21
#define SCLEX_RUBY 22
#define SCLEX_EIFFEL 23
#define SCLEX_EIFFELKW 24
#define SCLEX_TCL 25
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0 #define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1 #define SCE_P_COMMENTLINE 1
#define SCE_P_NUMBER 2 #define SCE_P_NUMBER 2
@@ -57,6 +69,9 @@
#define SCE_C_IDENTIFIER 11 #define SCE_C_IDENTIFIER 11
#define SCE_C_STRINGEOL 12 #define SCE_C_STRINGEOL 12
#define SCE_C_VERBATIM 13 #define SCE_C_VERBATIM 13
#define SCE_C_REGEX 14
#define SCE_C_COMMENTLINEDOC 15
#define SCE_C_WORD2 16
#define SCE_H_DEFAULT 0 #define SCE_H_DEFAULT 0
#define SCE_H_TAG 1 #define SCE_H_TAG 1
#define SCE_H_TAGUNKNOWN 2 #define SCE_H_TAGUNKNOWN 2
@@ -77,6 +92,8 @@
#define SCE_H_CDATA 17 #define SCE_H_CDATA 17
#define SCE_H_QUESTION 18 #define SCE_H_QUESTION 18
#define SCE_H_VALUE 19 #define SCE_H_VALUE 19
#define SCE_H_XCCOMMENT 20
#define SCE_H_SGML 21
#define SCE_HJ_START 40 #define SCE_HJ_START 40
#define SCE_HJ_DEFAULT 41 #define SCE_HJ_DEFAULT 41
#define SCE_HJ_COMMENT 42 #define SCE_HJ_COMMENT 42
@@ -89,6 +106,7 @@
#define SCE_HJ_SINGLESTRING 49 #define SCE_HJ_SINGLESTRING 49
#define SCE_HJ_SYMBOLS 50 #define SCE_HJ_SYMBOLS 50
#define SCE_HJ_STRINGEOL 51 #define SCE_HJ_STRINGEOL 51
#define SCE_HJ_REGEX 52
#define SCE_HJA_START 55 #define SCE_HJA_START 55
#define SCE_HJA_DEFAULT 56 #define SCE_HJA_DEFAULT 56
#define SCE_HJA_COMMENT 57 #define SCE_HJA_COMMENT 57
@@ -101,6 +119,7 @@
#define SCE_HJA_SINGLESTRING 64 #define SCE_HJA_SINGLESTRING 64
#define SCE_HJA_SYMBOLS 65 #define SCE_HJA_SYMBOLS 65
#define SCE_HJA_STRINGEOL 66 #define SCE_HJA_STRINGEOL 66
#define SCE_HJA_REGEX 67
#define SCE_HB_START 70 #define SCE_HB_START 70
#define SCE_HB_DEFAULT 71 #define SCE_HB_DEFAULT 71
#define SCE_HB_COMMENTLINE 72 #define SCE_HB_COMMENTLINE 72
@@ -151,9 +170,10 @@
#define SCE_HPHP_VARIABLE 123 #define SCE_HPHP_VARIABLE 123
#define SCE_HPHP_COMMENT 124 #define SCE_HPHP_COMMENT 124
#define SCE_HPHP_COMMENTLINE 125 #define SCE_HPHP_COMMENTLINE 125
#define SCE_HPHP_STRINGEOL 126 #define SCE_HPHP_HSTRING_VARIABLE 126
#define SCE_HPHP_OPERATOR 127
#define SCE_PL_DEFAULT 0 #define SCE_PL_DEFAULT 0
#define SCE_PL_HERE 1 #define SCE_PL_ERROR 1
#define SCE_PL_COMMENTLINE 2 #define SCE_PL_COMMENTLINE 2
#define SCE_PL_POD 3 #define SCE_PL_POD 3
#define SCE_PL_NUMBER 4 #define SCE_PL_NUMBER 4
@@ -168,12 +188,20 @@
#define SCE_PL_ARRAY 13 #define SCE_PL_ARRAY 13
#define SCE_PL_HASH 14 #define SCE_PL_HASH 14
#define SCE_PL_SYMBOLTABLE 15 #define SCE_PL_SYMBOLTABLE 15
#define SCE_PL_REF 16
#define SCE_PL_REGEX 17 #define SCE_PL_REGEX 17
#define SCE_PL_REGSUBST 18 #define SCE_PL_REGSUBST 18
#define SCE_PL_LONGQUOTE 19 #define SCE_PL_LONGQUOTE 19
#define SCE_PL_BACKTICKS 20 #define SCE_PL_BACKTICKS 20
#define SCE_PL_DATASECTION 21 #define SCE_PL_DATASECTION 21
#define SCE_PL_HERE_DELIM 22
#define SCE_PL_HERE_Q 23
#define SCE_PL_HERE_QQ 24
#define SCE_PL_HERE_QX 25
#define SCE_PL_STRING_Q 26
#define SCE_PL_STRING_QQ 27
#define SCE_PL_STRING_QX 28
#define SCE_PL_STRING_QR 29
#define SCE_PL_STRING_QW 30
#define SCE_L_DEFAULT 0 #define SCE_L_DEFAULT 0
#define SCE_L_COMMAND 1 #define SCE_L_COMMAND 1
#define SCE_L_TAG 2 #define SCE_L_TAG 2
@@ -199,6 +227,74 @@
#define SCE_ERR_CMD 4 #define SCE_ERR_CMD 4
#define SCE_ERR_BORLAND 5 #define SCE_ERR_BORLAND 5
#define SCE_ERR_PERL 6 #define SCE_ERR_PERL 6
#define SCE_ERR_NET 7
#define SCE_ERR_LUA 8
#define SCE_ERR_DIFF_CHANGED 10
#define SCE_ERR_DIFF_ADDITION 11
#define SCE_ERR_DIFF_DELETION 12
#define SCE_ERR_DIFF_MESSAGE 13
#define SCE_BAT_DEFAULT 0
#define SCE_BAT_COMMENT 1
#define SCE_BAT_WORD 2
#define SCE_BAT_LABEL 3
#define SCE_BAT_HIDE 4
#define SCE_BAT_COMMAND 5
#define SCE_BAT_IDENTIFIER 6
#define SCE_BAT_OPERATOR 7
#define SCE_MAKE_DEFAULT 0
#define SCE_MAKE_COMMENT 1
#define SCE_MAKE_PREPROCESSOR 2
#define SCE_MAKE_IDENTIFIER 3
#define SCE_MAKE_OPERATOR 4
#define SCE_MAKE_TARGET 5
#define SCE_MAKE_IDEOL 9
#define SCE_CONF_DEFAULT 0
#define SCE_CONF_COMMENT 1
#define SCE_CONF_NUMBER 2
#define SCE_CONF_IDENTIFIER 3
#define SCE_CONF_EXTENSION 4
#define SCE_CONF_PARAMETER 5
#define SCE_CONF_STRING 6
#define SCE_CONF_OPERATOR 7
#define SCE_CONF_IP 8
#define SCE_CONF_DIRECTIVE 9
#define SCE_AVE_DEFAULT 0
#define SCE_AVE_COMMENT 1
#define SCE_AVE_NUMBER 2
#define SCE_AVE_WORD 3
#define SCE_AVE_KEYWORD 4
#define SCE_AVE_STATEMENT 5
#define SCE_AVE_STRING 6
#define SCE_AVE_ENUM 7
#define SCE_AVE_STRINGEOL 8
#define SCE_AVE_IDENTIFIER 9
#define SCE_AVE_OPERATOR 10
#define SCE_ADA_DEFAULT 0
#define SCE_ADA_COMMENT 1
#define SCE_ADA_NUMBER 2
#define SCE_ADA_WORD 3
#define SCE_ADA_STRING 4
#define SCE_ADA_CHARACTER 5
#define SCE_ADA_OPERATOR 6
#define SCE_ADA_IDENTIFIER 7
#define SCE_ADA_STRINGEOL 8
#define SCE_LISP_DEFAULT 0
#define SCE_LISP_COMMENT 1
#define SCE_LISP_NUMBER 2
#define SCE_LISP_KEYWORD 3
#define SCE_LISP_STRING 6
#define SCE_LISP_STRINGEOL 8
#define SCE_LISP_IDENTIFIER 9
#define SCE_LISP_OPERATOR 10
#define SCE_EIFFEL_DEFAULT 0
#define SCE_EIFFEL_COMMENTLINE 1
#define SCE_EIFFEL_NUMBER 2
#define SCE_EIFFEL_WORD 3
#define SCE_EIFFEL_STRING 4
#define SCE_EIFFEL_CHARACTER 5
#define SCE_EIFFEL_OPERATOR 6
#define SCE_EIFFEL_IDENTIFIER 7
#define SCE_EIFFEL_STRINGEOL 8
//--Autogenerated -- end of section automatically generated from Scintilla.iface //--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif #endif

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// Scintilla.h - interface to the edit control /** @file Scintilla.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Interface to the edit control.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -18,7 +20,13 @@ void Scintilla_RegisterClasses(HINSTANCE hInstance);
#endif #endif
#endif #endif
typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wParam, long lParam); // Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
// hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
// May need to be changed for 64 bit platforms.
typedef unsigned long uptr_t;
typedef long sptr_t;
typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam);
//++Autogenerated -- start of section automatically generated from Scintilla.iface //++Autogenerated -- start of section automatically generated from Scintilla.iface
#define INVALID_POSITION -1 #define INVALID_POSITION -1
@@ -50,15 +58,16 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_GETVIEWWS 2020 #define SCI_GETVIEWWS 2020
#define SCI_SETVIEWWS 2021 #define SCI_SETVIEWWS 2021
#define SCI_POSITIONFROMPOINT 2022 #define SCI_POSITIONFROMPOINT 2022
#define SCI_POSITIONFROMPOINTCLOSE 2023
#define SCI_GOTOLINE 2024 #define SCI_GOTOLINE 2024
#define SCI_GOTOPOS 2025 #define SCI_GOTOPOS 2025
#define SCI_SETANCHOR 2026 #define SCI_SETANCHOR 2026
#define SCI_GETCURLINE 2027 #define SCI_GETCURLINE 2027
#define SCI_GETENDSTYLED 2028 #define SCI_GETENDSTYLED 2028
#define SCI_CONVERTEOLS 2029
#define SC_EOL_CRLF 0 #define SC_EOL_CRLF 0
#define SC_EOL_CR 1 #define SC_EOL_CR 1
#define SC_EOL_LF 2 #define SC_EOL_LF 2
#define SCI_CONVERTEOLS 2029
#define SCI_GETEOLMODE 2030 #define SCI_GETEOLMODE 2030
#define SCI_SETEOLMODE 2031 #define SCI_SETEOLMODE 2031
#define SCI_STARTSTYLING 2032 #define SCI_STARTSTYLING 2032
@@ -80,6 +89,24 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SC_MARK_ARROWDOWN 6 #define SC_MARK_ARROWDOWN 6
#define SC_MARK_MINUS 7 #define SC_MARK_MINUS 7
#define SC_MARK_PLUS 8 #define SC_MARK_PLUS 8
#define SC_MARK_VLINE 9
#define SC_MARK_LCORNER 10
#define SC_MARK_TCORNER 11
#define SC_MARK_BOXPLUS 12
#define SC_MARK_BOXPLUSCONNECTED 13
#define SC_MARK_BOXMINUS 14
#define SC_MARK_BOXMINUSCONNECTED 15
#define SC_MARK_LCORNERCURVE 16
#define SC_MARK_TCORNERCURVE 17
#define SC_MARK_CIRCLEPLUS 18
#define SC_MARK_CIRCLEPLUSCONNECTED 19
#define SC_MARK_CIRCLEMINUS 20
#define SC_MARK_CIRCLEMINUSCONNECTED 21
#define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26
#define SC_MARKNUM_FOLDERMIDTAIL 27
#define SC_MARKNUM_FOLDERTAIL 28
#define SC_MARKNUM_FOLDERSUB 29
#define SC_MARKNUM_FOLDER 30 #define SC_MARKNUM_FOLDER 30
#define SC_MARKNUM_FOLDEROPEN 31 #define SC_MARKNUM_FOLDEROPEN 31
#define SCI_MARKERDEFINE 2040 #define SCI_MARKERDEFINE 2040
@@ -137,6 +164,10 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_STYLESETEOLFILLED 2057 #define SCI_STYLESETEOLFILLED 2057
#define SCI_STYLERESETDEFAULT 2058 #define SCI_STYLERESETDEFAULT 2058
#define SCI_STYLESETUNDERLINE 2059 #define SCI_STYLESETUNDERLINE 2059
#define SC_CASE_MIXED 0
#define SC_CASE_UPPER 1
#define SC_CASE_LOWER 2
#define SCI_STYLESETCASE 2060
#define SCI_STYLESETCHARACTERSET 2066 #define SCI_STYLESETCHARACTERSET 2066
#define SCI_SETSELFORE 2067 #define SCI_SETSELFORE 2067
#define SCI_SETSELBACK 2068 #define SCI_SETSELBACK 2068
@@ -170,6 +201,10 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_SETLINESTATE 2092 #define SCI_SETLINESTATE 2092
#define SCI_GETLINESTATE 2093 #define SCI_GETLINESTATE 2093
#define SCI_GETMAXLINESTATE 2094 #define SCI_GETMAXLINESTATE 2094
#define SCI_GETCARETLINEVISIBLE 2095
#define SCI_SETCARETLINEVISIBLE 2096
#define SCI_GETCARETLINEBACK 2097
#define SCI_SETCARETLINEBACK 2098
#define SCI_AUTOCSHOW 2100 #define SCI_AUTOCSHOW 2100
#define SCI_AUTOCCANCEL 2101 #define SCI_AUTOCCANCEL 2101
#define SCI_AUTOCACTIVE 2102 #define SCI_AUTOCACTIVE 2102
@@ -186,6 +221,9 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_AUTOCGETCHOOSESINGLE 2114 #define SCI_AUTOCGETCHOOSESINGLE 2114
#define SCI_AUTOCSETIGNORECASE 2115 #define SCI_AUTOCSETIGNORECASE 2115
#define SCI_AUTOCGETIGNORECASE 2116 #define SCI_AUTOCGETIGNORECASE 2116
#define SCI_USERLISTSHOW 2117
#define SCI_AUTOCSETAUTOHIDE 2118
#define SCI_AUTOCGETAUTOHIDE 2119
#define SCI_SETINDENT 2122 #define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123 #define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124 #define SCI_SETUSETABS 2124
@@ -215,9 +253,10 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SC_PRINT_NORMAL 0 #define SC_PRINT_NORMAL 0
#define SC_PRINT_INVERTLIGHT 1 #define SC_PRINT_INVERTLIGHT 1
#define SC_PRINT_BLACKONWHITE 2 #define SC_PRINT_BLACKONWHITE 2
#define SC_PRINT_COLOURONWHITE 3
#define SC_PRINT_COLOURONWHITEDEFAULTBG 4
#define SCI_SETPRINTCOLOURMODE 2148 #define SCI_SETPRINTCOLOURMODE 2148
#define SCI_GETPRINTCOLOURMODE 2149 #define SCI_GETPRINTCOLOURMODE 2149
#define SCFIND_DOWN 1
#define SCFIND_WHOLEWORD 2 #define SCFIND_WHOLEWORD 2
#define SCFIND_MATCHCASE 4 #define SCFIND_MATCHCASE 4
#define SCFIND_WORDSTART 0x00100000 #define SCFIND_WORDSTART 0x00100000
@@ -260,6 +299,17 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_GETDIRECTPOINTER 2185 #define SCI_GETDIRECTPOINTER 2185
#define SCI_SETOVERTYPE 2186 #define SCI_SETOVERTYPE 2186
#define SCI_GETOVERTYPE 2187 #define SCI_GETOVERTYPE 2187
#define SCI_SETCARETWIDTH 2188
#define SCI_GETCARETWIDTH 2189
#define SCI_SETTARGETSTART 2190
#define SCI_GETTARGETSTART 2191
#define SCI_SETTARGETEND 2192
#define SCI_GETTARGETEND 2193
#define SCI_REPLACETARGET 2194
#define SCI_REPLACETARGETRE 2195
#define SCI_SEARCHINTARGET 2197
#define SCI_SETSEARCHFLAGS 2198
#define SCI_GETSEARCHFLAGS 2199
#define SCI_CALLTIPSHOW 2200 #define SCI_CALLTIPSHOW 2200
#define SCI_CALLTIPCANCEL 2201 #define SCI_CALLTIPCANCEL 2201
#define SCI_CALLTIPACTIVE 2202 #define SCI_CALLTIPACTIVE 2202
@@ -284,6 +334,14 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_TOGGLEFOLD 2231 #define SCI_TOGGLEFOLD 2231
#define SCI_ENSUREVISIBLE 2232 #define SCI_ENSUREVISIBLE 2232
#define SCI_SETFOLDFLAGS 2233 #define SCI_SETFOLDFLAGS 2233
#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234
#define SCI_SETTABINDENTS 2260
#define SCI_GETTABINDENTS 2261
#define SCI_SETBACKSPACEUNINDENTS 2262
#define SCI_GETBACKSPACEUNINDENTS 2263
#define SC_TIME_FOREVER 10000000
#define SCI_SETMOUSEDWELLTIME 2264
#define SCI_GETMOUSEDWELLTIME 2265
#define SCI_LINEDOWN 2300 #define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301 #define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302 #define SCI_LINEUP 2302
@@ -328,6 +386,7 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_UPPERCASE 2341 #define SCI_UPPERCASE 2341
#define SCI_LINESCROLLDOWN 2342 #define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343 #define SCI_LINESCROLLUP 2343
#define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350 #define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351 #define SCI_BRACEHIGHLIGHT 2351
#define SCI_BRACEBADLIGHT 2352 #define SCI_BRACEBADLIGHT 2352
@@ -352,6 +411,8 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define CARET_SLOP 0x01 #define CARET_SLOP 0x01
#define CARET_CENTER 0x02 #define CARET_CENTER 0x02
#define CARET_STRICT 0x04 #define CARET_STRICT 0x04
#define CARET_XEVEN 0x08
#define CARET_XJUMPS 0x10
#define SCI_SETCARETPOLICY 2369 #define SCI_SETCARETPOLICY 2369
#define SCI_LINESONSCREEN 2370 #define SCI_LINESONSCREEN 2370
#define SCI_USEPOPUP 2371 #define SCI_USEPOPUP 2371
@@ -362,6 +423,25 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_ADDREFDOCUMENT 2376 #define SCI_ADDREFDOCUMENT 2376
#define SCI_RELEASEDOCUMENT 2377 #define SCI_RELEASEDOCUMENT 2377
#define SCI_GETMODEVENTMASK 2378 #define SCI_GETMODEVENTMASK 2378
#define SCI_SETFOCUS 2380
#define SCI_GETFOCUS 2381
#define SCI_SETSTATUS 2382
#define SCI_GETSTATUS 2383
#define SCI_SETMOUSEDOWNCAPTURES 2384
#define SCI_GETMOUSEDOWNCAPTURES 2385
#define SC_CURSORNORMAL -1
#define SC_CURSORWAIT 3
#define SCI_SETCURSOR 2386
#define SCI_GETCURSOR 2387
#define SCI_WORDPARTLEFT 2390
#define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392
#define SCI_WORDPARTRIGHTEXTEND 2393
#define VISIBLE_SLOP 0x01
#define VISIBLE_STRICT 0x04
#define SCI_SETVISIBLEPOLICY 2394
#define SCI_DELLINELEFT 2395
#define SCI_DELLINERIGHT 2396
#define SCI_GRABFOCUS 2400 #define SCI_GRABFOCUS 2400
#define SCI_STARTRECORD 3001 #define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002 #define SCI_STOPRECORD 3002
@@ -370,6 +450,7 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_COLOURISE 4003 #define SCI_COLOURISE 4003
#define SCI_SETPROPERTY 4004 #define SCI_SETPROPERTY 4004
#define SCI_SETKEYWORDS 4005 #define SCI_SETKEYWORDS 4005
#define SCI_SETLEXERLANGUAGE 4006
#define SC_MOD_INSERTTEXT 0x1 #define SC_MOD_INSERTTEXT 0x1
#define SC_MOD_DELETETEXT 0x2 #define SC_MOD_DELETETEXT 0x2
#define SC_MOD_CHANGESTYLE 0x4 #define SC_MOD_CHANGESTYLE 0x4
@@ -419,6 +500,11 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCN_MARGINCLICK 2010 #define SCN_MARGINCLICK 2010
#define SCN_NEEDSHOWN 2011 #define SCN_NEEDSHOWN 2011
#define SCN_POSCHANGED 2012 #define SCN_POSCHANGED 2012
#define SCN_PAINTED 2013
#define SCN_USERLISTSELECTION 2014
#define SCN_URIDROPPED 2015
#define SCN_DWELLSTART 2016
#define SCN_DWELLEND 2017
//--Autogenerated -- end of section automatically generated from Scintilla.iface //--Autogenerated -- end of section automatically generated from Scintilla.iface
// Optional module for macro recording // Optional module for macro recording
@@ -437,14 +523,14 @@ struct CharacterRange {
}; };
struct TextRange { struct TextRange {
CharacterRange chrg; struct CharacterRange chrg;
char *lpstrText; char *lpstrText;
}; };
struct TextToFind { struct TextToFind {
CharacterRange chrg; struct CharacterRange chrg;
char *lpstrText; char *lpstrText;
CharacterRange chrgText; struct CharacterRange chrgText;
}; };
#ifdef PLATFORM_H #ifdef PLATFORM_H
@@ -463,8 +549,8 @@ struct RangeToFormat {
#endif #endif
struct NotifyHeader { struct NotifyHeader {
// hwndFrom is really an environment specifc window handle or pointer // hwndFrom is really an environment specifc window handle or pointer
// but most clients of Scintilla.h do not have this type visible. // but most clients of Scintilla.h do not have this type visible.
//WindowID hwndFrom; //WindowID hwndFrom;
void *hwndFrom; void *hwndFrom;
unsigned int idFrom; unsigned int idFrom;
@@ -472,26 +558,35 @@ struct NotifyHeader {
}; };
struct SCNotification { struct SCNotification {
NotifyHeader nmhdr; struct NotifyHeader nmhdr;
int position; // SCN_STYLENEEDED, SCN_MODIFIED int position; // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND
int ch; // SCN_CHARADDED, SCN_KEY int ch; // SCN_CHARADDED, SCN_KEY
int modifiers; // SCN_KEY int modifiers; // SCN_KEY
int modificationType; // SCN_MODIFIED int modificationType; // SCN_MODIFIED
const char *text; // SCN_MODIFIED const char *text; // SCN_MODIFIED
int length; // SCN_MODIFIED int length; // SCN_MODIFIED
int linesAdded; // SCN_MODIFIED int linesAdded; // SCN_MODIFIED
#ifdef MACRO_SUPPORT #ifdef MACRO_SUPPORT
int message; // SCN_MACRORECORD int message; // SCN_MACRORECORD
int wParam; // SCN_MACRORECORD uptr_t wParam; // SCN_MACRORECORD
int lParam; // SCN_MACRORECORD sptr_t lParam; // SCN_MACRORECORD
#endif #endif
int line; // SCN_MODIFIED int line; // SCN_MODIFIED
int foldLevelNow; // SCN_MODIFIED int foldLevelNow; // SCN_MODIFIED
int foldLevelPrev; // SCN_MODIFIED int foldLevelPrev; // SCN_MODIFIED
int margin; // SCN_MARGINCLICK int margin; // SCN_MARGINCLICK
int listType; // SCN_USERLISTSELECTION
int x; // SCN_DWELLSTART, SCN_DWELLEND
int y; // SCN_DWELLSTART, SCN_DWELLEND
}; };
#define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | (1<<SC_MARKNUM_FOLDEROPEN)) #define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | \
(1<<SC_MARKNUM_FOLDEROPEN) | \
(1<<SC_MARKNUM_FOLDERSUB) | \
(1<<SC_MARKNUM_FOLDERTAIL) | \
(1<<SC_MARKNUM_FOLDERMIDTAIL) | \
(1<<SC_MARKNUM_FOLDEROPENMID) | \
(1<<SC_MARKNUM_FOLDEREND))
// Deprecation section listing all API features that are deprecated and will // Deprecation section listing all API features that are deprecated and will
// will be removed completely in a future version. // will be removed completely in a future version.
@@ -499,10 +594,6 @@ struct SCNotification {
#ifdef INCLUDE_DEPRECATED_FEATURES #ifdef INCLUDE_DEPRECATED_FEATURES
// Deprecated in 1.27
#define SC_UNDOCOLLECT_NONE 0
#define SC_UNDOCOLLECT_AUTOSTART 1
#endif #endif
#endif #endif

View File

@@ -134,6 +134,10 @@ set void SetViewWS=2021(int viewWS,)
# Find the position from a point within the window. # Find the position from a point within the window.
fun int PositionFromPoint=2022(int x, int y) fun int PositionFromPoint=2022(int x, int y)
# Find the position from a point within the window but return
# INVALID_POSITION if not close to text.
fun int PositionFromPointClose=2023(int x, int y)
# Set caret to start of a line and ensure it is visible. # Set caret to start of a line and ensure it is visible.
fun void GotoLine=2024(int line,) fun void GotoLine=2024(int line,)
@@ -151,13 +155,13 @@ fun int GetCurLine=2027(int length, stringresult text)
# Retrieve the position of the last correctly styled character. # Retrieve the position of the last correctly styled character.
get position GetEndStyled=2028(,) get position GetEndStyled=2028(,)
# Convert all line endings in the document to use the current mode.
fun void ConvertEOLs=2029(,)
val SC_EOL_CRLF=0 val SC_EOL_CRLF=0
val SC_EOL_CR=1 val SC_EOL_CR=1
val SC_EOL_LF=2 val SC_EOL_LF=2
# Convert all line endings in the document to one mode.
fun void ConvertEOLs=2029(int eolMode,)
# Retrieve the current end of line mode - one of CRLF, CR, or LF. # Retrieve the current end of line mode - one of CRLF, CR, or LF.
get int GetEOLMode=2030(,) get int GetEOLMode=2030(,)
@@ -210,6 +214,27 @@ val SC_MARK_ARROWDOWN=6
val SC_MARK_MINUS=7 val SC_MARK_MINUS=7
val SC_MARK_PLUS=8 val SC_MARK_PLUS=8
# Shapes used for outlining column
val SC_MARK_VLINE=9
val SC_MARK_LCORNER=10
val SC_MARK_TCORNER=11
val SC_MARK_BOXPLUS=12
val SC_MARK_BOXPLUSCONNECTED=13
val SC_MARK_BOXMINUS=14
val SC_MARK_BOXMINUSCONNECTED=15
val SC_MARK_LCORNERCURVE=16
val SC_MARK_TCORNERCURVE=17
val SC_MARK_CIRCLEPLUS=18
val SC_MARK_CIRCLEPLUSCONNECTED=19
val SC_MARK_CIRCLEMINUS=20
val SC_MARK_CIRCLEMINUSCONNECTED=21
# Markers used for outlining column
val SC_MARKNUM_FOLDEREND=25
val SC_MARKNUM_FOLDEROPENMID=26
val SC_MARKNUM_FOLDERMIDTAIL=27
val SC_MARKNUM_FOLDERTAIL=28
val SC_MARKNUM_FOLDERSUB=29
val SC_MARKNUM_FOLDER=30 val SC_MARKNUM_FOLDER=30
val SC_MARKNUM_FOLDEROPEN=31 val SC_MARKNUM_FOLDEROPEN=31
@@ -327,6 +352,12 @@ fun void StyleResetDefault=2058(,)
# Set a style to be underlined or not. # Set a style to be underlined or not.
set void StyleSetUnderline=2059(int style, bool underline) set void StyleSetUnderline=2059(int style, bool underline)
val SC_CASE_MIXED=0
val SC_CASE_UPPER=1
val SC_CASE_LOWER=2
# Set a style to be mixed case, or to force upper or lower case.
set void StyleSetCase=2060(int style, int caseForce)
# Set the character set of the font in a style. # Set the character set of the font in a style.
set void StyleSetCharacterSet=2066(int style, int characterSet) set void StyleSetCharacterSet=2066(int style, int characterSet)
@@ -412,6 +443,18 @@ get int GetLineState=2093(int line,)
# Retrieve the last line number that has line state. # Retrieve the last line number that has line state.
get int GetMaxLineState=2094(,) get int GetMaxLineState=2094(,)
# Is the background of the line containing the caret in a different colour?
get bool GetCaretLineVisible=2095(,)
# Display the background of the line containing the caret in a different colour.
set void SetCaretLineVisible=2096(bool show,)
# Get the colour of the background of the line containing the caret.
get colour GetCaretLineBack=2097(,)
# Set the colour of the background of the line containing the caret.
set void SetCaretLineBack=2098(colour back,)
# Display a auto-completion list. # Display a auto-completion list.
# The lenEntered parameter indicates how many characters before # The lenEntered parameter indicates how many characters before
# the caret should be used to provide context. # the caret should be used to provide context.
@@ -465,6 +508,15 @@ set void AutoCSetIgnoreCase=2115(bool ignoreCase,)
# Retrieve state of ignore case flag. # Retrieve state of ignore case flag.
get bool AutoCGetIgnoreCase=2116(,) get bool AutoCGetIgnoreCase=2116(,)
# Display a list of strings and send notification when user chooses one.
fun void UserListShow=2117(int listType, string itemList)
# Set whether or not autocompletion is hidden automatically when nothing matches
set void AutoCSetAutoHide=2118(bool autoHide,)
# Retrieve whether or not autocompletion is hidden automatically when nothing matches
get bool AutoCGetAutoHide=2119(,)
# Set the number of spaces used for one level of indentation. # Set the number of spaces used for one level of indentation.
set void SetIndent=2122(int indentSize,) set void SetIndent=2122(int indentSize,)
@@ -551,6 +603,10 @@ val SC_PRINT_NORMAL=0
val SC_PRINT_INVERTLIGHT=1 val SC_PRINT_INVERTLIGHT=1
# PrintColourMode - force black text on white background for printing. # PrintColourMode - force black text on white background for printing.
val SC_PRINT_BLACKONWHITE=2 val SC_PRINT_BLACKONWHITE=2
# PrintColourMode - text stays coloured, but all background is forced to be white for printing.
val SC_PRINT_COLOURONWHITE=3
# PrintColourMode - only the default-background is forced to be white for printing.
val SC_PRINT_COLOURONWHITEDEFAULTBG=4
# Modify colours when printing for clearer printed text. # Modify colours when printing for clearer printed text.
set void SetPrintColourMode=2148(int mode,) set void SetPrintColourMode=2148(int mode,)
@@ -558,11 +614,9 @@ set void SetPrintColourMode=2148(int mode,)
# Returns the print colour mode. # Returns the print colour mode.
get int GetPrintColourMode=2149(,) get int GetPrintColourMode=2149(,)
val SCFIND_DOWN=1
val SCFIND_WHOLEWORD=2 val SCFIND_WHOLEWORD=2
val SCFIND_MATCHCASE=4 val SCFIND_MATCHCASE=4
val SCFIND_WORDSTART=0x00100000 val SCFIND_WORDSTART=0x00100000
# SCFIND_REGEXP is not yet implemented.
val SCFIND_REGEXP=0x00200000 val SCFIND_REGEXP=0x00200000
# Find some text in the document. # Find some text in the document.
@@ -582,13 +636,13 @@ fun int GetLine=2153(int line, stringresult text)
get int GetLineCount=2154(,) get int GetLineCount=2154(,)
# Sets the size in pixels of the left margin. # Sets the size in pixels of the left margin.
set void SetMarginLeft=2155(, int width) set void SetMarginLeft=2155(, int pixelWidth)
# Returns the size in pixels of the left margin. # Returns the size in pixels of the left margin.
get int GetMarginLeft=2156(,) get int GetMarginLeft=2156(,)
# Sets the size in pixels of the right margin. # Sets the size in pixels of the right margin.
set void SetMarginRight=2157(, int width) set void SetMarginRight=2157(, int pixelWidth)
# Returns the size in pixels of the right margin. # Returns the size in pixels of the right margin.
get int GetMarginRight=2158(,) get int GetMarginRight=2158(,)
@@ -684,6 +738,48 @@ set void SetOvertype=2186(bool overtype,)
# Returns true if overtype mode is active otherwise false is returned. # Returns true if overtype mode is active otherwise false is returned.
get bool GetOvertype=2187(,) get bool GetOvertype=2187(,)
# Set the width of the insert mode caret
set void SetCaretWidth=2188(int pixelWidth,)
# Returns the width of the insert mode caret
get int GetCaretWidth=2189(,)
# Sets the position that starts the target which is used for updating the
# document without affecting the scroll position.
set void SetTargetStart=2190(position pos,)
# Get the position that starts the target.
get position GetTargetStart=2191(,)
# Sets the position that ends the target which is used for updating the
# document without affecting the scroll position.
set void SetTargetEnd=2192(position pos,)
# Get the position that ends the target.
get position GetTargetEnd=2193(,)
# Replace the target text with the argument text.
# Returns the length of the replacement text.
fun int ReplaceTarget=2194(int length, string text)
# Replace the target text with the argument text after \d processing.
# Looks for \d where d is between 1 and 9 and replaces these with the strings
# matched in the last search operation which were surrounded by \( and \).
# Returns the length of the replacement text including any change
# caused by processing the \d patterns.
fun int ReplaceTargetRE=2195(int length, string text)
# Search for a counted string in the target and set the target to the found
# range.
# Returns length of range or -1 for failure in which case target is not moved.
fun int SearchInTarget=2197(int length, string text)
# Set the search flags used by SearchInTarget
set void SetSearchFlags=2198(int flags,)
# Get the search flags used by SearchInTarget
get int GetSearchFlags=2199(,)
# Show a call tip containing a definition near position pos. # Show a call tip containing a definition near position pos.
fun void CallTipShow=2200(position pos, string definition) fun void CallTipShow=2200(position pos, string definition)
@@ -751,6 +847,30 @@ fun void EnsureVisible=2232(int line,)
# Set some debugging options for folding # Set some debugging options for folding
fun void SetFoldFlags=2233(int flags,) fun void SetFoldFlags=2233(int flags,)
# Ensure a particular line is visible by expanding any header line hiding it.
# Use the currently set visibility policy to determine which range to display.
fun void EnsureVisibleEnforcePolicy=2234(int line,)
# Sets whether a tab pressed when caret is within indentation indents
set void SetTabIndents=2260(bool tabIndents,)
# Does a tab pressed when caret is within indentation indent?
get bool GetTabIndents=2261(,)
# Sets whether a backspace pressed when caret is within indentation unindents
set void SetBackSpaceUnIndents=2262(bool bsUnIndents,)
# Does a backspace pressed when caret is within indentation unindent?
get bool GetBackSpaceUnIndents=2263(,)
val SC_TIME_FOREVER=10000000
# Sets the time the mouse must sit still to generate a mouse dwell event
set void SetMouseDwellTime=2264(int periodMilliseconds,)
# Retrieve the time the mouse must sit still to generate a mouse dwell event
get int GetMouseDwellTime=2265(,)
## Start of key messages ## Start of key messages
# Move caret down one line. # Move caret down one line.
fun void LineDown=2300(,) fun void LineDown=2300(,)
@@ -887,6 +1007,9 @@ fun void LineScrollDown=2342(,)
# Scroll the document up, keeping the caret visible. # Scroll the document up, keeping the caret visible.
fun void LineScrollUp=2343(,) fun void LineScrollUp=2343(,)
# Move the caret inside current view if it's not there already
fun void MoveCaretInsideView=2401(,)
# How many characters are on a line, not including end of line characters. # How many characters are on a line, not including end of line characters.
fun int LineLength=2350(int line,) fun int LineLength=2350(int line,)
@@ -909,7 +1032,7 @@ set void SetViewEOL=2356(bool visible,)
get int GetDocPointer=2357(,) get int GetDocPointer=2357(,)
# Change the document object used. # Change the document object used.
set void SetDocPointer=2358(int pointer,) set void SetDocPointer=2358(,int pointer)
# Set which document modification events are sent to the container. # Set which document modification events are sent to the container.
set void SetModEventMask=2359(int mask,) set void SetModEventMask=2359(int mask,)
@@ -942,18 +1065,28 @@ set void SetEdgeColour=2365(colour edgeColour,)
fun void SearchAnchor=2366(,) fun void SearchAnchor=2366(,)
# Find some text starting at the search anchor. # Find some text starting at the search anchor.
# Does not ensure the selection is visible.
fun int SearchNext=2367(int flags, string text) fun int SearchNext=2367(int flags, string text)
# Find some text starting at the search anchor and moving backwards. # Find some text starting at the search anchor and moving backwards.
# Does not ensure the selection is visible.
fun int SearchPrev=2368(int flags, string text) fun int SearchPrev=2368(int flags, string text)
# Show caret within N lines of edge when it's scrolled to view # Show caret within N lines of edge when it's scrolled to view
# If CARET_SLOP not set then centre caret on screen when it's
# scrolled to view
val CARET_SLOP=0x01 val CARET_SLOP=0x01
# Center caret on screen when it's scrolled to view # Value not used
val CARET_CENTER=0x02 val CARET_CENTER=0x02
# OR this with CARET_CENTER to reposition even when visible, or # If CARET_SLOP also set then reposition whenever outside slop border
# OR this with CARET_SLOP to reposition whenever outside slop border # If CARET_SLOP not set then recentre even when visible
val CARET_STRICT=0x04 val CARET_STRICT=0x04
# If CARET_XEVEN set then both left and right margins are given equal weight
# rather than favouring left following behaviour.
val CARET_XEVEN=0x08
# If CARET_XJUMPS set then when caret reaches the margin the display jumps
# enough to leave the caret solidly within the display.
val CARET_XJUMPS=0x10
# Set the way the line the caret is on is kept visible. # Set the way the line the caret is on is kept visible.
fun void SetCaretPolicy=2369(int caretPolicy, int caretSlop) fun void SetCaretPolicy=2369(int caretPolicy, int caretSlop)
@@ -984,6 +1117,49 @@ fun void ReleaseDocument=2377(, int doc)
# Get which document modification events are sent to the container. # Get which document modification events are sent to the container.
get int GetModEventMask=2378(,) get int GetModEventMask=2378(,)
# Change internal focus flag
set void SetFocus=2380(bool focus,)
# Get internal focus flag
get bool GetFocus=2381(,)
# Change error status - 0 = OK
set void SetStatus=2382(int statusCode,)
# Get error status
get int GetStatus=2383(,)
# Set whether the mouse is captured when its button is pressed
set void SetMouseDownCaptures=2384(bool captures,)
# Get whether mouse gets captured
get bool GetMouseDownCaptures=2385(,)
val SC_CURSORNORMAL=-1
val SC_CURSORWAIT=3
# Sets the cursor to one of the SC_CURSOR* values
set void SetCursor=2386(int cursorType,)
# Get cursor type
get int GetCursor=2387(,)
# Move to the previous change in capitalistion
fun void WordPartLeft=2390(,)
# Move to the previous change in capitalistion extending selection to new caret position.
fun void WordPartLeftExtend=2391(,)
# Move to the change next in capitalistion
fun void WordPartRight=2392(,)
# Move to the next change in capitalistion extending selection to new caret position.
fun void WordPartRightExtend=2393(,)
# Constants for use with SetVisiblePolicy, similar to SetCaretPolicy
val VISIBLE_SLOP=0x01
val VISIBLE_STRICT=0x04
# Set the way the display area is determined when a particular line is to be moved to.
fun void SetVisiblePolicy=2394(int visiblePolicy, int visibleSlop)
# Delete back from the current position to the start of the line
fun void DelLineLeft=2395(,)
# Delete forwards from the current position to the end of the line
fun void DelLineRight=2396(,)
# Set the focus to this Scintilla widget. # Set the focus to this Scintilla widget.
# GTK+ Specific # GTK+ Specific
fun void GrabFocus=2400(,) fun void GrabFocus=2400(,)
@@ -1009,6 +1185,9 @@ set void SetProperty=4004(string key, string value)
# Set up the key words used by the lexer. # Set up the key words used by the lexer.
set void SetKeyWords=4005(int keywordSet, string keyWords) set void SetKeyWords=4005(int keywordSet, string keyWords)
# Set the lexing language of the document based on string name.
set void SetLexerLanguage=4006(, string language)
# Notifications # Notifications
# Type of modification and the action which caused the modification # Type of modification and the action which caused the modification
# These are defined as a bit mask to make it easy to specify which notifications are wanted. # These are defined as a bit mask to make it easy to specify which notifications are wanted.
@@ -1077,6 +1256,18 @@ val SCLEX_XCODE=13
val SCLEX_LATEX=14 val SCLEX_LATEX=14
val SCLEX_LUA=15 val SCLEX_LUA=15
val SCLEX_DIFF=16 val SCLEX_DIFF=16
val SCLEX_CONF=17
val SCLEX_PASCAL=18
val SCLEX_AVE=19
val SCLEX_ADA=20
val SCLEX_LISP=21
val SCLEX_RUBY=22
val SCLEX_EIFFEL=23
val SCLEX_EIFFELKW=24
val SCLEX_TCL=25
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
val SCLEX_AUTOMATIC=1000
# Lexical states for SCLEX_PYTHON # Lexical states for SCLEX_PYTHON
val SCE_P_DEFAULT=0 val SCE_P_DEFAULT=0
val SCE_P_COMMENTLINE=1 val SCE_P_COMMENTLINE=1
@@ -1107,6 +1298,9 @@ val SCE_C_OPERATOR=10
val SCE_C_IDENTIFIER=11 val SCE_C_IDENTIFIER=11
val SCE_C_STRINGEOL=12 val SCE_C_STRINGEOL=12
val SCE_C_VERBATIM=13 val SCE_C_VERBATIM=13
val SCE_C_REGEX=14
val SCE_C_COMMENTLINEDOC=15
val SCE_C_WORD2=16
# Lexical states for SCLEX_HTML, SCLEX_XML # Lexical states for SCLEX_HTML, SCLEX_XML
val SCE_H_DEFAULT=0 val SCE_H_DEFAULT=0
val SCE_H_TAG=1 val SCE_H_TAG=1
@@ -1130,6 +1324,10 @@ val SCE_H_CDATA=17
val SCE_H_QUESTION=18 val SCE_H_QUESTION=18
# More HTML # More HTML
val SCE_H_VALUE=19 val SCE_H_VALUE=19
# X-Code
val SCE_H_XCCOMMENT=20
# SGML
val SCE_H_SGML=21
# Embedded Javascript # Embedded Javascript
val SCE_HJ_START=40 val SCE_HJ_START=40
val SCE_HJ_DEFAULT=41 val SCE_HJ_DEFAULT=41
@@ -1143,6 +1341,7 @@ val SCE_HJ_DOUBLESTRING=48
val SCE_HJ_SINGLESTRING=49 val SCE_HJ_SINGLESTRING=49
val SCE_HJ_SYMBOLS=50 val SCE_HJ_SYMBOLS=50
val SCE_HJ_STRINGEOL=51 val SCE_HJ_STRINGEOL=51
val SCE_HJ_REGEX=52
# ASP Javascript # ASP Javascript
val SCE_HJA_START=55 val SCE_HJA_START=55
val SCE_HJA_DEFAULT=56 val SCE_HJA_DEFAULT=56
@@ -1156,6 +1355,7 @@ val SCE_HJA_DOUBLESTRING=63
val SCE_HJA_SINGLESTRING=64 val SCE_HJA_SINGLESTRING=64
val SCE_HJA_SYMBOLS=65 val SCE_HJA_SYMBOLS=65
val SCE_HJA_STRINGEOL=66 val SCE_HJA_STRINGEOL=66
val SCE_HJA_REGEX=67
# Embedded VBScript # Embedded VBScript
val SCE_HB_START=70 val SCE_HB_START=70
val SCE_HB_DEFAULT=71 val SCE_HB_DEFAULT=71
@@ -1211,10 +1411,11 @@ val SCE_HPHP_NUMBER=122
val SCE_HPHP_VARIABLE=123 val SCE_HPHP_VARIABLE=123
val SCE_HPHP_COMMENT=124 val SCE_HPHP_COMMENT=124
val SCE_HPHP_COMMENTLINE=125 val SCE_HPHP_COMMENTLINE=125
val SCE_HPHP_STRINGEOL=126 val SCE_HPHP_HSTRING_VARIABLE=126
val SCE_HPHP_OPERATOR=127
# Lexical states for SCLEX_PERL # Lexical states for SCLEX_PERL
val SCE_PL_DEFAULT=0 val SCE_PL_DEFAULT=0
val SCE_PL_HERE=1 val SCE_PL_ERROR=1
val SCE_PL_COMMENTLINE=2 val SCE_PL_COMMENTLINE=2
val SCE_PL_POD=3 val SCE_PL_POD=3
val SCE_PL_NUMBER=4 val SCE_PL_NUMBER=4
@@ -1229,12 +1430,20 @@ val SCE_PL_SCALAR=12
val SCE_PL_ARRAY=13 val SCE_PL_ARRAY=13
val SCE_PL_HASH=14 val SCE_PL_HASH=14
val SCE_PL_SYMBOLTABLE=15 val SCE_PL_SYMBOLTABLE=15
val SCE_PL_REF=16
val SCE_PL_REGEX=17 val SCE_PL_REGEX=17
val SCE_PL_REGSUBST=18 val SCE_PL_REGSUBST=18
val SCE_PL_LONGQUOTE=19 val SCE_PL_LONGQUOTE=19
val SCE_PL_BACKTICKS=20 val SCE_PL_BACKTICKS=20
val SCE_PL_DATASECTION=21 val SCE_PL_DATASECTION=21
val SCE_PL_HERE_DELIM=22
val SCE_PL_HERE_Q=23
val SCE_PL_HERE_QQ=24
val SCE_PL_HERE_QX=25
val SCE_PL_STRING_Q=26
val SCE_PL_STRING_QQ=27
val SCE_PL_STRING_QX=28
val SCE_PL_STRING_QR=29
val SCE_PL_STRING_QW=30
# Lexical states for SCLEX_LATEX # Lexical states for SCLEX_LATEX
val SCE_L_DEFAULT=0 val SCE_L_DEFAULT=0
val SCE_L_COMMAND=1 val SCE_L_COMMAND=1
@@ -1255,6 +1464,7 @@ val SCE_LUA_PREPROCESSOR=9
val SCE_LUA_OPERATOR=10 val SCE_LUA_OPERATOR=10
val SCE_LUA_IDENTIFIER=11 val SCE_LUA_IDENTIFIER=11
val SCE_LUA_STRINGEOL=12 val SCE_LUA_STRINGEOL=12
# Lexical states for SCLEX_ERRORLIST
val SCE_ERR_DEFAULT=0 val SCE_ERR_DEFAULT=0
val SCE_ERR_PYTHON=1 val SCE_ERR_PYTHON=1
val SCE_ERR_GCC=2 val SCE_ERR_GCC=2
@@ -1262,6 +1472,81 @@ val SCE_ERR_MS=3
val SCE_ERR_CMD=4 val SCE_ERR_CMD=4
val SCE_ERR_BORLAND=5 val SCE_ERR_BORLAND=5
val SCE_ERR_PERL=6 val SCE_ERR_PERL=6
val SCE_ERR_NET=7
val SCE_ERR_LUA=8
val SCE_ERR_DIFF_CHANGED=10
val SCE_ERR_DIFF_ADDITION=11
val SCE_ERR_DIFF_DELETION=12
val SCE_ERR_DIFF_MESSAGE=13
# Lexical states for SCLEX_BATCH
val SCE_BAT_DEFAULT=0
val SCE_BAT_COMMENT=1
val SCE_BAT_WORD=2
val SCE_BAT_LABEL=3
val SCE_BAT_HIDE=4
val SCE_BAT_COMMAND=5
val SCE_BAT_IDENTIFIER=6
val SCE_BAT_OPERATOR=7
# Lexical states for SCLEX_MAKEFILE
val SCE_MAKE_DEFAULT=0
val SCE_MAKE_COMMENT=1
val SCE_MAKE_PREPROCESSOR=2
val SCE_MAKE_IDENTIFIER=3
val SCE_MAKE_OPERATOR=4
val SCE_MAKE_TARGET=5
val SCE_MAKE_IDEOL=9
# Lexical states for the SCLEX_CONF (Apache Configuration Files Lexer)
val SCE_CONF_DEFAULT=0
val SCE_CONF_COMMENT=1
val SCE_CONF_NUMBER=2
val SCE_CONF_IDENTIFIER=3
val SCE_CONF_EXTENSION=4
val SCE_CONF_PARAMETER=5
val SCE_CONF_STRING=6
val SCE_CONF_OPERATOR=7
val SCE_CONF_IP=8
val SCE_CONF_DIRECTIVE=9
# Avenue
val SCE_AVE_DEFAULT=0
val SCE_AVE_COMMENT=1
val SCE_AVE_NUMBER=2
val SCE_AVE_WORD=3
val SCE_AVE_KEYWORD=4
val SCE_AVE_STATEMENT=5
val SCE_AVE_STRING=6
val SCE_AVE_ENUM=7
val SCE_AVE_STRINGEOL=8
val SCE_AVE_IDENTIFIER=9
val SCE_AVE_OPERATOR=10
# Lexical states for SCLEX_ADA
val SCE_ADA_DEFAULT=0
val SCE_ADA_COMMENT=1
val SCE_ADA_NUMBER=2
val SCE_ADA_WORD=3
val SCE_ADA_STRING=4
val SCE_ADA_CHARACTER=5
val SCE_ADA_OPERATOR=6
val SCE_ADA_IDENTIFIER=7
val SCE_ADA_STRINGEOL=8
# Lexical states for SCLEX_LISP
val SCE_LISP_DEFAULT=0
val SCE_LISP_COMMENT=1
val SCE_LISP_NUMBER=2
val SCE_LISP_KEYWORD=3
val SCE_LISP_STRING=6
val SCE_LISP_STRINGEOL=8
val SCE_LISP_IDENTIFIER=9
val SCE_LISP_OPERATOR=10
# Lexical states for SCLEX_EIFFEL and SCLEX_EIFFELKW
val SCE_EIFFEL_DEFAULT=0
val SCE_EIFFEL_COMMENTLINE=1
val SCE_EIFFEL_NUMBER=2
val SCE_EIFFEL_WORD=3
val SCE_EIFFEL_STRING=4
val SCE_EIFFEL_CHARACTER=5
val SCE_EIFFEL_OPERATOR=6
val SCE_EIFFEL_IDENTIFIER=7
val SCE_EIFFEL_STRINGEOL=8
# Events # Events
@@ -1282,9 +1567,16 @@ evt void MacroRecord=2009(int message, int wParam, int lParam)
evt void MarginClick=2010(int modifiers, int position, int margin) evt void MarginClick=2010(int modifiers, int position, int margin)
evt void NeedShown=2011(int position, int length) evt void NeedShown=2011(int position, int length)
evt void PosChanged=2012(int position) evt void PosChanged=2012(int position)
evt void Painted=2013(void)
evt void UserListSelection=2014(int listType, string text)
evt void URIDropped=2015(string text)
evt void DwellStart=2016(int position)
evt void DwellEnd=2017(int position)
cat Deprecated cat Deprecated
val SCFIND_DOWN=1
################################################ ################################################
# From WinDefs.h # From WinDefs.h

View File

@@ -1,7 +1,9 @@
// Scintilla source code edit control // Scintilla source code edit control
// ScintillaWidget.h - definition of Scintilla widget for GTK+ /** @file ScintillaWidget.h
// Only needed by GTK+ code but is harmless on other platforms. ** Definition of Scintilla widget for GTK+.
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Only needed by GTK+ code but is harmless on other platforms.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef SCINTILLAWIDGET_H #ifndef SCINTILLAWIDGET_H
@@ -9,6 +11,17 @@
#if PLAT_GTK #if PLAT_GTK
#ifndef SCINTILLA_H
#ifdef _MSC_VER
#pragma message(__FILE__ "(1) : warning : Scintilla.h should be included before ScintillaWidget.h")
#pragma message("This will be required in the next version of Scintilla")
#else
#warning Scintilla.h should be included before ScintillaWidget.h
#warning This will be required in the next version of Scintilla
#endif
#include "Scintilla.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -21,7 +34,7 @@ typedef struct _ScintillaObject ScintillaObject;
typedef struct _ScintillaClass ScintillaClass; typedef struct _ScintillaClass ScintillaClass;
struct _ScintillaObject { struct _ScintillaObject {
GtkFixed vbox; GtkContainer cont;
void *pscin; void *pscin;
}; };
@@ -35,7 +48,7 @@ struct _ScintillaClass {
guint scintilla_get_type (void); guint scintilla_get_type (void);
GtkWidget* scintilla_new (void); GtkWidget* scintilla_new (void);
void scintilla_set_id (ScintillaObject *sci,int id); void scintilla_set_id (ScintillaObject *sci,int id);
long scintilla_send_message (ScintillaObject *sci,int iMessage,int wParam,int lParam); sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,11 +1,23 @@
// Scintilla source code edit control // Scintilla source code edit control
// WinDefs.h - the subset of definitions from Windows needed by Scintilla for GTK+ /** @file WinDefs.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** The subset of definitions from Windows needed by Scintilla for GTK+.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef WINDEFS_H #ifndef WINDEFS_H
#define WINDEFS_H #define WINDEFS_H
/* Running GTK version on win32 */
#if PLAT_GTK_WIN32
#include "Windows.h"
#include "Richedit.h"
/* Name conflicts */
#undef DrawText
#undef FindText
#else
#define WORD short #define WORD short
#define WPARAM unsigned long #define WPARAM unsigned long
#define LPARAM long #define LPARAM long
@@ -180,4 +192,6 @@ struct FORMATRANGE {
//#define LOWORD(x) (x & 0xffff) //#define LOWORD(x) (x & 0xffff)
//#define HIWORD(x) (x >> 16) //#define HIWORD(x) (x >> 16)
#endif /* !_MSC_VER */
#endif #endif

View File

@@ -1,7 +1,13 @@
// WindowAccessor.h - implementation of BufferAccess and StylingAccess on a Scintilla rapid easy access to contents of a Scintilla // Scintilla source code edit control
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> /** @file WindowAccessor.h
** Implementation of BufferAccess and StylingAccess on a Scintilla
** rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
/**
*/
class WindowAccessor : public Accessor { class WindowAccessor : public Accessor {
// Private so WindowAccessor objects can not be copied // Private so WindowAccessor objects can not be copied
WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {} WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {}
@@ -36,6 +42,9 @@ public:
int GetPropertyInt(const char *key, int defaultValue=0) { int GetPropertyInt(const char *key, int defaultValue=0) {
return props.GetInt(key, defaultValue); return props.GetInt(key, defaultValue);
} }
char *GetProperties() {
return props.ToString();
}
void StartAt(unsigned int start, char chMask=31); void StartAt(unsigned int start, char chMask=31);
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };

View File

@@ -1,13 +1,17 @@
// Scintilla source code edit control // Scintilla source code edit control
// AutoComplete.cxx - defines the auto completion list box /** @file AutoComplete.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the auto completion list box.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include "Platform.h" #include "Platform.h"
#include "PropSet.h"
#include "AutoComplete.h" #include "AutoComplete.h"
AutoComplete::AutoComplete() : AutoComplete::AutoComplete() :
@@ -17,7 +21,8 @@ AutoComplete::AutoComplete() :
chooseSingle(false), chooseSingle(false),
posStart(0), posStart(0),
startLen(0), startLen(0),
cancelAtStartPos(true) { cancelAtStartPos(true),
autoHide(true) {
stopChars[0] = '\0'; stopChars[0] = '\0';
fillUpChars[0] = '\0'; fillUpChars[0] = '\0';
} }
@@ -85,7 +90,6 @@ void AutoComplete::SetList(const char *list) {
} }
delete []words; delete []words;
} }
lb.Sort();
} }
void AutoComplete::Show() { void AutoComplete::Show() {
@@ -113,9 +117,42 @@ void AutoComplete::Move(int delta) {
} }
void AutoComplete::Select(const char *word) { void AutoComplete::Select(const char *word) {
int pos = lb.Find(word); int lenWord = strlen(word);
//Platform::DebugPrintf("Autocompleting at <%s> %d\n", wordCurrent, pos); int location = -1;
if (pos != -1) const int maxItemLen=1000;
lb.Select(pos); char item[maxItemLen];
int start = 0; // lower bound of the api array block to search
int end = lb.Length() - 1; // upper bound of the api array block to search
while ((start <= end) && (location == -1)) { // Binary searching loop
int pivot = (start + end) / 2;
lb.GetValue(pivot, item, maxItemLen);
int cond;
if (ignoreCase)
cond = CompareNCaseInsensitive(word, item, lenWord);
else
cond = strncmp(word, item, lenWord);
if (!cond) {
// Find first match
while (pivot > start) {
lb.GetValue(pivot-1, item, maxItemLen);
if (ignoreCase)
cond = CompareNCaseInsensitive(word, item, lenWord);
else
cond = strncmp(word, item, lenWord);
if (0 != cond)
break;
--pivot;
}
location = pivot;
} else if (cond < 0) {
end = pivot - 1;
} else if (cond > 0) {
start = pivot + 1;
}
}
if (location == -1 && autoHide)
Cancel();
else
lb.Select(location);
} }

View File

@@ -1,56 +1,62 @@
// Scintilla source code edit control // Scintilla source code edit control
// AutoComplete.h - defines the auto completion list box /** @file AutoComplete.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Defines the auto completion list box.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef AUTOCOMPLETE_H #ifndef AUTOCOMPLETE_H
#define AUTOCOMPLETE_H #define AUTOCOMPLETE_H
/**
*/
class AutoComplete { class AutoComplete {
bool active; bool active;
char stopChars[256]; char stopChars[256];
char fillUpChars[256]; char fillUpChars[256];
char separator; char separator;
public: public:
bool ignoreCase; bool ignoreCase;
bool chooseSingle; bool chooseSingle;
ListBox lb; ListBox lb;
int posStart; int posStart;
int startLen; int startLen;
// Should autocompletion be canceled if editor's currentPos <= startPos? /// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos; bool cancelAtStartPos;
bool autoHide;
AutoComplete(); AutoComplete();
~AutoComplete(); ~AutoComplete();
// Is the auto completion list displayed? /// Is the auto completion list displayed?
bool Active(); bool Active();
// Display the auto completion list positioned to be near a character position /// Display the auto completion list positioned to be near a character position
void Start(Window &parent, int ctrlID, int position, int startLen_); void Start(Window &parent, int ctrlID, int position, int startLen_);
// The stop chars are characters which, when typed, cause the auto completion list to disappear /// The stop chars are characters which, when typed, cause the auto completion list to disappear
void SetStopChars(const char *stopChars_); void SetStopChars(const char *stopChars_);
bool IsStopChar(char ch); bool IsStopChar(char ch);
// The fillup chars are characters which, when typed, fill up the selected word /// The fillup chars are characters which, when typed, fill up the selected word
void SetFillUpChars(const char *fillUpChars_); void SetFillUpChars(const char *fillUpChars_);
bool IsFillUpChar(char ch); bool IsFillUpChar(char ch);
// The separator character is used when interpreting the list in SetList /// The separator character is used when interpreting the list in SetList
void SetSeparator(char separator_); void SetSeparator(char separator_);
char GetSeparator(); char GetSeparator();
// The list string contains a sequence of words separated by the separator character /// The list string contains a sequence of words separated by the separator character
void SetList(const char *list); void SetList(const char *list);
void Show(); void Show();
void Cancel(); void Cancel();
// Move the current list element by delta, scrolling appropriately /// Move the current list element by delta, scrolling appropriately
void Move(int delta); void Move(int delta);
// Select a list element that starts with word as the current element /// Select a list element that starts with word as the current element
void Select(const char *word); void Select(const char *word);
}; };

View File

@@ -1,10 +1,12 @@
// Scintilla source code edit control // Scintilla source code edit control
// CallTip.cxx - code for displaying call tips /** @file CallTip.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Code for displaying call tips.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "Platform.h" #include "Platform.h"
@@ -27,6 +29,7 @@ CallTip::CallTip() {
} }
CallTip::~CallTip() { CallTip::~CallTip() {
font.Release();
wCallTip.Destroy(); wCallTip.Destroy();
delete []val; delete []val;
val = 0; val = 0;
@@ -42,7 +45,7 @@ void CallTip::RefreshColourPalette(Palette &pal, bool want) {
void CallTip::PaintCT(Surface *surfaceWindow) { void CallTip::PaintCT(Surface *surfaceWindow) {
if (!val) if (!val)
return; return ;
PRectangle rcClientPos = wCallTip.GetClientPosition(); PRectangle rcClientPos = wCallTip.GetClientPosition();
PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left, PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left,
rcClientPos.bottom - rcClientPos.top); rcClientPos.bottom - rcClientPos.top);
@@ -117,7 +120,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size) { const char *faceName, int size) {
Surface surfaceMeasure; Surface surfaceMeasure;
surfaceMeasure.Init(); surfaceMeasure.Init();
int deviceHeight = (size * surfaceMeasure.LogPixelsY()) / 72; int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false); font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
if (val) if (val)
delete []val; delete []val;
@@ -146,10 +149,9 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
int lineHeight = surfaceMeasure.Height(font); int lineHeight = surfaceMeasure.Height(font);
// Extra line for border and an empty line at top and bottom // Extra line for border and an empty line at top and bottom
int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2; int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2;
return PRectangle(pt.x -5, pt.y + lineHeight + 1, pt.x + width - 5, pt.y + lineHeight + 1 + height); return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
} }
void CallTip::CallTipCancel() { void CallTip::CallTipCancel() {
inCallTipMode = false; inCallTipMode = false;
if (wCallTip.Created()) { if (wCallTip.Created()) {

View File

@@ -1,11 +1,15 @@
// Scintilla source code edit control // Scintilla source code edit control
// CallTip.h - interface to the call tip control /** @file CallTip.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Interface to the call tip control.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef CALLTIP_H #ifndef CALLTIP_H
#define CALLTIP_H #define CALLTIP_H
/**
*/
class CallTip { class CallTip {
int startHighlight; int startHighlight;
int endHighlight; int endHighlight;
@@ -14,6 +18,7 @@ class CallTip {
// Private so CallTip objects can not be copied // Private so CallTip objects can not be copied
CallTip(const CallTip &) {} CallTip(const CallTip &) {}
CallTip &operator=(const CallTip &) { return *this; } CallTip &operator=(const CallTip &) { return *this; }
public: public:
Window wCallTip; Window wCallTip;
Window wDraw; Window wDraw;
@@ -28,19 +33,19 @@ public:
CallTip(); CallTip();
~CallTip(); ~CallTip();
// Claim or accept palette entries for the colours required to paint a calltip /// Claim or accept palette entries for the colours required to paint a calltip.
void RefreshColourPalette(Palette &pal, bool want); void RefreshColourPalette(Palette &pal, bool want);
void PaintCT(Surface *surfaceWindow); void PaintCT(Surface *surfaceWindow);
// Setup the calltip and return a rectangle of the area required /// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(int pos, Point pt, const char *defn, PRectangle CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size); const char *faceName, int size);
void CallTipCancel(); void CallTipCancel();
// Set a range of characters to be displayed in a highlight style. /// Set a range of characters to be displayed in a highlight style.
// Commonly used to highlight the current parameter. /// Commonly used to highlight the current parameter.
void SetHighlight(int start, int end); void SetHighlight(int start, int end);
}; };

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// CellBuffer.cxx - manages a buffer of cells /** @file CellBuffer.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages a buffer of cells.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdio.h> #include <stdio.h>
@@ -416,22 +418,19 @@ UndoHistory::~UndoHistory() {
} }
void UndoHistory::EnsureUndoRoom() { void UndoHistory::EnsureUndoRoom() {
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction); // Have to test that there is room for 2 more actions in the array
if (currentAction >= 2) { // as two actions may be created by the calling function
// Have to test that there is room for 2 more actions in the array if (currentAction >= (lenActions - 2)) {
// as two actions may be created by this function // Run out of undo nodes so extend the array
if (currentAction >= (lenActions - 2)) { int lenActionsNew = lenActions * 2;
// Run out of undo nodes so extend the array Action *actionsNew = new Action[lenActionsNew];
int lenActionsNew = lenActions * 2; if (!actionsNew)
Action *actionsNew = new Action[lenActionsNew]; return ;
if (!actionsNew) for (int act = 0; act <= currentAction; act++)
return ; actionsNew[act].Grab(&actions[act]);
for (int act = 0; act <= currentAction; act++) delete []actions;
actionsNew[act].Grab(&actions[act]); lenActions = lenActionsNew;
delete []actions; actions = actionsNew;
lenActions = lenActionsNew;
actions = actionsNew;
}
} }
} }
@@ -450,14 +449,27 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng
currentAction++; currentAction++;
} else if (currentAction == savePoint) { } else if (currentAction == savePoint) {
currentAction++; currentAction++;
} else if ((at == removeAction) &&
((position + lengthData * 2) != actPrevious.position)) {
// Removals must be at same position to coalesce
currentAction++;
} else if ((at == insertAction) && } else if ((at == insertAction) &&
(position != (actPrevious.position + actPrevious.lenData*2))) { (position != (actPrevious.position + actPrevious.lenData*2))) {
// Insertions must be immediately after to coalesce // Insertions must be immediately after to coalesce
currentAction++; currentAction++;
} else if (!actions[currentAction].mayCoalesce) {
// Not allowed to coalesce if this set
currentAction++;
} else if (at == removeAction) {
if ((lengthData == 1) || (lengthData == 2)){
if ((position + lengthData * 2) == actPrevious.position) {
; // Backspace -> OK
} else if (position == actPrevious.position) {
; // Delete -> OK
} else {
// Removals must be at same position to coalesce
currentAction++;
}
} else {
// Removals must be of one character to coalesce
currentAction++;
}
} else { } else {
//Platform::DebugPrintf("action coalesced\n"); //Platform::DebugPrintf("action coalesced\n");
} }
@@ -582,6 +594,7 @@ CellBuffer::CellBuffer(int initialLength) {
part2body = body + gaplen; part2body = body + gaplen;
readOnly = false; readOnly = false;
collectingUndo = true; collectingUndo = true;
growSize = 4000;
} }
CellBuffer::~CellBuffer() { CellBuffer::~CellBuffer() {
@@ -612,7 +625,9 @@ void CellBuffer::RoomFor(int insertionLength) {
if (gaplen <= insertionLength) { if (gaplen <= insertionLength) {
//Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength); //Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
GapTo(length); GapTo(length);
int newSize = size + insertionLength + 4000; if (growSize * 6 < size)
growSize *= 2;
int newSize = size + insertionLength + growSize;
//Platform::DebugPrintf("moved gap %d\n", newSize); //Platform::DebugPrintf("moved gap %d\n", newSize);
char *newBody = new char[newSize]; char *newBody = new char[newSize];
memcpy(newBody, body, size); memcpy(newBody, body, size);
@@ -733,6 +748,8 @@ bool CellBuffer::SetStyleAt(int position, char style, char mask) {
bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mask) { bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mask) {
int bytePos = position * 2 + 1; int bytePos = position * 2 + 1;
bool changed = false; bool changed = false;
PLATFORM_ASSERT(lengthStyle == 0 ||
(lengthStyle > 0 && lengthStyle + position < length));
while (lengthStyle--) { while (lengthStyle--) {
char curVal = ByteAt(bytePos); char curVal = ByteAt(bytePos);
if ((curVal & mask) != style) { if ((curVal & mask) != style) {
@@ -779,7 +796,7 @@ int CellBuffer::LineStart(int line) {
if (line < 0) if (line < 0)
return 0; return 0;
else if (line > lv.lines) else if (line > lv.lines)
return length; return Length();
else else
return lv.linesData[line].startPosition; return lv.linesData[line].startPosition;
} }
@@ -930,7 +947,6 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
ignoreNL = true; // First \n is not real deletion ignoreNL = true; // First \n is not real deletion
} }
char ch = chNext; char ch = chNext;
for (int i = 0; i < deleteLength; i += 2) { for (int i = 0; i < deleteLength; i += 2) {
chNext = ' '; chNext = ' ';
@@ -948,7 +964,6 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
ignoreNL = false; // Further \n are not real deletions ignoreNL = false; // Further \n are not real deletions
} }
ch = chNext; ch = chNext;
} }
// May have to fix up end if last deletion causes cr to be next to lf // May have to fix up end if last deletion causes cr to be next to lf

View File

@@ -1,28 +1,35 @@
// Scintilla source code edit control // Scintilla source code edit control
// CellBuffer.h - manages the text of the document /** @file CellBuffer.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages the text of the document.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef CELLBUFFER_H #ifndef CELLBUFFER_H
#define CELLBUFFER_H #define CELLBUFFER_H
// This holds the marker identifier and the marker type to display. /**
// MarkerHandleNumbers are members of lists. * This holds the marker identifier and the marker type to display.
* MarkerHandleNumbers are members of lists.
*/
struct MarkerHandleNumber { struct MarkerHandleNumber {
int handle; int handle;
int number; int number;
MarkerHandleNumber *next; MarkerHandleNumber *next;
}; };
// A marker handle set contains any number of MarkerHandleNumbers /**
* A marker handle set contains any number of MarkerHandleNumbers.
*/
class MarkerHandleSet { class MarkerHandleSet {
MarkerHandleNumber *root; MarkerHandleNumber *root;
public: public:
MarkerHandleSet(); MarkerHandleSet();
~MarkerHandleSet(); ~MarkerHandleSet();
int Length(); int Length();
int NumberFromHandle(int handle); int NumberFromHandle(int handle);
int MarkValue(); // Bit set of marker numbers int MarkValue(); ///< Bit set of marker numbers.
bool Contains(int handle); bool Contains(int handle);
bool InsertHandle(int handle, int markerNum); bool InsertHandle(int handle, int markerNum);
void RemoveHandle(int handle); void RemoveHandle(int handle);
@@ -30,8 +37,10 @@ public:
void CombineWith(MarkerHandleSet *other); void CombineWith(MarkerHandleSet *other);
}; };
// Each line stores the starting position of the first character of the line in the cell buffer /**
// and potentially a marker handle set. Often a line will not have any attached markers. * Each line stores the starting position of the first character of the line in the cell buffer
* and potentially a marker handle set. Often a line will not have any attached markers.
*/
struct LineData { struct LineData {
int startPosition; int startPosition;
MarkerHandleSet *handleSet; MarkerHandleSet *handleSet;
@@ -39,7 +48,9 @@ struct LineData {
} }
}; };
// The line vector contains information about each of the lines in a cell buffer. /**
* The line vector contains information about each of the lines in a cell buffer.
*/
class LineVector { class LineVector {
public: public:
enum { growSize = 4000 }; enum { growSize = 4000 };
@@ -48,22 +59,22 @@ public:
int size; int size;
int *levels; int *levels;
int sizeLevels; int sizeLevels;
// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
int handleCurrent; int handleCurrent;
LineVector(); LineVector();
~LineVector(); ~LineVector();
void Init(); void Init();
void Expand(int sizeNew); void Expand(int sizeNew);
void ExpandLevels(int sizeNew=-1); void ExpandLevels(int sizeNew=-1);
void ClearLevels(); void ClearLevels();
void InsertValue(int pos, int value); void InsertValue(int pos, int value);
void SetValue(int pos, int value); void SetValue(int pos, int value);
void Remove(int pos); void Remove(int pos);
int LineFromPosition(int pos); int LineFromPosition(int pos);
int AddMark(int line, int marker); int AddMark(int line, int marker);
void MergeMarkers(int pos); void MergeMarkers(int pos);
void DeleteMark(int line, int markerNum); void DeleteMark(int line, int markerNum);
@@ -71,9 +82,11 @@ public:
int LineFromHandle(int markerHandle); int LineFromHandle(int markerHandle);
}; };
// Actions are used to store all the information required to perform one undo/redo step.
enum actionType { insertAction, removeAction, startAction }; enum actionType { insertAction, removeAction, startAction };
/**
* Actions are used to store all the information required to perform one undo/redo step.
*/
class Action { class Action {
public: public:
actionType at; actionType at;
@@ -89,6 +102,9 @@ public:
void Grab(Action *source); void Grab(Action *source);
}; };
/**
*
*/
class UndoHistory { class UndoHistory {
Action *actions; Action *actions;
int lenActions; int lenActions;
@@ -98,25 +114,25 @@ class UndoHistory {
int savePoint; int savePoint;
void EnsureUndoRoom(); void EnsureUndoRoom();
public: public:
UndoHistory(); UndoHistory();
~UndoHistory(); ~UndoHistory();
void AppendAction(actionType at, int position, char *data, int length); void AppendAction(actionType at, int position, char *data, int length);
void BeginUndoAction(); void BeginUndoAction();
void EndUndoAction(); void EndUndoAction();
void DropUndoSequence(); void DropUndoSequence();
void DeleteUndoHistory(); void DeleteUndoHistory();
// The save point is a marker in the undo stack where the container has stated that /// The save point is a marker in the undo stack where the container has stated that
// the buffer was saved. Undo and redo can move over the save point. /// the buffer was saved. Undo and redo can move over the save point.
void SetSavePoint(); void SetSavePoint();
bool IsSavePoint() const; bool IsSavePoint() const;
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// called that many times. Similarly for redo. /// called that many times. Similarly for redo.
bool CanUndo() const; bool CanUndo() const;
int StartUndo(); int StartUndo();
const Action &GetUndoStep() const; const Action &GetUndoStep() const;
@@ -127,9 +143,11 @@ public:
void CompletedRedoStep(); void CompletedRedoStep();
}; };
// Holder for an expandable array of characters that supports undo and line markers /**
// Based on article "Data Structures in a Bit-Mapped Text Editor" * Holder for an expandable array of characters that supports undo and line markers.
// by Wilfred J. Hansen, Byte January 1987, page 183 * Based on article "Data Structures in a Bit-Mapped Text Editor"
* by Wilfred J. Hansen, Byte January 1987, page 183.
*/
class CellBuffer { class CellBuffer {
private: private:
char *body; char *body;
@@ -139,6 +157,7 @@ private:
int gaplen; int gaplen;
char *part2body; char *part2body;
bool readOnly; bool readOnly;
int growSize;
bool collectingUndo; bool collectingUndo;
UndoHistory uh; UndoHistory uh;
@@ -157,12 +176,12 @@ public:
CellBuffer(int initialLength = 4000); CellBuffer(int initialLength = 4000);
~CellBuffer(); ~CellBuffer();
// Retrieving positions outside the range of the buffer works and returns 0 /// Retrieving positions outside the range of the buffer works and returns 0
char CharAt(int position); char CharAt(int position);
void GetCharRange(char *buffer, int position, int lengthRetrieve); void GetCharRange(char *buffer, int position, int lengthRetrieve);
char StyleAt(int position); char StyleAt(int position);
int ByteLength(); int ByteLength();
int Length(); int Length();
int Lines(); int Lines();
@@ -170,23 +189,23 @@ public:
int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
const char *InsertString(int position, char *s, int insertLength); const char *InsertString(int position, char *s, int insertLength);
void InsertCharStyle(int position, char ch, char style); void InsertCharStyle(int position, char ch, char style);
// Setting styles for positions outside the range of the buffer is safe and has no effect. /// Setting styles for positions outside the range of the buffer is safe and has no effect.
// True is returned if the style of a character changed. /// @return true if the style of a character is changed.
bool SetStyleAt(int position, char style, char mask='\377'); bool SetStyleAt(int position, char style, char mask='\377');
bool SetStyleFor(int position, int length, char style, char mask); bool SetStyleFor(int position, int length, char style, char mask);
const char *DeleteChars(int position, int deleteLength); const char *DeleteChars(int position, int deleteLength);
bool IsReadOnly(); bool IsReadOnly();
void SetReadOnly(bool set); void SetReadOnly(bool set);
// The save point is a marker in the undo stack where the container has stated that /// The save point is a marker in the undo stack where the container has stated that
// the buffer was saved. Undo and redo can move over the save point. /// the buffer was saved. Undo and redo can move over the save point.
void SetSavePoint(); void SetSavePoint();
bool IsSavePoint(); bool IsSavePoint();
// Line marker functions /// Line marker functions
int AddMark(int line, int markerNum); int AddMark(int line, int markerNum);
void DeleteMark(int line, int markerNum); void DeleteMark(int line, int markerNum);
void DeleteMarkFromHandle(int markerHandle); void DeleteMarkFromHandle(int markerHandle);
@@ -194,7 +213,7 @@ public:
void DeleteAllMarks(int markerNum); void DeleteAllMarks(int markerNum);
int LineFromHandle(int markerHandle); int LineFromHandle(int markerHandle);
// Without undo /// Actions without undo
void BasicInsertString(int position, char *s, int insertLength); void BasicInsertString(int position, char *s, int insertLength);
void BasicDeleteChars(int position, int deleteLength); void BasicDeleteChars(int position, int deleteLength);
@@ -203,9 +222,9 @@ public:
void BeginUndoAction(); void BeginUndoAction();
void EndUndoAction(); void EndUndoAction();
void DeleteUndoHistory(); void DeleteUndoHistory();
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// called that many times. Similarly for redo. /// called that many times. Similarly for redo.
bool CanUndo(); bool CanUndo();
int StartUndo(); int StartUndo();
const Action &GetUndoStep() const; const Action &GetUndoStep() const;
@@ -214,14 +233,14 @@ public:
int StartRedo(); int StartRedo();
const Action &GetRedoStep() const; const Action &GetRedoStep() const;
void PerformRedoStep(); void PerformRedoStep();
int SetLineState(int line, int state); int SetLineState(int line, int state);
int GetLineState(int line); int GetLineState(int line);
int GetMaxLineState(); int GetMaxLineState();
int SetLevel(int line, int level); int SetLevel(int line, int level);
int GetLevel(int line); int GetLevel(int line);
void ClearLevels(); void ClearLevels();
}; };
#define CELL_SIZE 2 #define CELL_SIZE 2

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// ContractionState.cxx - manages visibility of lines for folding /** @file ContractionState.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages visibility of lines for folding.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include "Platform.h" #include "Platform.h"

View File

@@ -1,15 +1,19 @@
// Scintilla source code edit control // Scintilla source code edit control
// ContractionState.h - manages visibility of lines for folding /** @file ContractionState.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Manages visibility of lines for folding.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef CONTRACTIONSTATE_H #ifndef CONTRACTIONSTATE_H
#define CONTRACTIONSTATE_H #define CONTRACTIONSTATE_H
/**
*/
class OneLine { class OneLine {
public: public:
int displayLine; // position within set of visible lines int displayLine; ///< Position within set of visible lines
int docLine; // inverse of displayLine int docLine; ///< Inverse of @a displayLine
bool visible; bool visible;
bool expanded; bool expanded;
@@ -17,6 +21,8 @@ public:
virtual ~OneLine() {} virtual ~OneLine() {}
}; };
/**
*/
class ContractionState { class ContractionState {
void Grow(int sizeNew); void Grow(int sizeNew);
enum { growSize = 4000 }; enum { growSize = 4000 };
@@ -26,6 +32,7 @@ class ContractionState {
int size; int size;
mutable bool valid; mutable bool valid;
void MakeValid() const; void MakeValid() const;
public: public:
ContractionState(); ContractionState();
virtual ~ContractionState(); virtual ~ContractionState();

View File

@@ -1,6 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
// Document.cxx - text document that handles notifications, DBCS, styling, words and end of line /** @file Document.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Text document that handles notifications, DBCS, styling, words and end of line.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -14,6 +16,12 @@
#include "SVector.h" #include "SVector.h"
#include "CellBuffer.h" #include "CellBuffer.h"
#include "Document.h" #include "Document.h"
#include "RESearch.h"
// This is ASCII specific but is safe with chars >= 0x80
inline bool isspacechar(unsigned char ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
Document::Document() { Document::Document() {
refCount = 0; refCount = 0;
@@ -25,7 +33,6 @@ Document::Document() {
dbcsCodePage = 0; dbcsCodePage = 0;
stylingBits = 5; stylingBits = 5;
stylingBitsMask = 0x1F; stylingBitsMask = 0x1F;
stylingPos = 0;
stylingMask = 0; stylingMask = 0;
for (int ch = 0; ch < 256; ch++) { for (int ch = 0; ch < 256; ch++) {
wordchars[ch] = isalnum(ch) || ch == '_'; wordchars[ch] = isalnum(ch) || ch == '_';
@@ -36,8 +43,14 @@ Document::Document() {
tabInChars = 8; tabInChars = 8;
indentInChars = 0; indentInChars = 0;
useTabs = true; useTabs = true;
tabIndents = true;
backspaceUnindents = false;
watchers = 0; watchers = 0;
lenWatchers = 0; lenWatchers = 0;
matchesValid = false;
pre = 0;
substituted = 0;
} }
Document::~Document() { Document::~Document() {
@@ -47,6 +60,10 @@ Document::~Document() {
delete []watchers; delete []watchers;
watchers = 0; watchers = 0;
lenWatchers = 0; lenWatchers = 0;
delete pre;
pre = 0;
delete []substituted;
substituted = 0;
} }
// Increase reference count and return its previous value. // Increase reference count and return its previous value.
@@ -68,27 +85,27 @@ void Document::SetSavePoint() {
NotifySavePoint(true); NotifySavePoint(true);
} }
int Document::AddMark(int line, int markerNum) { int Document::AddMark(int line, int markerNum) {
int prev = cb.AddMark(line, markerNum); int prev = cb.AddMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
return prev; return prev;
} }
void Document::DeleteMark(int line, int markerNum) { void Document::DeleteMark(int line, int markerNum) {
cb.DeleteMark(line, markerNum); cb.DeleteMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
} }
void Document::DeleteMarkFromHandle(int markerHandle) { void Document::DeleteMarkFromHandle(int markerHandle) {
cb.DeleteMarkFromHandle(markerHandle); cb.DeleteMarkFromHandle(markerHandle);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
} }
void Document::DeleteAllMarks(int markerNum) { void Document::DeleteAllMarks(int markerNum) {
cb.DeleteAllMarks(markerNum); cb.DeleteAllMarks(markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh); NotifyModified(mh);
} }
@@ -131,10 +148,11 @@ int Document::VCHomePosition(int position) {
return startText; return startText;
} }
int Document::SetLevel(int line, int level) { int Document::SetLevel(int line, int level) {
int prev = cb.SetLevel(line, level); int prev = cb.SetLevel(line, level);
if (prev != level) { if (prev != level) {
DocModification mh(SC_MOD_CHANGEFOLD, LineStart(line), 0, 0, 0); DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
LineStart(line), 0, 0, 0);
mh.line = line; mh.line = line;
mh.foldLevelNow = level; mh.foldLevelNow = level;
mh.foldLevelPrev = prev; mh.foldLevelPrev = prev;
@@ -146,7 +164,7 @@ int Document::SetLevel(int line, int level) {
static bool IsSubordinate(int levelStart, int levelTry) { static bool IsSubordinate(int levelStart, int levelTry) {
if (levelTry & SC_FOLDLEVELWHITEFLAG) if (levelTry & SC_FOLDLEVELWHITEFLAG)
return true; return true;
else else
return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK); return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK);
} }
@@ -155,16 +173,16 @@ int Document::GetLastChild(int lineParent, int level) {
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK; level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
int maxLine = LinesTotal(); int maxLine = LinesTotal();
int lineMaxSubord = lineParent; int lineMaxSubord = lineParent;
while (lineMaxSubord < maxLine-1) { while (lineMaxSubord < maxLine - 1) {
EnsureStyledTo(LineStart(lineMaxSubord+2)); EnsureStyledTo(LineStart(lineMaxSubord + 2));
if (!IsSubordinate(level, GetLevel(lineMaxSubord+1))) if (!IsSubordinate(level, GetLevel(lineMaxSubord + 1)))
break; break;
lineMaxSubord++; lineMaxSubord++;
} }
if (lineMaxSubord > lineParent) { if (lineMaxSubord > lineParent) {
if (level > (GetLevel(lineMaxSubord+1) & SC_FOLDLEVELNUMBERMASK)) { if (level > (GetLevel(lineMaxSubord + 1) & SC_FOLDLEVELNUMBERMASK)) {
// Have chewed up some whitespace that belongs to a parent so seek back // Have chewed up some whitespace that belongs to a parent so seek back
if ((lineMaxSubord > lineParent) && (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG)) { if (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG) {
lineMaxSubord--; lineMaxSubord--;
} }
} }
@@ -174,15 +192,15 @@ int Document::GetLastChild(int lineParent, int level) {
int Document::GetFoldParent(int line) { int Document::GetFoldParent(int line) {
int level = GetLevel(line); int level = GetLevel(line);
int lineLook = line-1; int lineLook = line - 1;
while ((lineLook > 0) && ( while ((lineLook > 0) && (
(!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) || (!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) ||
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level)) ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level))
) { ) {
lineLook--; lineLook--;
} }
if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) && if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) &&
((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) { ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) {
return lineLook; return lineLook;
} else { } else {
return -1; return -1;
@@ -241,12 +259,12 @@ int Document::LenChar(int pos) {
if (ch < 0x80) if (ch < 0x80)
return 1; return 1;
int len = 2; int len = 2;
if (ch >= (0x80+0x40+0x20)) if (ch >= (0x80 + 0x40 + 0x20))
len = 3; len = 3;
int lengthDoc = Length(); int lengthDoc = Length();
if ((pos + len) > lengthDoc) if ((pos + len) > lengthDoc)
return lengthDoc-pos; return lengthDoc -pos;
else else
return len; return len;
} else if (IsDBCS(pos)) { } else if (IsDBCS(pos)) {
return 2; return 2;
@@ -292,7 +310,7 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
// ch is a trail byte // ch is a trail byte
if (moveDir > 0) if (moveDir > 0)
pos++; pos++;
else else
pos--; pos--;
ch = static_cast<unsigned char>(cb.CharAt(pos)); ch = static_cast<unsigned char>(cb.CharAt(pos));
} }
@@ -314,6 +332,7 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
//Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-"); //Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
} }
if (atLeadByte) { if (atLeadByte) {
// Position is between a lead byte and a trail byte // Position is between a lead byte and a trail byte
if (moveDir > 0) if (moveDir > 0)
@@ -338,9 +357,9 @@ void Document::ModifiedAt(int pos) {
// Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number // Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
void Document::DeleteChars(int pos, int len) { void Document::DeleteChars(int pos, int len) {
if ((pos + len) > Length()) if ((pos + len) > Length())
return; return ;
if (cb.IsReadOnly() && enteredReadOnlyCount==0) { if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
enteredReadOnlyCount++; enteredReadOnlyCount++;
NotifyModifyAttempt(); NotifyModifyAttempt();
enteredReadOnlyCount--; enteredReadOnlyCount--;
@@ -349,28 +368,31 @@ void Document::DeleteChars(int pos, int len) {
enteredCount++; enteredCount++;
if (!cb.IsReadOnly()) { if (!cb.IsReadOnly()) {
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_BEFOREDELETE | SC_PERFORMED_USER, SC_MOD_BEFOREDELETE | SC_PERFORMED_USER,
pos, len, pos, len,
0, 0)); 0, 0));
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
const char *text = cb.DeleteChars(pos*2, len * 2); const char *text = cb.DeleteChars(pos * 2, len * 2);
if (startSavePoint && cb.IsCollectingUndo()) if (startSavePoint && cb.IsCollectingUndo())
NotifySavePoint(!startSavePoint); NotifySavePoint(!startSavePoint);
ModifiedAt(pos); if ((pos < Length()) || (pos == 0))
ModifiedAt(pos);
else
ModifiedAt(pos-1);
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_DELETETEXT | SC_PERFORMED_USER, SC_MOD_DELETETEXT | SC_PERFORMED_USER,
pos, len, pos, len,
LinesTotal() - prevLinesTotal, text)); LinesTotal() - prevLinesTotal, text));
} }
enteredCount--; enteredCount--;
} }
} }
void Document::InsertStyledString(int position, char *s, int insertLength) { void Document::InsertStyledString(int position, char *s, int insertLength) {
if (cb.IsReadOnly() && enteredReadOnlyCount==0) { if (cb.IsReadOnly() && enteredReadOnlyCount == 0) {
enteredReadOnlyCount++; enteredReadOnlyCount++;
NotifyModifyAttempt(); NotifyModifyAttempt();
enteredReadOnlyCount--; enteredReadOnlyCount--;
@@ -379,10 +401,10 @@ void Document::InsertStyledString(int position, char *s, int insertLength) {
enteredCount++; enteredCount++;
if (!cb.IsReadOnly()) { if (!cb.IsReadOnly()) {
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER, SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
position / 2, insertLength / 2, position / 2, insertLength / 2,
0, 0)); 0, 0));
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
const char *text = cb.InsertString(position, s, insertLength); const char *text = cb.InsertString(position, s, insertLength);
@@ -390,10 +412,10 @@ void Document::InsertStyledString(int position, char *s, int insertLength) {
NotifySavePoint(!startSavePoint); NotifySavePoint(!startSavePoint);
ModifiedAt(position / 2); ModifiedAt(position / 2);
NotifyModified( NotifyModified(
DocModification( DocModification(
SC_MOD_INSERTTEXT | SC_PERFORMED_USER, SC_MOD_INSERTTEXT | SC_PERFORMED_USER,
position / 2, insertLength / 2, position / 2, insertLength / 2,
LinesTotal() - prevLinesTotal, text)); LinesTotal() - prevLinesTotal, text));
} }
enteredCount--; enteredCount--;
} }
@@ -406,21 +428,21 @@ int Document::Undo() {
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
int steps = cb.StartUndo(); int steps = cb.StartUndo();
//Platform::DebugPrintf("Steps=%d\n", steps); //Platform::DebugPrintf("Steps=%d\n", steps);
for (int step=0; step<steps; step++) { for (int step = 0; step < steps; step++) {
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
const Action &action = cb.GetUndoStep(); const Action &action = cb.GetUndoStep();
if (action.at == removeAction) { if (action.at == removeAction) {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action)); SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action));
} else { } else {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action));
} }
cb.PerformUndoStep(); cb.PerformUndoStep();
int cellPosition = action.position / 2; int cellPosition = action.position / 2;
ModifiedAt(cellPosition); ModifiedAt(cellPosition);
newPos = cellPosition; newPos = cellPosition;
int modFlags = SC_PERFORMED_UNDO; int modFlags = SC_PERFORMED_UNDO;
// With undo, an insertion action becomes a deletion notification // With undo, an insertion action becomes a deletion notification
if (action.at == removeAction) { if (action.at == removeAction) {
@@ -429,12 +451,12 @@ int Document::Undo() {
} else { } else {
modFlags |= SC_MOD_DELETETEXT; modFlags |= SC_MOD_DELETETEXT;
} }
if (step == steps-1) if (step == steps - 1)
modFlags |= SC_LASTSTEPINUNDOREDO; modFlags |= SC_LASTSTEPINUNDOREDO;
NotifyModified(DocModification(modFlags, cellPosition, action.lenData, NotifyModified(DocModification(modFlags, cellPosition, action.lenData,
LinesTotal() - prevLinesTotal, action.data)); LinesTotal() - prevLinesTotal, action.data));
} }
bool endSavePoint = cb.IsSavePoint(); bool endSavePoint = cb.IsSavePoint();
if (startSavePoint != endSavePoint) if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint); NotifySavePoint(endSavePoint);
@@ -449,20 +471,20 @@ int Document::Redo() {
enteredCount++; enteredCount++;
bool startSavePoint = cb.IsSavePoint(); bool startSavePoint = cb.IsSavePoint();
int steps = cb.StartRedo(); int steps = cb.StartRedo();
for (int step=0; step<steps; step++) { for (int step = 0; step < steps; step++) {
int prevLinesTotal = LinesTotal(); int prevLinesTotal = LinesTotal();
const Action &action = cb.GetRedoStep(); const Action &action = cb.GetRedoStep();
if (action.at == insertAction) { if (action.at == insertAction) {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action));
} else { } else {
NotifyModified(DocModification( NotifyModified(DocModification(
SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action));
} }
cb.PerformRedoStep(); cb.PerformRedoStep();
ModifiedAt(action.position / 2); ModifiedAt(action.position / 2);
newPos = action.position / 2; newPos = action.position / 2;
int modFlags = SC_PERFORMED_REDO; int modFlags = SC_PERFORMED_REDO;
if (action.at == insertAction) { if (action.at == insertAction) {
newPos += action.lenData; newPos += action.lenData;
@@ -470,13 +492,13 @@ int Document::Redo() {
} else { } else {
modFlags |= SC_MOD_DELETETEXT; modFlags |= SC_MOD_DELETETEXT;
} }
if (step == steps-1) if (step == steps - 1)
modFlags |= SC_LASTSTEPINUNDOREDO; modFlags |= SC_LASTSTEPINUNDOREDO;
NotifyModified( NotifyModified(
DocModification(modFlags, action.position / 2, action.lenData, DocModification(modFlags, action.position / 2, action.lenData,
LinesTotal() - prevLinesTotal, action.data)); LinesTotal() - prevLinesTotal, action.data));
} }
bool endSavePoint = cb.IsSavePoint(); bool endSavePoint = cb.IsSavePoint();
if (startSavePoint != endSavePoint) if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint); NotifySavePoint(endSavePoint);
@@ -526,7 +548,7 @@ int Document::DelCharBack(int pos) {
DeleteChars(pos - 2, 2); DeleteChars(pos - 2, 2);
return pos - 2; return pos - 2;
} else if (SC_CP_UTF8 == dbcsCodePage) { } else if (SC_CP_UTF8 == dbcsCodePage) {
int startChar = MovePositionOutsideChar(pos-1, -1, false); int startChar = MovePositionOutsideChar(pos - 1, -1, false);
DeleteChars(startChar, pos - startChar); DeleteChars(startChar, pos - startChar);
return startChar; return startChar;
} else if (IsDBCS(pos - 1)) { } else if (IsDBCS(pos - 1)) {
@@ -568,13 +590,13 @@ int Document::GetLineIndentation(int line) {
if ((line >= 0) && (line < LinesTotal())) { if ((line >= 0) && (line < LinesTotal())) {
int lineStart = LineStart(line); int lineStart = LineStart(line);
int length = Length(); int length = Length();
for (int i=lineStart;i<length;i++) { for (int i = lineStart;i < length;i++) {
char ch = cb.CharAt(i); char ch = cb.CharAt(i);
if (ch == ' ') if (ch == ' ')
indent++; indent++;
else if (ch == '\t') else if (ch == '\t')
indent = NextTab(indent, tabInChars); indent = NextTab(indent, tabInChars);
else else
return indent; return indent;
} }
} }
@@ -596,8 +618,8 @@ void Document::SetLineIndentation(int line, int indent) {
} }
int Document::GetLineIndentPosition(int line) { int Document::GetLineIndentPosition(int line) {
if (line < 0) if (line < 0)
return 0; return 0;
int pos = LineStart(line); int pos = LineStart(line);
int length = Length(); int length = Length();
while ((pos < length) && isindentchar(cb.CharAt(pos))) { while ((pos < length) && isindentchar(cb.CharAt(pos))) {
@@ -610,7 +632,7 @@ int Document::GetColumn(int pos) {
int column = 0; int column = 0;
int line = LineFromPosition(pos); int line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) { if ((line >= 0) && (line < LinesTotal())) {
for (int i=LineStart(line);i<pos;i++) { for (int i = LineStart(line);i < pos;i++) {
char ch = cb.CharAt(i); char ch = cb.CharAt(i);
if (ch == '\t') if (ch == '\t')
column = NextTab(column, tabInChars); column = NextTab(column, tabInChars);
@@ -640,7 +662,7 @@ void Document::ConvertLineEnds(int eolModeSet) {
BeginUndoAction(); BeginUndoAction();
for (int pos = 0; pos < Length(); pos++) { for (int pos = 0; pos < Length(); pos++) {
if (cb.CharAt(pos) == '\r') { if (cb.CharAt(pos) == '\r') {
if (cb.CharAt(pos+1) == '\n') { if (cb.CharAt(pos + 1) == '\n') {
if (eolModeSet != SC_EOL_CRLF) { if (eolModeSet != SC_EOL_CRLF) {
DeleteChars(pos, 2); DeleteChars(pos, 2);
if (eolModeSet == SC_EOL_CR) if (eolModeSet == SC_EOL_CR)
@@ -677,7 +699,7 @@ void Document::ConvertLineEnds(int eolModeSet) {
} }
bool Document::IsWordChar(unsigned char ch) { bool Document::IsWordChar(unsigned char ch) {
if ((SC_CP_UTF8 == dbcsCodePage) && (ch >0x80)) if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80))
return true; return true;
return wordchars[ch]; return wordchars[ch];
} }
@@ -697,19 +719,19 @@ int Document::NextWordStart(int pos, int delta) {
if (delta < 0) { if (delta < 0) {
while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t')) while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))
pos--; pos--;
if (isspace(cb.CharAt(pos - 1))) { // Back up to previous line if (isspacechar(cb.CharAt(pos - 1))) { // Back up to previous line
while (pos > 0 && isspace(cb.CharAt(pos - 1))) while (pos > 0 && isspacechar(cb.CharAt(pos - 1)))
pos--; pos--;
} else { } else {
bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1)); bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1));
while (pos > 0 && !isspace(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1)))) while (pos > 0 && !isspacechar(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1))))
pos--; pos--;
} }
} else { } else {
bool startAtWordChar = IsWordChar(cb.CharAt(pos)); bool startAtWordChar = IsWordChar(cb.CharAt(pos));
while (pos < (Length()) && isspace(cb.CharAt(pos))) while (pos < (Length()) && isspacechar(cb.CharAt(pos)))
pos++; pos++;
while (pos < (Length()) && !isspace(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos)))) while (pos < (Length()) && !isspacechar(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos))))
pos++; pos++;
while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t')) while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))
pos++; pos++;
@@ -717,6 +739,10 @@ int Document::NextWordStart(int pos, int delta) {
return pos; return pos;
} }
/**
* Check that the character before the given position
* is not a word character.
*/
bool Document::IsWordStartAt(int pos) { bool Document::IsWordStartAt(int pos) {
if (pos > 0) { if (pos > 0) {
return !IsWordChar(CharAt(pos - 1)); return !IsWordChar(CharAt(pos - 1));
@@ -724,6 +750,10 @@ bool Document::IsWordStartAt(int pos) {
return true; return true;
} }
/**
* Check that the character after the given position
* is not a word character.
*/
bool Document::IsWordEndAt(int pos) { bool Document::IsWordEndAt(int pos) {
if (pos < Length() - 1) { if (pos < Length() - 1) {
return !IsWordChar(CharAt(pos)); return !IsWordChar(CharAt(pos));
@@ -731,74 +761,233 @@ bool Document::IsWordEndAt(int pos) {
return true; return true;
} }
/**
* Check that the given range is delimited by
* non word characters.
*/
bool Document::IsWordAt(int start, int end) { bool Document::IsWordAt(int start, int end) {
return IsWordStartAt(start) && IsWordEndAt(end); return IsWordStartAt(start) && IsWordEndAt(end);
} }
// Find text in document, supporting both forward and backward // The comparison and case changing functions here assume ASCII
// searches (just pass minPos > maxPos to do a backward search) // or extended ASCII such as the normal Windows code page.
// Has not been tested with backwards DBCS searches yet.
long Document::FindText(int minPos, int maxPos, const char *s,
bool caseSensitive, bool word, bool wordStart) {
bool forward = minPos <= maxPos;
int increment = forward ? 1 : -1;
// Range endpoints should not be inside DBCS characters, but just in case, move them. static inline char MakeUpperCase(char ch) {
int startPos = MovePositionOutsideChar(minPos, increment, false); if (ch < 'a' || ch > 'z')
int endPos = MovePositionOutsideChar(maxPos, increment, false); return ch;
else
// Compute actual search ranges needed return static_cast<char>(ch - 'a' + 'A');
int lengthFind = strlen(s); }
int endSearch = endPos;
if (startPos <= endPos) { static inline char MakeLowerCase(char ch) {
endSearch = endPos - lengthFind + 1; if (ch < 'A' || ch > 'Z')
} return ch;
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind); else
char firstChar = s[0]; return static_cast<char>(ch - 'A' + 'a');
if (!caseSensitive) }
firstChar = static_cast<char>(toupper(firstChar));
int pos = startPos; // Define a way for the Regular Expression code to access the document
while (forward ? (pos < endSearch) : (pos >= endSearch)) { class DocumentIndexer : public CharacterIndexer {
char ch = CharAt(pos); Document *pdoc;
if (caseSensitive) { int end;
if (ch == firstChar) { public:
bool found = true; DocumentIndexer(Document *pdoc_, int end_) :
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) { pdoc(pdoc_), end(end_) {}
ch = CharAt(pos + posMatch);
if (ch != s[posMatch]) virtual char CharAt(int index) {
found = false; if (index < 0 || index >= end)
} return 0;
if (found) { else
if ((!word && !wordStart) || return pdoc->CharAt(index);
word && IsWordAt(pos, pos + lengthFind) || }
wordStart && IsWordStartAt(pos)) };
return pos;
} /**
} * Find text in document, supporting both forward and backward
* searches (just pass minPos > maxPos to do a backward search)
* Has not been tested with backwards DBCS searches yet.
*/
long Document::FindText(int minPos, int maxPos, const char *s,
bool caseSensitive, bool word, bool wordStart, bool regExp,
int *length) {
if (regExp) {
if (!pre)
pre = new RESearch();
if (!pre)
return -1;
int startPos;
int endPos;
if (minPos <= maxPos) {
startPos = minPos;
endPos = maxPos;
} else { } else {
if (toupper(ch) == firstChar) { startPos = maxPos;
bool found = true; endPos = minPos;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) { }
ch = CharAt(pos + posMatch);
if (toupper(ch) != toupper(s[posMatch])) // Range endpoints should not be inside DBCS characters, but just in case, move them.
found = false; startPos = MovePositionOutsideChar(startPos, 1, false);
} endPos = MovePositionOutsideChar(endPos, 1, false);
if (found) {
if (!(word && wordStart) || const char *errmsg = pre->Compile(s, *length, caseSensitive);
word && IsWordAt(pos, pos + lengthFind) || if (errmsg) {
wordStart && IsWordStartAt(pos)) return -1;
return pos; }
} // Find a variable in a property file: \$(\([A-Za-z0-9_.]+\))
// Replace first '.' with '-' in each property file variable reference:
// Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\))
// Replace: $(\1-\2)
int lineRangeStart = LineFromPosition(startPos);
int lineRangeEnd = LineFromPosition(endPos);
if ((startPos >= LineEnd(lineRangeStart)) && (lineRangeStart < lineRangeEnd)) {
// the start position is at end of line or between line end characters.
lineRangeStart++;
startPos = LineStart(lineRangeStart);
}
int pos = -1;
int lenRet = 0;
char searchEnd = s[*length - 1];
if (*length == 1) {
// These produce empty selections so nudge them on if needed
if (s[0] == '^') {
if (startPos == LineStart(lineRangeStart))
startPos++;
} else if (s[0] == '$') {
if ((startPos == LineEnd(lineRangeStart)) && (lineRangeStart < lineRangeEnd))
startPos = LineStart(lineRangeStart + 1);
}
lineRangeStart = LineFromPosition(startPos);
lineRangeEnd = LineFromPosition(endPos);
}
for (int line = lineRangeStart; line <= lineRangeEnd; line++) {
int startOfLine = LineStart(line);
int endOfLine = LineEnd(line);
if (line == lineRangeStart) {
if ((startPos != startOfLine) && (s[0] == '^'))
continue; // Can't match start of line if start position after start of line
startOfLine = startPos;
}
if (line == lineRangeEnd) {
if ((endPos != endOfLine) && (searchEnd == '$'))
continue; // Can't match end of line if end position before end of line
endOfLine = endPos;
}
DocumentIndexer di(this, endOfLine);
int success = pre->Execute(di, startOfLine, endOfLine);
if (success) {
pos = pre->bopat[0];
lenRet = pre->eopat[0] - pre->bopat[0];
break;
} }
} }
pos += increment; *length = lenRet;
if (dbcsCodePage) { return pos;
// Ensure trying to match from start of character
pos = MovePositionOutsideChar(pos, increment, false); } else {
bool forward = minPos <= maxPos;
int increment = forward ? 1 : -1;
// Range endpoints should not be inside DBCS characters, but just in case, move them.
int startPos = MovePositionOutsideChar(minPos, increment, false);
int endPos = MovePositionOutsideChar(maxPos, increment, false);
// Compute actual search ranges needed
int lengthFind = *length;
if (lengthFind == -1)
lengthFind = strlen(s);
int endSearch = endPos;
if (startPos <= endPos) {
endSearch = endPos - lengthFind + 1;
}
//Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind);
char firstChar = s[0];
if (!caseSensitive)
firstChar = static_cast<char>(MakeUpperCase(firstChar));
int pos = startPos;
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
char ch = CharAt(pos);
if (caseSensitive) {
if (ch == firstChar) {
bool found = true;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
ch = CharAt(pos + posMatch);
if (ch != s[posMatch])
found = false;
}
if (found) {
if ((!word && !wordStart) ||
word && IsWordAt(pos, pos + lengthFind) ||
wordStart && IsWordStartAt(pos))
return pos;
}
}
} else {
if (MakeUpperCase(ch) == firstChar) {
bool found = true;
for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) {
ch = CharAt(pos + posMatch);
if (MakeUpperCase(ch) != MakeUpperCase(s[posMatch]))
found = false;
}
if (found) {
if ((!word && !wordStart) ||
word && IsWordAt(pos, pos + lengthFind) ||
wordStart && IsWordStartAt(pos))
return pos;
}
}
}
pos += increment;
if (dbcsCodePage) {
// Ensure trying to match from start of character
pos = MovePositionOutsideChar(pos, increment, false);
}
} }
} }
//Platform::DebugPrintf("Not found\n"); //Platform::DebugPrintf("Not found\n");
return - 1; return -1;
}
const char *Document::SubstituteByPosition(const char *text, int *length) {
if (!pre)
return 0;
delete []substituted;
substituted = 0;
DocumentIndexer di(this, Length());
if (!pre->GrabMatches(di))
return 0;
unsigned int lenResult = 0;
for (int i = 0; i < *length; i++) {
if ((text[i] == '\\') && (text[i + 1] >= '1' && text[i + 1] <= '9')) {
unsigned int patNum = text[i + 1] - '0';
lenResult += pre->eopat[patNum] - pre->bopat[patNum];
i++;
} else {
lenResult++;
}
}
substituted = new char[lenResult + 1];
if (!substituted)
return 0;
char *o = substituted;
for (int j = 0; j < *length; j++) {
if ((text[j] == '\\') && (text[j + 1] >= '1' && text[j + 1] <= '9')) {
unsigned int patNum = text[j + 1] - '0';
unsigned int len = pre->eopat[patNum] - pre->bopat[patNum];
if (pre->pat[patNum]) // Will be null if try for a match that did not occur
memcpy(o, pre->pat[patNum], len);
o += len;
j++;
} else {
*o++ = text[j];
}
}
*o = '\0';
*length = lenResult;
return substituted;
} }
int Document::LinesTotal() { int Document::LinesTotal() {
@@ -806,18 +995,18 @@ int Document::LinesTotal() {
} }
void Document::ChangeCase(Range r, bool makeUpperCase) { void Document::ChangeCase(Range r, bool makeUpperCase) {
for (int pos=r.start; pos<r.end; pos++) { for (int pos = r.start; pos < r.end; pos++) {
char ch = CharAt(pos); char ch = CharAt(pos);
if (dbcsCodePage && IsDBCS(pos)) { if (dbcsCodePage && IsDBCS(pos)) {
pos += LenChar(pos); pos += LenChar(pos);
} else { } else {
if (makeUpperCase) { if (makeUpperCase) {
if (islower(ch)) { if (islower(ch)) {
ChangeChar(pos, static_cast<char>(toupper(ch))); ChangeChar(pos, static_cast<char>(MakeUpperCase(ch)));
} }
} else { } else {
if (isupper(ch)) { if (isupper(ch)) {
ChangeChar(pos, static_cast<char>(tolower(ch))); ChangeChar(pos, static_cast<char>(MakeLowerCase(ch)));
} }
} }
} }
@@ -844,28 +1033,27 @@ void Document::SetWordChars(unsigned char *chars) {
void Document::SetStylingBits(int bits) { void Document::SetStylingBits(int bits) {
stylingBits = bits; stylingBits = bits;
stylingBitsMask = 0; stylingBitsMask = 0;
for (int bit=0; bit<stylingBits; bit++) { for (int bit = 0; bit < stylingBits; bit++) {
stylingBitsMask <<= 1; stylingBitsMask <<= 1;
stylingBitsMask |= 1; stylingBitsMask |= 1;
} }
} }
void Document::StartStyling(int position, char mask) { void Document::StartStyling(int position, char mask) {
stylingPos = position;
stylingMask = mask; stylingMask = mask;
endStyled = position;
} }
void Document::SetStyleFor(int length, char style) { void Document::SetStyleFor(int length, char style) {
if (enteredCount == 0) { if (enteredCount == 0) {
enteredCount++; enteredCount++;
int prevEndStyled = endStyled; int prevEndStyled = endStyled;
if (cb.SetStyleFor(stylingPos, length, style, stylingMask)) { if (cb.SetStyleFor(endStyled, length, style, stylingMask)) {
DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
prevEndStyled, length); prevEndStyled, length);
NotifyModified(mh); NotifyModified(mh);
} }
stylingPos += length; endStyled += length;
endStyled = stylingPos;
enteredCount--; enteredCount--;
} }
} }
@@ -875,15 +1063,14 @@ void Document::SetStyles(int length, char *styles) {
enteredCount++; enteredCount++;
int prevEndStyled = endStyled; int prevEndStyled = endStyled;
bool didChange = false; bool didChange = false;
for (int iPos = 0; iPos < length; iPos++, stylingPos++) { for (int iPos = 0; iPos < length; iPos++, endStyled++) {
if (cb.SetStyleAt(stylingPos, styles[iPos], stylingMask)) { if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
didChange = true; didChange = true;
} }
} }
endStyled = stylingPos;
if (didChange) { if (didChange) {
DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
prevEndStyled, endStyled - prevEndStyled); prevEndStyled, endStyled - prevEndStyled);
NotifyModified(mh); NotifyModified(mh);
} }
enteredCount--; enteredCount--;
@@ -958,3 +1145,85 @@ void Document::NotifyModified(DocModification mh) {
watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData); watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData);
} }
} }
bool Document::IsWordPartSeparator(char ch) {
return ispunct(ch) && IsWordChar(ch);
}
int Document::WordPartLeft(int pos) {
if (pos > 0) {
--pos;
char startChar = cb.CharAt(pos);
if (IsWordPartSeparator(startChar)) {
while (pos > 0 && IsWordPartSeparator(cb.CharAt(pos))) {
--pos;
}
}
if (pos > 0) {
startChar = cb.CharAt(pos);
--pos;
if (islower(startChar)) {
while (pos > 0 && islower(cb.CharAt(pos)))
--pos;
if (!isupper(cb.CharAt(pos)) && !islower(cb.CharAt(pos)))
++pos;
} else if (isupper(startChar)) {
while (pos > 0 && isupper(cb.CharAt(pos)))
--pos;
if (!isupper(cb.CharAt(pos)))
++pos;
} else if (isdigit(startChar)) {
while (pos > 0 && isdigit(cb.CharAt(pos)))
--pos;
if (!isdigit(cb.CharAt(pos)))
++pos;
} else if (ispunct(startChar)) {
while (pos > 0 && ispunct(cb.CharAt(pos)))
--pos;
if (!ispunct(cb.CharAt(pos)))
++pos;
} else if (isspacechar(startChar)) {
while (pos > 0 && isspacechar(cb.CharAt(pos)))
--pos;
if (!isspacechar(cb.CharAt(pos)))
++pos;
}
}
}
return pos;
}
int Document::WordPartRight(int pos) {
char startChar = cb.CharAt(pos);
int length = Length();
if (IsWordPartSeparator(startChar)) {
while (pos < length && IsWordPartSeparator(cb.CharAt(pos)))
++pos;
startChar = cb.CharAt(pos);
}
if (islower(startChar)) {
while (pos < length && islower(cb.CharAt(pos)))
++pos;
} else if (isupper(startChar)) {
if (islower(cb.CharAt(pos + 1))) {
++pos;
while (pos < length && islower(cb.CharAt(pos)))
++pos;
} else {
while (pos < length && isupper(cb.CharAt(pos)))
++pos;
}
if (islower(cb.CharAt(pos)) && isupper(cb.CharAt(pos - 1)))
--pos;
} else if (isdigit(startChar)) {
while (pos < length && isdigit(cb.CharAt(pos)))
++pos;
} else if (ispunct(startChar)) {
while (pos < length && ispunct(cb.CharAt(pos)))
++pos;
} else if (isspacechar(startChar)) {
while (pos < length && isspacechar(cb.CharAt(pos)))
++pos;
}
return pos;
}

View File

@@ -1,36 +1,42 @@
// Scintilla source code edit control // Scintilla source code edit control
// Document.h - text document that handles notifications, DBCS, styling, words and end of line /** @file Document.h
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Text document that handles notifications, DBCS, styling, words and end of line.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef DOCUMENT_H #ifndef DOCUMENT_H
#define DOCUMENT_H #define DOCUMENT_H
// A Position is a position within a document between two characters or at the beginning or end. /**
// Sometimes used as a character index where it identifies the character after the position. * A Position is a position within a document between two characters or at the beginning or end.
* Sometimes used as a character index where it identifies the character after the position.
*/
typedef int Position; typedef int Position;
const Position invalidPosition = -1; const Position invalidPosition = -1;
// The range class represents a range of text in a document. /**
// The two values are not sorted as one end may be more significant than the other * The range class represents a range of text in a document.
// as is the case for the selection where the end position is the position of the caret. * The two values are not sorted as one end may be more significant than the other
// If either position is invalidPosition then the range is invalid and most operations will fail. * as is the case for the selection where the end position is the position of the caret.
* If either position is invalidPosition then the range is invalid and most operations will fail.
*/
class Range { class Range {
public: public:
Position start; Position start;
Position end; Position end;
Range(Position pos=0) : Range(Position pos=0) :
start(pos), end(pos) { start(pos), end(pos) {
}; };
Range(Position start_, Position end_) : Range(Position start_, Position end_) :
start(start_), end(end_) { start(start_), end(end_) {
}; };
bool Valid() const { bool Valid() const {
return (start != invalidPosition) && (end != invalidPosition); return (start != invalidPosition) && (end != invalidPosition);
} }
bool Contains(Position pos) const { bool Contains(Position pos) const {
if (start < end) { if (start < end) {
return (pos >= start && pos <= end); return (pos >= start && pos <= end);
@@ -38,11 +44,11 @@ public:
return (pos <= start && pos >= end); return (pos <= start && pos >= end);
} }
} }
bool Contains(Range other) const { bool Contains(Range other) const {
return Contains(other.start) && Contains(other.end); return Contains(other.start) && Contains(other.end);
} }
bool Overlaps(Range other) const { bool Overlaps(Range other) const {
return return
Contains(other.start) || Contains(other.start) ||
@@ -54,11 +60,14 @@ public:
class DocWatcher; class DocWatcher;
class DocModification; class DocModification;
class RESearch;
/**
*/
class Document { class Document {
public: public:
// Used to pair watcher pointer with user data /** Used to pair watcher pointer with user data. */
class WatcherWithUserData { class WatcherWithUserData {
public: public:
DocWatcher *watcher; DocWatcher *watcher;
@@ -68,37 +77,42 @@ public:
userData = 0; userData = 0;
} }
}; };
private: private:
int refCount; int refCount;
CellBuffer cb; CellBuffer cb;
bool wordchars[256]; bool wordchars[256];
int stylingPos;
char stylingMask; char stylingMask;
int endStyled; int endStyled;
int enteredCount; int enteredCount;
int enteredReadOnlyCount; int enteredReadOnlyCount;
WatcherWithUserData *watchers; WatcherWithUserData *watchers;
int lenWatchers; int lenWatchers;
bool matchesValid;
RESearch *pre;
char *substituted;
public: public:
int stylingBits; int stylingBits;
int stylingBitsMask; int stylingBitsMask;
int eolMode; int eolMode;
// dbcsCodePage can also be SC_CP_UTF8 to enable UTF-8 mode /// Can also be SC_CP_UTF8 to enable UTF-8 mode
int dbcsCodePage; int dbcsCodePage;
int tabInChars; int tabInChars;
int indentInChars; int indentInChars;
bool useTabs; bool useTabs;
bool tabIndents;
bool backspaceUnindents;
Document(); Document();
virtual ~Document(); virtual ~Document();
int AddRef(); int AddRef();
int Release(); int Release();
int LineFromPosition(int pos); int LineFromPosition(int pos);
int ClampPositionIntoDocument(int pos); int ClampPositionIntoDocument(int pos);
bool IsCrLf(int pos); bool IsCrLf(int pos);
@@ -165,12 +179,13 @@ public:
int NextWordStart(int pos, int delta); int NextWordStart(int pos, int delta);
int Length() { return cb.Length(); } int Length() { return cb.Length(); }
long FindText(int minPos, int maxPos, const char *s, long FindText(int minPos, int maxPos, const char *s,
bool caseSensitive, bool word, bool wordStart); bool caseSensitive, bool word, bool wordStart, bool regExp, int *length);
long FindText(int iMessage, unsigned long wParam, long lParam); long FindText(int iMessage, unsigned long wParam, long lParam);
const char *SubstituteByPosition(const char *text, int *length);
int LinesTotal(); int LinesTotal();
void ChangeCase(Range r, bool makeUpperCase); void ChangeCase(Range r, bool makeUpperCase);
void SetWordChars(unsigned char *chars); void SetWordChars(unsigned char *chars);
void SetStylingBits(int bits); void SetStylingBits(int bits);
void StartStyling(int position, char mask); void StartStyling(int position, char mask);
@@ -182,12 +197,16 @@ public:
int SetLineState(int line, int state) { return cb.SetLineState(line, state); } int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); } int GetLineState(int line) { return cb.GetLineState(line); }
int GetMaxLineState() { return cb.GetMaxLineState(); } int GetMaxLineState() { return cb.GetMaxLineState(); }
bool AddWatcher(DocWatcher *watcher, void *userData); bool AddWatcher(DocWatcher *watcher, void *userData);
bool RemoveWatcher(DocWatcher *watcher, void *userData); bool RemoveWatcher(DocWatcher *watcher, void *userData);
const WatcherWithUserData *GetWatchers() const { return watchers; } const WatcherWithUserData *GetWatchers() const { return watchers; }
int GetLenWatchers() const { return lenWatchers; } int GetLenWatchers() const { return lenWatchers; }
bool IsWordPartSeparator(char ch);
int WordPartLeft(int pos);
int WordPartRight(int pos);
private: private:
bool IsDBCS(int pos); bool IsDBCS(int pos);
bool IsWordChar(unsigned char ch); bool IsWordChar(unsigned char ch);
@@ -195,24 +214,26 @@ private:
bool IsWordEndAt(int pos); bool IsWordEndAt(int pos);
bool IsWordAt(int start, int end); bool IsWordAt(int start, int end);
void ModifiedAt(int pos); void ModifiedAt(int pos);
void NotifyModifyAttempt(); void NotifyModifyAttempt();
void NotifySavePoint(bool atSavePoint); void NotifySavePoint(bool atSavePoint);
void NotifyModified(DocModification mh); void NotifyModified(DocModification mh);
int IndentSize() { return indentInChars ? indentInChars : tabInChars; } int IndentSize() { return indentInChars ? indentInChars : tabInChars; }
}; };
// To optimise processing of document modifications by DocWatchers, a hint is passed indicating the /**
// scope of the change. * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the
// If the DocWatcher is a document view then this can be used to optimise screen updating. * scope of the change.
* If the DocWatcher is a document view then this can be used to optimise screen updating.
*/
class DocModification { class DocModification {
public: public:
int modificationType; int modificationType;
int position; int position;
int length; int length;
int linesAdded; // Negative if lines deleted int linesAdded; /**< Negative if lines deleted. */
const char *text; // Only valid for changes to text, not for changes to style const char *text; /**< Only valid for changes to text, not for changes to style. */
int line; int line;
int foldLevelNow; int foldLevelNow;
int foldLevelPrev; int foldLevelPrev;
@@ -239,12 +260,14 @@ public:
foldLevelPrev(0) {} foldLevelPrev(0) {}
}; };
// A class that wants to receive notifications from a Document must be derived from DocWatcher /**
// and implement the notification methods. It can then be added to the watcher list with AddWatcher. * A class that wants to receive notifications from a Document must be derived from DocWatcher
* and implement the notification methods. It can then be added to the watcher list with AddWatcher.
*/
class DocWatcher { class DocWatcher {
public: public:
virtual ~DocWatcher() {} virtual ~DocWatcher() {}
virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0; virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0;
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0; virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0; virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;

View File

@@ -1,11 +1,13 @@
// SciTE - Scintilla based Text Editor // Scintilla source code edit control
// Accessor.cxx - rapid easy access to contents of a Scintilla /** @file DocumentAccessor.cxx
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> ** Rapid easy access to contents of a Scintilla.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include "Platform.h" #include "Platform.h"
@@ -21,12 +23,12 @@
DocumentAccessor::~DocumentAccessor() { DocumentAccessor::~DocumentAccessor() {
} }
#if PLAT_WIN #if PLAT_WIN
bool DocumentAccessor::InternalIsLeadByte(char ch) { bool DocumentAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage) if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the // For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte. // same so none is considered a lead byte.
return false; return false;
else else
return IsDBCSLeadByteEx(codePage, ch); return IsDBCSLeadByteEx(codePage, ch);
} }
@@ -36,7 +38,7 @@ bool DocumentAccessor::InternalIsLeadByte(char ch) {
bool DocumentAccessor::InternalIsLeadByte(char) { bool DocumentAccessor::InternalIsLeadByte(char) {
return false; return false;
} }
#endif #endif
void DocumentAccessor::Fill(int position) { void DocumentAccessor::Fill(int position) {
if (lenDoc == -1) if (lenDoc == -1)
@@ -70,10 +72,10 @@ int DocumentAccessor::LevelAt(int line) {
return pdoc->GetLevel(line); return pdoc->GetLevel(line);
} }
int DocumentAccessor::Length() { int DocumentAccessor::Length() {
if (lenDoc == -1) if (lenDoc == -1)
lenDoc = pdoc->Length(); lenDoc = pdoc->Length();
return lenDoc; return lenDoc;
} }
int DocumentAccessor::GetLineState(int line) { int DocumentAccessor::GetLineState(int line) {
@@ -132,12 +134,12 @@ void DocumentAccessor::Flush() {
int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) { int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
int end = Length(); int end = Length();
int spaceFlags = 0; int spaceFlags = 0;
// Determines the indentation level of the current line and also checks for consistent // Determines the indentation level of the current line and also checks for consistent
// indentation compared to the previous line. // indentation compared to the previous line.
// Indentation is judged consistent when the indentation whitespace of each line lines // Indentation is judged consistent when the indentation whitespace of each line lines
// the same or the indentation of one line is a prefix of the other. // the same or the indentation of one line is a prefix of the other.
int pos = LineStart(line); int pos = LineStart(line);
char ch = (*this)[pos]; char ch = (*this)[pos];
int indent = 0; int indent = 0;
@@ -164,11 +166,12 @@ int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnI
} }
ch = (*this)[++pos]; ch = (*this)[++pos];
} }
*flags = spaceFlags; *flags = spaceFlags;
indent += SC_FOLDLEVELBASE; indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment... // if completely empty line or the start of a comment...
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) ) if ((ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') ||
(pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
return indent | SC_FOLDLEVELWHITEFLAG; return indent | SC_FOLDLEVELWHITEFLAG;
else else
return indent; return indent;

Some files were not shown because too many files have changed in this diff Show More