Updated wxSTC from Scintilla 1.40 to Scintilla 1.45
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -73,6 +73,9 @@
|
||||
#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
|
||||
#define wxSTC_MARK_CIRCLEMINUS 20
|
||||
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
|
||||
|
||||
// Invisible mark that only sets the line background color
|
||||
#define wxSTC_MARK_BACKGROUND 22
|
||||
#define wxSTC_MARK_CHARACTER 10000
|
||||
|
||||
// Markers used for outlining column
|
||||
@@ -83,6 +86,7 @@
|
||||
#define wxSTC_MARKNUM_FOLDERSUB 29
|
||||
#define wxSTC_MARKNUM_FOLDER 30
|
||||
#define wxSTC_MARKNUM_FOLDEROPEN 31
|
||||
#define wxSTC_MASK_FOLDERS 0xFE000000
|
||||
#define wxSTC_MARGIN_SYMBOL 0
|
||||
#define wxSTC_MARGIN_NUMBER 1
|
||||
|
||||
@@ -127,10 +131,10 @@
|
||||
#define wxSTC_INDIC_TT 2
|
||||
#define wxSTC_INDIC_DIAGONAL 3
|
||||
#define wxSTC_INDIC_STRIKE 4
|
||||
#define wxSTC_INDIC0_MASK 32
|
||||
#define wxSTC_INDIC1_MASK 64
|
||||
#define wxSTC_INDIC2_MASK 128
|
||||
#define wxSTC_INDICS_MASK 224
|
||||
#define wxSTC_INDIC0_MASK 0x20
|
||||
#define wxSTC_INDIC1_MASK 0x40
|
||||
#define wxSTC_INDIC2_MASK 0x80
|
||||
#define wxSTC_INDICS_MASK 0xE0
|
||||
|
||||
// PrintColourMode - use same colours as screen.
|
||||
#define wxSTC_PRINT_NORMAL 0
|
||||
@@ -159,6 +163,12 @@
|
||||
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000
|
||||
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
|
||||
#define wxSTC_TIME_FOREVER 10000000
|
||||
#define wxSTC_WRAP_NONE 0
|
||||
#define wxSTC_WRAP_WORD 1
|
||||
#define wxSTC_CACHE_NONE 0
|
||||
#define wxSTC_CACHE_CARET 1
|
||||
#define wxSTC_CACHE_PAGE 2
|
||||
#define wxSTC_CACHE_DOCUMENT 3
|
||||
#define wxSTC_CMD_LINEDOWN 2300
|
||||
#define wxSTC_CMD_LINEDOWNEXTEND 2301
|
||||
#define wxSTC_CMD_LINEUP 2302
|
||||
@@ -203,6 +213,7 @@
|
||||
#define wxSTC_CMD_UPPERCASE 2341
|
||||
#define wxSTC_CMD_LINESCROLLDOWN 2342
|
||||
#define wxSTC_CMD_LINESCROLLUP 2343
|
||||
#define wxSTC_CMD_DELETEBACKNOTLINE 2344
|
||||
#define wxSTC_EDGE_NONE 0
|
||||
#define wxSTC_EDGE_LINE 1
|
||||
#define wxSTC_EDGE_BACKGROUND 2
|
||||
@@ -302,6 +313,12 @@
|
||||
#define wxSTC_LEX_EIFFELKW 24
|
||||
#define wxSTC_LEX_TCL 25
|
||||
#define wxSTC_LEX_NNCRONTAB 26
|
||||
#define wxSTC_LEX_BULLANT 27
|
||||
#define wxSTC_LEX_VBSCRIPT 28
|
||||
#define wxSTC_LEX_ASP 29
|
||||
#define wxSTC_LEX_PHP 30
|
||||
#define wxSTC_LEX_BAAN 31
|
||||
#define wxSTC_LEX_MATLAB 32
|
||||
|
||||
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
// value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
@@ -323,7 +340,7 @@
|
||||
#define wxSTC_P_COMMENTBLOCK 12
|
||||
#define wxSTC_P_STRINGEOL 13
|
||||
|
||||
// Lexical states for SCLEX_CPP, SCLEX_VB
|
||||
// Lexical states for SCLEX_CPP
|
||||
#define wxSTC_C_DEFAULT 0
|
||||
#define wxSTC_C_COMMENT 1
|
||||
#define wxSTC_C_COMMENTLINE 2
|
||||
@@ -344,6 +361,17 @@
|
||||
#define wxSTC_C_COMMENTDOCKEYWORD 17
|
||||
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
|
||||
|
||||
// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
|
||||
#define wxSTC_B_DEFAULT 0
|
||||
#define wxSTC_B_COMMENT 1
|
||||
#define wxSTC_B_NUMBER 2
|
||||
#define wxSTC_B_KEYWORD 3
|
||||
#define wxSTC_B_STRING 4
|
||||
#define wxSTC_B_PREPROCESSOR 5
|
||||
#define wxSTC_B_OPERATOR 6
|
||||
#define wxSTC_B_IDENTIFIER 7
|
||||
#define wxSTC_B_DATE 8
|
||||
|
||||
// Lexical states for SCLEX_HTML, SCLEX_XML
|
||||
#define wxSTC_H_DEFAULT 0
|
||||
#define wxSTC_H_TAG 1
|
||||
@@ -531,6 +559,11 @@
|
||||
#define wxSTC_LUA_OPERATOR 10
|
||||
#define wxSTC_LUA_IDENTIFIER 11
|
||||
#define wxSTC_LUA_STRINGEOL 12
|
||||
#define wxSTC_LUA_WORD2 13
|
||||
#define wxSTC_LUA_WORD3 14
|
||||
#define wxSTC_LUA_WORD4 15
|
||||
#define wxSTC_LUA_WORD5 16
|
||||
#define wxSTC_LUA_WORD6 17
|
||||
|
||||
// Lexical states for SCLEX_ERRORLIST
|
||||
#define wxSTC_ERR_DEFAULT 0
|
||||
@@ -602,6 +635,19 @@
|
||||
#define wxSTC_ADA_IDENTIFIER 7
|
||||
#define wxSTC_ADA_STRINGEOL 8
|
||||
|
||||
// Lexical states for SCLEX_BAAN
|
||||
#define wxSTC_BAAN_DEFAULT 0
|
||||
#define wxSTC_BAAN_COMMENT 1
|
||||
#define wxSTC_BAAN_COMMENTDOC 2
|
||||
#define wxSTC_BAAN_NUMBER 3
|
||||
#define wxSTC_BAAN_WORD 4
|
||||
#define wxSTC_BAAN_STRING 5
|
||||
#define wxSTC_BAAN_PREPROCESSOR 6
|
||||
#define wxSTC_BAAN_OPERATOR 7
|
||||
#define wxSTC_BAAN_IDENTIFIER 8
|
||||
#define wxSTC_BAAN_STRINGEOL 9
|
||||
#define wxSTC_BAAN_WORD2 10
|
||||
|
||||
// Lexical states for SCLEX_LISP
|
||||
#define wxSTC_LISP_DEFAULT 0
|
||||
#define wxSTC_LISP_COMMENT 1
|
||||
@@ -636,21 +682,17 @@
|
||||
#define wxSTC_NNCRONTAB_ENVIRONMENT 9
|
||||
#define wxSTC_NNCRONTAB_IDENTIFIER 10
|
||||
|
||||
// Lexical states for SCLEX_MATLAB
|
||||
#define wxSTC_MATLAB_DEFAULT 0
|
||||
#define wxSTC_MATLAB_COMMENT 1
|
||||
#define wxSTC_MATLAB_COMMAND 2
|
||||
#define wxSTC_MATLAB_NUMBER 3
|
||||
#define wxSTC_MATLAB_KEYWORD 4
|
||||
#define wxSTC_MATLAB_STRING 5
|
||||
#define wxSTC_MATLAB_OPERATOR 6
|
||||
#define wxSTC_MATLAB_IDENTIFIER 7
|
||||
|
||||
// END of generated section
|
||||
//----------------------------------------------------------------------
|
||||
// Others
|
||||
|
||||
#define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEROPEN) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERSUB) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERTAIL) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERMIDTAIL) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEROPENMID) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEREND))
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ScintillaWX; // forward declare
|
||||
@@ -821,7 +863,7 @@ public:
|
||||
void SetCodePage(int codePage);
|
||||
|
||||
// Set the symbol used for a particular marker number,
|
||||
// and optionally the for and background colours.
|
||||
// and optionally the fore and background colours.
|
||||
void MarkerDefine(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground = wxNullColour,
|
||||
const wxColour& background = wxNullColour);
|
||||
@@ -832,8 +874,8 @@ public:
|
||||
// Set the background colour used for a particular marker number.
|
||||
void MarkerSetBackground(int markerNumber, const wxColour& back);
|
||||
|
||||
// Add a marker to a line.
|
||||
void MarkerAdd(int line, int markerNumber);
|
||||
// Add a marker to a line, returning an ID which can be used to find or delete the marker.
|
||||
int MarkerAdd(int line, int markerNumber);
|
||||
|
||||
// Delete a marker from a line
|
||||
void MarkerDelete(int line, int markerNumber);
|
||||
@@ -980,7 +1022,7 @@ public:
|
||||
// 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.
|
||||
// Dsplay 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.
|
||||
@@ -989,6 +1031,10 @@ public:
|
||||
// Set the colour of the background of the line containing the caret.
|
||||
void SetCaretLineBack(const wxColour& back);
|
||||
|
||||
// Set a style to be changeable or not (read only).
|
||||
// Experimental feature, currently buggy.
|
||||
void StyleSetChangeable(int style, bool changeable);
|
||||
|
||||
// Display a auto-completion list.
|
||||
// The lenEntered parameter indicates how many characters before
|
||||
// the caret should be used to provide context.
|
||||
@@ -1027,7 +1073,8 @@ public:
|
||||
// Retrieve whether auto-completion cancelled by backspacing before start.
|
||||
bool AutoCompGetCancelAtStart();
|
||||
|
||||
// Define a set of character that when typed fills up the selected word.
|
||||
// Define a set of characters that when typed will cause the autocompletion to
|
||||
// choose the selected item.
|
||||
void AutoCompSetFillUps(const wxString& characterSet);
|
||||
|
||||
// Should a single item auto-completion list automatically choose the item.
|
||||
@@ -1051,6 +1098,12 @@ public:
|
||||
// Retrieve whether or not autocompletion is hidden automatically when nothing matches
|
||||
bool AutoCompGetAutoHide();
|
||||
|
||||
// Set whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
void AutoCompSetDropRestOfWord(bool dropRestOfWord);
|
||||
|
||||
// Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
bool AutoCompGetDropRestOfWord();
|
||||
|
||||
// Set the number of spaces used for one level of indentation.
|
||||
void SetIndent(int indentSize);
|
||||
|
||||
@@ -1369,6 +1422,28 @@ public:
|
||||
// Retrieve the time the mouse must sit still to generate a mouse dwell event
|
||||
int GetMouseDwellTime();
|
||||
|
||||
// Get position of start of word
|
||||
int WordStartPosition(int pos, bool onlyWordCharacters);
|
||||
|
||||
// Get position of end of word
|
||||
int WordEndPosition(int pos, bool onlyWordCharacters);
|
||||
|
||||
// Sets whether text is word wrapped
|
||||
void SetWrapMode(int mode);
|
||||
|
||||
// Retrieve whether text is word wrapped
|
||||
int GetWrapMode();
|
||||
|
||||
// Sets the degree of caching of layout information
|
||||
void SetLayoutCache(int mode);
|
||||
|
||||
// Retrieve the degree of caching of layout information
|
||||
int GetLayoutCache();
|
||||
|
||||
// Delete the selection or if no selection, the character before the caret.
|
||||
// Will not delete the chraacter before at the start of a line.
|
||||
void DeleteBackNotLine();
|
||||
|
||||
// Move the caret inside current view if it's not there already
|
||||
void MoveCaretInsideView();
|
||||
|
||||
@@ -1487,6 +1562,13 @@ public:
|
||||
// Get cursor type
|
||||
int GetCursor();
|
||||
|
||||
// Change the way control characters are displayed:
|
||||
// If symbol is < 32, keep the drawn way, else, use the given character
|
||||
void SetControlCharSymbol(int symbol);
|
||||
|
||||
// Get the way control characters are displayed
|
||||
int GetControlCharSymbol();
|
||||
|
||||
// Move to the previous change in capitalistion
|
||||
void WordPartLeft();
|
||||
|
||||
@@ -1508,6 +1590,10 @@ public:
|
||||
// Delete forwards from the current position to the end of the line
|
||||
void DelLineRight();
|
||||
|
||||
// Get and Set the xOffset (ie, horizonal scroll position)
|
||||
void SetXOffset(int newOffset);
|
||||
int GetXOffset();
|
||||
|
||||
// Start notifying the container of all key presses and commands.
|
||||
void StartRecord();
|
||||
|
||||
|
@@ -34,6 +34,9 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
KeyMap.o \
|
||||
KeyWords.o \
|
||||
LexAVE.o \
|
||||
LexBaan.o \
|
||||
LexBullant.o \
|
||||
LexMatlab.o \
|
||||
LexAda.o \
|
||||
LexCPP.o \
|
||||
LexConf.o \
|
||||
@@ -61,7 +64,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
|
||||
DEPFILES=$(OBJECTS:.o=.d)
|
||||
|
||||
APPEXTRADEFS=-D__WX__ -DSCI_LEXER -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
|
||||
APPEXTRADEFS=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
|
||||
|
||||
include $(top_builddir)/src/makelib.env
|
||||
|
||||
|
@@ -6,7 +6,10 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "PlatWX.h"
|
||||
#include "wx/stc/stc.h"
|
||||
|
||||
|
||||
@@ -14,6 +17,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
|
||||
Point Point::FromLong(long lpoint) {
|
||||
return Point(lpoint & 0xFFFF, lpoint >> 16);
|
||||
}
|
||||
@@ -29,35 +33,12 @@ PRectangle PRectangleFromwxRect(wxRect rc) {
|
||||
rc.GetRight()+1, rc.GetBottom()+1);
|
||||
}
|
||||
|
||||
Colour::Colour(long lcol) {
|
||||
co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff);
|
||||
wxColour wxColourFromCA(const ColourAllocated& ca) {
|
||||
ColourDesired cd(ca.AsLong());
|
||||
return wxColour(cd.GetRed(), cd.GetGreen(), cd.GetBlue());
|
||||
}
|
||||
|
||||
Colour::Colour(unsigned int red, unsigned int green, unsigned int blue) {
|
||||
co.Set(red, green, blue);
|
||||
}
|
||||
|
||||
bool Colour::operator==(const Colour &other) const {
|
||||
return co == other.co;
|
||||
}
|
||||
|
||||
long Colour::AsLong() const {
|
||||
return (((long)co.Blue() << 16) |
|
||||
((long)co.Green() << 8) |
|
||||
((long)co.Red()));
|
||||
}
|
||||
|
||||
unsigned int Colour::GetRed() {
|
||||
return co.Red();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetGreen() {
|
||||
return co.Green();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetBlue() {
|
||||
return co.Blue();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Palette::Palette() {
|
||||
used = 0;
|
||||
@@ -84,7 +65,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
|
||||
|
||||
if (used < numEntries) {
|
||||
entries[used].desired = cp.desired;
|
||||
entries[used].allocated = cp.desired;
|
||||
entries[used].allocated.Set(cp.desired.AsLong());
|
||||
used++;
|
||||
}
|
||||
} else {
|
||||
@@ -94,7 +75,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
cp.allocated = cp.desired;
|
||||
cp.allocated.Set(cp.desired.AsLong());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +85,8 @@ void Palette::Allocate(Window &) {
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Font::Font() {
|
||||
id = 0;
|
||||
ascent = 0;
|
||||
@@ -113,36 +96,172 @@ Font::~Font() {
|
||||
}
|
||||
|
||||
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
|
||||
// TODO: what to do about the characterSet?
|
||||
wxFontEncoding encoding;
|
||||
|
||||
Release();
|
||||
|
||||
switch (characterSet) {
|
||||
default:
|
||||
case wxSTC_CHARSET_ANSI:
|
||||
case wxSTC_CHARSET_DEFAULT:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_BALTIC:
|
||||
encoding = wxFONTENCODING_ISO8859_13;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_CHINESEBIG5:
|
||||
encoding = wxFONTENCODING_CP950;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_EASTEUROPE:
|
||||
encoding = wxFONTENCODING_ISO8859_2;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_GB2312:
|
||||
encoding = wxFONTENCODING_CP936;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_GREEK:
|
||||
encoding = wxFONTENCODING_ISO8859_7;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_HANGUL:
|
||||
encoding = wxFONTENCODING_CP949;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_MAC:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_OEM:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_RUSSIAN:
|
||||
encoding = wxFONTENCODING_KOI8;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_SHIFTJIS:
|
||||
encoding = wxFONTENCODING_CP932;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_SYMBOL:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_TURKISH:
|
||||
encoding = wxFONTENCODING_ISO8859_9;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_JOHAB:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_HEBREW:
|
||||
encoding = wxFONTENCODING_ISO8859_8;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_ARABIC:
|
||||
encoding = wxFONTENCODING_ISO8859_6;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_VIETNAMESE:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_THAI:
|
||||
encoding = wxFONTENCODING_ISO8859_11;
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Use wxFontMapper and wxEncodingConverter if encoding not available.
|
||||
|
||||
id = new wxFont(size,
|
||||
wxDEFAULT,
|
||||
italic ? wxITALIC : wxNORMAL,
|
||||
bold ? wxBOLD : wxNORMAL,
|
||||
false,
|
||||
faceName,
|
||||
wxFONTENCODING_DEFAULT);
|
||||
encoding);
|
||||
}
|
||||
|
||||
|
||||
void Font::Release() {
|
||||
if (id)
|
||||
delete id;
|
||||
delete (wxFont*)id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Surface::Surface() :
|
||||
class SurfaceImpl : public Surface {
|
||||
private:
|
||||
wxDC* hdc;
|
||||
bool hdcOwned;
|
||||
wxBitmap* bitmap;
|
||||
int x;
|
||||
int y;
|
||||
bool unicodeMode;
|
||||
|
||||
public:
|
||||
SurfaceImpl();
|
||||
~SurfaceImpl();
|
||||
|
||||
void Init();
|
||||
void Init(SurfaceID sid);
|
||||
void InitPixMap(int width, int height, Surface *surface_);
|
||||
|
||||
void Release();
|
||||
bool Initialised();
|
||||
void PenColour(ColourAllocated fore);
|
||||
int LogPixelsY();
|
||||
int DeviceHeightFont(int points);
|
||||
void MoveTo(int x_, int y_);
|
||||
void LineTo(int x_, int y_);
|
||||
void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
|
||||
void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
|
||||
void FillRectangle(PRectangle rc, ColourAllocated back);
|
||||
void FillRectangle(PRectangle rc, Surface &surfacePattern);
|
||||
void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
|
||||
void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
|
||||
void Copy(PRectangle rc, Point from, Surface &surfaceSource);
|
||||
|
||||
void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
|
||||
void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
|
||||
void MeasureWidths(Font &font_, const char *s, int len, int *positions);
|
||||
int WidthText(Font &font_, const char *s, int len);
|
||||
int WidthChar(Font &font_, char ch);
|
||||
int Ascent(Font &font_);
|
||||
int Descent(Font &font_);
|
||||
int InternalLeading(Font &font_);
|
||||
int ExternalLeading(Font &font_);
|
||||
int Height(Font &font_);
|
||||
int AverageCharWidth(Font &font_);
|
||||
|
||||
int SetPalette(Palette *pal, bool inBackGround);
|
||||
void SetClip(PRectangle rc);
|
||||
void FlushCachedState();
|
||||
|
||||
void SetUnicodeMode(bool unicodeMode_);
|
||||
|
||||
void BrushColour(ColourAllocated back);
|
||||
void SetFont(Font &font_);
|
||||
};
|
||||
|
||||
|
||||
|
||||
SurfaceImpl::SurfaceImpl() :
|
||||
hdc(0), hdcOwned(0), bitmap(0),
|
||||
x(0), y(0) {
|
||||
}
|
||||
x(0), y(0), unicodeMode(0)
|
||||
{}
|
||||
|
||||
Surface::~Surface() {
|
||||
SurfaceImpl::~SurfaceImpl() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Surface::Release() {
|
||||
void SurfaceImpl::Release() {
|
||||
if (bitmap) {
|
||||
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
|
||||
delete bitmap;
|
||||
@@ -156,24 +275,24 @@ void Surface::Release() {
|
||||
}
|
||||
|
||||
|
||||
bool Surface::Initialised() {
|
||||
bool SurfaceImpl::Initialised() {
|
||||
return hdc != 0;
|
||||
}
|
||||
|
||||
void Surface::Init() {
|
||||
void SurfaceImpl::Init() {
|
||||
Release();
|
||||
hdc = new wxMemoryDC();
|
||||
hdcOwned = true;
|
||||
}
|
||||
|
||||
void Surface::Init(SurfaceID hdc_) {
|
||||
void SurfaceImpl::Init(SurfaceID hdc_) {
|
||||
Release();
|
||||
hdc = hdc_;
|
||||
hdc = (wxDC*)hdc_;
|
||||
}
|
||||
|
||||
void Surface::InitPixMap(int width, int height, Surface *surface_) {
|
||||
void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_) {
|
||||
Release();
|
||||
hdc = new wxMemoryDC(surface_->hdc);
|
||||
hdc = new wxMemoryDC();
|
||||
hdcOwned = true;
|
||||
if (width < 1) width = 1;
|
||||
if (height < 1) height = 1;
|
||||
@@ -181,64 +300,63 @@ void Surface::InitPixMap(int width, int height, Surface *surface_) {
|
||||
((wxMemoryDC*)hdc)->SelectObject(*bitmap);
|
||||
}
|
||||
|
||||
void Surface::PenColour(Colour fore) {
|
||||
hdc->SetPen(wxPen(fore.co, 1, wxSOLID));
|
||||
void SurfaceImpl::PenColour(ColourAllocated fore) {
|
||||
hdc->SetPen(wxPen(wxColourFromCA(fore), 1, wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::BrushColor(Colour back) {
|
||||
hdc->SetBrush(wxBrush(back.co, wxSOLID));
|
||||
void SurfaceImpl::BrushColour(ColourAllocated back) {
|
||||
hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::SetFont(Font &font_) {
|
||||
void SurfaceImpl::SetFont(Font &font_) {
|
||||
if (font_.GetID()) {
|
||||
hdc->SetFont(*font_.GetID());
|
||||
hdc->SetFont(*((wxFont*)font_.GetID()));
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::LogPixelsY() {
|
||||
int SurfaceImpl::LogPixelsY() {
|
||||
return hdc->GetPPI().y;
|
||||
}
|
||||
|
||||
|
||||
int Surface::DeviceHeightFont(int points) {
|
||||
int SurfaceImpl::DeviceHeightFont(int points) {
|
||||
return points;
|
||||
// int logPix = LogPixelsY();
|
||||
// return (points * logPix + logPix / 2) / 72;
|
||||
}
|
||||
|
||||
|
||||
void Surface::MoveTo(int x_, int y_) {
|
||||
void SurfaceImpl::MoveTo(int x_, int y_) {
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::LineTo(int x_, int y_) {
|
||||
void SurfaceImpl::LineTo(int x_, int y_) {
|
||||
hdc->DrawLine(x,y, x_,y_);
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::Polygon(Point *pts, int npts, Colour fore,
|
||||
Colour back) {
|
||||
void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawPolygon(npts, (wxPoint*)pts);
|
||||
}
|
||||
|
||||
void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
|
||||
void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Colour back) {
|
||||
BrushColor(back);
|
||||
void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
|
||||
BrushColour(back);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
wxBrush br;
|
||||
if (surfacePattern.bitmap)
|
||||
br = wxBrush(*surfacePattern.bitmap);
|
||||
if (((SurfaceImpl&)surfacePattern).bitmap)
|
||||
br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap);
|
||||
else // Something is wrong so display in red
|
||||
br = wxBrush(*wxRED, wxSOLID);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
@@ -246,79 +364,112 @@ void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
|
||||
void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4);
|
||||
}
|
||||
|
||||
void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
|
||||
void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawEllipse(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
|
||||
void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
hdc->Blit(r.x, r.y, r.width, r.height,
|
||||
surfaceSource.hdc, from.x, from.y, wxCOPY);
|
||||
((SurfaceImpl&)surfaceSource).hdc,
|
||||
from.x, from.y, wxCOPY);
|
||||
}
|
||||
|
||||
void Surface::DrawText(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len, Colour fore, Colour back) {
|
||||
void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len,
|
||||
ColourAllocated fore, ColourAllocated back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
hdc->SetTextForeground(wxColourFromCA(fore));
|
||||
hdc->SetTextBackground(wxColourFromCA(back));
|
||||
FillRectangle(rc, back);
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
// ybase is where the baseline should be, but wxWin uses the upper left
|
||||
// corner, so I need to calculate the real position for the text...
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
hdc->DrawText(str, rc.left, ybase - font.ascent);
|
||||
}
|
||||
|
||||
void Surface::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, Colour fore, Colour back) {
|
||||
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len,
|
||||
ColourAllocated fore, ColourAllocated back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
hdc->SetTextForeground(wxColourFromCA(fore));
|
||||
hdc->SetTextBackground(wxColourFromCA(back));
|
||||
FillRectangle(rc, back);
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
// see comments above
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
hdc->DrawText(str, rc.left, ybase - font.ascent);
|
||||
hdc->DestroyClippingRegion();
|
||||
}
|
||||
|
||||
int Surface::WidthText(Font &font, const char *s, int len) {
|
||||
int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(wxString(s, len), &w, &h);
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
hdc->GetTextExtent(str, &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
void Surface::MeasureWidths(Font &font, const char *s, int len, int *positions) {
|
||||
void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
SetFont(font);
|
||||
int totalWidth = 0;
|
||||
for (int i=0; i<len; i++) {
|
||||
for (size_t i=0; i<(size_t)len; i++) {
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(s[i], &w, &h);
|
||||
hdc->GetTextExtent(str[i], &w, &h);
|
||||
totalWidth += w;
|
||||
positions[i] = totalWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::WidthChar(Font &font, char ch) {
|
||||
int SurfaceImpl::WidthChar(Font &font, char ch) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
hdc->GetTextExtent(ch, &w, &h);
|
||||
#endif
|
||||
return w;
|
||||
}
|
||||
|
||||
#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
#define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
int Surface::Ascent(Font &font) {
|
||||
int SurfaceImpl::Ascent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
@@ -326,66 +477,81 @@ int Surface::Ascent(Font &font) {
|
||||
return font.ascent;
|
||||
}
|
||||
|
||||
int Surface::Descent(Font &font) {
|
||||
int SurfaceImpl::Descent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return d;
|
||||
}
|
||||
|
||||
int Surface::InternalLeading(Font &font) {
|
||||
int SurfaceImpl::InternalLeading(Font &font) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Surface::ExternalLeading(Font &font) {
|
||||
int SurfaceImpl::ExternalLeading(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return e;
|
||||
}
|
||||
|
||||
int Surface::Height(Font &font) {
|
||||
int SurfaceImpl::Height(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharHeight();
|
||||
}
|
||||
|
||||
int Surface::AverageCharWidth(Font &font) {
|
||||
int SurfaceImpl::AverageCharWidth(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharWidth();
|
||||
}
|
||||
|
||||
int Surface::SetPalette(Palette *pal, bool inBackGround) {
|
||||
int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Surface::SetClip(PRectangle rc) {
|
||||
void SurfaceImpl::SetClip(PRectangle rc) {
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FlushCachedState() {
|
||||
void SurfaceImpl::FlushCachedState() {
|
||||
}
|
||||
|
||||
void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
|
||||
// TODO: Make this jive with wxUSE_UNICODE
|
||||
unicodeMode=unicodeMode_;
|
||||
}
|
||||
|
||||
Surface *Surface::Allocate() {
|
||||
return new SurfaceImpl;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
inline wxWindow* GETWIN(WindowID id) { return (wxWindow*)id; }
|
||||
|
||||
Window::~Window() {
|
||||
}
|
||||
|
||||
void Window::Destroy() {
|
||||
if (id)
|
||||
id->Destroy();
|
||||
GETWIN(id)->Destroy();
|
||||
id = 0;
|
||||
}
|
||||
|
||||
bool Window::HasFocus() {
|
||||
return wxWindow::FindFocus() == id;
|
||||
return wxWindow::FindFocus() == GETWIN(id);
|
||||
}
|
||||
|
||||
PRectangle Window::GetPosition() {
|
||||
wxRect rc(id->GetPosition(), id->GetSize());
|
||||
wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize());
|
||||
return PRectangleFromwxRect(rc);
|
||||
}
|
||||
|
||||
void Window::SetPosition(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->SetSize(r);
|
||||
GETWIN(id)->SetSize(r);
|
||||
}
|
||||
|
||||
void Window::SetPositionRelative(PRectangle rc, Window) {
|
||||
@@ -393,25 +559,25 @@ void Window::SetPositionRelative(PRectangle rc, Window) {
|
||||
}
|
||||
|
||||
PRectangle Window::GetClientPosition() {
|
||||
wxSize sz = id->GetClientSize();
|
||||
wxSize sz = GETWIN(id)->GetClientSize();
|
||||
return PRectangle(0, 0, sz.x, sz.y);
|
||||
}
|
||||
|
||||
void Window::Show(bool show) {
|
||||
id->Show(show);
|
||||
GETWIN(id)->Show(show);
|
||||
}
|
||||
|
||||
void Window::InvalidateAll() {
|
||||
id->Refresh(false);
|
||||
GETWIN(id)->Refresh(false);
|
||||
}
|
||||
|
||||
void Window::InvalidateRectangle(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->Refresh(false, &r);
|
||||
GETWIN(id)->Refresh(false, &r);
|
||||
}
|
||||
|
||||
void Window::SetFont(Font &font) {
|
||||
id->SetFont(*font.GetID());
|
||||
GETWIN(id)->SetFont(*((wxFont*)font.GetID()));
|
||||
}
|
||||
|
||||
void Window::SetCursor(Cursor curs) {
|
||||
@@ -444,19 +610,23 @@ void Window::SetCursor(Cursor curs) {
|
||||
break;
|
||||
}
|
||||
|
||||
id->SetCursor(wxCursor(cursorId));
|
||||
GETWIN(id)->SetCursor(wxCursor(cursorId));
|
||||
}
|
||||
|
||||
|
||||
void Window::SetTitle(const char *s) {
|
||||
id->SetTitle(s);
|
||||
#if wxUSE_UNICODE
|
||||
#error Fix this...
|
||||
#else
|
||||
GETWIN(id)->SetTitle(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper classes for ListBox
|
||||
|
||||
// A wxListBox that gives focus to its parent if it gets it.
|
||||
// A wxListBox that gives focus back to its parent if it gets it.
|
||||
class wxSTCListBox : public wxListBox {
|
||||
public:
|
||||
wxSTCListBox(wxWindow* parent, wxWindowID id)
|
||||
@@ -532,7 +702,9 @@ BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
#define GETLB(win) (((wxSTCListBoxWin*)win)->GetLB())
|
||||
inline wxListBox* GETLB(WindowID win) {
|
||||
return (((wxSTCListBoxWin*)win)->GetLB());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -543,7 +715,7 @@ ListBox::~ListBox() {
|
||||
}
|
||||
|
||||
void ListBox::Create(Window &parent, int ctrlID) {
|
||||
id = new wxSTCListBoxWin(parent.id, ctrlID);
|
||||
id = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID);
|
||||
}
|
||||
|
||||
void ListBox::SetVisibleRows(int rows) {
|
||||
@@ -569,7 +741,7 @@ void ListBox::SetAverageCharWidth(int width) {
|
||||
}
|
||||
|
||||
void ListBox::SetFont(Font &font) {
|
||||
GETLB(id)->SetFont(*font.GetID());
|
||||
GETLB(id)->SetFont(*((wxFont*)font.GetID()));
|
||||
}
|
||||
|
||||
void ListBox::Clear() {
|
||||
@@ -605,14 +777,18 @@ int ListBox::Find(const char *prefix) {
|
||||
}
|
||||
|
||||
void ListBox::GetValue(int n, char *value, int len) {
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this...
|
||||
wxString text = GETLB(id)->GetString(n);
|
||||
strncpy(value, text.c_str(), len);
|
||||
value[len-1] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBox::Sort() {
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Menu::Menu() : id(0) {
|
||||
}
|
||||
@@ -624,26 +800,27 @@ void Menu::CreatePopUp() {
|
||||
|
||||
void Menu::Destroy() {
|
||||
if (id)
|
||||
delete id;
|
||||
delete (wxMenu*)id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
void Menu::Show(Point pt, Window &w) {
|
||||
w.GetID()->PopupMenu(id, pt.x - 4, pt.y);
|
||||
GETWIN(w.GetID())->PopupMenu((wxMenu*)id, pt.x - 4, pt.y);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Colour Platform::Chrome() {
|
||||
ColourDesired Platform::Chrome() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
return ColourDesired(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
Colour Platform::ChromeHighlight() {
|
||||
ColourDesired Platform::ChromeHighlight() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
return ColourDesired(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
const char *Platform::DefaultFont() {
|
||||
@@ -744,6 +921,26 @@ int Platform::Clamp(int val, int minVal, int maxVal) {
|
||||
}
|
||||
|
||||
|
||||
bool Platform::IsDBCSLeadByte(int codePage, char ch) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
ElapsedTime::ElapsedTime() {
|
||||
wxStartTimer();
|
||||
}
|
||||
|
||||
double ElapsedTime::Duration(bool reset) {
|
||||
double result = wxGetElapsedTime(reset);
|
||||
result /= 1000.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
8
contrib/src/stc/PlatWX.h
Normal file
8
contrib/src/stc/PlatWX.h
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
wxRect wxRectFromPRectangle(PRectangle prc);
|
||||
PRectangle PRectangleFromwxRect(wxRect rc);
|
||||
wxColour wxColourFromCA(const ColourAllocated& ca);
|
||||
|
@@ -14,10 +14,10 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ScintillaWX.h"
|
||||
#include "wx/stc/stc.h"
|
||||
#include "PlatWX.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -82,10 +82,10 @@ public:
|
||||
|
||||
void OnPaint(wxPaintEvent& evt) {
|
||||
wxPaintDC dc(this);
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(&dc);
|
||||
m_ct->PaintCT(&surfaceWindow);
|
||||
surfaceWindow.Release();
|
||||
Surface* surfaceWindow = Surface::Allocate();
|
||||
surfaceWindow->Init(&dc);
|
||||
m_ct->PaintCT(surfaceWindow);
|
||||
delete surfaceWindow;
|
||||
}
|
||||
|
||||
#if wxUSE_POPUPWIN
|
||||
@@ -184,7 +184,7 @@ void ScintillaWX::SetTicking(bool on) {
|
||||
if (timer.ticking) {
|
||||
steTimer = new wxSTCTimer(this);
|
||||
steTimer->Start(timer.tickSize);
|
||||
timer.tickerID = (int)steTimer;
|
||||
timer.tickerID = steTimer;
|
||||
} else {
|
||||
steTimer = (wxSTCTimer*)timer.tickerID;
|
||||
steTimer->Stop();
|
||||
@@ -343,12 +343,12 @@ void ScintillaWX::CreateCallTipWindow(PRectangle) {
|
||||
|
||||
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
||||
if (!label[0])
|
||||
popup.GetID()->AppendSeparator();
|
||||
((wxMenu*)popup.GetID())->AppendSeparator();
|
||||
else
|
||||
popup.GetID()->Append(cmd, label);
|
||||
((wxMenu*)popup.GetID())->Append(cmd, label);
|
||||
|
||||
if (!enabled)
|
||||
popup.GetID()->Enable(cmd, enabled);
|
||||
((wxMenu*)popup.GetID())->Enable(cmd, enabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -379,13 +379,13 @@ long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lPar
|
||||
void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
|
||||
|
||||
paintState = painting;
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(dc);
|
||||
Surface* surfaceWindow = Surface::Allocate();
|
||||
surfaceWindow->Init(dc);
|
||||
PRectangle rcPaint = PRectangleFromwxRect(rect);
|
||||
dc->BeginDrawing();
|
||||
Paint(&surfaceWindow, rcPaint);
|
||||
Paint(surfaceWindow, rcPaint);
|
||||
dc->EndDrawing();
|
||||
surfaceWindow.Release();
|
||||
delete surfaceWindow;
|
||||
if (paintState == paintAbandoned) {
|
||||
// Painting area was insufficient to cover new styling or brace highlight positions
|
||||
FullPaint();
|
||||
@@ -466,9 +466,10 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int
|
||||
|
||||
|
||||
void ScintillaWX::DoSize(int width, int height) {
|
||||
PRectangle rcClient(0,0,width,height);
|
||||
SetScrollBarsTo(rcClient);
|
||||
DropGraphics();
|
||||
// PRectangle rcClient(0,0,width,height);
|
||||
// SetScrollBarsTo(rcClient);
|
||||
// DropGraphics();
|
||||
ChangeSize();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoLoseFocus(){
|
||||
@@ -622,10 +623,10 @@ void ScintillaWX::FullPaint() {
|
||||
rcPaint = GetTextRectangle();
|
||||
paintingAllText = true;
|
||||
wxClientDC dc(stc);
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(&dc);
|
||||
Paint(&surfaceWindow, rcPaint);
|
||||
surfaceWindow.Release();
|
||||
Surface* surfaceWindow = Surface::Allocate();
|
||||
surfaceWindow->Init(&dc);
|
||||
Paint(surfaceWindow, rcPaint);
|
||||
delete surfaceWindow;
|
||||
|
||||
// stc->Refresh(FALSE);
|
||||
|
||||
|
@@ -19,6 +19,11 @@
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
|
@@ -187,6 +187,18 @@ SOURCE=.\scintilla\src\LexAVE.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexBaan.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexBullant.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexMatlab.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexConf.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -154,7 +154,7 @@ methodOverrideMap = {
|
||||
MarkerSetBackground(markerNumber, background);''',
|
||||
|
||||
('Set the symbol used for a particular marker number,',
|
||||
'and optionally the for and background colours.')),
|
||||
'and optionally the fore and background colours.')),
|
||||
|
||||
'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
|
||||
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
|
||||
@@ -226,6 +226,8 @@ methodOverrideMap = {
|
||||
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
|
||||
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
|
||||
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
|
||||
'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
|
||||
'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
|
||||
|
||||
|
||||
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
|
||||
|
@@ -17,7 +17,7 @@ SCINTILLA=.\scintilla
|
||||
|
||||
S=$(SCINTILLA)\src
|
||||
|
||||
STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S)
|
||||
STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S)
|
||||
|
||||
LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
|
||||
|
||||
@@ -34,6 +34,9 @@ OBJECTS = \
|
||||
KeyWords.obj \
|
||||
LexAVE.obj \
|
||||
LexAda.obj \
|
||||
LexBaan.obj \
|
||||
LexBullant.obj \
|
||||
LexMatlab.obj \
|
||||
LexCPP.obj \
|
||||
LexConf.obj \
|
||||
LexCrontab.obj \
|
||||
|
@@ -7,7 +7,7 @@ WXDIR = ../../..
|
||||
|
||||
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
|
||||
S=$(SCINTILLA)/src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
|
||||
|
||||
OBJECTS = \
|
||||
$(S)/AutoComplete.$(OBJSUFF) \
|
||||
@@ -22,6 +22,9 @@ OBJECTS = \
|
||||
$(S)/KeyWords.$(OBJSUFF) \
|
||||
$(S)/LexAVE.$(OBJSUFF) \
|
||||
$(S)/LexAda.$(OBJSUFF) \
|
||||
$(S)/LexBaan.$(OBJSUFF) \
|
||||
$(S)/LexBullant.$(OBJSUFF) \
|
||||
$(S)/LexMatlab.$(OBJSUFF) \
|
||||
$(S)/LexCPP.$(OBJSUFF) \
|
||||
$(S)/LexConf.$(OBJSUFF) \
|
||||
$(S)/LexCrontab.$(OBJSUFF) \
|
||||
|
@@ -9,7 +9,7 @@
|
||||
WXDIR = $(WXWIN)
|
||||
SCINTILLA=.\scintilla
|
||||
S=$(SCINTILLA)\src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
|
||||
NOPCH=1
|
||||
|
||||
!include $(WXDIR)\src\makevc.env
|
||||
@@ -27,6 +27,9 @@ OBJECTS = \
|
||||
$(D)\KeyWords.obj \
|
||||
$(D)\LexAVE.obj \
|
||||
$(D)\LexAda.obj \
|
||||
$(D)\LexBaan.obj \
|
||||
$(D)\LexBullant.obj \
|
||||
$(D)\LexMatlab.obj \
|
||||
$(D)\LexCPP.obj \
|
||||
$(D)\LexConf.obj \
|
||||
$(D)\LexCrontab.obj \
|
||||
|
@@ -3,5 +3,5 @@ scintilla/include directories from the Scintilla/SCiTE source
|
||||
distribution. All other code needed to implement Scintilla on top of
|
||||
wxWindows is located in the directory above this one.
|
||||
|
||||
The current version of the Scintilla code is 1.40
|
||||
The current version of the Scintilla code is 1.45
|
||||
|
||||
|
@@ -15,25 +15,25 @@ typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyl
|
||||
*/
|
||||
class LexerModule {
|
||||
protected:
|
||||
LexerModule *next;
|
||||
const LexerModule *next;
|
||||
int language;
|
||||
const char *languageName;
|
||||
LexerFunction fnLexer;
|
||||
LexerFunction fnFolder;
|
||||
|
||||
static LexerModule *base;
|
||||
static const LexerModule *base;
|
||||
static int nextLanguage;
|
||||
|
||||
public:
|
||||
const char *languageName;
|
||||
LexerModule(int language_, LexerFunction fnLexer_,
|
||||
const char *languageName_=0, LexerFunction fnFolder_=0);
|
||||
int GetLanguage() { return language; }
|
||||
int GetLanguage() const { return language; }
|
||||
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler);
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
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);
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
static const LexerModule *Find(int language);
|
||||
static const LexerModule *Find(const char *languageName);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,7 @@
|
||||
** 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.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef PLATFORM_H
|
||||
@@ -18,8 +18,13 @@
|
||||
#define PLAT_GTK_WIN32 0
|
||||
#define PLAT_WIN 0
|
||||
#define PLAT_WX 0
|
||||
#define PLAT_FOX 0
|
||||
|
||||
#if defined(__WX__)
|
||||
#if defined(FOX)
|
||||
#undef PLAT_FOX
|
||||
#define PLAT_FOX 1
|
||||
|
||||
#elif defined(__WX__)
|
||||
#undef PLAT_WX
|
||||
#define PLAT_WX 1
|
||||
|
||||
@@ -39,79 +44,14 @@
|
||||
#endif
|
||||
|
||||
|
||||
// Include the main header for each platform
|
||||
|
||||
#if PLAT_GTK
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4505 4514 4710 4800)
|
||||
#endif
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#endif
|
||||
|
||||
#if PLAT_WIN
|
||||
#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out
|
||||
// Vassili Bourdo: shut up annoying Visual C++ warnings:
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4244 4309 4710 4800)
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#endif
|
||||
|
||||
#if PLAT_WX
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#define ColourID scColourID
|
||||
#define FontID scFontID
|
||||
#define SurfaceID scSurfaceID
|
||||
#define WindowID scWindowID
|
||||
#define MenuID scMenuID
|
||||
#define Point scPoint
|
||||
#define PRectangle scPRectangle
|
||||
#define Colour scColour
|
||||
#define ColourPair scColourPair
|
||||
#define Window scWindow
|
||||
#define Palette scPalette
|
||||
#define Font scFont
|
||||
#define Surface scSurface
|
||||
#define Window scWindow
|
||||
#define ListBox scListBox
|
||||
#define Menu scMenu
|
||||
#define Platform scPlatform
|
||||
#define TextRange scTextRange
|
||||
#define KeyMap scKeyMap
|
||||
#define Style scStyle
|
||||
|
||||
|
||||
// Underlying the implementation of the platform classes are platform specific types.
|
||||
// Sometimes these need to be passed around by client code so they are defined here
|
||||
|
||||
#if PLAT_GTK
|
||||
typedef GdkColor ColourID;
|
||||
typedef GdkFont* FontID;
|
||||
typedef GdkDrawable* SurfaceID;
|
||||
typedef GtkWidget* WindowID;
|
||||
typedef GtkItemFactory* MenuID;
|
||||
#endif
|
||||
|
||||
#if PLAT_WIN
|
||||
typedef COLORREF ColourID;
|
||||
typedef HFONT FontID;
|
||||
typedef HDC SurfaceID;
|
||||
typedef HWND WindowID;
|
||||
typedef HMENU MenuID;
|
||||
#endif
|
||||
|
||||
#if PLAT_WX
|
||||
typedef wxColour ColourID;
|
||||
typedef wxFont* FontID;
|
||||
typedef wxDC* SurfaceID;
|
||||
typedef wxWindow* WindowID;
|
||||
typedef wxMenu* MenuID;
|
||||
#endif
|
||||
typedef void *FontID;
|
||||
typedef void *SurfaceID;
|
||||
typedef void *WindowID;
|
||||
typedef void *MenuID;
|
||||
typedef void *TickerID;
|
||||
|
||||
/**
|
||||
* A geometric point class.
|
||||
@@ -168,42 +108,88 @@ public:
|
||||
int Height() { return bottom - top; }
|
||||
};
|
||||
|
||||
#if PLAT_WX
|
||||
wxRect wxRectFromPRectangle(PRectangle prc);
|
||||
PRectangle PRectangleFromwxRect(wxRect rc);
|
||||
#endif
|
||||
/**
|
||||
* In some circumstances, including Win32 in paletted mode and GTK+, each colour
|
||||
* must be allocated before use. The desired colours are held in the ColourDesired class,
|
||||
* and after allocation the allocation entry is stored in the ColourAllocated class. In other
|
||||
* circumstances, such as Win32 in true colour mode, the allocation process just copies
|
||||
* the RGB values from the desired to the allocated class.
|
||||
* As each desired colour requires allocation before it can be used, the ColourPair class
|
||||
* holds both a ColourDesired and a ColourAllocated
|
||||
* The Palette class is responsible for managing the palette of colours which contains a
|
||||
* list of ColourPair objects and performs the allocation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A colour class.
|
||||
* Holds a desired RGB colour.
|
||||
*/
|
||||
class Colour {
|
||||
ColourID co;
|
||||
class ColourDesired {
|
||||
long co;
|
||||
public:
|
||||
Colour(long lcol=0);
|
||||
Colour(unsigned int red, unsigned int green, unsigned int blue);
|
||||
bool operator==(const Colour &other) const;
|
||||
long AsLong() const;
|
||||
unsigned int GetRed();
|
||||
unsigned int GetGreen();
|
||||
unsigned int GetBlue();
|
||||
ColourDesired(long lcol=0) {
|
||||
co = lcol;
|
||||
}
|
||||
|
||||
friend class Surface;
|
||||
friend class Palette;
|
||||
ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
|
||||
co = red | (green << 8) | (blue << 16);
|
||||
}
|
||||
|
||||
bool operator==(const ColourDesired &other) const {
|
||||
return co == other.co;
|
||||
}
|
||||
|
||||
void Set(long lcol) {
|
||||
co = lcol;
|
||||
}
|
||||
|
||||
long AsLong() const {
|
||||
return co;
|
||||
}
|
||||
|
||||
unsigned int GetRed() {
|
||||
return co & 0xff;
|
||||
}
|
||||
|
||||
unsigned int GetGreen() {
|
||||
return (co >> 8) & 0xff;
|
||||
}
|
||||
|
||||
unsigned int GetBlue() {
|
||||
return (co >> 16) & 0xff;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Colour pairs hold a desired colour and the colour that the graphics engine
|
||||
* allocates to approximate the desired colour.
|
||||
* To make palette management more automatic, ColourPairs could register at
|
||||
* construction time with a palette management object.
|
||||
* Holds an allocated RGB colour which may be an approximation to the desired colour.
|
||||
*/
|
||||
class ColourAllocated {
|
||||
long coAllocated;
|
||||
|
||||
public:
|
||||
|
||||
ColourAllocated(long lcol=0) {
|
||||
coAllocated = lcol;
|
||||
}
|
||||
|
||||
void Set(long lcol) {
|
||||
coAllocated = lcol;
|
||||
}
|
||||
|
||||
long AsLong() const {
|
||||
return coAllocated;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Colour pairs hold a desired colour and an allocated colour.
|
||||
*/
|
||||
struct ColourPair {
|
||||
Colour desired;
|
||||
Colour allocated;
|
||||
ColourDesired desired;
|
||||
ColourAllocated allocated;
|
||||
|
||||
ColourPair(Colour desired_=Colour(0,0,0)) {
|
||||
ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
|
||||
desired = desired_;
|
||||
allocated = desired;
|
||||
allocated.Set(desired.AsLong());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -217,14 +203,13 @@ class Palette {
|
||||
enum {numEntries = 100};
|
||||
ColourPair entries[numEntries];
|
||||
#if PLAT_GTK
|
||||
GdkColor *allocatedPalette;
|
||||
void *allocatedPalette; // GdkColor *
|
||||
int allocatedLen;
|
||||
#elif PLAT_WIN
|
||||
HPALETTE hpal;
|
||||
#elif PLAT_WX
|
||||
// wxPalette* pal; // **** Is this needed?
|
||||
#endif
|
||||
public:
|
||||
#if PLAT_WIN
|
||||
void *hpal;
|
||||
#endif
|
||||
bool allowRealization;
|
||||
|
||||
Palette();
|
||||
@@ -240,8 +225,6 @@ public:
|
||||
void WantFind(ColourPair &cp, bool want);
|
||||
|
||||
void Allocate(Window &w);
|
||||
|
||||
friend class Surface;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -267,6 +250,7 @@ public:
|
||||
// Alias another font - caller guarantees not to Release
|
||||
void SetID(FontID id_) { id = id_; }
|
||||
friend class Surface;
|
||||
friend class SurfaceImpl;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -274,97 +258,67 @@ public:
|
||||
*/
|
||||
class Surface {
|
||||
private:
|
||||
bool unicodeMode;
|
||||
#if PLAT_GTK
|
||||
GdkDrawable *drawable;
|
||||
GdkGC *gc;
|
||||
GdkPixmap *ppixmap;
|
||||
int x;
|
||||
int y;
|
||||
bool inited;
|
||||
bool createdGC;
|
||||
#elif PLAT_WIN
|
||||
HDC hdc;
|
||||
bool hdcOwned;
|
||||
HPEN pen;
|
||||
HPEN penOld;
|
||||
HBRUSH brush;
|
||||
HBRUSH brushOld;
|
||||
HFONT font;
|
||||
HFONT fontOld;
|
||||
HBITMAP bitmap;
|
||||
HBITMAP bitmapOld;
|
||||
HPALETTE paletteOld;
|
||||
#elif PLAT_WX
|
||||
wxDC* hdc;
|
||||
bool hdcOwned;
|
||||
wxBitmap* bitmap;
|
||||
int x;
|
||||
int y;
|
||||
#endif
|
||||
|
||||
// Private so Surface objects can not be copied
|
||||
Surface(const Surface &) {}
|
||||
Surface &operator=(const Surface &) { return *this; }
|
||||
#if PLAT_WIN || PLAT_WX
|
||||
void BrushColor(Colour back);
|
||||
void SetFont(Font &font_);
|
||||
#endif
|
||||
public:
|
||||
Surface();
|
||||
~Surface();
|
||||
Surface() {};
|
||||
virtual ~Surface() {};
|
||||
static Surface *Allocate();
|
||||
|
||||
void Init();
|
||||
void Init(SurfaceID hdc_);
|
||||
void InitPixMap(int width, int height, Surface *surface_);
|
||||
virtual void Init()=0;
|
||||
virtual void Init(SurfaceID sid)=0;
|
||||
virtual void InitPixMap(int width, int height, Surface *surface_)=0;
|
||||
|
||||
void Release();
|
||||
bool Initialised();
|
||||
void PenColour(Colour fore);
|
||||
int LogPixelsY();
|
||||
int DeviceHeightFont(int points);
|
||||
void MoveTo(int x_, int y_);
|
||||
void LineTo(int x_, int y_);
|
||||
void Polygon(Point *pts, int npts, Colour fore, Colour back);
|
||||
void RectangleDraw(PRectangle rc, Colour fore, Colour back);
|
||||
void FillRectangle(PRectangle rc, Colour back);
|
||||
void FillRectangle(PRectangle rc, Surface &surfacePattern);
|
||||
void RoundedRectangle(PRectangle rc, Colour fore, Colour back);
|
||||
void Ellipse(PRectangle rc, Colour fore, Colour back);
|
||||
void Copy(PRectangle rc, Point from, Surface &surfaceSource);
|
||||
virtual void Release()=0;
|
||||
virtual bool Initialised()=0;
|
||||
virtual void PenColour(ColourAllocated fore)=0;
|
||||
virtual int LogPixelsY()=0;
|
||||
virtual int DeviceHeightFont(int points)=0;
|
||||
virtual void MoveTo(int x_, int y_)=0;
|
||||
virtual void LineTo(int x_, int y_)=0;
|
||||
virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
|
||||
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
|
||||
virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
|
||||
|
||||
void DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
|
||||
void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
|
||||
void MeasureWidths(Font &font_, const char *s, int len, int *positions);
|
||||
int WidthText(Font &font_, const char *s, int len);
|
||||
int WidthChar(Font &font_, char ch);
|
||||
int Ascent(Font &font_);
|
||||
int Descent(Font &font_);
|
||||
int InternalLeading(Font &font_);
|
||||
int ExternalLeading(Font &font_);
|
||||
int Height(Font &font_);
|
||||
int AverageCharWidth(Font &font_);
|
||||
virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
|
||||
virtual int WidthText(Font &font_, const char *s, int len)=0;
|
||||
virtual int WidthChar(Font &font_, char ch)=0;
|
||||
virtual int Ascent(Font &font_)=0;
|
||||
virtual int Descent(Font &font_)=0;
|
||||
virtual int InternalLeading(Font &font_)=0;
|
||||
virtual int ExternalLeading(Font &font_)=0;
|
||||
virtual int Height(Font &font_)=0;
|
||||
virtual int AverageCharWidth(Font &font_)=0;
|
||||
|
||||
int SetPalette(Palette *pal, bool inBackGround);
|
||||
void SetClip(PRectangle rc);
|
||||
void FlushCachedState();
|
||||
virtual int SetPalette(Palette *pal, bool inBackGround)=0;
|
||||
virtual void SetClip(PRectangle rc)=0;
|
||||
virtual void FlushCachedState()=0;
|
||||
|
||||
void SetUnicodeMode(bool unicodeMode_) {
|
||||
unicodeMode=unicodeMode_;
|
||||
}
|
||||
virtual void SetUnicodeMode(bool unicodeMode_)=0;
|
||||
};
|
||||
|
||||
/**
|
||||
* A simple callback action passing one piece of untyped user data.
|
||||
*/
|
||||
typedef void (*CallBackAction)(void*);
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
friend class ListBox;
|
||||
protected:
|
||||
WindowID id;
|
||||
public:
|
||||
Window() : id(0) {}
|
||||
Window(const Window &source) : id(source.id) {}
|
||||
Window() : id(0), cursorLast(cursorInvalid) {}
|
||||
Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
|
||||
virtual ~Window();
|
||||
Window &operator=(WindowID id_) {
|
||||
id = id_;
|
||||
@@ -382,20 +336,19 @@ public:
|
||||
void InvalidateAll();
|
||||
void InvalidateRectangle(PRectangle rc);
|
||||
virtual void SetFont(Font &font);
|
||||
enum Cursor { cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
|
||||
enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
|
||||
void SetCursor(Cursor curs);
|
||||
void SetTitle(const char *s);
|
||||
#if PLAT_WIN
|
||||
LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0);
|
||||
int GetDlgCtrlID();
|
||||
HINSTANCE GetInstance();
|
||||
#endif
|
||||
private:
|
||||
Cursor cursorLast;
|
||||
};
|
||||
|
||||
/**
|
||||
* Listbox management.
|
||||
*/
|
||||
|
||||
class ListBox : public Window {
|
||||
private:
|
||||
#if PLAT_GTK
|
||||
WindowID list;
|
||||
WindowID scroller;
|
||||
@@ -404,6 +357,9 @@ class ListBox : public Window {
|
||||
int desiredVisibleRows;
|
||||
unsigned int maxItemCharacters;
|
||||
unsigned int aveCharWidth;
|
||||
public:
|
||||
CallBackAction doubleClickAction;
|
||||
void *doubleClickActionData;
|
||||
public:
|
||||
ListBox();
|
||||
virtual ~ListBox();
|
||||
@@ -420,6 +376,10 @@ public:
|
||||
int Find(const char *prefix);
|
||||
void GetValue(int n, char *value, int len);
|
||||
void Sort();
|
||||
void SetDoubleClickAction(CallBackAction action, void *data) {
|
||||
doubleClickAction = action;
|
||||
doubleClickActionData = data;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -435,6 +395,14 @@ public:
|
||||
void Show(Point pt, Window &w);
|
||||
};
|
||||
|
||||
class ElapsedTime {
|
||||
long bigBit;
|
||||
long littleBit;
|
||||
public:
|
||||
ElapsedTime();
|
||||
double Duration(bool reset=false);
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -448,8 +416,8 @@ public:
|
||||
// but gcc warns about this
|
||||
Platform() {}
|
||||
~Platform() {}
|
||||
static Colour Chrome();
|
||||
static Colour ChromeHighlight();
|
||||
static ColourDesired Chrome();
|
||||
static ColourDesired ChromeHighlight();
|
||||
static const char *DefaultFont();
|
||||
static int DefaultFontSize();
|
||||
static unsigned int DoubleClickTime();
|
||||
@@ -457,6 +425,7 @@ public:
|
||||
static bool IsKeyDown(int key);
|
||||
static long SendScintilla(
|
||||
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
|
||||
static bool IsDBCSLeadByte(int codePage, char ch);
|
||||
|
||||
// These are utility functions not really tied to a platform
|
||||
static int Minimum(int a, int b);
|
||||
@@ -483,4 +452,9 @@ public:
|
||||
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
|
||||
#endif
|
||||
|
||||
// Shut up annoying Visual C++ warnings:
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4244 4309 4514 4710)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file PropSet.h
|
||||
** A Java style properties file module.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef PROPSET_H
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
SString Expand(const char *withVars);
|
||||
int GetInt(const char *key, int defaultValue=0);
|
||||
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();
|
||||
char *ToString(); // Caller must delete[] the return value
|
||||
bool GetFirst(char **key, char **val);
|
||||
@@ -70,7 +70,8 @@ public:
|
||||
char *Allocate(int size);
|
||||
void SetFromAllocated();
|
||||
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, SString wordCharacters="");
|
||||
char *GetNearestWords(const char *wordStart, int searchLen=-1,
|
||||
bool ignoreCase=false, char otherSeparator='\0');
|
||||
};
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#ifndef SSTRING_H
|
||||
#define SSTRING_H
|
||||
|
||||
// These functions are implemented because each platform calls them something different
|
||||
// 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);
|
||||
@@ -17,93 +17,48 @@ bool EqualCaseInsensitive(const char *a, const char *b);
|
||||
// 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;
|
||||
/** Type of string lengths (sizes) and positions (indexes). */
|
||||
typedef unsigned int lenpos_t;
|
||||
/** Out of bounds value indicating that the string argument should be measured. */
|
||||
enum { measure_length=0xffffffffU};
|
||||
|
||||
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
|
||||
private:
|
||||
char *s; ///< The C string
|
||||
lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
|
||||
lenpos_t sLen; ///< The size of the string in s
|
||||
lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
|
||||
enum { sizeGrowthDefault = 64 };
|
||||
bool grow(lenpos_t lenNew) {
|
||||
while (sizeGrowth * 6 < lenNew) {
|
||||
sizeGrowth *= 2;
|
||||
}
|
||||
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) {
|
||||
char *sNew = new char[lenNew + sizeGrowth + 1];
|
||||
if (sNew) {
|
||||
if (s) {
|
||||
*s = '\0';
|
||||
memcpy(sNew, s, sLen);
|
||||
delete []s;
|
||||
}
|
||||
sLen = 0;
|
||||
s = sNew;
|
||||
s[sLen] = '\0';
|
||||
sSize = lenNew + sizeGrowth;
|
||||
}
|
||||
/** Size of buffer. */
|
||||
size_type size(void) const { ///<
|
||||
if (s)
|
||||
return sSize;
|
||||
else
|
||||
return 0;
|
||||
return sNew != 0;
|
||||
}
|
||||
/** Size of string in buffer. */
|
||||
int length() const {
|
||||
return sLen;
|
||||
}
|
||||
SString &assign(const char* sOther, int sSize_ = -1) {
|
||||
|
||||
SString &assign(const char *sOther, lenpos_t sSize_=measure_length) {
|
||||
if (!sOther) {
|
||||
sSize_ = 0;
|
||||
}
|
||||
if (sSize_ < 0) {
|
||||
} else if (sSize_ == measure_length) {
|
||||
sSize_ = strlen(sOther);
|
||||
}
|
||||
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
|
||||
@@ -114,7 +69,7 @@ public:
|
||||
sLen = sSize_;
|
||||
} else {
|
||||
delete []s;
|
||||
s = StringDup(sOther, sSize_);
|
||||
s = StringAllocate(sOther, sSize_);
|
||||
if (s) {
|
||||
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
|
||||
sLen = strlen(s);
|
||||
@@ -124,8 +79,56 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SString &assign(const SString& sOther, int sSize_ = -1) {
|
||||
return assign(sOther.s, sSize_);
|
||||
|
||||
public:
|
||||
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
|
||||
}
|
||||
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(source.s);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(s_);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(const char *s_, lenpos_t first, lenpos_t last) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(s_ + first, last - first);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(int i) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%0d", i);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(double d, int precision) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%.*f", precision, d);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
~SString() {
|
||||
delete []s;
|
||||
s = 0;
|
||||
sSize = 0;
|
||||
sLen = 0;
|
||||
}
|
||||
void clear() {
|
||||
if (s) {
|
||||
*s = '\0';
|
||||
}
|
||||
sLen = 0;
|
||||
}
|
||||
/** Size of buffer. */
|
||||
lenpos_t size() const {
|
||||
if (s)
|
||||
return sSize;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
/** Size of string in buffer. */
|
||||
lenpos_t length() const {
|
||||
return sLen;
|
||||
}
|
||||
SString &operator=(const char *source) {
|
||||
return assign(source);
|
||||
@@ -162,7 +165,7 @@ public:
|
||||
else
|
||||
return false;
|
||||
}
|
||||
void setsizegrowth(int sizeGrowth_) {
|
||||
void setsizegrowth(lenpos_t sizeGrowth_) {
|
||||
sizeGrowth = sizeGrowth_;
|
||||
}
|
||||
const char *c_str() const {
|
||||
@@ -179,77 +182,167 @@ public:
|
||||
sLen = 0;
|
||||
return sRet;
|
||||
}
|
||||
char operator[](int i) const {
|
||||
char operator[](lenpos_t 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)
|
||||
SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') {
|
||||
if (!sOther) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
int lenSep = 0;
|
||||
if (sLen && sep) // Only add a separator if not empty
|
||||
if (sLen && sep) { // Only add a separator if not empty
|
||||
lenSep = 1;
|
||||
int lenNew = sLen + sLenOther + lenSep;
|
||||
if (lenNew + 1 < sSize) {
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther + lenSep;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew + 1 < sSize) || (grow(lenNew))) {
|
||||
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;
|
||||
}
|
||||
s[sLen] = '\0';
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SString &operator +=(const char *sOther) {
|
||||
return append(sOther, -1);
|
||||
SString &operator+=(const char *sOther) {
|
||||
return append(sOther, static_cast<lenpos_t>(measure_length));
|
||||
}
|
||||
SString &operator +=(const SString &sOther) {
|
||||
SString &operator+=(const SString &sOther) {
|
||||
return append(sOther.s, sOther.sSize);
|
||||
}
|
||||
SString &operator +=(char ch) {
|
||||
SString &operator+=(char ch) {
|
||||
return append(&ch, 1);
|
||||
}
|
||||
SString &appendwithseparator(const char* sOther, char sep) {
|
||||
SString &appendwithseparator(const char *sOther, char sep) {
|
||||
return append(sOther, strlen(sOther), sep);
|
||||
}
|
||||
SString &insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther=measure_length) {
|
||||
if (!sOther) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew + 1 < sSize) || grow(lenNew)) {
|
||||
lenpos_t moveChars = sLen - pos + 1;
|
||||
for (lenpos_t i = moveChars; i > 0; i--) {
|
||||
s[pos + sLenOther + i - 1] = s[pos + i - 1];
|
||||
}
|
||||
memcpy(s + pos, sOther, sLenOther);
|
||||
sLen = lenNew;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/** Remove @a len characters from the @a pos position, included.
|
||||
* Characters at pos + len and beyond replace characters at pos.
|
||||
* If @a len is 0, or greater than the length of the string
|
||||
* starting at @a pos, the string is just truncated at @a pos.
|
||||
*/
|
||||
void remove(lenpos_t pos, lenpos_t len) {
|
||||
if (len < 1 || pos + len >= sLen) {
|
||||
s[pos] = '\0';
|
||||
sLen = pos;
|
||||
} else {
|
||||
for (lenpos_t i = pos; i < sLen - len + 1; i++) {
|
||||
s[i] = s[i+len];
|
||||
}
|
||||
sLen -= len;
|
||||
}
|
||||
}
|
||||
/** Read an integral numeric value from the string. */
|
||||
int value() const {
|
||||
if (s)
|
||||
return atoi(s);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
void substitute(char find, char replace) {
|
||||
int search(const char *sFind, lenpos_t start=0) {
|
||||
if (start < sLen) {
|
||||
const char *sFound = strstr(s + start, sFind);
|
||||
if (sFound) {
|
||||
return sFound - s;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
bool contains(const char *sFind) {
|
||||
return search(sFind) >= 0;
|
||||
}
|
||||
int substitute(char chFind, char chReplace) {
|
||||
int c = 0;
|
||||
char *t = s;
|
||||
while (t) {
|
||||
t = strchr(t, find);
|
||||
t = strchr(t, chFind);
|
||||
if (t) {
|
||||
*t = replace;
|
||||
*t = chReplace;
|
||||
t++;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
int substitute(const char *sFind, const char *sReplace) {
|
||||
int c = 0;
|
||||
lenpos_t lenFind = strlen(sFind);
|
||||
lenpos_t lenReplace = strlen(sReplace);
|
||||
int posFound = search(sFind);
|
||||
while (posFound >= 0) {
|
||||
remove(posFound, lenFind);
|
||||
insert(posFound, sReplace, lenReplace);
|
||||
posFound = search(sFind, posFound + lenReplace);
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
int remove(const char *sFind) {
|
||||
return substitute(sFind, "");
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
static char *StringAllocate(
|
||||
const char *s, ///< The string to duplicate
|
||||
lenpos_t len=measure_length) ///< The length of memory to allocate. Optional.
|
||||
{
|
||||
if (s == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (len == measure_length) {
|
||||
len = strlen(s);
|
||||
}
|
||||
char *sNew = new char[len + 1];
|
||||
if (sNew) {
|
||||
strncpy(sNew, s, len);
|
||||
sNew[len] = '\0';
|
||||
}
|
||||
return sNew;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
SString::lenpos_t len=SString::measure_length) ///< The length of memory to allocate. Optional.
|
||||
{
|
||||
return SString::StringAllocate(s, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file SciLexer.h
|
||||
** Interface to the added lexer functions in the SciLexer version of the edit control.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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
|
||||
@@ -41,6 +41,12 @@
|
||||
#define SCLEX_EIFFELKW 24
|
||||
#define SCLEX_TCL 25
|
||||
#define SCLEX_NNCRONTAB 26
|
||||
#define SCLEX_BULLANT 27
|
||||
#define SCLEX_VBSCRIPT 28
|
||||
#define SCLEX_ASP 29
|
||||
#define SCLEX_PHP 30
|
||||
#define SCLEX_BAAN 31
|
||||
#define SCLEX_MATLAB 32
|
||||
#define SCLEX_AUTOMATIC 1000
|
||||
#define SCE_P_DEFAULT 0
|
||||
#define SCE_P_COMMENTLINE 1
|
||||
@@ -75,6 +81,15 @@
|
||||
#define SCE_C_WORD2 16
|
||||
#define SCE_C_COMMENTDOCKEYWORD 17
|
||||
#define SCE_C_COMMENTDOCKEYWORDERROR 18
|
||||
#define SCE_B_DEFAULT 0
|
||||
#define SCE_B_COMMENT 1
|
||||
#define SCE_B_NUMBER 2
|
||||
#define SCE_B_KEYWORD 3
|
||||
#define SCE_B_STRING 4
|
||||
#define SCE_B_PREPROCESSOR 5
|
||||
#define SCE_B_OPERATOR 6
|
||||
#define SCE_B_IDENTIFIER 7
|
||||
#define SCE_B_DATE 8
|
||||
#define SCE_H_DEFAULT 0
|
||||
#define SCE_H_TAG 1
|
||||
#define SCE_H_TAGUNKNOWN 2
|
||||
@@ -233,6 +248,11 @@
|
||||
#define SCE_LUA_OPERATOR 10
|
||||
#define SCE_LUA_IDENTIFIER 11
|
||||
#define SCE_LUA_STRINGEOL 12
|
||||
#define SCE_LUA_WORD2 13
|
||||
#define SCE_LUA_WORD3 14
|
||||
#define SCE_LUA_WORD4 15
|
||||
#define SCE_LUA_WORD5 16
|
||||
#define SCE_LUA_WORD6 17
|
||||
#define SCE_ERR_DEFAULT 0
|
||||
#define SCE_ERR_PYTHON 1
|
||||
#define SCE_ERR_GCC 2
|
||||
@@ -291,6 +311,17 @@
|
||||
#define SCE_ADA_OPERATOR 6
|
||||
#define SCE_ADA_IDENTIFIER 7
|
||||
#define SCE_ADA_STRINGEOL 8
|
||||
#define SCE_BAAN_DEFAULT 0
|
||||
#define SCE_BAAN_COMMENT 1
|
||||
#define SCE_BAAN_COMMENTDOC 2
|
||||
#define SCE_BAAN_NUMBER 3
|
||||
#define SCE_BAAN_WORD 4
|
||||
#define SCE_BAAN_STRING 5
|
||||
#define SCE_BAAN_PREPROCESSOR 6
|
||||
#define SCE_BAAN_OPERATOR 7
|
||||
#define SCE_BAAN_IDENTIFIER 8
|
||||
#define SCE_BAAN_STRINGEOL 9
|
||||
#define SCE_BAAN_WORD2 10
|
||||
#define SCE_LISP_DEFAULT 0
|
||||
#define SCE_LISP_COMMENT 1
|
||||
#define SCE_LISP_NUMBER 2
|
||||
@@ -319,6 +350,14 @@
|
||||
#define SCE_NNCRONTAB_STRING 8
|
||||
#define SCE_NNCRONTAB_ENVIRONMENT 9
|
||||
#define SCE_NNCRONTAB_IDENTIFIER 10
|
||||
#define SCE_MATLAB_DEFAULT 0
|
||||
#define SCE_MATLAB_COMMENT 1
|
||||
#define SCE_MATLAB_COMMAND 2
|
||||
#define SCE_MATLAB_NUMBER 3
|
||||
#define SCE_MATLAB_KEYWORD 4
|
||||
#define SCE_MATLAB_STRING 5
|
||||
#define SCE_MATLAB_OPERATOR 6
|
||||
#define SCE_MATLAB_IDENTIFIER 7
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
#endif
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file Scintilla.h
|
||||
** Interface to the edit control.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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
|
||||
@@ -12,10 +12,11 @@
|
||||
#define SCINTILLA_H
|
||||
|
||||
#if PLAT_WIN
|
||||
#ifdef STATIC_BUILD
|
||||
void Scintilla_RegisterClasses(HINSTANCE hInstance);
|
||||
#endif
|
||||
// Return false on failure:
|
||||
bool Scintilla_RegisterClasses(void *hInstance);
|
||||
bool Scintilla_ReleaseResources();
|
||||
#endif
|
||||
int Scintilla_LinkLexers();
|
||||
|
||||
// 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.
|
||||
@@ -99,6 +100,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_MARK_CIRCLEPLUSCONNECTED 19
|
||||
#define SC_MARK_CIRCLEMINUS 20
|
||||
#define SC_MARK_CIRCLEMINUSCONNECTED 21
|
||||
#define SC_MARK_BACKGROUND 22
|
||||
#define SC_MARK_CHARACTER 10000
|
||||
#define SC_MARKNUM_FOLDEREND 25
|
||||
#define SC_MARKNUM_FOLDEROPENMID 26
|
||||
@@ -107,6 +109,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_MARKNUM_FOLDERSUB 29
|
||||
#define SC_MARKNUM_FOLDER 30
|
||||
#define SC_MARKNUM_FOLDEROPEN 31
|
||||
#define SC_MASK_FOLDERS 0xFE000000
|
||||
#define SCI_MARKERDEFINE 2040
|
||||
#define SCI_MARKERSETFORE 2041
|
||||
#define SCI_MARKERSETBACK 2042
|
||||
@@ -187,10 +190,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define INDIC_TT 2
|
||||
#define INDIC_DIAGONAL 3
|
||||
#define INDIC_STRIKE 4
|
||||
#define INDIC0_MASK 32
|
||||
#define INDIC1_MASK 64
|
||||
#define INDIC2_MASK 128
|
||||
#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
|
||||
#define INDIC0_MASK 0x20
|
||||
#define INDIC1_MASK 0x40
|
||||
#define INDIC2_MASK 0x80
|
||||
#define INDICS_MASK 0xE0
|
||||
#define SCI_INDICSETSTYLE 2080
|
||||
#define SCI_INDICGETSTYLE 2081
|
||||
#define SCI_INDICSETFORE 2082
|
||||
@@ -204,6 +207,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_SETCARETLINEVISIBLE 2096
|
||||
#define SCI_GETCARETLINEBACK 2097
|
||||
#define SCI_SETCARETLINEBACK 2098
|
||||
#define SCI_STYLESETCHANGEABLE 2099
|
||||
#define SCI_AUTOCSHOW 2100
|
||||
#define SCI_AUTOCCANCEL 2101
|
||||
#define SCI_AUTOCACTIVE 2102
|
||||
@@ -223,6 +227,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_USERLISTSHOW 2117
|
||||
#define SCI_AUTOCSETAUTOHIDE 2118
|
||||
#define SCI_AUTOCGETAUTOHIDE 2119
|
||||
#define SCI_AUTOCSETDROPRESTOFWORD 2270
|
||||
#define SCI_AUTOCGETDROPRESTOFWORD 2271
|
||||
#define SCI_SETINDENT 2122
|
||||
#define SCI_GETINDENT 2123
|
||||
#define SCI_SETUSETABS 2124
|
||||
@@ -341,6 +347,18 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_TIME_FOREVER 10000000
|
||||
#define SCI_SETMOUSEDWELLTIME 2264
|
||||
#define SCI_GETMOUSEDWELLTIME 2265
|
||||
#define SCI_WORDSTARTPOSITION 2266
|
||||
#define SCI_WORDENDPOSITION 2267
|
||||
#define SC_WRAP_NONE 0
|
||||
#define SC_WRAP_WORD 1
|
||||
#define SCI_SETWRAPMODE 2268
|
||||
#define SCI_GETWRAPMODE 2269
|
||||
#define SC_CACHE_NONE 0
|
||||
#define SC_CACHE_CARET 1
|
||||
#define SC_CACHE_PAGE 2
|
||||
#define SC_CACHE_DOCUMENT 3
|
||||
#define SCI_SETLAYOUTCACHE 2272
|
||||
#define SCI_GETLAYOUTCACHE 2273
|
||||
#define SCI_LINEDOWN 2300
|
||||
#define SCI_LINEDOWNEXTEND 2301
|
||||
#define SCI_LINEUP 2302
|
||||
@@ -385,6 +403,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_UPPERCASE 2341
|
||||
#define SCI_LINESCROLLDOWN 2342
|
||||
#define SCI_LINESCROLLUP 2343
|
||||
#define SCI_DELETEBACKNOTLINE 2344
|
||||
#define SCI_MOVECARETINSIDEVIEW 2401
|
||||
#define SCI_LINELENGTH 2350
|
||||
#define SCI_BRACEHIGHLIGHT 2351
|
||||
@@ -432,6 +451,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_CURSORWAIT 3
|
||||
#define SCI_SETCURSOR 2386
|
||||
#define SCI_GETCURSOR 2387
|
||||
#define SCI_SETCONTROLCHARSYMBOL 2388
|
||||
#define SCI_GETCONTROLCHARSYMBOL 2389
|
||||
#define SCI_WORDPARTLEFT 2390
|
||||
#define SCI_WORDPARTLEFTEXTEND 2391
|
||||
#define SCI_WORDPARTRIGHT 2392
|
||||
@@ -441,6 +462,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_SETVISIBLEPOLICY 2394
|
||||
#define SCI_DELLINELEFT 2395
|
||||
#define SCI_DELLINERIGHT 2396
|
||||
#define SCI_SETXOFFSET 2397
|
||||
#define SCI_GETXOFFSET 2398
|
||||
#define SCI_GRABFOCUS 2400
|
||||
#define SCI_STARTRECORD 3001
|
||||
#define SCI_STOPRECORD 3002
|
||||
@@ -493,12 +516,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCN_KEY 2005
|
||||
#define SCN_DOUBLECLICK 2006
|
||||
#define SCN_UPDATEUI 2007
|
||||
#define SCN_CHECKBRACE 2007
|
||||
#define SCN_MODIFIED 2008
|
||||
#define SCN_MACRORECORD 2009
|
||||
#define SCN_MARGINCLICK 2010
|
||||
#define SCN_NEEDSHOWN 2011
|
||||
#define SCN_POSCHANGED 2012
|
||||
#define SCN_PAINTED 2013
|
||||
#define SCN_USERLISTSELECTION 2014
|
||||
#define SCN_URIDROPPED 2015
|
||||
@@ -571,20 +592,15 @@ struct SCNotification {
|
||||
int y; // SCN_DWELLSTART, SCN_DWELLEND
|
||||
};
|
||||
|
||||
#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
|
||||
// will be removed completely in a future version.
|
||||
// To enable these features define INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
#define SCN_POSCHANGED 2012
|
||||
#define SCN_CHECKBRACE 2007
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
## This file defines the interface to Scintilla
|
||||
|
||||
## Copyright 2000-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
## The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
## A line starting with ## is a pure comment and should be stripped by readers.
|
||||
## A line starting with #! is for future shbang use
|
||||
## A line starting with # followed by a space is a documentation comment and refers
|
||||
@@ -25,6 +28,9 @@
|
||||
## The syntax for evt is <featureType><ws><returnType><ws><name>[=<number]([<param>[,<param>]*])
|
||||
## Feature names that contain an underscore are defined by Windows, so in these
|
||||
## cases, using the Windows definition is preferred where available.
|
||||
## The feature numbers are stable so features will not be renumbered.
|
||||
## Features may be removed but they will go through a period of deprecation
|
||||
## before removal which is signalled by moving them into the Deprecated category.
|
||||
|
||||
## Types:
|
||||
## void
|
||||
@@ -35,20 +41,27 @@
|
||||
## string -> pointer to const character
|
||||
## stringresult -> pointer to character
|
||||
## cells -> pointer to array of cells, each cell containing a style byte and character byte
|
||||
## textrange -> range of a min and a max position with an output string
|
||||
## findtext -> searchrange, text -> foundposition
|
||||
## keymod -> integer containing key in low half and modifiers in high half
|
||||
## formatrange
|
||||
## Types no longer used:
|
||||
## findtextex -> searchrange
|
||||
## charrange -> range of a min and a max position
|
||||
## charrangeresult -> like charrange, but output param
|
||||
## textrange -> charrange + output string
|
||||
## findtext -> searchrange, text -> foundposition
|
||||
## findtextex -> searchrange
|
||||
## keymod -> integer containing key in low half and modifiers in high half
|
||||
## countedstring
|
||||
## formatrange
|
||||
## point -> x,y
|
||||
## pointresult -> like point, but output param
|
||||
## rectangle -> left,top,right,bottom
|
||||
## Client code should ignore definitions containing types it does not understand, except
|
||||
## for possibly #defining the constants
|
||||
|
||||
## String arguments may contain NUL ('\0') characters where the calls provide a length
|
||||
## argument and retrieve NUL characters. All retrieved strings except for those retrieved
|
||||
## by GetLine also have a NUL appended but client code should calculate the size that
|
||||
## will be returned rather than relying upon the NUL whenever possible. Allow for the
|
||||
## extra NUL character when allocating buffers.
|
||||
|
||||
cat Basics
|
||||
|
||||
################################################
|
||||
@@ -229,6 +242,9 @@ val SC_MARK_CIRCLEPLUSCONNECTED=19
|
||||
val SC_MARK_CIRCLEMINUS=20
|
||||
val SC_MARK_CIRCLEMINUSCONNECTED=21
|
||||
|
||||
# Invisible mark that only sets the line background color
|
||||
val SC_MARK_BACKGROUND=22
|
||||
|
||||
val SC_MARK_CHARACTER=10000
|
||||
|
||||
# Markers used for outlining column
|
||||
@@ -240,6 +256,8 @@ val SC_MARKNUM_FOLDERSUB=29
|
||||
val SC_MARKNUM_FOLDER=30
|
||||
val SC_MARKNUM_FOLDEROPEN=31
|
||||
|
||||
val SC_MASK_FOLDERS=0xFE000000
|
||||
|
||||
# Set the symbol used for a particular marker number.
|
||||
fun void MarkerDefine=2040(int markerNumber, int markerSymbol)
|
||||
|
||||
@@ -249,8 +267,8 @@ fun void MarkerSetFore=2041(int markerNumber, colour fore)
|
||||
# Set the background colour used for a particular marker number.
|
||||
fun void MarkerSetBack=2042(int markerNumber, colour back)
|
||||
|
||||
# Add a marker to a line.
|
||||
fun void MarkerAdd=2043(int line, int markerNumber)
|
||||
# Add a marker to a line, returning an ID which can be used to find or delete the marker.
|
||||
fun int MarkerAdd=2043(int line, int markerNumber)
|
||||
|
||||
# Delete a marker from a line
|
||||
fun void MarkerDelete=2044(int line, int markerNumber)
|
||||
@@ -413,11 +431,10 @@ val INDIC_SQUIGGLE=1
|
||||
val INDIC_TT=2
|
||||
val INDIC_DIAGONAL=3
|
||||
val INDIC_STRIKE=4
|
||||
val INDIC0_MASK=32
|
||||
val INDIC1_MASK=64
|
||||
val INDIC2_MASK=128
|
||||
val INDICS_MASK=224
|
||||
##INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
|
||||
val INDIC0_MASK=0x20
|
||||
val INDIC1_MASK=0x40
|
||||
val INDIC2_MASK=0x80
|
||||
val INDICS_MASK=0xE0
|
||||
|
||||
# Set an indicator to plain, squiggle or TT.
|
||||
set void IndicSetStyle=2080(int indic, int style)
|
||||
@@ -451,7 +468,7 @@ 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.
|
||||
# Dsplay 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.
|
||||
@@ -460,6 +477,10 @@ get colour GetCaretLineBack=2097(,)
|
||||
# Set the colour of the background of the line containing the caret.
|
||||
set void SetCaretLineBack=2098(colour back,)
|
||||
|
||||
# Set a style to be changeable or not (read only).
|
||||
# Experimental feature, currently buggy.
|
||||
set void StyleSetChangeable=2099(int style, bool changeable)
|
||||
|
||||
# Display a auto-completion list.
|
||||
# The lenEntered parameter indicates how many characters before
|
||||
# the caret should be used to provide context.
|
||||
@@ -498,7 +519,8 @@ set void AutoCSetCancelAtStart=2110(bool cancel,)
|
||||
# Retrieve whether auto-completion cancelled by backspacing before start.
|
||||
get bool AutoCGetCancelAtStart=2111(,)
|
||||
|
||||
# Define a set of character that when typed fills up the selected word.
|
||||
# Define a set of characters that when typed will cause the autocompletion to
|
||||
# choose the selected item.
|
||||
set void AutoCSetFillUps=2112(, string characterSet)
|
||||
|
||||
# Should a single item auto-completion list automatically choose the item.
|
||||
@@ -522,6 +544,12 @@ set void AutoCSetAutoHide=2118(bool autoHide,)
|
||||
# Retrieve whether or not autocompletion is hidden automatically when nothing matches
|
||||
get bool AutoCGetAutoHide=2119(,)
|
||||
|
||||
# Set whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,)
|
||||
|
||||
# Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
get bool AutoCGetDropRestOfWord=2271(,)
|
||||
|
||||
# Set the number of spaces used for one level of indentation.
|
||||
set void SetIndent=2122(int indentSize,)
|
||||
|
||||
@@ -878,6 +906,32 @@ set void SetMouseDwellTime=2264(int periodMilliseconds,)
|
||||
# Retrieve the time the mouse must sit still to generate a mouse dwell event
|
||||
get int GetMouseDwellTime=2265(,)
|
||||
|
||||
# Get position of start of word
|
||||
fun int WordStartPosition=2266(position pos, bool onlyWordCharacters)
|
||||
|
||||
# Get position of end of word
|
||||
fun int WordEndPosition=2267(position pos, bool onlyWordCharacters)
|
||||
|
||||
val SC_WRAP_NONE=0
|
||||
val SC_WRAP_WORD=1
|
||||
|
||||
# Sets whether text is word wrapped
|
||||
set void SetWrapMode=2268(int mode,)
|
||||
|
||||
# Retrieve whether text is word wrapped
|
||||
get int GetWrapMode=2269(,)
|
||||
|
||||
val SC_CACHE_NONE=0
|
||||
val SC_CACHE_CARET=1
|
||||
val SC_CACHE_PAGE=2
|
||||
val SC_CACHE_DOCUMENT=3
|
||||
|
||||
# Sets the degree of caching of layout information
|
||||
set void SetLayoutCache=2272(int mode,)
|
||||
|
||||
# Retrieve the degree of caching of layout information
|
||||
get int GetLayoutCache=2273(,)
|
||||
|
||||
## Start of key messages
|
||||
# Move caret down one line.
|
||||
fun void LineDown=2300(,)
|
||||
@@ -1014,6 +1068,10 @@ fun void LineScrollDown=2342(,)
|
||||
# Scroll the document up, keeping the caret visible.
|
||||
fun void LineScrollUp=2343(,)
|
||||
|
||||
# Delete the selection or if no selection, the character before the caret.
|
||||
# Will not delete the chraacter before at the start of a line.
|
||||
fun void DeleteBackNotLine=2344(,)
|
||||
|
||||
# Move the caret inside current view if it's not there already
|
||||
fun void MoveCaretInsideView=2401(,)
|
||||
|
||||
@@ -1146,6 +1204,12 @@ set void SetCursor=2386(int cursorType,)
|
||||
# Get cursor type
|
||||
get int GetCursor=2387(,)
|
||||
|
||||
# Change the way control characters are displayed:
|
||||
# If symbol is < 32, keep the drawn way, else, use the given character
|
||||
set void SetControlCharSymbol=2388(int symbol,)
|
||||
# Get the way control characters are displayed
|
||||
get int GetControlCharSymbol=2389(,)
|
||||
|
||||
# Move to the previous change in capitalistion
|
||||
fun void WordPartLeft=2390(,)
|
||||
# Move to the previous change in capitalistion extending selection to new caret position.
|
||||
@@ -1167,6 +1231,10 @@ fun void DelLineLeft=2395(,)
|
||||
# Delete forwards from the current position to the end of the line
|
||||
fun void DelLineRight=2396(,)
|
||||
|
||||
# Get and Set the xOffset (ie, horizonal scroll position)
|
||||
set void SetXOffset=2397(int newOffset,)
|
||||
get int GetXOffset=2398(,)
|
||||
|
||||
# Set the focus to this Scintilla widget.
|
||||
# GTK+ Specific
|
||||
fun void GrabFocus=2400(,)
|
||||
@@ -1273,6 +1341,13 @@ val SCLEX_EIFFEL=23
|
||||
val SCLEX_EIFFELKW=24
|
||||
val SCLEX_TCL=25
|
||||
val SCLEX_NNCRONTAB=26
|
||||
val SCLEX_BULLANT=27
|
||||
val SCLEX_VBSCRIPT=28
|
||||
val SCLEX_ASP=29
|
||||
val SCLEX_PHP=30
|
||||
val SCLEX_BAAN=31
|
||||
val SCLEX_MATLAB=32
|
||||
|
||||
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
val SCLEX_AUTOMATIC=1000
|
||||
@@ -1291,7 +1366,7 @@ val SCE_P_OPERATOR=10
|
||||
val SCE_P_IDENTIFIER=11
|
||||
val SCE_P_COMMENTBLOCK=12
|
||||
val SCE_P_STRINGEOL=13
|
||||
# Lexical states for SCLEX_CPP, SCLEX_VB
|
||||
# Lexical states for SCLEX_CPP
|
||||
val SCE_C_DEFAULT=0
|
||||
val SCE_C_COMMENT=1
|
||||
val SCE_C_COMMENTLINE=2
|
||||
@@ -1311,6 +1386,16 @@ val SCE_C_COMMENTLINEDOC=15
|
||||
val SCE_C_WORD2=16
|
||||
val SCE_C_COMMENTDOCKEYWORD=17
|
||||
val SCE_C_COMMENTDOCKEYWORDERROR=18
|
||||
# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
|
||||
val SCE_B_DEFAULT=0
|
||||
val SCE_B_COMMENT=1
|
||||
val SCE_B_NUMBER=2
|
||||
val SCE_B_KEYWORD=3
|
||||
val SCE_B_STRING=4
|
||||
val SCE_B_PREPROCESSOR=5
|
||||
val SCE_B_OPERATOR=6
|
||||
val SCE_B_IDENTIFIER=7
|
||||
val SCE_B_DATE=8
|
||||
# Lexical states for SCLEX_HTML, SCLEX_XML
|
||||
val SCE_H_DEFAULT=0
|
||||
val SCE_H_TAG=1
|
||||
@@ -1484,6 +1569,11 @@ val SCE_LUA_PREPROCESSOR=9
|
||||
val SCE_LUA_OPERATOR=10
|
||||
val SCE_LUA_IDENTIFIER=11
|
||||
val SCE_LUA_STRINGEOL=12
|
||||
val SCE_LUA_WORD2=13
|
||||
val SCE_LUA_WORD3=14
|
||||
val SCE_LUA_WORD4=15
|
||||
val SCE_LUA_WORD5=16
|
||||
val SCE_LUA_WORD6=17
|
||||
# Lexical states for SCLEX_ERRORLIST
|
||||
val SCE_ERR_DEFAULT=0
|
||||
val SCE_ERR_PYTHON=1
|
||||
@@ -1548,6 +1638,18 @@ val SCE_ADA_CHARACTER=5
|
||||
val SCE_ADA_OPERATOR=6
|
||||
val SCE_ADA_IDENTIFIER=7
|
||||
val SCE_ADA_STRINGEOL=8
|
||||
# Lexical states for SCLEX_BAAN
|
||||
val SCE_BAAN_DEFAULT=0
|
||||
val SCE_BAAN_COMMENT=1
|
||||
val SCE_BAAN_COMMENTDOC=2
|
||||
val SCE_BAAN_NUMBER=3
|
||||
val SCE_BAAN_WORD=4
|
||||
val SCE_BAAN_STRING=5
|
||||
val SCE_BAAN_PREPROCESSOR=6
|
||||
val SCE_BAAN_OPERATOR=7
|
||||
val SCE_BAAN_IDENTIFIER=8
|
||||
val SCE_BAAN_STRINGEOL=9
|
||||
val SCE_BAAN_WORD2=10
|
||||
# Lexical states for SCLEX_LISP
|
||||
val SCE_LISP_DEFAULT=0
|
||||
val SCE_LISP_COMMENT=1
|
||||
@@ -1579,6 +1681,15 @@ val SCE_NNCRONTAB_NUMBER=7
|
||||
val SCE_NNCRONTAB_STRING=8
|
||||
val SCE_NNCRONTAB_ENVIRONMENT=9
|
||||
val SCE_NNCRONTAB_IDENTIFIER=10
|
||||
# Lexical states for SCLEX_MATLAB
|
||||
val SCE_MATLAB_DEFAULT=0
|
||||
val SCE_MATLAB_COMMENT=1
|
||||
val SCE_MATLAB_COMMAND=2
|
||||
val SCE_MATLAB_NUMBER=3
|
||||
val SCE_MATLAB_KEYWORD=4
|
||||
val SCE_MATLAB_STRING=5
|
||||
val SCE_MATLAB_OPERATOR=6
|
||||
val SCE_MATLAB_IDENTIFIER=7
|
||||
|
||||
# Events
|
||||
|
||||
@@ -1591,14 +1702,10 @@ evt void ModifyAttemptRO=2004(void)
|
||||
evt void Key=2005(int ch, int modifiers)
|
||||
evt void DoubleClick=2006(void)
|
||||
evt void UpdateUI=2007(void)
|
||||
# The old name for SCN_UPDATEUI
|
||||
val SCN_CHECKBRACE=2007
|
||||
evt void Modified=2008(int position, int modificationType, string text, int length, int linesAdded, int line, int foldLevelNow, int foldLevelPrev)
|
||||
# Optional module for macro recording
|
||||
evt void MacroRecord=2009(int message, int wParam, int lParam)
|
||||
evt void MarginClick=2010(int modifiers, int position, int margin)
|
||||
evt void NeedShown=2011(int position, int length)
|
||||
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)
|
||||
@@ -1606,3 +1713,7 @@ evt void DwellStart=2016(int position)
|
||||
evt void DwellEnd=2017(int position)
|
||||
|
||||
cat Deprecated
|
||||
|
||||
# The old name for SCN_UPDATEUI
|
||||
val SCN_CHECKBRACE=2007
|
||||
evt void PosChanged=2012(int position)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file AutoComplete.cxx
|
||||
** Defines the auto completion list box.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -22,7 +22,8 @@ AutoComplete::AutoComplete() :
|
||||
posStart(0),
|
||||
startLen(0),
|
||||
cancelAtStartPos(true),
|
||||
autoHide(true) {
|
||||
autoHide(true),
|
||||
dropRestOfWord(false) {
|
||||
stopChars[0] = '\0';
|
||||
fillUpChars[0] = '\0';
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file AutoComplete.h
|
||||
** Defines the auto completion list box.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef AUTOCOMPLETE_H
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
/// Should autocompletion be canceled if editor's currentPos <= startPos?
|
||||
bool cancelAtStartPos;
|
||||
bool autoHide;
|
||||
bool dropRestOfWord;
|
||||
|
||||
AutoComplete();
|
||||
~AutoComplete();
|
||||
|
@@ -21,11 +21,11 @@ CallTip::CallTip() {
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
|
||||
colourBG.desired = Colour(0xff, 0xff, 0xff);
|
||||
colourUnSel.desired = Colour(0x80, 0x80, 0x80);
|
||||
colourSel.desired = Colour(0, 0, 0x80);
|
||||
colourShade.desired = Colour(0, 0, 0);
|
||||
colourLight.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
|
||||
colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
|
||||
colourSel.desired = ColourDesired(0, 0, 0x80);
|
||||
colourShade.desired = ColourDesired(0, 0, 0);
|
||||
colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
|
||||
}
|
||||
|
||||
CallTip::~CallTip() {
|
||||
@@ -81,7 +81,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
rcClient.left = x;
|
||||
rcClient.top = ytext - ascent - 1;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
|
||||
chunkVal, thisStartHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
@@ -91,7 +91,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
rcClient.top = ytext;
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
|
||||
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
|
||||
colourSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
@@ -100,7 +100,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
chunkLength - thisEndHighlight);
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
|
||||
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
chunkVal = chunkEnd + 1;
|
||||
@@ -117,21 +117,25 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
}
|
||||
|
||||
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size) {
|
||||
Surface surfaceMeasure;
|
||||
surfaceMeasure.Init();
|
||||
int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
|
||||
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
|
||||
const char *faceName, int size, bool unicodeMode_) {
|
||||
if (val)
|
||||
delete []val;
|
||||
val = new char[strlen(defn) + 1];
|
||||
if (!val)
|
||||
return PRectangle();
|
||||
strcpy(val, defn);
|
||||
unicodeMode = unicodeMode_;
|
||||
Surface *surfaceMeasure = Surface::Allocate();
|
||||
if (!surfaceMeasure)
|
||||
return PRectangle();
|
||||
surfaceMeasure->Init();
|
||||
surfaceMeasure->SetUnicodeMode(unicodeMode);
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
inCallTipMode = true;
|
||||
posStartCallTip = pos;
|
||||
int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
|
||||
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
|
||||
// Look for multiple lines in the text
|
||||
// Only support \n here - simply means container must avoid \r!
|
||||
int width = 0;
|
||||
@@ -139,16 +143,17 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *newline;
|
||||
const char *look = val;
|
||||
while ((newline = strchr(look, '\n')) != NULL) {
|
||||
int thisWidth = surfaceMeasure.WidthText(font, look, newline - look);
|
||||
int thisWidth = surfaceMeasure->WidthText(font, look, newline - look);
|
||||
width = Platform::Maximum(width, thisWidth);
|
||||
look = newline + 1;
|
||||
numLines++;
|
||||
}
|
||||
int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look));
|
||||
int lastWidth = surfaceMeasure->WidthText(font, look, strlen(look));
|
||||
width = Platform::Maximum(width, lastWidth) + 10;
|
||||
int lineHeight = surfaceMeasure.Height(font);
|
||||
int lineHeight = surfaceMeasure->Height(font);
|
||||
// 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;
|
||||
delete surfaceMeasure;
|
||||
return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ public:
|
||||
ColourPair colourSel;
|
||||
ColourPair colourShade;
|
||||
ColourPair colourLight;
|
||||
bool unicodeMode;
|
||||
|
||||
CallTip();
|
||||
~CallTip();
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
|
||||
/// Setup the calltip and return a rectangle of the area required.
|
||||
PRectangle CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size);
|
||||
const char *faceName, int size, bool unicodeMode_);
|
||||
|
||||
void CallTipCancel();
|
||||
|
||||
|
@@ -11,8 +11,9 @@
|
||||
|
||||
OneLine::OneLine() {
|
||||
displayLine = 0;
|
||||
docLine = 0;
|
||||
//docLine = 0;
|
||||
visible = true;
|
||||
height = 1;
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
@@ -22,6 +23,8 @@ ContractionState::ContractionState() {
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
valid = false;
|
||||
docLines = 0;
|
||||
sizeDocLines = 0;
|
||||
}
|
||||
|
||||
ContractionState::~ContractionState() {
|
||||
@@ -32,12 +35,32 @@ void ContractionState::MakeValid() const {
|
||||
if (!valid) {
|
||||
// Could be cleverer by keeping the index of the last still valid entry
|
||||
// rather than invalidating all.
|
||||
int lineDisplay = 0;
|
||||
linesInDisplay = 0;
|
||||
for (int lineInDoc=0; lineInDoc<linesInDoc; lineInDoc++) {
|
||||
lines[lineInDoc].displayLine = linesInDisplay;
|
||||
if (lines[lineInDoc].visible) {
|
||||
linesInDisplay += lines[lineInDoc].height;
|
||||
}
|
||||
}
|
||||
if (sizeDocLines < linesInDisplay) {
|
||||
delete []docLines;
|
||||
int *docLinesNew = new int[linesInDisplay + growSize];
|
||||
if (!docLinesNew) {
|
||||
docLines = 0;
|
||||
sizeDocLines = 0;
|
||||
return;
|
||||
}
|
||||
docLines = docLinesNew;
|
||||
sizeDocLines = linesInDisplay + growSize;
|
||||
}
|
||||
|
||||
int lineInDisplay=0;
|
||||
for (int line=0; line<linesInDoc; line++) {
|
||||
lines[line].displayLine = lineDisplay;
|
||||
if (lines[line].visible) {
|
||||
lines[lineDisplay].docLine = line;
|
||||
lineDisplay++;
|
||||
for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
|
||||
docLines[lineInDisplay] = line;
|
||||
lineInDisplay++;
|
||||
}
|
||||
}
|
||||
}
|
||||
valid = true;
|
||||
@@ -50,6 +73,9 @@ void ContractionState::Clear() {
|
||||
size = 0;
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
delete []docLines;
|
||||
docLines = 0;
|
||||
sizeDocLines = 0;
|
||||
}
|
||||
|
||||
int ContractionState::LinesInDoc() const {
|
||||
@@ -57,6 +83,9 @@ int ContractionState::LinesInDoc() const {
|
||||
}
|
||||
|
||||
int ContractionState::LinesDisplayed() const {
|
||||
if (size != 0) {
|
||||
MakeValid();
|
||||
}
|
||||
return linesInDisplay;
|
||||
}
|
||||
|
||||
@@ -75,11 +104,15 @@ int ContractionState::DocFromDisplay(int lineDisplay) const {
|
||||
if (lineDisplay <= 0)
|
||||
return 0;
|
||||
if (lineDisplay >= linesInDisplay)
|
||||
return linesInDoc-1;
|
||||
return linesInDoc;
|
||||
if (size == 0)
|
||||
return lineDisplay;
|
||||
MakeValid();
|
||||
return lines[lineDisplay].docLine;
|
||||
if (docLines) { // Valid allocation
|
||||
return docLines[lineDisplay];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::Grow(int sizeNew) {
|
||||
@@ -113,13 +146,15 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
|
||||
Grow(linesInDoc + lineCount + growSize);
|
||||
}
|
||||
linesInDoc += lineCount;
|
||||
linesInDisplay += lineCount;
|
||||
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
|
||||
lines[i].visible = lines[i - lineCount].visible;
|
||||
lines[i].height = lines[i - lineCount].height;
|
||||
linesInDisplay += lines[i].height;
|
||||
lines[i].expanded = lines[i - lineCount].expanded;
|
||||
}
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
|
||||
lines[lineDoc+d].height = 1;
|
||||
lines[lineDoc+d].expanded = true;
|
||||
}
|
||||
valid = false;
|
||||
@@ -134,7 +169,7 @@ void ContractionState::DeleteLines(int lineDoc, int lineCount) {
|
||||
int deltaDisplayed = 0;
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
if (lines[lineDoc+d].visible)
|
||||
deltaDisplayed--;
|
||||
deltaDisplayed -= lines[lineDoc+d].height;
|
||||
}
|
||||
for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
|
||||
if (i != 0) // Line zero is always visible
|
||||
@@ -170,7 +205,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible
|
||||
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
|
||||
for (int line=lineDocStart; line <= lineDocEnd; line++) {
|
||||
if (lines[line].visible != visible) {
|
||||
delta += visible ? 1 : -1;
|
||||
delta += visible ? lines[line].height : -lines[line].height;
|
||||
lines[line].visible = visible;
|
||||
}
|
||||
}
|
||||
@@ -192,6 +227,11 @@ bool ContractionState::GetExpanded(int lineDoc) const {
|
||||
|
||||
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||
if (size == 0) {
|
||||
if (expanded) {
|
||||
// If in completely expanded state then setting
|
||||
// one line to expanded has no effect.
|
||||
return false;
|
||||
}
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
@@ -203,6 +243,38 @@ bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ContractionState::GetHeight(int lineDoc) const {
|
||||
if (size == 0)
|
||||
return 1;
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].height;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the number of display lines needed for this line.
|
||||
// Return true if this is a change.
|
||||
bool ContractionState::SetHeight(int lineDoc, int height) {
|
||||
if (lineDoc > linesInDoc)
|
||||
return false;
|
||||
if (size == 0) {
|
||||
if (height == 1) {
|
||||
// If in completely expanded state then all lines
|
||||
// assumed to have height of one so no effect here.
|
||||
return false;
|
||||
}
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
if (lines[lineDoc].height != height) {
|
||||
lines[lineDoc].height = height;
|
||||
valid = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::ShowAll() {
|
||||
delete []lines;
|
||||
lines = 0;
|
||||
|
@@ -13,7 +13,8 @@
|
||||
class OneLine {
|
||||
public:
|
||||
int displayLine; ///< Position within set of visible lines
|
||||
int docLine; ///< Inverse of @a displayLine
|
||||
//int docLine; ///< Inverse of @a displayLine
|
||||
int height; ///< Number of display lines needed to show all of the line
|
||||
bool visible;
|
||||
bool expanded;
|
||||
|
||||
@@ -27,9 +28,11 @@ class ContractionState {
|
||||
void Grow(int sizeNew);
|
||||
enum { growSize = 4000 };
|
||||
int linesInDoc;
|
||||
int linesInDisplay;
|
||||
mutable int linesInDisplay;
|
||||
mutable OneLine *lines;
|
||||
int size;
|
||||
mutable int *docLines;
|
||||
mutable int sizeDocLines;
|
||||
mutable bool valid;
|
||||
void MakeValid() const;
|
||||
|
||||
@@ -53,6 +56,9 @@ public:
|
||||
bool GetExpanded(int lineDoc) const;
|
||||
bool SetExpanded(int lineDoc, bool expanded);
|
||||
|
||||
int GetHeight(int lineDoc) const;
|
||||
bool SetHeight(int lineDoc, int height);
|
||||
|
||||
void ShowAll();
|
||||
};
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file Document.cxx
|
||||
** Text document that handles notifications, DBCS, styling, words and end of line.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "RESearch.h"
|
||||
|
||||
// This is ASCII specific but is safe with chars >= 0x80
|
||||
inline bool isspacechar(unsigned char ch) {
|
||||
static inline bool isspacechar(unsigned char ch) {
|
||||
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
|
||||
}
|
||||
|
||||
@@ -34,10 +34,9 @@ Document::Document() {
|
||||
stylingBits = 5;
|
||||
stylingBitsMask = 0x1F;
|
||||
stylingMask = 0;
|
||||
for (int ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = isalnum(ch) || ch == '_';
|
||||
}
|
||||
SetWordChars(0);
|
||||
endStyled = 0;
|
||||
styleClock = 0;
|
||||
enteredCount = 0;
|
||||
enteredReadOnlyCount = 0;
|
||||
tabInChars = 8;
|
||||
@@ -219,7 +218,6 @@ bool Document::IsCrLf(int pos) {
|
||||
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool Document::IsDBCS(int pos) {
|
||||
if (dbcsCodePage) {
|
||||
if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
@@ -232,7 +230,7 @@ bool Document::IsDBCS(int pos) {
|
||||
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
|
||||
startLine--;
|
||||
while (startLine <= pos) {
|
||||
if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) {
|
||||
if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine))) {
|
||||
startLine++;
|
||||
if (startLine >= pos)
|
||||
return true;
|
||||
@@ -243,13 +241,6 @@ bool Document::IsDBCS(int pos) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool Document::IsDBCS(int) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
int Document::LenChar(int pos) {
|
||||
if (IsCrLf(pos)) {
|
||||
@@ -302,7 +293,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
|
||||
// Not between CR and LF
|
||||
|
||||
#if PLAT_WIN
|
||||
if (dbcsCodePage) {
|
||||
if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
|
||||
@@ -324,12 +314,11 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
while (startLine < pos) {
|
||||
if (atLeadByte)
|
||||
atLeadByte = false;
|
||||
else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine)))
|
||||
else if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine)))
|
||||
atLeadByte = true;
|
||||
else
|
||||
atLeadByte = false;
|
||||
startLine++;
|
||||
//Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +331,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return pos;
|
||||
}
|
||||
@@ -634,21 +622,46 @@ int Document::GetColumn(int pos) {
|
||||
int column = 0;
|
||||
int line = LineFromPosition(pos);
|
||||
if ((line >= 0) && (line < LinesTotal())) {
|
||||
for (int i = LineStart(line);i < pos;i++) {
|
||||
for (int i = LineStart(line);i < pos;) {
|
||||
char ch = cb.CharAt(i);
|
||||
if (ch == '\t')
|
||||
if (ch == '\t') {
|
||||
column = NextTab(column, tabInChars);
|
||||
else if (ch == '\r')
|
||||
i++;
|
||||
} else if (ch == '\r') {
|
||||
return column;
|
||||
else if (ch == '\n')
|
||||
} else if (ch == '\n') {
|
||||
return column;
|
||||
else
|
||||
} else {
|
||||
column++;
|
||||
i = MovePositionOutsideChar(i + 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
int Document::FindColumn(int line, int column) {
|
||||
int position = LineStart(line);
|
||||
int columnCurrent = 0;
|
||||
if ((line >= 0) && (line < LinesTotal())) {
|
||||
while (columnCurrent < column) {
|
||||
char ch = cb.CharAt(position);
|
||||
if (ch == '\t') {
|
||||
columnCurrent = NextTab(columnCurrent, tabInChars);
|
||||
position++;
|
||||
} else if (ch == '\r') {
|
||||
return position;
|
||||
} else if (ch == '\n') {
|
||||
return position;
|
||||
} else {
|
||||
columnCurrent++;
|
||||
position = MovePositionOutsideChar(position + 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
void Document::Indent(bool forwards, int lineBottom, int lineTop) {
|
||||
// Dedent - suck white space off the front of the line to dedent by equivalent of a tab
|
||||
for (int line = lineBottom; line >= lineTop; line--) {
|
||||
@@ -700,72 +713,88 @@ void Document::ConvertLineEnds(int eolModeSet) {
|
||||
EndUndoAction();
|
||||
}
|
||||
|
||||
bool Document::IsWordChar(unsigned char ch) {
|
||||
if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80))
|
||||
return true;
|
||||
return wordchars[ch];
|
||||
Document::charClassification Document::WordCharClass(unsigned char ch) {
|
||||
if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80))
|
||||
return ccWord;
|
||||
return charClass[ch];
|
||||
}
|
||||
|
||||
int Document::ExtendWordSelect(int pos, int delta) {
|
||||
/**
|
||||
* Used by commmands that want to select whole words.
|
||||
* Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0.
|
||||
*/
|
||||
int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) {
|
||||
charClassification ccStart = ccWord;
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && IsWordChar(cb.CharAt(pos - 1)))
|
||||
if (!onlyWordCharacters)
|
||||
ccStart = WordCharClass(cb.CharAt(pos-1));
|
||||
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
|
||||
pos--;
|
||||
} else {
|
||||
while (pos < (Length()) && IsWordChar(cb.CharAt(pos)))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
int Document::NextWordStart(int pos, int delta) {
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))
|
||||
pos--;
|
||||
if (isspacechar(cb.CharAt(pos - 1))) { // Back up to previous line
|
||||
while (pos > 0 && isspacechar(cb.CharAt(pos - 1)))
|
||||
pos--;
|
||||
} else {
|
||||
bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1));
|
||||
while (pos > 0 && !isspacechar(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1))))
|
||||
pos--;
|
||||
}
|
||||
} else {
|
||||
bool startAtWordChar = IsWordChar(cb.CharAt(pos));
|
||||
while (pos < (Length()) && isspacechar(cb.CharAt(pos)))
|
||||
pos++;
|
||||
while (pos < (Length()) && !isspacechar(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos))))
|
||||
pos++;
|
||||
while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))
|
||||
if (!onlyWordCharacters)
|
||||
ccStart = WordCharClass(cb.CharAt(pos));
|
||||
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the character before the given position
|
||||
* is not a word character.
|
||||
* Find the start of the next word in either a forward (delta >= 0) or backwards direction
|
||||
* (delta < 0).
|
||||
* This is looking for a transition between character classes although there is also some
|
||||
* additional movement to transit white space.
|
||||
* Used by cursor movement by word commands.
|
||||
*/
|
||||
int Document::NextWordStart(int pos, int delta) {
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccSpace))
|
||||
pos--;
|
||||
if (pos > 0) {
|
||||
charClassification ccStart = WordCharClass(cb.CharAt(pos-1));
|
||||
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) {
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
charClassification ccStart = WordCharClass(cb.CharAt(pos));
|
||||
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
|
||||
pos++;
|
||||
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccSpace))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the character at the given position is a word or punctuation character and that
|
||||
* the previous character is of a different character class.
|
||||
*/
|
||||
bool Document::IsWordStartAt(int pos) {
|
||||
if (pos > 0) {
|
||||
return !IsWordChar(CharAt(pos - 1));
|
||||
charClassification ccPos = WordCharClass(CharAt(pos));
|
||||
return (ccPos == ccWord || ccPos == ccPunctuation) &&
|
||||
(ccPos != WordCharClass(CharAt(pos - 1)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the character after the given position
|
||||
* is not a word character.
|
||||
* Check that the character at the given position is a word or punctuation character and that
|
||||
* the next character is of a different character class.
|
||||
*/
|
||||
bool Document::IsWordEndAt(int pos) {
|
||||
if (pos < Length() - 1) {
|
||||
return !IsWordChar(CharAt(pos));
|
||||
charClassification ccPrev = WordCharClass(CharAt(pos-1));
|
||||
return (ccPrev == ccWord || ccPrev == ccPunctuation) &&
|
||||
(ccPrev != WordCharClass(CharAt(pos)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the given range is delimited by
|
||||
* non word characters.
|
||||
* Check that the given range is has transitions between character classes at both
|
||||
* ends and where the characters on the inside are word or punctuation characters.
|
||||
*/
|
||||
bool Document::IsWordAt(int start, int end) {
|
||||
return IsWordStartAt(start) && IsWordEndAt(end);
|
||||
@@ -1018,16 +1047,22 @@ void Document::ChangeCase(Range r, bool makeUpperCase) {
|
||||
void Document::SetWordChars(unsigned char *chars) {
|
||||
int ch;
|
||||
for (ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = false;
|
||||
if (ch == '\r' || ch == '\n')
|
||||
charClass[ch] = ccNewLine;
|
||||
else if (ch < 0x20 || ch == ' ')
|
||||
charClass[ch] = ccSpace;
|
||||
else
|
||||
charClass[ch] = ccPunctuation;
|
||||
}
|
||||
if (chars) {
|
||||
while (*chars) {
|
||||
wordchars[*chars] = true;
|
||||
charClass[*chars] = ccWord;
|
||||
chars++;
|
||||
}
|
||||
} else {
|
||||
for (ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = isalnum(ch) || ch == '_';
|
||||
if (ch >= 0x80 || isalnum(ch) || ch == '_')
|
||||
charClass[ch] = ccWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1066,6 +1101,7 @@ void Document::SetStyles(int length, char *styles) {
|
||||
int prevEndStyled = endStyled;
|
||||
bool didChange = false;
|
||||
for (int iPos = 0; iPos < length; iPos++, endStyled++) {
|
||||
PLATFORM_ASSERT(endStyled < Length());
|
||||
if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
|
||||
didChange = true;
|
||||
}
|
||||
@@ -1080,6 +1116,12 @@ void Document::SetStyles(int length, char *styles) {
|
||||
}
|
||||
|
||||
bool Document::EnsureStyledTo(int pos) {
|
||||
if (pos > GetEndStyled()) {
|
||||
styleClock++;
|
||||
if (styleClock > 0x100000) {
|
||||
styleClock = 0;
|
||||
}
|
||||
}
|
||||
// Ask the watchers to style, and stop as soon as one responds.
|
||||
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
|
||||
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
|
||||
@@ -1149,7 +1191,7 @@ void Document::NotifyModified(DocModification mh) {
|
||||
}
|
||||
|
||||
bool Document::IsWordPartSeparator(char ch) {
|
||||
return ispunct(ch) && IsWordChar(ch);
|
||||
return ispunct(ch) && (WordCharClass(ch) == ccWord);
|
||||
}
|
||||
|
||||
int Document::WordPartLeft(int pos) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file Document.h
|
||||
** Text document that handles notifications, DBCS, styling, words and end of line.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef DOCUMENT_H
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
return (start != invalidPosition) && (end != invalidPosition);
|
||||
}
|
||||
|
||||
// Is the position within the range?
|
||||
bool Contains(Position pos) const {
|
||||
if (start < end) {
|
||||
return (pos >= start && pos <= end);
|
||||
@@ -45,6 +46,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Is the character after pos within the range?
|
||||
bool ContainsCharacter(Position pos) const {
|
||||
if (start < end) {
|
||||
return (pos >= start && pos < end);
|
||||
} else {
|
||||
return (pos < start && pos >= end);
|
||||
}
|
||||
}
|
||||
|
||||
bool Contains(Range other) const {
|
||||
return Contains(other.start) && Contains(other.end);
|
||||
}
|
||||
@@ -81,9 +91,11 @@ public:
|
||||
private:
|
||||
int refCount;
|
||||
CellBuffer cb;
|
||||
bool wordchars[256];
|
||||
enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
|
||||
charClassification charClass[256];
|
||||
char stylingMask;
|
||||
int endStyled;
|
||||
int styleClock;
|
||||
int enteredCount;
|
||||
int enteredReadOnlyCount;
|
||||
|
||||
@@ -140,6 +152,7 @@ public:
|
||||
void SetLineIndentation(int line, int indent);
|
||||
int GetLineIndentPosition(int line);
|
||||
int GetColumn(int position);
|
||||
int FindColumn(int line, int column);
|
||||
void Indent(bool forwards, int lineBottom, int lineTop);
|
||||
void ConvertLineEnds(int eolModeSet);
|
||||
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
|
||||
@@ -175,7 +188,7 @@ public:
|
||||
int GetFoldParent(int line);
|
||||
|
||||
void Indent(bool forwards);
|
||||
int ExtendWordSelect(int pos, int delta);
|
||||
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
|
||||
int NextWordStart(int pos, int delta);
|
||||
int Length() { return cb.Length(); }
|
||||
long FindText(int minPos, int maxPos, const char *s,
|
||||
@@ -193,6 +206,7 @@ public:
|
||||
void SetStyles(int length, char *styles);
|
||||
int GetEndStyled() { return endStyled; }
|
||||
bool EnsureStyledTo(int pos);
|
||||
int GetStyleClock() { return styleClock; }
|
||||
|
||||
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
||||
int GetLineState(int line) { return cb.GetLineState(line); }
|
||||
@@ -209,7 +223,7 @@ public:
|
||||
|
||||
private:
|
||||
bool IsDBCS(int pos);
|
||||
bool IsWordChar(unsigned char ch);
|
||||
charClassification WordCharClass(unsigned char ch);
|
||||
bool IsWordStartAt(int pos);
|
||||
bool IsWordEndAt(int pos);
|
||||
bool IsWordAt(int start, int end);
|
||||
|
@@ -23,22 +23,14 @@
|
||||
DocumentAccessor::~DocumentAccessor() {
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool DocumentAccessor::InternalIsLeadByte(char ch) {
|
||||
if (SC_CP_UTF8 == codePage)
|
||||
// For lexing, all characters >= 0x80 are treated the
|
||||
// same so none is considered a lead byte.
|
||||
return false;
|
||||
else
|
||||
return IsDBCSLeadByteEx(codePage, ch);
|
||||
return Platform::IsDBCSLeadByte(codePage, ch);
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool DocumentAccessor::InternalIsLeadByte(char) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void DocumentAccessor::Fill(int position) {
|
||||
if (lenDoc == -1)
|
||||
@@ -88,6 +80,7 @@ int DocumentAccessor::SetLineState(int line, int state) {
|
||||
|
||||
void DocumentAccessor::StartAt(unsigned int start, char chMask) {
|
||||
pdoc->StartStyling(start, chMask);
|
||||
startPosStyling = start;
|
||||
}
|
||||
|
||||
void DocumentAccessor::StartSegment(unsigned int pos) {
|
||||
@@ -111,6 +104,7 @@ void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
|
||||
chFlags = 0;
|
||||
chAttr |= chFlags;
|
||||
for (unsigned int i = startSeg; i <= pos; i++) {
|
||||
PLATFORM_ASSERT((startPosStyling + validLen) < Length());
|
||||
styleBuf[validLen++] = static_cast<char>(chAttr);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +122,7 @@ void DocumentAccessor::Flush() {
|
||||
if (validLen > 0) {
|
||||
pdoc->SetStyles(validLen, styleBuf);
|
||||
validLen = 0;
|
||||
startPosStyling += validLen;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@ protected:
|
||||
char chFlags;
|
||||
char chWhile;
|
||||
unsigned int startSeg;
|
||||
int startPosStyling;
|
||||
|
||||
bool InternalIsLeadByte(char ch);
|
||||
void Fill(int position);
|
||||
@@ -33,7 +34,8 @@ protected:
|
||||
public:
|
||||
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
|
||||
Accessor(), pdoc(pdoc_), props(props_), id(id_),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
|
||||
startSeg(0), startPosStyling(0) {
|
||||
}
|
||||
~DocumentAccessor();
|
||||
char StyleAt(int position);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
/** @file Editor.h
|
||||
** Defines the main editor class.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef EDITOR_H
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
bool ticking;
|
||||
int ticksToWait;
|
||||
enum {tickSize = 100};
|
||||
int tickerID;
|
||||
TickerID tickerID;
|
||||
|
||||
Timer();
|
||||
};
|
||||
@@ -34,20 +34,81 @@ public:
|
||||
/**
|
||||
*/
|
||||
class LineLayout {
|
||||
public:
|
||||
private:
|
||||
friend class LineLayoutCache;
|
||||
int *lineStarts;
|
||||
int lenLineStarts;
|
||||
/// Drawing is only performed for @a maxLineLength characters on each line.
|
||||
enum {maxLineLength = 4000};
|
||||
int lineNumber;
|
||||
bool inCache;
|
||||
public:
|
||||
enum { wrapWidthInfinite = 0x7ffffff };
|
||||
int maxLineLength;
|
||||
int numCharsInLine;
|
||||
enum validLevel { llInvalid, llPositions, llLines } validity;
|
||||
int xHighlightGuide;
|
||||
bool highlightColumn;
|
||||
int selStart;
|
||||
int selEnd;
|
||||
bool containsCaret;
|
||||
int edgeColumn;
|
||||
char chars[maxLineLength+1];
|
||||
char styles[maxLineLength+1];
|
||||
char indicators[maxLineLength+1];
|
||||
int positions[maxLineLength+1];
|
||||
char *chars;
|
||||
char *styles;
|
||||
char *indicators;
|
||||
int *positions;
|
||||
char bracePreviousStyles[2];
|
||||
|
||||
// Wrapped line support
|
||||
int widthLine;
|
||||
int lines;
|
||||
|
||||
LineLayout(int maxLineLength_);
|
||||
virtual ~LineLayout();
|
||||
void Resize(int maxLineLength_);
|
||||
void Free();
|
||||
void Invalidate(validLevel validity_);
|
||||
int LineStart(int line) {
|
||||
if (line <= 0) {
|
||||
return 0;
|
||||
} else if ((line >= lines) || !lineStarts) {
|
||||
return numCharsInLine;
|
||||
} else {
|
||||
return lineStarts[line];
|
||||
}
|
||||
}
|
||||
void SetLineStart(int line, int start);
|
||||
void SetBracesHighlight(Range rangeLine, Position braces[],
|
||||
char bracesMatchStyle, int xHighlight);
|
||||
void RestoreBracesHighlight(Range rangeLine, Position braces[]);
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class LineLayoutCache {
|
||||
int level;
|
||||
int length;
|
||||
int size;
|
||||
LineLayout **cache;
|
||||
bool allInvalidated;
|
||||
int styleClock;
|
||||
void Allocate(int length_);
|
||||
void AllocateForLevel(int linesOnScreen, int linesInDoc);
|
||||
public:
|
||||
LineLayoutCache();
|
||||
virtual ~LineLayoutCache();
|
||||
void Deallocate();
|
||||
enum {
|
||||
llcNone=SC_CACHE_NONE,
|
||||
llcCaret=SC_CACHE_CARET,
|
||||
llcPage=SC_CACHE_PAGE,
|
||||
llcDocument=SC_CACHE_DOCUMENT
|
||||
};
|
||||
void Invalidate(LineLayout::validLevel validity_);
|
||||
void SetLevel(int level_);
|
||||
int GetLevel() { return level; }
|
||||
LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
|
||||
int linesOnScreen, int linesInDoc);
|
||||
void Dispose(LineLayout *ll);
|
||||
};
|
||||
|
||||
class SelectionText {
|
||||
@@ -70,6 +131,38 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A smart pointer class to ensure Surfaces are set up and deleted correctly.
|
||||
*/
|
||||
class AutoSurface {
|
||||
private:
|
||||
Surface *surf;
|
||||
public:
|
||||
AutoSurface(bool unicodeMode) {
|
||||
surf = Surface::Allocate();
|
||||
if (surf) {
|
||||
surf->Init();
|
||||
surf->SetUnicodeMode(unicodeMode);
|
||||
}
|
||||
}
|
||||
AutoSurface(SurfaceID sid, bool unicodeMode) {
|
||||
surf = Surface::Allocate();
|
||||
if (surf) {
|
||||
surf->Init(sid);
|
||||
surf->SetUnicodeMode(unicodeMode);
|
||||
}
|
||||
}
|
||||
~AutoSurface() {
|
||||
delete surf;
|
||||
}
|
||||
Surface *operator->() const {
|
||||
return surf;
|
||||
}
|
||||
operator Surface *() const {
|
||||
return surf;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class Editor : public DocWatcher {
|
||||
@@ -92,6 +185,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int printMagnification;
|
||||
int printColourMode;
|
||||
int cursorMode;
|
||||
int controlCharSymbol;
|
||||
|
||||
bool hasFocus;
|
||||
bool hideSelection;
|
||||
@@ -107,11 +201,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
|
||||
bool horizontalScrollBarVisible;
|
||||
|
||||
Surface pixmapLine;
|
||||
Surface pixmapSelMargin;
|
||||
Surface pixmapSelPattern;
|
||||
Surface pixmapIndentGuide;
|
||||
Surface pixmapIndentGuideHighlight;
|
||||
Surface *pixmapLine;
|
||||
Surface *pixmapSelMargin;
|
||||
Surface *pixmapSelPattern;
|
||||
Surface *pixmapIndentGuide;
|
||||
Surface *pixmapIndentGuideHighlight;
|
||||
|
||||
LineLayoutCache llc;
|
||||
|
||||
KeyMap kmap;
|
||||
|
||||
@@ -174,6 +270,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int foldFlags;
|
||||
ContractionState cs;
|
||||
|
||||
// Wrapping support
|
||||
enum { eWrapNone, eWrapWord } wrapState;
|
||||
int wrapWidth;
|
||||
int docLineLastWrapped;
|
||||
|
||||
Document *pdoc;
|
||||
|
||||
Editor();
|
||||
@@ -223,16 +324,22 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual void ScrollText(int linesToMove);
|
||||
void HorizontalScrollTo(int xPos);
|
||||
void MoveCaretInsideView();
|
||||
int DisplayFromPosition(int pos);
|
||||
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
|
||||
void ShowCaretAtCurrentPosition();
|
||||
void DropCaret();
|
||||
void InvalidateCaret();
|
||||
|
||||
void NeedWrapping(int docLineStartWrapping=0);
|
||||
bool WrapLines();
|
||||
|
||||
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
|
||||
void PaintSelMargin(Surface *surface, PRectangle &rc);
|
||||
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll);
|
||||
LineLayout *RetrieveLineLayout(int lineNumber);
|
||||
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
|
||||
int width=LineLayout::wrapWidthInfinite);
|
||||
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
|
||||
PRectangle rcLine, LineLayout &ll);
|
||||
PRectangle rcLine, LineLayout *ll, int subLine=0);
|
||||
void Paint(Surface *surfaceWindow, PRectangle rcArea);
|
||||
long FormatRange(bool draw, RangeToFormat *pfr);
|
||||
|
||||
@@ -240,11 +347,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual void SetHorizontalScrollPos() = 0;
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
|
||||
virtual void ReconfigureScrollBars();
|
||||
void SetScrollBarsTo(PRectangle rsClient);
|
||||
void SetScrollBars();
|
||||
void ChangeSize();
|
||||
|
||||
void AddChar(char ch);
|
||||
virtual void AddCharUTF(char *s, unsigned int len);
|
||||
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
void ClearSelection();
|
||||
void ClearAll();
|
||||
void ClearDocumentStyle();
|
||||
@@ -258,11 +365,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
void Undo();
|
||||
void Redo();
|
||||
void DelChar();
|
||||
void DelCharBack();
|
||||
void DelCharBack(bool allowLineStartDeletion);
|
||||
virtual void ClaimSelection() = 0;
|
||||
|
||||
virtual void NotifyChange() = 0;
|
||||
virtual void NotifyFocus(bool focus);
|
||||
virtual int GetCtrlID() { return ctrlID; }
|
||||
virtual void NotifyParent(SCNotification scn) = 0;
|
||||
virtual void NotifyStyleToNeeded(int endStyleNeeded);
|
||||
void NotifyChar(int ch);
|
||||
@@ -278,6 +386,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
void NotifyModifyAttempt(Document *document, void *userData);
|
||||
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
||||
void CheckModificationForWrap(DocModification mh);
|
||||
void NotifyModified(Document *document, DocModification mh, void *userData);
|
||||
void NotifyDeleted(Document *document, void *userData);
|
||||
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
|
||||
@@ -339,9 +448,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
|
||||
|
||||
public:
|
||||
// Public so scintilla_send_message can use it
|
||||
// Public so the COM thunks can access it.
|
||||
bool IsUnicodeMode() const;
|
||||
// Public so scintilla_send_message can use it.
|
||||
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;
|
||||
};
|
||||
|
||||
|
@@ -14,7 +14,7 @@ class Indicator {
|
||||
public:
|
||||
int style;
|
||||
ColourPair fore;
|
||||
Indicator() : style(INDIC_PLAIN), fore(Colour(0,0,0)) {
|
||||
Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) {
|
||||
}
|
||||
void Draw(Surface *surface, PRectangle &rc);
|
||||
};
|
||||
|
@@ -62,7 +62,7 @@ unsigned int KeyMap::Find(int key, int modifiers) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
KeyToCommand KeyMap::MapDefault[] = {
|
||||
const KeyToCommand KeyMap::MapDefault[] = {
|
||||
{SCK_DOWN, SCI_NORM, SCI_LINEDOWN},
|
||||
{SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND},
|
||||
{SCK_DOWN, SCI_CTRL, SCI_LINESCROLLDOWN},
|
||||
|
@@ -30,7 +30,7 @@ class KeyMap {
|
||||
KeyToCommand *kmap;
|
||||
int len;
|
||||
int alloc;
|
||||
static KeyToCommand MapDefault[];
|
||||
static const KeyToCommand MapDefault[];
|
||||
|
||||
public:
|
||||
KeyMap();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file KeyWords.cxx
|
||||
** Colourise for particular languages.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -19,15 +19,15 @@
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
LexerModule *LexerModule::base = 0;
|
||||
const LexerModule *LexerModule::base = 0;
|
||||
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
|
||||
|
||||
LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
|
||||
const char *languageName_, LexerFunction fnFolder_) :
|
||||
language(language_),
|
||||
languageName(languageName_),
|
||||
fnLexer(fnLexer_),
|
||||
fnFolder(fnFolder_) {
|
||||
fnFolder(fnFolder_),
|
||||
languageName(languageName_) {
|
||||
next = base;
|
||||
base = this;
|
||||
if (language == SCLEX_AUTOMATIC) {
|
||||
@@ -36,8 +36,8 @@ LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule *LexerModule::Find(int language) {
|
||||
LexerModule *lm = base;
|
||||
const LexerModule *LexerModule::Find(int language) {
|
||||
const LexerModule *lm = base;
|
||||
while (lm) {
|
||||
if (lm->language == language) {
|
||||
return lm;
|
||||
@@ -47,9 +47,9 @@ LexerModule *LexerModule::Find(int language) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LexerModule *LexerModule::Find(const char *languageName) {
|
||||
const LexerModule *LexerModule::Find(const char *languageName) {
|
||||
if (languageName) {
|
||||
LexerModule *lm = base;
|
||||
const LexerModule *lm = base;
|
||||
while (lm) {
|
||||
if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
|
||||
return lm;
|
||||
@@ -61,13 +61,13 @@ LexerModule *LexerModule::Find(const char *languageName) {
|
||||
}
|
||||
|
||||
void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
WordList *keywordlists[], Accessor &styler) const {
|
||||
if (fnLexer)
|
||||
fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
|
||||
}
|
||||
|
||||
void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
WordList *keywordlists[], Accessor &styler) const {
|
||||
if (fnFolder) {
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
// Move back one line in case deletion wrecked current line fold state
|
||||
@@ -98,6 +98,10 @@ static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[
|
||||
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
|
||||
|
||||
#ifdef __vms
|
||||
#define LINK_LEXERS
|
||||
#endif
|
||||
|
||||
#ifdef LINK_LEXERS
|
||||
|
||||
// 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"
|
||||
@@ -106,8 +110,13 @@ LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
|
||||
// Taken from wxWindow's stc.cpp. Walter.
|
||||
|
||||
int wxForceScintillaLexers(void) {
|
||||
return Scintilla_LinkLexers();
|
||||
}
|
||||
|
||||
int Scintilla_LinkLexers() {
|
||||
extern LexerModule lmAda;
|
||||
extern LexerModule lmAVE;
|
||||
extern LexerModule lmBaan;
|
||||
extern LexerModule lmBatch;
|
||||
extern LexerModule lmConf;
|
||||
extern LexerModule lmCPP;
|
||||
@@ -120,6 +129,7 @@ int wxForceScintillaLexers(void) {
|
||||
extern LexerModule lmLISP;
|
||||
extern LexerModule lmLua;
|
||||
extern LexerModule lmMake;
|
||||
extern LexerModule lmMatlab;
|
||||
extern LexerModule lmPascal;
|
||||
extern LexerModule lmPerl;
|
||||
extern LexerModule lmProps;
|
||||
@@ -128,10 +138,12 @@ int wxForceScintillaLexers(void) {
|
||||
extern LexerModule lmSQL;
|
||||
extern LexerModule lmVB;
|
||||
extern LexerModule lmXML;
|
||||
extern LexerModule lmBullant;
|
||||
|
||||
if (
|
||||
&lmAda
|
||||
&& &lmAVE
|
||||
&& &lmBaan
|
||||
&& &lmConf
|
||||
&& &lmDiff
|
||||
&& &lmLatex
|
||||
@@ -142,6 +154,7 @@ int wxForceScintillaLexers(void) {
|
||||
&& &lmProps
|
||||
&& &lmErrorList
|
||||
&& &lmMake
|
||||
&& &lmMatlab
|
||||
&& &lmBatch
|
||||
&& &lmPerl
|
||||
&& &lmPython
|
||||
@@ -153,6 +166,7 @@ int wxForceScintillaLexers(void) {
|
||||
&& &lmLISP
|
||||
&& &lmLua
|
||||
&& &lmNull
|
||||
&& &lmBullant
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
|
@@ -26,7 +26,7 @@ static void ColouriseAveDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold");
|
||||
bool fold = styler.GetPropertyInt("fold") != 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
|
@@ -49,7 +49,7 @@ inline void classifyWordAda(unsigned int start, unsigned int end,
|
||||
}
|
||||
|
||||
|
||||
inline bool isAdaOperator(char ch) {
|
||||
static inline bool isAdaOperator(char ch) {
|
||||
|
||||
if (ch == '&' || ch == '\'' || ch == '(' || ch == ')' ||
|
||||
ch == '*' || ch == '+' || ch == ',' || ch == '-' ||
|
||||
|
189
contrib/src/stc/scintilla/src/LexBaan.cxx
Normal file
189
contrib/src/stc/scintilla/src/LexBaan.cxx
Normal file
@@ -0,0 +1,189 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexBaan.cxx
|
||||
** Lexer for Baan.
|
||||
** Based heavily on LexCPP.cxx
|
||||
**/
|
||||
// Copyright 2001- by Vamsi Potluru <vamsi@who.net> & Praveen Ambekar <ambekarpraveen@yahoo.com>
|
||||
// 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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '$' || ch == ':');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static void ColouriseBaanDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
|
||||
|
||||
if (initStyle == SCE_BAAN_STRINGEOL) // Does not leak onto next line
|
||||
initStyle = SCE_BAAN_DEFAULT;
|
||||
|
||||
int visibleChars = 0;
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (sc.state == SCE_BAAN_OPERATOR) {
|
||||
sc.SetState(SCE_BAAN_DEFAULT);
|
||||
} else if (sc.state == SCE_BAAN_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_BAAN_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_BAAN_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_BAAN_WORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_BAAN_WORD2);
|
||||
}
|
||||
sc.SetState(SCE_BAAN_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_BAAN_PREPROCESSOR) {
|
||||
if (stylingWithinPreprocessor) {
|
||||
if (IsASpace(sc.ch)) {
|
||||
sc.SetState(SCE_BAAN_DEFAULT);
|
||||
}
|
||||
} else {
|
||||
if (sc.atLineEnd && (sc.chNext != '^')) {
|
||||
sc.SetState(SCE_BAAN_DEFAULT);
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_BAAN_COMMENT) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_BAAN_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_BAAN_COMMENTDOC) {
|
||||
if (sc.MatchIgnoreCase("enddllusage")) {
|
||||
for (unsigned int i = 0; i < 10; i++){
|
||||
sc.Forward();
|
||||
}
|
||||
sc.ForwardSetState(SCE_BAAN_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_BAAN_STRING) {
|
||||
if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_BAAN_DEFAULT);
|
||||
} else if ((sc.atLineEnd) && (sc.chNext != '^')) {
|
||||
sc.ChangeState(SCE_BAAN_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_C_DEFAULT);
|
||||
visibleChars = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.state == SCE_BAAN_DEFAULT) {
|
||||
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_BAAN_NUMBER);
|
||||
} else if (sc.MatchIgnoreCase("dllusage")){
|
||||
sc.SetState(SCE_BAAN_COMMENTDOC);
|
||||
do {
|
||||
sc.Forward();
|
||||
} while ((!sc.atLineEnd) && sc.More());
|
||||
} else if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_BAAN_IDENTIFIER);
|
||||
} else if (sc.Match('|')){
|
||||
sc.SetState(SCE_BAAN_COMMENT);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_BAAN_STRING);
|
||||
} else if (sc.ch == '#' && visibleChars == 0) {
|
||||
// Preprocessor commands are alone on their line
|
||||
sc.SetState(SCE_BAAN_PREPROCESSOR);
|
||||
// Skip whitespace between # and preprocessor word
|
||||
do {
|
||||
sc.Forward();
|
||||
} while (IsASpace(sc.ch) && sc.More());
|
||||
} else if (isoperator(static_cast<char>(sc.ch))) {
|
||||
sc.SetState(SCE_BAAN_OPERATOR);
|
||||
}
|
||||
}
|
||||
if (sc.atLineEnd) {
|
||||
// Reset states to begining of colourise so no surprises
|
||||
// if different sets of lines lexed.
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!IsASpace(sc.ch)) {
|
||||
visibleChars++;
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static void FoldBaanDoc(unsigned int startPos, int length, int initStyle, WordList *[],
|
||||
Accessor &styler) {
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
unsigned int endPos = 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);
|
||||
int style = initStyle;
|
||||
for (unsigned int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int stylePrev = style;
|
||||
style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if (foldComment &&
|
||||
(style == SCE_BAAN_COMMENT || style == SCE_BAAN_COMMENTDOC)) {
|
||||
if (style != stylePrev) {
|
||||
levelCurrent++;
|
||||
} else if ((style != styleNext) && !atEOL) {
|
||||
// Comments don't end at end of line and the next character may be unstyled.
|
||||
levelCurrent--;
|
||||
}
|
||||
}
|
||||
if (style == SCE_BAAN_OPERATOR) {
|
||||
if (ch == '{') {
|
||||
levelCurrent++;
|
||||
} else if (ch == '}') {
|
||||
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);
|
||||
}
|
||||
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 lmBaan(SCLEX_BAAN, ColouriseBaanDoc, "baan", FoldBaanDoc);
|
233
contrib/src/stc/scintilla/src/LexBullant.cxx
Normal file
233
contrib/src/stc/scintilla/src/LexBullant.cxx
Normal file
@@ -0,0 +1,233 @@
|
||||
// SciTE - Scintilla based Text Editor
|
||||
// LexBullant.cxx - lexer for Bullant
|
||||
|
||||
#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 classifyWordBullant(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, "end method") == 0 ||
|
||||
strcmp(s, "end case") == 0 ||
|
||||
strcmp(s, "end class") == 0 ||
|
||||
strcmp(s, "end debug") == 0 ||
|
||||
strcmp(s, "end test") == 0 ||
|
||||
strcmp(s, "end if") == 0 ||
|
||||
strcmp(s, "end lock") == 0 ||
|
||||
strcmp(s, "end transaction") == 0 ||
|
||||
strcmp(s, "end trap") == 0 ||
|
||||
strcmp(s, "end until") == 0 ||
|
||||
strcmp(s, "end while") == 0)
|
||||
lev = -1;*/
|
||||
if (strcmp(s, "end") == 0)
|
||||
lev = -1;
|
||||
else if (strcmp(s, "method") == 0 ||
|
||||
strcmp(s, "case") == 0 ||
|
||||
strcmp(s, "class") == 0 ||
|
||||
strcmp(s, "debug") == 0 ||
|
||||
strcmp(s, "test") == 0 ||
|
||||
strcmp(s, "if") == 0 ||
|
||||
strcmp(s, "lock") == 0 ||
|
||||
strcmp(s, "transaction") == 0 ||
|
||||
strcmp(s, "trap") == 0 ||
|
||||
strcmp(s, "until") == 0 ||
|
||||
strcmp(s, "while") == 0)
|
||||
lev = 1;
|
||||
}
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
return lev;
|
||||
}
|
||||
|
||||
static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold") != 0;
|
||||
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;
|
||||
// int blockChange = 0;
|
||||
styler.StartSegment(startPos);
|
||||
int endFoundThisLine = 0;
|
||||
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
|
||||
endFoundThisLine = 0;
|
||||
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;
|
||||
|
||||
/* int indentBlock = GetLineIndentation(lineCurrent);
|
||||
if (blockChange==1){
|
||||
lineCurrent++;
|
||||
int pos=SetLineIndentation(lineCurrent, indentBlock + indentSize);
|
||||
} else if (blockChange==-1) {
|
||||
indentBlock -= indentSize;
|
||||
if (indentBlock < 0)
|
||||
indentBlock = 0;
|
||||
SetLineIndentation(lineCurrent, indentBlock);
|
||||
lineCurrent++;
|
||||
}
|
||||
blockChange=0;
|
||||
*/ }
|
||||
if (!isspace(ch))
|
||||
visibleChars++;
|
||||
|
||||
if (styler.IsLeadByte(ch)) {
|
||||
chNext = styler.SafeGetCharAt(i + 2);
|
||||
chPrev = ' ';
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (iswordstart(ch)) {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_IDENTIFIER;
|
||||
} else if (ch == '@' && chNext == 'o') {
|
||||
if ((styler.SafeGetCharAt(i+2) =='f') && (styler.SafeGetCharAt(i+3) == 'f')) {
|
||||
styler.ColourTo(i-1, state);
|
||||
state = SCE_C_COMMENT;
|
||||
}
|
||||
} else if (ch == '#') {
|
||||
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 (isoperator(ch)) {
|
||||
styler.ColourTo(i-1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
} else if (state == SCE_C_IDENTIFIER) {
|
||||
if (!iswordchar(ch)) {
|
||||
int levelChange = classifyWordBullant(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||
state = SCE_C_DEFAULT;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
if (ch == '#') {
|
||||
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 (endFoundThisLine == 0)
|
||||
levelCurrent+=levelChange;
|
||||
if (levelChange == -1)
|
||||
endFoundThisLine=1;
|
||||
}
|
||||
} else if (state == SCE_C_COMMENT) {
|
||||
if (ch == '@' && chNext == 'o') {
|
||||
if (styler.SafeGetCharAt(i+2) == 'n') {
|
||||
styler.ColourTo(i+2, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
i+=2;
|
||||
}
|
||||
}
|
||||
} else if (state == SCE_C_COMMENTLINE) {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
endFoundThisLine = 0;
|
||||
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') {
|
||||
endFoundThisLine = 0;
|
||||
styler.ColourTo(i-1, SCE_C_STRINGEOL);
|
||||
state = SCE_C_STRINGEOL;
|
||||
}
|
||||
} else if (state == SCE_C_CHARACTER) {
|
||||
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||
endFoundThisLine = 0;
|
||||
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, levelCurrent | flagsNext);
|
||||
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmBullant(SCLEX_BULLANT, ColouriseBullantDoc, "bullant");
|
@@ -2,7 +2,7 @@
|
||||
/** @file LexCPP.cxx
|
||||
** Lexer for C++, C, Java, and Javascript.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -24,22 +24,22 @@ static bool IsOKBeforeRE(const int ch) {
|
||||
return (ch == '(') || (ch == '=') || (ch == ',');
|
||||
}
|
||||
|
||||
inline bool IsAWordChar(const int ch) {
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
inline bool IsAWordStart(const int ch) {
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
inline bool IsADoxygenChar(const int ch) {
|
||||
static inline bool IsADoxygenChar(const int ch) {
|
||||
return (islower(ch) || ch == '$' || ch == '@' ||
|
||||
ch == '\\' || ch == '&' || ch == '<' ||
|
||||
ch == '>' || ch == '#' || ch == '{' ||
|
||||
ch == '}' || ch == '[' || ch == ']');
|
||||
}
|
||||
|
||||
inline bool IsStateComment(const int state) {
|
||||
static inline bool IsStateComment(const int state) {
|
||||
return ((state == SCE_C_COMMENT) ||
|
||||
(state == SCE_C_COMMENTLINE) ||
|
||||
(state == SCE_C_COMMENTDOC) ||
|
||||
@@ -47,7 +47,7 @@ inline bool IsStateComment(const int state) {
|
||||
(state == SCE_C_COMMENTDOCKEYWORDERROR));
|
||||
}
|
||||
|
||||
inline bool IsStateString(const int state) {
|
||||
static inline bool IsStateString(const int state) {
|
||||
return ((state == SCE_C_STRING) || (state == SCE_C_VERBATIM));
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
|
||||
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
|
||||
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
|
||||
|
||||
// Do not leak onto next line
|
||||
if (initStyle == SCE_C_STRINGEOL)
|
||||
@@ -66,7 +66,6 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
|
||||
int chPrevNonWhite = ' ';
|
||||
int visibleChars = 0;
|
||||
int noDocChars = 0;
|
||||
bool lastWordWasUUID = false;
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
@@ -126,12 +125,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
if (sc.Match('*', '/')) {
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_C_DEFAULT);
|
||||
} else if ((sc.ch == '@' || sc.ch == '\\') && (noDocChars == 0)) {
|
||||
} else if (sc.ch == '@' || sc.ch == '\\') {
|
||||
sc.SetState(SCE_C_COMMENTDOCKEYWORD);
|
||||
} else if (sc.atLineEnd) {
|
||||
noDocChars = 0;
|
||||
} else if (!isspace(sc.ch) && (sc.ch != '*')) {
|
||||
noDocChars++;
|
||||
}
|
||||
} else if (sc.state == SCE_C_COMMENTLINE || sc.state == SCE_C_COMMENTLINEDOC) {
|
||||
if (sc.atLineEnd) {
|
||||
@@ -219,7 +214,6 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
}
|
||||
} else if (sc.Match('/', '*')) {
|
||||
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
|
||||
noDocChars = 0;
|
||||
sc.SetState(SCE_C_COMMENTDOC);
|
||||
} else {
|
||||
sc.SetState(SCE_C_COMMENT);
|
||||
@@ -268,8 +262,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
|
||||
|
||||
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);
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
unsigned int endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
|
@@ -172,6 +172,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k
|
||||
|
||||
}
|
||||
}
|
||||
delete []buffer;
|
||||
}
|
||||
|
||||
LexerModule lmConf(SCLEX_CONF, ColouriseConfDoc, "conf");
|
||||
|
@@ -199,6 +199,7 @@ static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordLi
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete []buffer;
|
||||
}
|
||||
|
||||
LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab");
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
inline bool isEiffelOperator(unsigned int ch) {
|
||||
static 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 == '=' ||
|
||||
@@ -32,11 +32,11 @@ inline bool isEiffelOperator(unsigned int ch) {
|
||||
ch == '!' || ch == '@' || ch == '?';
|
||||
}
|
||||
|
||||
inline bool IsAWordChar(unsigned int ch) {
|
||||
static inline bool IsAWordChar(unsigned int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
inline bool IsAWordStart(unsigned int ch) {
|
||||
static inline bool IsAWordStart(unsigned int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file LexHTML.cxx
|
||||
** Lexer for HTML.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
@@ -23,10 +24,18 @@
|
||||
#define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
|
||||
#define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
|
||||
|
||||
enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
|
||||
enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
|
||||
enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
|
||||
enum script_mode { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
|
||||
|
||||
static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, script_type prevValue) {
|
||||
char s[30 + 1];
|
||||
unsigned int i = 0;
|
||||
for (; i < end - start + 1 && i < 30; i++) {
|
||||
@@ -67,7 +76,7 @@ static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, u
|
||||
return iResult;
|
||||
}
|
||||
|
||||
static int ScriptOfState(int state) {
|
||||
static script_type ScriptOfState(int state) {
|
||||
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
|
||||
return eScriptPython;
|
||||
} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
|
||||
@@ -76,7 +85,7 @@ static int ScriptOfState(int state) {
|
||||
return eScriptJS;
|
||||
} else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
|
||||
return eScriptPHP;
|
||||
} else if ((state >= SCE_H_SGML_DEFAULT) && (state <= SCE_H_SGML_BLOCK_DEFAULT)) {
|
||||
} else if ((state >= SCE_H_SGML_DEFAULT) && (state < SCE_H_SGML_BLOCK_DEFAULT)) {
|
||||
return eScriptSGML;
|
||||
} else if (state == SCE_H_SGML_BLOCK_DEFAULT) {
|
||||
return eScriptSGMLblock;
|
||||
@@ -85,7 +94,7 @@ static int ScriptOfState(int state) {
|
||||
}
|
||||
}
|
||||
|
||||
static int statePrintForState(int state, int inScriptType) {
|
||||
static int statePrintForState(int state, script_mode inScriptType) {
|
||||
int StateToPrint;
|
||||
|
||||
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
|
||||
@@ -219,7 +228,7 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
|
||||
}
|
||||
|
||||
static void classifyWordHTJS(unsigned int start, unsigned int end,
|
||||
WordList &keywords, Accessor &styler, int inScriptType) {
|
||||
WordList &keywords, Accessor &styler, script_mode inScriptType) {
|
||||
char chAttr = SCE_HJ_WORD;
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
if (wordIsNumber)
|
||||
@@ -237,7 +246,7 @@ static void classifyWordHTJS(unsigned int start, unsigned int end,
|
||||
styler.ColourTo(end, statePrintForState(chAttr, inScriptType));
|
||||
}
|
||||
|
||||
static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, int inScriptType) {
|
||||
static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) {
|
||||
char chAttr = SCE_HB_IDENTIFIER;
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||
if (wordIsNumber)
|
||||
@@ -262,8 +271,8 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
|
||||
return SCE_HB_DEFAULT;
|
||||
}
|
||||
|
||||
static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) {
|
||||
bool wordIsNumber = isdigit(styler[start]);
|
||||
static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) {
|
||||
bool wordIsNumber = isdigit(styler[start]) != 0;
|
||||
char s[30 + 1];
|
||||
unsigned int i = 0;
|
||||
for (; i < end - start + 1 && i < 30; i++) {
|
||||
@@ -287,14 +296,14 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key
|
||||
// Called when in a PHP word
|
||||
static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
char chAttr = SCE_HPHP_DEFAULT;
|
||||
bool wordIsNumber = isdigit(styler[start]);
|
||||
bool wordIsNumber = isdigit(styler[start]) != 0;
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_HPHP_NUMBER;
|
||||
else {
|
||||
char s[30 + 1];
|
||||
char s[100 + 1];
|
||||
unsigned int i = 0;
|
||||
for (; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = styler[start + i];
|
||||
for (; i < end - start + 1 && i < 100; i++) {
|
||||
s[i] = static_cast<char>(tolower(styler[start + i]));
|
||||
}
|
||||
s[i] = '\0';
|
||||
if (keywords.InList(s))
|
||||
@@ -324,7 +333,7 @@ static bool isWordCdata(unsigned int start, unsigned int end, Accessor &styler)
|
||||
}
|
||||
|
||||
// Return the first state to reach when entering a scripting language
|
||||
static int StateForScript(int scriptLanguage) {
|
||||
static int StateForScript(script_type scriptLanguage) {
|
||||
int Result;
|
||||
switch (scriptLanguage) {
|
||||
case eScriptVBS:
|
||||
@@ -349,11 +358,11 @@ static int StateForScript(int scriptLanguage) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline bool ishtmlwordchar(char ch) {
|
||||
static inline bool ishtmlwordchar(char ch) {
|
||||
return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
|
||||
}
|
||||
|
||||
inline bool issgmlwordchar(char ch) {
|
||||
static inline bool issgmlwordchar(char ch) {
|
||||
return isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[';
|
||||
}
|
||||
|
||||
@@ -419,18 +428,18 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
lineState = eScriptJS << 8;
|
||||
lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4;
|
||||
}
|
||||
int inScriptType = (lineState >> 0) & 0x03; // 2 bits of scripting type
|
||||
script_mode inScriptType = script_mode((lineState >> 0) & 0x03); // 2 bits of scripting mode
|
||||
bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
|
||||
bool tagClosing = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
|
||||
int aspScript = (lineState >> 4) & 0x0F; // 4 bits of script name
|
||||
int clientScript = (lineState >> 8) & 0x0F; // 4 bits of script name
|
||||
script_type aspScript = script_type((lineState >> 4) & 0x0F); // 4 bits of script name
|
||||
script_type clientScript = script_type((lineState >> 8) & 0x0F); // 4 bits of script name
|
||||
int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state
|
||||
|
||||
int scriptLanguage = ScriptOfState(state);
|
||||
script_type scriptLanguage = ScriptOfState(state);
|
||||
|
||||
const bool foldHTML = styler.GetPropertyInt("fold.html", 0);
|
||||
const bool foldHTML = styler.GetPropertyInt("fold.html", 0) != 0;
|
||||
const bool fold = foldHTML && styler.GetPropertyInt("fold");
|
||||
const bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
|
||||
const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
@@ -502,6 +511,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,8 +740,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
}
|
||||
break;
|
||||
case SCE_H_SGML_DEFAULT:
|
||||
if (scriptLanguage == eScriptSGMLblock)
|
||||
StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
|
||||
case SCE_H_SGML_BLOCK_DEFAULT:
|
||||
// if (scriptLanguage == eScriptSGMLblock)
|
||||
// StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
|
||||
|
||||
if (ch == '\"') {
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
@@ -750,6 +762,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
} else if (ch == '[') {
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
scriptLanguage = eScriptSGMLblock;
|
||||
state = SCE_H_SGML_BLOCK_DEFAULT;
|
||||
} else if (ch == ']') {
|
||||
if (scriptLanguage == eScriptSGMLblock) {
|
||||
styler.ColourTo(i, StateToPrint);
|
||||
@@ -758,6 +771,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
styler.ColourTo(i - 1, StateToPrint);
|
||||
styler.ColourTo(i, SCE_H_SGML_ERROR);
|
||||
}
|
||||
state = SCE_H_SGML_DEFAULT;
|
||||
} else if (scriptLanguage == eScriptSGMLblock) {
|
||||
if ((ch == '!') && (chPrev == '<')) {
|
||||
styler.ColourTo(i - 2, StateToPrint);
|
||||
@@ -805,7 +819,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
i += size - 1;
|
||||
visibleChars += size - 1;
|
||||
ch = styler.SafeGetCharAt(i);
|
||||
if (scriptLanguage == eScriptSGMLblock) {
|
||||
state = SCE_H_SGML_BLOCK_DEFAULT;
|
||||
} else {
|
||||
state = SCE_H_SGML_DEFAULT;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
@@ -1541,5 +1559,299 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
|
||||
}
|
||||
}
|
||||
|
||||
static bool isASPScript(int state) {
|
||||
return
|
||||
(state >= SCE_HJA_START && state <= SCE_HJA_REGEX) ||
|
||||
(state >= SCE_HBA_START && state <= SCE_HBA_STRINGEOL) ||
|
||||
(state >= SCE_HPA_DEFAULT && state <= SCE_HPA_IDENTIFIER);
|
||||
}
|
||||
|
||||
static void ColouriseHBAPiece(StyleContext &sc, WordList *keywordlists[]) {
|
||||
WordList &keywordsVBS = *keywordlists[2];
|
||||
if (sc.state == SCE_HBA_WORD) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (keywordsVBS.InList(s)) {
|
||||
if (strcmp(s, "rem") == 0) {
|
||||
sc.ChangeState(SCE_HBA_COMMENTLINE);
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_HBA_DEFAULT);
|
||||
}
|
||||
} else {
|
||||
sc.SetState(SCE_HBA_DEFAULT);
|
||||
}
|
||||
} else {
|
||||
sc.ChangeState(SCE_HBA_IDENTIFIER);
|
||||
sc.SetState(SCE_HBA_DEFAULT);
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_HBA_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_HBA_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HBA_STRING) {
|
||||
if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_HBA_DEFAULT);
|
||||
} else if (sc.ch == '\r' || sc.ch == '\n') {
|
||||
sc.ChangeState(SCE_HBA_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_HBA_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HBA_COMMENTLINE) {
|
||||
if (sc.ch == '\r' || sc.ch == '\n') {
|
||||
sc.SetState(SCE_HBA_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.state == SCE_HBA_DEFAULT) {
|
||||
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_HBA_NUMBER);
|
||||
} else if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_HBA_WORD);
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_HBA_COMMENTLINE);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_HBA_STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseHTMLPiece(StyleContext &sc, WordList *keywordlists[]) {
|
||||
WordList &keywordsTags = *keywordlists[0];
|
||||
if (sc.state == SCE_H_COMMENT) {
|
||||
if (sc.Match("-->")) {
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_H_ENTITY) {
|
||||
if (sc.ch == ';') {
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
} else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch)) { // Should check that '#' follows '&', but it is unlikely anyway...
|
||||
sc.ChangeState(SCE_H_TAGUNKNOWN);
|
||||
sc.SetState(SCE_H_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_H_TAGUNKNOWN) {
|
||||
if (!ishtmlwordchar(static_cast<char>(sc.ch)) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (s[1] == '/') {
|
||||
if (keywordsTags.InList(s + 2)) {
|
||||
sc.ChangeState(SCE_H_TAG);
|
||||
}
|
||||
} else {
|
||||
if (keywordsTags.InList(s + 1)) {
|
||||
sc.ChangeState(SCE_H_TAG);
|
||||
}
|
||||
}
|
||||
if (sc.ch == '>') {
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
} else if (sc.Match('/', '>')) {
|
||||
sc.SetState(SCE_H_TAGEND);
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
} else {
|
||||
sc.SetState(SCE_H_OTHER);
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_H_ATTRIBUTE) {
|
||||
if (!ishtmlwordchar(static_cast<char>(sc.ch))) {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (!keywordsTags.InList(s)) {
|
||||
sc.ChangeState(SCE_H_ATTRIBUTEUNKNOWN);
|
||||
}
|
||||
sc.SetState(SCE_H_OTHER);
|
||||
}
|
||||
} else if (sc.state == SCE_H_OTHER) {
|
||||
if (sc.ch == '>') {
|
||||
sc.SetState(SCE_H_TAG);
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
} else if (sc.Match('/', '>')) {
|
||||
sc.SetState(SCE_H_TAG);
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
} else if (sc.chPrev == '=') {
|
||||
sc.SetState(SCE_H_VALUE);
|
||||
}
|
||||
} else if (sc.state == SCE_H_DOUBLESTRING) {
|
||||
if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_H_OTHER);
|
||||
}
|
||||
} else if (sc.state == SCE_H_SINGLESTRING) {
|
||||
if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_H_OTHER);
|
||||
}
|
||||
} else if (sc.state == SCE_H_NUMBER) {
|
||||
if (!IsADigit(sc.ch)) {
|
||||
sc.SetState(SCE_H_OTHER);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.state == SCE_H_DEFAULT) {
|
||||
if (sc.ch == '<') {
|
||||
if (sc.Match("<!--"))
|
||||
sc.SetState(SCE_H_COMMENT);
|
||||
else
|
||||
sc.SetState(SCE_H_TAGUNKNOWN);
|
||||
} else if (sc.ch == '&') {
|
||||
sc.SetState(SCE_H_ENTITY);
|
||||
}
|
||||
} else if ((sc.state == SCE_H_OTHER) || (sc.state == SCE_H_VALUE)) {
|
||||
if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_H_DOUBLESTRING);
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_H_SINGLESTRING);
|
||||
} else if (IsADigit(sc.ch)) {
|
||||
sc.SetState(SCE_H_NUMBER);
|
||||
} else if (sc.ch == '>') {
|
||||
sc.SetState(SCE_H_TAG);
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
} else if (ishtmlwordchar(static_cast<char>(sc.ch))) {
|
||||
sc.SetState(SCE_H_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseASPPiece(StyleContext &sc, WordList *keywordlists[]) {
|
||||
// Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
|
||||
if ((sc.state == SCE_H_ASPAT || isASPScript(sc.state)) && sc.Match('%', '>')) {
|
||||
sc.SetState(SCE_H_ASP);
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
}
|
||||
|
||||
// Handle some ASP script
|
||||
if (sc.state >= SCE_HBA_START && sc.state <= SCE_HBA_STRINGEOL) {
|
||||
ColouriseHBAPiece(sc, keywordlists);
|
||||
} else if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) {
|
||||
ColouriseHTMLPiece(sc, keywordlists);
|
||||
}
|
||||
|
||||
// Enter new sc.state
|
||||
if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) {
|
||||
if (sc.Match('<', '%')) {
|
||||
if (sc.state == SCE_H_TAGUNKNOWN)
|
||||
sc.ChangeState(SCE_H_ASP);
|
||||
else
|
||||
sc.SetState(SCE_H_ASP);
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
if (sc.ch == '@') {
|
||||
sc.ForwardSetState(SCE_H_ASPAT);
|
||||
} else {
|
||||
if (sc.ch == '=') {
|
||||
sc.Forward();
|
||||
}
|
||||
sc.SetState(SCE_HBA_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
// Lexer for HTML requires more lexical states (7 bits worth) than most lexers
|
||||
StyleContext sc(startPos, length, initStyle, styler, 0x7f);
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
ColouriseASPPiece(sc, keywordlists);
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static void ColourisePHPPiece(StyleContext &sc, WordList *keywordlists[]) {
|
||||
// Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
|
||||
if (sc.state >= SCE_HPHP_DEFAULT && sc.state <= SCE_HPHP_OPERATOR) {
|
||||
if (!isPHPStringState(sc.state) &&
|
||||
(sc.state != SCE_HPHP_COMMENT) &&
|
||||
(sc.Match('?', '>'))) {
|
||||
sc.SetState(SCE_H_QUESTION);
|
||||
sc.Forward();
|
||||
sc.ForwardSetState(SCE_H_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) {
|
||||
ColouriseHTMLPiece(sc, keywordlists);
|
||||
}
|
||||
|
||||
// Handle some PHP script
|
||||
if (sc.state == SCE_HPHP_WORD) {
|
||||
if (!IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HPHP_COMMENTLINE) {
|
||||
if (sc.ch == '\r' || sc.ch == '\n') {
|
||||
sc.SetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HPHP_COMMENT) {
|
||||
if (sc.Match('*', '/')) {
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
sc.SetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HPHP_HSTRING) {
|
||||
if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HPHP_SIMPLESTRING) {
|
||||
if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HPHP_VARIABLE) {
|
||||
if (!IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_HPHP_OPERATOR) {
|
||||
sc.SetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
|
||||
// Enter new sc.state
|
||||
if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) {
|
||||
if (sc.Match("<?php")) {
|
||||
sc.SetState(SCE_H_QUESTION);
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
sc.SetState(SCE_HPHP_DEFAULT);
|
||||
}
|
||||
}
|
||||
if (sc.state == SCE_HPHP_DEFAULT) {
|
||||
if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_HPHP_WORD);
|
||||
} else if (sc.ch == '#') {
|
||||
sc.SetState(SCE_HPHP_COMMENTLINE);
|
||||
} else if (sc.Match("<!--")) {
|
||||
sc.SetState(SCE_HPHP_COMMENTLINE);
|
||||
} else if (sc.Match('/', '/')) {
|
||||
sc.SetState(SCE_HPHP_COMMENTLINE);
|
||||
} else if (sc.Match('/', '*')) {
|
||||
sc.SetState(SCE_HPHP_COMMENT);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_HPHP_HSTRING);
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_HPHP_SIMPLESTRING);
|
||||
} else if (sc.ch == '$') {
|
||||
sc.SetState(SCE_HPHP_VARIABLE);
|
||||
} else if (isoperator(static_cast<char>(sc.ch))) {
|
||||
sc.SetState(SCE_HPHP_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
// Lexer for HTML requires more lexical states (7 bits worth) than most lexers
|
||||
StyleContext sc(startPos, length, initStyle, styler, 0x7f);
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
ColourisePHPPiece(sc, keywordlists);
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
|
||||
LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
|
||||
LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp");
|
||||
LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php");
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include "SciLexer.h"
|
||||
|
||||
|
||||
inline bool isLispoperator(char ch) {
|
||||
static inline bool isLispoperator(char ch) {
|
||||
if (isascii(ch) && isalnum(ch))
|
||||
return false;
|
||||
if (ch == '\'' || ch == '(' || ch == ')' )
|
||||
@@ -29,7 +29,7 @@ inline bool isLispoperator(char ch) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isLispwordstart(char ch) {
|
||||
static inline bool isLispwordstart(char ch) {
|
||||
return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) &&
|
||||
ch != '\n' && ch != '\r' && ch != '\"';
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@
|
||||
**
|
||||
** Written by Paul Winwood.
|
||||
** Folder by Alexey Yutkin.
|
||||
** Modified by Marcos E. Wurzius
|
||||
**/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -17,10 +18,21 @@
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
|
||||
inline bool isLuaOperator(char ch) {
|
||||
if (isalnum(ch))
|
||||
return false;
|
||||
@@ -35,198 +47,133 @@ inline bool isLuaOperator(char ch) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void classifyWordLua(unsigned int start,
|
||||
unsigned int end,
|
||||
WordList &keywords,
|
||||
Accessor &styler) {
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (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_LUA_IDENTIFIER;
|
||||
|
||||
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,
|
||||
int length,
|
||||
int initStyle,
|
||||
WordList *keywordlists[],
|
||||
static void ColouriseLuaDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
WordList &keywords5 = *keywordlists[4];
|
||||
WordList &keywords6 = *keywordlists[5];
|
||||
int literalString = 0;
|
||||
int literalStringFlag =0;
|
||||
|
||||
styler.StartAt(startPos);
|
||||
styler.GetLine(startPos);
|
||||
// Do not leak onto next line
|
||||
if (initStyle == SCE_LUA_STRINGEOL)
|
||||
initStyle = SCE_LUA_DEFAULT;
|
||||
|
||||
int state = initStyle;
|
||||
char chPrev = ' ';
|
||||
char chNext = styler[startPos];
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
bool firstChar = true;
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
if(startPos == 0 && sc.ch == '#') sc.SetState(SCE_LUA_COMMENTLINE);
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
/* 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;
|
||||
// Handle line continuation generically.
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.Match("\\\n")) {
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == SCE_LUA_STRINGEOL) {
|
||||
if (ch != '\r' && ch != '\n') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_LUA_DEFAULT;
|
||||
if (sc.Match("\\\r\n")) {
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == SCE_LUA_LITERALSTRING && ch == '[' && chNext == '[') {
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_LUA_OPERATOR) {
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
} else if (sc.state == SCE_LUA_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_LUA_IDENTIFIER) {
|
||||
if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
if (keywords.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD);
|
||||
} else if (keywords2.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD2);
|
||||
} else if (keywords3.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD3);
|
||||
} else if (keywords4.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD4);
|
||||
} else if (keywords5.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD5);
|
||||
} else if (keywords6.InList(s)) {
|
||||
sc.ChangeState(SCE_LUA_WORD6);
|
||||
}
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
} else if (sc.state == SCE_LUA_COMMENTLINE ) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_LUA_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_LUA_STRING) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_LUA_DEFAULT);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ChangeState(SCE_LUA_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_LUA_DEFAULT);
|
||||
}
|
||||
|
||||
} else if (sc.state == SCE_LUA_CHARACTER) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_LUA_DEFAULT);
|
||||
} else if (sc.atLineEnd) {
|
||||
sc.ChangeState(SCE_LUA_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_LUA_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_LUA_LITERALSTRING) {
|
||||
if (sc.chPrev == '[' && sc.ch == '[' && literalStringFlag != 1) {
|
||||
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;
|
||||
literalStringFlag = 1;
|
||||
}
|
||||
else if (sc.chPrev == ']' && sc.ch == ']' && literalStringFlag != 2 ) {
|
||||
if((--literalString == 1))
|
||||
sc.ForwardSetState(SCE_LUA_DEFAULT);
|
||||
literalStringFlag = 2;
|
||||
}
|
||||
else literalStringFlag = 0;
|
||||
}
|
||||
// Determine if a new state should be entered.
|
||||
if (sc.state == SCE_LUA_DEFAULT) {
|
||||
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_LUA_NUMBER);
|
||||
} else if (IsAWordStart(sc.ch) || (sc.ch == '@')) {
|
||||
sc.SetState(SCE_LUA_IDENTIFIER);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_LUA_STRING);
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_LUA_CHARACTER);
|
||||
} else if (sc.ch == '[' && sc.chNext == '[') {
|
||||
sc.SetState(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);
|
||||
} else if (sc.ch == '-' && sc.chNext == '-') {
|
||||
sc.SetState(SCE_LUA_COMMENTLINE);
|
||||
} else if (isLuaOperator(static_cast<char>(sc.ch))) {
|
||||
sc.SetState(SCE_LUA_OPERATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
chPrev = ch;
|
||||
firstChar = (ch == '\r' || ch == '\n');
|
||||
}
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
|
||||
static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[],
|
||||
Accessor &styler) {
|
||||
unsigned int lengthDoc = startPos + length;
|
||||
@@ -235,6 +182,7 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
char chNext = styler[startPos];
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
char s[10];
|
||||
for (unsigned int i = startPos; i < lengthDoc; i++) {
|
||||
@@ -243,23 +191,34 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
|
||||
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') {
|
||||
if (style == SCE_LUA_WORD) {
|
||||
if ( ch == 'i' || ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') {
|
||||
for (unsigned int j = 0; j < 8; j++) {
|
||||
if (!iswordchar(styler[i + j])) break;
|
||||
if (!iswordchar(styler[i + j]))
|
||||
break;
|
||||
s[j] = styler[i + j];
|
||||
s[j + 1] = '\0';
|
||||
}
|
||||
|
||||
if ((strcmp(s, "then") == 0) || (strcmp(s, "do") == 0)
|
||||
if ((strcmp(s, "if") == 0) || (strcmp(s, "do") == 0)
|
||||
|| (strcmp(s, "function") == 0))
|
||||
levelCurrent++;
|
||||
if (strcmp(s, "end") == 0) levelCurrent--;
|
||||
if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0))
|
||||
levelCurrent--;
|
||||
|
||||
}
|
||||
}
|
||||
else if (style == SCE_LUA_OPERATOR)
|
||||
{
|
||||
if(ch == '{' || ch == '(')
|
||||
levelCurrent++;
|
||||
else if(ch == '}' || ch == ')')
|
||||
levelCurrent--;
|
||||
}
|
||||
|
||||
if (atEOL) {
|
||||
int lev = levelPrev;
|
||||
if (visibleChars == 0)
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
if ((levelCurrent > levelPrev) && (visibleChars > 0))
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
@@ -274,6 +233,7 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
|
||||
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);
|
||||
}
|
||||
|
168
contrib/src/stc/scintilla/src/LexMatlab.cxx
Normal file
168
contrib/src/stc/scintilla/src/LexMatlab.cxx
Normal file
@@ -0,0 +1,168 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexMatlab.cxx
|
||||
** Lexer for Matlab.
|
||||
** Written by Jos<6F> Fonseca
|
||||
**/
|
||||
// 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 "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static bool IsMatlabComment(Accessor &styler, int pos, int len) {
|
||||
return len > 0 && (styler[pos] == '%' || styler[pos] == '!') ;
|
||||
}
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool transpose = false;
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (sc.state == SCE_MATLAB_OPERATOR) {
|
||||
if (sc.chPrev == '.') {
|
||||
if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') {
|
||||
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = false;
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = true;
|
||||
} else {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
}
|
||||
} else {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_KEYWORD) {
|
||||
if (!isalnum(sc.ch) && sc.ch != '_') {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (keywords.InList(s)) {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = false;
|
||||
} else {
|
||||
sc.ChangeState(SCE_MATLAB_IDENTIFIER);
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = true;
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_NUMBER) {
|
||||
if (!isdigit(sc.ch) && sc.ch != '.'
|
||||
&& !(sc.ch == 'e' || sc.ch == 'E')
|
||||
&& !((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E'))) {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = true;
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_STRING) {
|
||||
// Matlab doubles quotes to preserve them, so just end this string
|
||||
// state now as a following quote will start again
|
||||
if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.state == SCE_MATLAB_DEFAULT) {
|
||||
if (sc.ch == '%') {
|
||||
sc.SetState(SCE_MATLAB_COMMENT);
|
||||
} else if (sc.ch == '!') {
|
||||
sc.SetState(SCE_MATLAB_COMMAND);
|
||||
} else if (sc.ch == '\'') {
|
||||
if (transpose) {
|
||||
sc.SetState(SCE_MATLAB_OPERATOR);
|
||||
} else {
|
||||
sc.SetState(SCE_MATLAB_STRING);
|
||||
}
|
||||
} else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) {
|
||||
sc.SetState(SCE_MATLAB_NUMBER);
|
||||
} else if (isalpha(sc.ch)) {
|
||||
sc.SetState(SCE_MATLAB_KEYWORD);
|
||||
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
|
||||
if (sc.ch == ')' || sc.ch == ']') {
|
||||
transpose = true;
|
||||
} else {
|
||||
transpose = false;
|
||||
}
|
||||
sc.SetState(SCE_MATLAB_OPERATOR);
|
||||
} else {
|
||||
transpose = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static void FoldMatlabDoc(unsigned int startPos, int length, int,
|
||||
WordList *[], Accessor &styler) {
|
||||
int endPos = 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, IsMatlabComment);
|
||||
char chNext = styler[startPos];
|
||||
for (int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
|
||||
int lev = indentCurrent;
|
||||
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsMatlabComment);
|
||||
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, IsMatlabComment);
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
indentCurrent = indentNext;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
lineCurrent++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmMatlab(SCLEX_MATLAB, ColouriseMatlabDoc, "matlab", FoldMatlabDoc);
|
@@ -20,6 +20,11 @@
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static inline bool AtEOL(Accessor &styler, unsigned int i) {
|
||||
return (styler[i] == '\n') ||
|
||||
((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
|
||||
}
|
||||
|
||||
static void ColouriseBatchLine(
|
||||
char *lineBuffer,
|
||||
unsigned int lengthLine,
|
||||
@@ -31,13 +36,13 @@ static void ColouriseBatchLine(
|
||||
unsigned int i = 0;
|
||||
unsigned int state = SCE_BAT_DEFAULT;
|
||||
|
||||
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip initial spaces
|
||||
while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip initial spaces
|
||||
i++;
|
||||
}
|
||||
if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
|
||||
styler.ColourTo(startLine + i, SCE_BAT_HIDE);
|
||||
i++;
|
||||
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip next spaces
|
||||
while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip next spaces
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -130,23 +135,20 @@ static void ColouriseBatchDoc(
|
||||
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0, startLine = startPos;
|
||||
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||
unsigned int linePos = 0;
|
||||
unsigned int 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)) {
|
||||
if (AtEOL(styler, i) || (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,
|
||||
if (linePos > 0) { // Last line does not have ending characters
|
||||
ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
|
||||
keywords, styler);
|
||||
}
|
||||
}
|
||||
@@ -182,13 +184,16 @@ static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[
|
||||
unsigned int linePos = 0;
|
||||
for (unsigned int i = startPos; i < startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
// End of line (or of line buffer) met, colourise it
|
||||
lineBuffer[linePos] = '\0';
|
||||
ColouriseDiffLine(lineBuffer, i, styler);
|
||||
linePos = 0;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColouriseDiffLine(lineBuffer, startPos + length, styler);
|
||||
if (linePos > 0) { // Last line does not have ending characters
|
||||
ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
|
||||
}
|
||||
}
|
||||
|
||||
static void ColourisePropsLine(
|
||||
@@ -199,8 +204,9 @@ static void ColourisePropsLine(
|
||||
Accessor &styler) {
|
||||
|
||||
unsigned int i = 0;
|
||||
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
|
||||
while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
|
||||
i++;
|
||||
if (i < lengthLine) {
|
||||
if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
|
||||
styler.ColourTo(endPos, 1);
|
||||
} else if (lineBuffer[i] == '[') {
|
||||
@@ -212,9 +218,9 @@ static void ColourisePropsLine(
|
||||
styler.ColourTo(endPos, 0);
|
||||
} else {
|
||||
// Search for the '=' character
|
||||
while (lineBuffer[i] != '=' && (i < lengthLine - 1))
|
||||
while ((i < lengthLine) && (lineBuffer[i] != '='))
|
||||
i++;
|
||||
if (lineBuffer[i] == '=') {
|
||||
if ((i < lengthLine) && (lineBuffer[i] == '=')) {
|
||||
styler.ColourTo(startLine + i - 1, 0);
|
||||
styler.ColourTo(startLine + i, 3);
|
||||
styler.ColourTo(endPos, 0);
|
||||
@@ -222,26 +228,30 @@ static void ColourisePropsLine(
|
||||
styler.ColourTo(endPos, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
styler.ColourTo(endPos, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
|
||||
char lineBuffer[1024];
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0, startLine = startPos;
|
||||
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||
unsigned int linePos = 0;
|
||||
unsigned int startLine = startPos;
|
||||
for (unsigned int i = startPos; i < startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if ((styler[i] == '\r' && styler.SafeGetCharAt(i + 1) != '\n') ||
|
||||
styler[i] == '\n' ||
|
||||
(linePos >= sizeof(lineBuffer) - 1)) {
|
||||
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
// End of line (or of line buffer) met, colourise it
|
||||
lineBuffer[linePos] = '\0';
|
||||
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
|
||||
linePos = 0;
|
||||
startLine = i + 1;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
|
||||
if (linePos > 0) { // Last line does not have ending characters
|
||||
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
|
||||
}
|
||||
}
|
||||
|
||||
static void ColouriseMakeLine(
|
||||
@@ -256,7 +266,7 @@ static void ColouriseMakeLine(
|
||||
unsigned int state = SCE_MAKE_DEFAULT;
|
||||
bool bSpecial = false;
|
||||
// Skip initial spaces
|
||||
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) {
|
||||
while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
|
||||
i++;
|
||||
}
|
||||
if (lineBuffer[i] == '#') { // Comment
|
||||
@@ -277,6 +287,8 @@ static void ColouriseMakeLine(
|
||||
}
|
||||
if (!bSpecial) {
|
||||
if (lineBuffer[i] == ':') {
|
||||
// We should check that no colouring was made since the beginning of the line,
|
||||
// to avoid colouring stuff like /OUT:file
|
||||
styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
|
||||
styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
|
||||
styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
|
||||
@@ -306,18 +318,20 @@ static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[
|
||||
char lineBuffer[1024];
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0, startLine = startPos;
|
||||
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||
unsigned int linePos = 0;
|
||||
unsigned int 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)) {
|
||||
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
// End of line (or of line buffer) met, colourise it
|
||||
lineBuffer[linePos] = '\0';
|
||||
ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
|
||||
linePos = 0;
|
||||
startLine = i + 1;
|
||||
}
|
||||
}
|
||||
if (linePos > 0) {
|
||||
ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length, styler);
|
||||
if (linePos > 0) { // Last line does not have ending characters
|
||||
ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,15 +361,15 @@ static void ColouriseErrorListLine(
|
||||
// Borland warning message
|
||||
styler.ColourTo(endPos, SCE_ERR_BORLAND);
|
||||
} else if (strstr(lineBuffer, "at line " ) &&
|
||||
strstr(lineBuffer, "at line " ) < lineBuffer + lengthLine &&
|
||||
(strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
|
||||
strstr(lineBuffer, "file ") &&
|
||||
strstr(lineBuffer, "file ") < 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, " at " ) < (lineBuffer + lengthLine)) &&
|
||||
strstr(lineBuffer, " line ") &&
|
||||
strstr(lineBuffer, " line ") < lineBuffer + lengthLine) {
|
||||
(strstr(lineBuffer, " line ") < (lineBuffer + lengthLine))) {
|
||||
// perl error message
|
||||
styler.ColourTo(endPos, SCE_ERR_PERL);
|
||||
} else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
|
||||
@@ -368,26 +382,26 @@ static void ColouriseErrorListLine(
|
||||
// Look for <filename>(line,pos)message
|
||||
int state = 0;
|
||||
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;
|
||||
} else if (state == 0 && lineBuffer[i] == '(') {
|
||||
} else if ((state == 0) && (lineBuffer[i] == '(')) {
|
||||
state = 10;
|
||||
} else if (state == 1 && isdigit(lineBuffer[i])) {
|
||||
} else if ((state == 1) && isdigit(lineBuffer[i])) {
|
||||
state = 2;
|
||||
} else if (state == 2 && lineBuffer[i] == ':') {
|
||||
} else if ((state == 2) && (lineBuffer[i] == ':')) {
|
||||
state = 3;
|
||||
break;
|
||||
} else if (state == 2 && !isdigit(lineBuffer[i])) {
|
||||
} else if ((state == 2) && !isdigit(lineBuffer[i])) {
|
||||
state = 99;
|
||||
} else if (state == 10 && isdigit(lineBuffer[i])) {
|
||||
} else if ((state == 10) && isdigit(lineBuffer[i])) {
|
||||
state = 11;
|
||||
} else if (state == 11 && lineBuffer[i] == ',') {
|
||||
} else if ((state == 11) && (lineBuffer[i] == ',')) {
|
||||
state = 14;
|
||||
} else if (state == 11 && lineBuffer[i] == ')') {
|
||||
} else if ((state == 11) && (lineBuffer[i] == ')')) {
|
||||
state = 12;
|
||||
} else if (state == 12 && lineBuffer[i] == ':') {
|
||||
} else if ((state == 12) && (lineBuffer[i] == ':')) {
|
||||
state = 13;
|
||||
} else if (state == 14 && lineBuffer[i] == ')') {
|
||||
} else if ((state == 14) && (lineBuffer[i] == ')')) {
|
||||
state = 15;
|
||||
break;
|
||||
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
|
||||
@@ -409,15 +423,18 @@ static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordLi
|
||||
styler.StartAt(startPos);
|
||||
styler.StartSegment(startPos);
|
||||
unsigned int linePos = 0;
|
||||
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||
for (unsigned int i = startPos; i < startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||
// End of line (or of line buffer) met, colourise it
|
||||
lineBuffer[linePos] = '\0';
|
||||
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
|
||||
linePos = 0;
|
||||
}
|
||||
}
|
||||
if (linePos > 0)
|
||||
ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
|
||||
if (linePos > 0) { // Last line does not have ending characters
|
||||
ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
|
||||
}
|
||||
}
|
||||
|
||||
static int isSpecial(char s) {
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#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++) {
|
||||
@@ -49,7 +48,7 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold");
|
||||
bool fold = styler.GetPropertyInt("fold") != 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
|
@@ -656,7 +656,7 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||
}
|
||||
chPrev = ch;
|
||||
}
|
||||
styler.ColourTo(lengthDoc, state);
|
||||
styler.ColourTo(lengthDoc - 1, state);
|
||||
}
|
||||
|
||||
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl");
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file LexPython.cxx
|
||||
** Lexer for Python.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -23,7 +23,7 @@
|
||||
enum kwType { kwOther, kwClass, kwDef, kwImport };
|
||||
|
||||
static bool IsPyComment(Accessor &styler, int pos, int len) {
|
||||
return len>0 && styler[pos]=='#';
|
||||
return len > 0 && styler[pos] == '#';
|
||||
}
|
||||
|
||||
static bool IsPyStringStart(int ch, int chNext, int chNext2) {
|
||||
@@ -51,8 +51,7 @@ static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
|
||||
i++;
|
||||
ch = styler.SafeGetCharAt(i);
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
}
|
||||
else if (ch == 'u' || ch == 'U') {
|
||||
} else if (ch == 'u' || ch == 'U') {
|
||||
if (chNext == 'r' || chNext == 'R')
|
||||
i += 2;
|
||||
else
|
||||
@@ -83,11 +82,11 @@ static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsAWordChar(int ch) {
|
||||
static inline bool IsAWordChar(int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
inline bool IsAWordStart(int ch) {
|
||||
static inline bool IsAWordStart(int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
@@ -100,11 +99,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
if (startPos > 0) {
|
||||
if (lineCurrent > 0) {
|
||||
startPos = styler.LineStart(lineCurrent-1);
|
||||
startPos = styler.LineStart(lineCurrent - 1);
|
||||
if (startPos == 0)
|
||||
initStyle = SCE_P_DEFAULT;
|
||||
else
|
||||
initStyle = styler.StyleAt(startPos-1);
|
||||
initStyle = styler.StyleAt(startPos - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +119,10 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
kwType kwLast = kwOther;
|
||||
int spaceFlags = 0;
|
||||
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
|
||||
bool hexadecimal = false;
|
||||
|
||||
// Python uses a different mask because bad indentation is marked by oring with 32
|
||||
StyleContext sc(startPos, endPos-startPos, initStyle, styler, 0x7f);
|
||||
StyleContext sc(startPos, endPos - startPos, initStyle, styler, 0x7f);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
@@ -156,6 +156,8 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
sc.ChangeState(SCE_P_STRINGEOL);
|
||||
sc.ForwardSetState(SCE_P_DEFAULT);
|
||||
}
|
||||
if (!sc.More())
|
||||
break;
|
||||
}
|
||||
|
||||
// Check for a state end
|
||||
@@ -163,10 +165,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
kwLast = kwOther;
|
||||
sc.SetState(SCE_C_DEFAULT);
|
||||
} else if (sc.state == SCE_P_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
if (!IsAWordChar(sc.ch) &&
|
||||
!(!hexadecimal && ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
|
||||
sc.SetState(SCE_P_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_P_WORD) {
|
||||
} else if (sc.state == SCE_P_IDENTIFIER) {
|
||||
if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) {
|
||||
char s[100];
|
||||
sc.GetCurrent(s, sizeof(s));
|
||||
@@ -232,20 +235,25 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
|
||||
// Check for a new state starting character
|
||||
if (sc.state == SCE_P_DEFAULT) {
|
||||
if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
|
||||
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
if (sc.ch == '0' && (sc.chNext == 'x' || sc.chNext == 'X')) {
|
||||
hexadecimal = true;
|
||||
} else {
|
||||
hexadecimal = false;
|
||||
}
|
||||
sc.SetState(SCE_P_NUMBER);
|
||||
} else if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
|
||||
sc.SetState(SCE_P_OPERATOR);
|
||||
} else if (sc.ch == '#') {
|
||||
sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);
|
||||
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_P_NUMBER);
|
||||
} else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2))) {
|
||||
int nextIndex = 0;
|
||||
sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex));
|
||||
while (nextIndex > (sc.currentPos+1)) {
|
||||
while (nextIndex > (sc.currentPos + 1)) {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (IsAWordStart(sc.ch)) {
|
||||
sc.SetState(SCE_P_WORD);
|
||||
sc.SetState(SCE_P_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,7 +262,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||
|
||||
static bool IsCommentLine(int line, Accessor &styler) {
|
||||
int pos = styler.LineStart(line);
|
||||
int eol_pos = styler.LineStart(line+1) - 1;
|
||||
int eol_pos = styler.LineStart(line + 1) - 1;
|
||||
for (int i = pos; i < eol_pos; i++) {
|
||||
char ch = styler[i];
|
||||
if (ch == '#')
|
||||
@@ -267,17 +275,17 @@ static bool IsCommentLine(int line, Accessor &styler) {
|
||||
|
||||
static bool IsQuoteLine(int line, Accessor &styler) {
|
||||
int style = styler.StyleAt(styler.LineStart(line)) & 31;
|
||||
return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
|
||||
return ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
|
||||
}
|
||||
|
||||
|
||||
static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
|
||||
WordList *[], Accessor &styler) {
|
||||
const int maxPos = startPos + length;
|
||||
const int maxLines = styler.GetLine(maxPos-1); // Requested last line
|
||||
const int maxLines = styler.GetLine(maxPos - 1); // Requested last line
|
||||
const int docLines = styler.GetLine(styler.Length() - 1); // Available last line
|
||||
const bool foldComment = styler.GetPropertyInt("fold.comment.python");
|
||||
const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
|
||||
const bool foldComment = styler.GetPropertyInt("fold.comment.python") != 0;
|
||||
const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0;
|
||||
|
||||
// Backtrack to previous non-blank line so we can determine indent level
|
||||
// for any white space lines (needed esp. within triple quoted strings)
|
||||
@@ -300,7 +308,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
|
||||
startPos = styler.LineStart(lineCurrent);
|
||||
int prev_state = SCE_P_DEFAULT & 31;
|
||||
if (lineCurrent >= 1)
|
||||
prev_state = styler.StyleAt(startPos-1) & 31;
|
||||
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)
|
||||
@@ -320,7 +328,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
|
||||
// Information about next line is only available if not at end of document
|
||||
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
|
||||
int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
|
||||
quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
|
||||
quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
|
||||
}
|
||||
const int quote_start = (quote && !prevQuote);
|
||||
const int quote_continue = (quote && prevQuote);
|
||||
|
@@ -21,7 +21,7 @@
|
||||
|
||||
static void ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]);
|
||||
bool wordIsNumber = isdigit(styler[start]) != 0;
|
||||
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = styler[start + i];
|
||||
s[i + 1] = '\0';
|
||||
@@ -294,9 +294,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
|
||||
chPrev = ch;
|
||||
}
|
||||
if (state == SCE_P_WORD) {
|
||||
ClassifyWordRb(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
|
||||
ClassifyWordRb(styler.GetStartSegment(), lengthDoc-1, keywords, styler, prevWord);
|
||||
} else {
|
||||
styler.ColourTo(lengthDoc, state);
|
||||
styler.ColourTo(lengthDoc-1, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file LexSQL.cxx
|
||||
** Lexer for SQL.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -43,7 +43,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool fold = styler.GetPropertyInt("fold");
|
||||
bool fold = styler.GetPropertyInt("fold") != 0;
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
int spaceFlags = 0;
|
||||
|
||||
|
@@ -15,136 +15,142 @@
|
||||
|
||||
#include "PropSet.h"
|
||||
#include "Accessor.h"
|
||||
#include "StyleContext.h"
|
||||
#include "KeyWords.h"
|
||||
#include "Scintilla.h"
|
||||
#include "SciLexer.h"
|
||||
|
||||
static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
|
||||
|
||||
char s[100];
|
||||
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.') ||
|
||||
(styler[start] == '&' && tolower(styler[start+1]) == 'h');
|
||||
unsigned int i;
|
||||
for (i = 0; i < end - start + 1 && i < 30; i++) {
|
||||
s[i] = static_cast<char>(tolower(styler[start + i]));
|
||||
}
|
||||
s[i] = '\0';
|
||||
char chAttr = SCE_C_DEFAULT;
|
||||
if (wordIsNumber)
|
||||
chAttr = SCE_C_NUMBER;
|
||||
else {
|
||||
if (strcmp(s, "rem") == 0)
|
||||
chAttr = SCE_C_COMMENTLINE;
|
||||
else if (keywords.InList(s))
|
||||
chAttr = SCE_C_WORD;
|
||||
}
|
||||
styler.ColourTo(end, chAttr);
|
||||
if (chAttr == SCE_C_COMMENTLINE)
|
||||
return SCE_C_COMMENTLINE;
|
||||
else
|
||||
return SCE_C_DEFAULT;
|
||||
}
|
||||
|
||||
static bool IsVBComment(Accessor &styler, int pos, int len) {
|
||||
return len>0 && styler[pos]=='\'';
|
||||
}
|
||||
|
||||
static inline bool IsTypeCharacter(const int ch) {
|
||||
return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$';
|
||||
}
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsADateCharacter(const int ch) {
|
||||
return (ch < 0x80) &&
|
||||
(isalnum(ch) || ch == '|' || ch == '-' || ch == '/' || ch == ':' || ch == ' ' || ch == '\t');
|
||||
}
|
||||
|
||||
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
int visibleChars = 0;
|
||||
int state = initStyle;
|
||||
char chNext = styler[startPos];
|
||||
styler.StartSegment(startPos);
|
||||
int lengthDoc = startPos + length;
|
||||
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 += 1;
|
||||
continue;
|
||||
}
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
// End of line
|
||||
if (state == SCE_C_COMMENTLINE || state == SCE_C_PREPROCESSOR) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
}
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!isspacechar(ch))
|
||||
visibleChars++;
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (iswordstart(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_WORD;
|
||||
} else if (ch == '\'') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_STRING;
|
||||
} else if (ch == '#' && visibleChars == 1) {
|
||||
// Preprocessor commands are alone on their line
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_PREPROCESSOR;
|
||||
} else if (ch == '&' && tolower(chNext) == 'h') {
|
||||
styler.ColourTo(i - 1, state);
|
||||
state = SCE_C_WORD;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
} else if (state == SCE_C_WORD) {
|
||||
if (!iswordchar(ch)) {
|
||||
state = classifyWordVB(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||
if (state == SCE_C_DEFAULT) {
|
||||
if (ch == '\'') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_C_STRING;
|
||||
} else if (isoperator(ch)) {
|
||||
styler.ColourTo(i - 1, state);
|
||||
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||
}
|
||||
}
|
||||
if (sc.state == SCE_B_OPERATOR) {
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
} else if (sc.state == SCE_B_KEYWORD) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
if (vbScriptSyntax || !IsTypeCharacter(sc.ch)) {
|
||||
if (sc.ch == ']')
|
||||
sc.Forward();
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (keywords.InList(s)) {
|
||||
if (strcmp(s, "rem") == 0) {
|
||||
sc.ChangeState(SCE_B_COMMENT);
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
} else {
|
||||
if (state == SCE_C_STRING) {
|
||||
// VB doubles quotes to preserve them
|
||||
if (ch == '\"') {
|
||||
styler.ColourTo(i, state);
|
||||
state = SCE_C_DEFAULT;
|
||||
i++;
|
||||
ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||
if (ch == '\'') {
|
||||
state = SCE_C_COMMENTLINE;
|
||||
} else if (ch == '\"') {
|
||||
state = SCE_C_STRING;
|
||||
} else if (iswordstart(ch)) {
|
||||
state = SCE_C_WORD;
|
||||
} else {
|
||||
sc.ChangeState(SCE_B_IDENTIFIER);
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_B_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
styler.ColourTo(lengthDoc, state);
|
||||
} else if (sc.state == SCE_B_STRING) {
|
||||
// VB doubles quotes to preserve them, so just end this string
|
||||
// state now as a following quote will start again
|
||||
if (sc.ch == '\"') {
|
||||
if (tolower(sc.chNext) == 'c') {
|
||||
sc.Forward();
|
||||
}
|
||||
sc.ForwardSetState(SCE_B_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_B_COMMENT) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_B_PREPROCESSOR) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_B_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_B_DATE) {
|
||||
if (sc.ch == '#' || !IsADateCharacter(sc.chNext)) {
|
||||
sc.ForwardSetState(SCE_B_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.state == SCE_B_DEFAULT) {
|
||||
if (sc.ch == '\'') {
|
||||
sc.SetState(SCE_B_COMMENT);
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.SetState(SCE_B_STRING);
|
||||
} else if (sc.ch == '#' && visibleChars == 0) {
|
||||
// Preprocessor commands are alone on their line
|
||||
sc.SetState(SCE_B_PREPROCESSOR);
|
||||
} else if (sc.ch == '#') {
|
||||
int n = 1;
|
||||
int chSeek = ' ';
|
||||
while (chSeek == ' ' || chSeek == '\t') {
|
||||
chSeek = sc.GetRelative(n);
|
||||
n++;
|
||||
}
|
||||
if (IsADigit(chSeek)) {
|
||||
sc.SetState(SCE_B_DATE);
|
||||
} else {
|
||||
sc.SetState(SCE_B_OPERATOR);
|
||||
}
|
||||
} else if (sc.ch == '&' && tolower(sc.chNext) == 'h') {
|
||||
sc.SetState(SCE_B_NUMBER);
|
||||
} else if (sc.ch == '&' && tolower(sc.chNext) == 'o') {
|
||||
sc.SetState(SCE_B_NUMBER);
|
||||
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_B_NUMBER);
|
||||
} else if (IsAWordStart(sc.ch) || (sc.ch == '[')) {
|
||||
sc.SetState(SCE_B_KEYWORD);
|
||||
} else if (isoperator(static_cast<char>(sc.ch)) || (sc.ch == '\\')) {
|
||||
sc.SetState(SCE_B_OPERATOR);
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.atLineEnd) {
|
||||
visibleChars = 0;
|
||||
}
|
||||
if (!IsASpace(sc.ch)) {
|
||||
visibleChars++;
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static void FoldVBDoc(unsigned int startPos, int length, int initStyle,
|
||||
static void FoldVBDoc(unsigned int startPos, int length, int,
|
||||
WordList *[], Accessor &styler) {
|
||||
int lengthDoc = startPos + length;
|
||||
int endPos = startPos + length;
|
||||
|
||||
// Backtrack to previous line in case need to fix its fold status
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
@@ -152,28 +158,18 @@ static void FoldVBDoc(unsigned int startPos, int length, int initStyle,
|
||||
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++) {
|
||||
for (int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int style = styler.StyleAt(i) & 31;
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
|
||||
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)) {
|
||||
@@ -194,4 +190,16 @@ static void FoldVBDoc(unsigned int startPos, int length, int initStyle,
|
||||
}
|
||||
}
|
||||
|
||||
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc, "vb", FoldVBDoc);
|
||||
static void ColouriseVBNetDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
ColouriseVBDoc(startPos, length, initStyle, keywordlists, styler, false);
|
||||
}
|
||||
|
||||
static void ColouriseVBScriptDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
ColouriseVBDoc(startPos, length, initStyle, keywordlists, styler, true);
|
||||
}
|
||||
|
||||
LexerModule lmVB(SCLEX_VB, ColouriseVBNetDoc, "vb", FoldVBDoc);
|
||||
LexerModule lmVBScript(SCLEX_VBSCRIPT, ColouriseVBScriptDoc, "vbscript", FoldVBDoc);
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#include "Scintilla.h"
|
||||
#include "LineMarker.h"
|
||||
|
||||
static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
|
||||
static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
|
||||
PRectangle rc;
|
||||
rc.left = centreX - armSize;
|
||||
rc.top = centreY - armSize;
|
||||
@@ -19,7 +19,7 @@ static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Col
|
||||
surface->RectangleDraw(rc, back, fore);
|
||||
}
|
||||
|
||||
static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
|
||||
static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
|
||||
PRectangle rcCircle;
|
||||
rcCircle.left = centreX - armSize;
|
||||
rcCircle.top = centreY - armSize;
|
||||
@@ -28,14 +28,14 @@ static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize,
|
||||
surface->Ellipse(rcCircle, back, fore);
|
||||
}
|
||||
|
||||
static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
|
||||
static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated 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) {
|
||||
static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
|
||||
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
|
||||
surface->FillRectangle(rcH, fore);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
|
||||
rcSmall.bottom = rc.bottom - 2;
|
||||
surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
|
||||
|
||||
} else if (markType == SC_MARK_EMPTY) {
|
||||
} else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND) {
|
||||
// An invisible marker so don't draw anything
|
||||
|
||||
} else if (markType == SC_MARK_VLINE) {
|
||||
|
@@ -17,8 +17,8 @@ public:
|
||||
ColourPair back;
|
||||
LineMarker() {
|
||||
markType = SC_MARK_CIRCLE;
|
||||
fore = Colour(0,0,0);
|
||||
back = Colour(0xff,0xff,0xff);
|
||||
fore = ColourDesired(0,0,0);
|
||||
back = ColourDesired(0xff,0xff,0xff);
|
||||
}
|
||||
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
|
||||
};
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file PropSet.cxx
|
||||
** A Java style properties file module.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
// Maintain a dictionary of properties
|
||||
@@ -30,7 +30,6 @@ static inline bool IsLetter(char ch) {
|
||||
return ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'));
|
||||
}
|
||||
|
||||
|
||||
int CompareCaseInsensitive(const char *a, const char *b) {
|
||||
while (*a && *b) {
|
||||
if (*a != *b) {
|
||||
@@ -65,7 +64,6 @@ int CompareNCaseInsensitive(const char *a, const char *b, int len) {
|
||||
return *a - *b;
|
||||
}
|
||||
|
||||
|
||||
bool EqualCaseInsensitive(const char *a, const char *b) {
|
||||
return 0 == CompareCaseInsensitive(a, b);
|
||||
}
|
||||
@@ -561,7 +559,7 @@ bool WordList::InList(const char *s) {
|
||||
* The length of the word to compare is passed too.
|
||||
* Letter case can be ignored or preserved (default).
|
||||
*/
|
||||
const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/) {
|
||||
const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */) {
|
||||
int start = 0; // lower bound of the api array block to search
|
||||
int end = len - 1; // upper bound of the api array block to search
|
||||
int pivot; // index of api array element just being compared
|
||||
@@ -579,7 +577,7 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
|
||||
pivot = (start + end) >> 1;
|
||||
word = wordsNoCase[pivot];
|
||||
cond = CompareNCaseInsensitive(wordStart, word, searchLen);
|
||||
if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
|
||||
if (!cond && (!wordCharacters.contains(word[searchLen])))
|
||||
return word; // result must not be freed with free()
|
||||
else if (cond > 0)
|
||||
start = pivot + 1;
|
||||
@@ -591,7 +589,7 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
|
||||
pivot = (start + end) >> 1;
|
||||
word = words[pivot];
|
||||
cond = strncmp(wordStart, word, searchLen);
|
||||
if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
|
||||
if (!cond && (!wordCharacters.contains(word[searchLen])))
|
||||
return word; // result must not be freed with free()
|
||||
else if (cond > 0)
|
||||
start = pivot + 1;
|
||||
|
@@ -30,8 +30,8 @@
|
||||
* Modification history:
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.2 2001/10/18 01:24:58 RD
|
||||
* Updated to version 1.40 of Scintilla
|
||||
* Revision 1.3 2002/03/18 22:31:00 RD
|
||||
* Updated wxSTC from Scintilla 1.40 to Scintilla 1.45
|
||||
*
|
||||
* Revision 1.6 2001/04/29 13:32:10 nyamatongwe
|
||||
* Addition of new target methods - versions of ReplaceTarget that take counted
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file ScintillaBase.cxx
|
||||
** An enhanced subclass of Editor with calltips, autocomplete and context menu.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -63,10 +63,10 @@ void ScintillaBase::RefreshColourPalette(Palette &pal, bool want) {
|
||||
ct.RefreshColourPalette(pal, want);
|
||||
}
|
||||
|
||||
void ScintillaBase::AddCharUTF(char *s, unsigned int len) {
|
||||
void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
|
||||
bool acActiveBeforeCharAdded = ac.Active();
|
||||
if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s))
|
||||
Editor::AddCharUTF(s, len);
|
||||
Editor::AddCharUTF(s, len, treatAsDBCS);
|
||||
if (acActiveBeforeCharAdded)
|
||||
AutoCompleteChanged(s[0]);
|
||||
}
|
||||
@@ -137,7 +137,12 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
|
||||
AutoCompleteMove(5000);
|
||||
return 0;
|
||||
case SCI_DELETEBACK:
|
||||
DelCharBack();
|
||||
DelCharBack(true);
|
||||
AutoCompleteChanged();
|
||||
EnsureCaretVisible();
|
||||
return 0;
|
||||
case SCI_DELETEBACKNOTLINE:
|
||||
DelCharBack(false);
|
||||
AutoCompleteChanged();
|
||||
EnsureCaretVisible();
|
||||
return 0;
|
||||
@@ -160,11 +165,12 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
|
||||
(iMessage != SCI_CHARRIGHT) &&
|
||||
(iMessage != SCI_CHARLEFTEXTEND) &&
|
||||
(iMessage != SCI_EDITTOGGLEOVERTYPE) &&
|
||||
(iMessage != SCI_DELETEBACK)
|
||||
(iMessage != SCI_DELETEBACK) &&
|
||||
(iMessage != SCI_DELETEBACKNOTLINE)
|
||||
) {
|
||||
ct.CallTipCancel();
|
||||
}
|
||||
if (iMessage == SCI_DELETEBACK) {
|
||||
if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
|
||||
if (currentPos <= ct.posStartCallTip) {
|
||||
ct.CallTipCancel();
|
||||
}
|
||||
@@ -173,6 +179,11 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
|
||||
return Editor::KeyCommand(iMessage);
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteDoubleClick(void* p) {
|
||||
ScintillaBase* sci = reinterpret_cast<ScintillaBase*>(p);
|
||||
sci->AutoCompleteCompleted();
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
|
||||
//Platform::DebugPrintf("AutoComplete %s\n", list);
|
||||
ct.CallTipCancel();
|
||||
@@ -190,7 +201,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
|
||||
pdoc->InsertString(currentPos, list + lenEntered);
|
||||
SetEmptySelection(currentPos + strlen(list + lenEntered));
|
||||
}
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ac.Start(wMain, idAutoComplete, currentPos, lenEntered);
|
||||
@@ -222,6 +233,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
|
||||
ac.lb.SetPositionRelative(rcac, wMain);
|
||||
ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font);
|
||||
ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth);
|
||||
ac.lb.SetDoubleClickAction(AutoCompleteDoubleClick, this);
|
||||
|
||||
ac.SetList(list);
|
||||
|
||||
@@ -295,14 +307,18 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
|
||||
scn.lParam = 0;
|
||||
scn.text = userListSelected.c_str();
|
||||
NotifyParent(scn);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Position firstPos = ac.posStart - ac.startLen;
|
||||
if (currentPos < firstPos)
|
||||
return ;
|
||||
if (currentPos != firstPos) {
|
||||
pdoc->DeleteChars(firstPos, currentPos - firstPos);
|
||||
Position endPos = currentPos;
|
||||
if (ac.dropRestOfWord)
|
||||
endPos = pdoc->ExtendWordSelect(endPos, 1, true);
|
||||
if (endPos < firstPos)
|
||||
return;
|
||||
pdoc->BeginUndoAction();
|
||||
if (endPos != firstPos) {
|
||||
pdoc->DeleteChars(firstPos, endPos - firstPos);
|
||||
}
|
||||
SetEmptySelection(ac.posStart);
|
||||
if (item != -1) {
|
||||
@@ -312,6 +328,7 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
|
||||
pdoc->InsertString(firstPos, piece.c_str());
|
||||
SetEmptySelection(firstPos + piece.length());
|
||||
}
|
||||
pdoc->EndUndoAction();
|
||||
}
|
||||
|
||||
void ScintillaBase::ContextMenu(Point pt) {
|
||||
@@ -374,7 +391,7 @@ void ScintillaBase::Colourise(int start, int end) {
|
||||
styleStart = styler.StyleAt(start - 1);
|
||||
styler.SetCodePage(pdoc->dbcsCodePage);
|
||||
|
||||
if (lexCurrent) { // Should always succeed as null lexer should always be available
|
||||
if (lexCurrent && (len > 0)) { // Should always succeed as null lexer should always be available
|
||||
lexCurrent->Lex(start, len, styleStart, keyWordLists, styler);
|
||||
styler.Flush();
|
||||
if (styler.GetPropertyInt("fold")) {
|
||||
@@ -392,7 +409,7 @@ void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
|
||||
int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);
|
||||
endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);
|
||||
Colourise(endStyled, endStyleNeeded);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
Editor::NotifyStyleToNeeded(endStyleNeeded);
|
||||
@@ -435,7 +452,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
|
||||
break;
|
||||
|
||||
case SCI_AUTOCSETCANCELATSTART:
|
||||
ac.cancelAtStartPos = wParam;
|
||||
ac.cancelAtStartPos = wParam != 0;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETCANCELATSTART:
|
||||
@@ -446,14 +463,14 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
|
||||
break;
|
||||
|
||||
case SCI_AUTOCSETCHOOSESINGLE:
|
||||
ac.chooseSingle = wParam;
|
||||
ac.chooseSingle = wParam != 0;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETCHOOSESINGLE:
|
||||
return ac.chooseSingle;
|
||||
|
||||
case SCI_AUTOCSETIGNORECASE:
|
||||
ac.ignoreCase = wParam;
|
||||
ac.ignoreCase = wParam != 0;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETIGNORECASE:
|
||||
@@ -465,12 +482,19 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
|
||||
break;
|
||||
|
||||
case SCI_AUTOCSETAUTOHIDE:
|
||||
ac.autoHide = wParam;
|
||||
ac.autoHide = wParam != 0;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETAUTOHIDE:
|
||||
return ac.autoHide;
|
||||
|
||||
case SCI_AUTOCSETDROPRESTOFWORD:
|
||||
ac.dropRestOfWord = wParam != 0;
|
||||
break;
|
||||
|
||||
case SCI_AUTOCGETDROPRESTOFWORD:
|
||||
return ac.dropRestOfWord;
|
||||
|
||||
case SCI_CALLTIPSHOW: {
|
||||
AutoCompleteCancel();
|
||||
if (!ct.wCallTip.Created()) {
|
||||
@@ -479,7 +503,8 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
|
||||
PRectangle rc = ct.CallTipStart(currentPos, pt,
|
||||
reinterpret_cast<char *>(lParam),
|
||||
vs.styles[STYLE_DEFAULT].fontName,
|
||||
vs.styles[STYLE_DEFAULT].sizeZoomed);
|
||||
vs.styles[STYLE_DEFAULT].sizeZoomed,
|
||||
IsUnicodeMode());
|
||||
// If the call-tip window would be out of the client
|
||||
// space, adjust so it displays above the text.
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
@@ -511,12 +536,12 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
|
||||
break;
|
||||
|
||||
case SCI_CALLTIPSETBACK:
|
||||
ct.colourBG = Colour(wParam);
|
||||
ct.colourBG = ColourDesired(wParam);
|
||||
InvalidateStyleRedraw();
|
||||
break;
|
||||
|
||||
case SCI_USEPOPUP:
|
||||
displayPopupMenu = wParam;
|
||||
displayPopupMenu = wParam != 0;
|
||||
break;
|
||||
|
||||
#ifdef SCI_LEXER
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file ScintillaBase.h
|
||||
** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef SCINTILLABASE_H
|
||||
@@ -41,7 +41,7 @@ protected:
|
||||
|
||||
#ifdef SCI_LEXER
|
||||
int lexLanguage;
|
||||
LexerModule *lexCurrent;
|
||||
const LexerModule *lexCurrent;
|
||||
PropSet props;
|
||||
enum {numWordLists=6};
|
||||
WordList *keyWordLists[numWordLists+1];
|
||||
@@ -57,7 +57,7 @@ protected:
|
||||
|
||||
virtual void RefreshColourPalette(Palette &pal, bool want);
|
||||
|
||||
virtual void AddCharUTF(char *s, unsigned int len);
|
||||
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
void Command(int cmdId);
|
||||
virtual void CancelModes();
|
||||
virtual int KeyCommand(unsigned int iMessage);
|
||||
@@ -68,6 +68,7 @@ protected:
|
||||
void AutoCompleteChanged(char ch=0);
|
||||
void AutoCompleteCompleted(char fillUp='\0');
|
||||
void AutoCompleteMoveToCurrentWord();
|
||||
static void AutoCompleteDoubleClick(void* p);
|
||||
|
||||
virtual void CreateCallTipWindow(PRectangle rc) = 0;
|
||||
|
||||
|
@@ -14,15 +14,15 @@
|
||||
|
||||
Style::Style() {
|
||||
aliasOfDefaultFont = true;
|
||||
Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
|
||||
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
|
||||
Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
|
||||
false, false, false, false, caseMixed, true);
|
||||
false, false, false, false, caseMixed, true, true);
|
||||
}
|
||||
|
||||
Style::Style(const Style &source) {
|
||||
Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
|
||||
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
|
||||
0, 0, 0,
|
||||
false, false, false, false, caseMixed, true);
|
||||
false, false, false, false, caseMixed, true, true);
|
||||
fore.desired = source.fore.desired;
|
||||
back.desired = source.back.desired;
|
||||
characterSet = source.characterSet;
|
||||
@@ -33,6 +33,7 @@ Style::Style(const Style &source) {
|
||||
underline = source.underline;
|
||||
caseForce = source.caseForce;
|
||||
visible = source.visible;
|
||||
changeable = source.changeable;
|
||||
}
|
||||
|
||||
Style::~Style() {
|
||||
@@ -46,9 +47,9 @@ Style::~Style() {
|
||||
Style &Style::operator=(const Style &source) {
|
||||
if (this == &source)
|
||||
return * this;
|
||||
Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
|
||||
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
|
||||
0, 0, SC_CHARSET_DEFAULT,
|
||||
false, false, false, false, caseMixed, true);
|
||||
false, false, false, false, caseMixed, true, true);
|
||||
fore.desired = source.fore.desired;
|
||||
back.desired = source.back.desired;
|
||||
characterSet = source.characterSet;
|
||||
@@ -59,13 +60,15 @@ Style &Style::operator=(const Style &source) {
|
||||
underline = source.underline;
|
||||
caseForce = source.caseForce;
|
||||
visible = source.visible;
|
||||
changeable = source.changeable;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Style::Clear(Colour fore_, Colour back_, int size_,
|
||||
void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_, bool visible_) {
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool visible_, bool changeable_) {
|
||||
fore.desired = fore_;
|
||||
back.desired = back_;
|
||||
characterSet = characterSet_;
|
||||
@@ -77,6 +80,7 @@ void Style::Clear(Colour fore_, Colour back_, int size_,
|
||||
underline = underline_;
|
||||
caseForce = caseForce_;
|
||||
visible = visible_;
|
||||
changeable = changeable_;
|
||||
if (aliasOfDefaultFont)
|
||||
font.SetID(0);
|
||||
else
|
||||
@@ -96,7 +100,8 @@ void Style::ClearTo(const Style &source) {
|
||||
source.eolFilled,
|
||||
source.underline,
|
||||
source.caseForce,
|
||||
source.visible);
|
||||
source.visible,
|
||||
source.changeable);
|
||||
}
|
||||
|
||||
bool Style::EquivalentFontTo(const Style *other) const {
|
||||
|
@@ -25,6 +25,7 @@ public:
|
||||
enum ecaseForced {caseMixed, caseUpper, caseLower};
|
||||
ecaseForced caseForce;
|
||||
bool visible;
|
||||
bool changeable;
|
||||
|
||||
Font font;
|
||||
int sizeZoomed;
|
||||
@@ -39,14 +40,16 @@ public:
|
||||
Style(const Style &source);
|
||||
~Style();
|
||||
Style &operator=(const Style &source);
|
||||
void Clear(Colour fore_, Colour back_,
|
||||
void Clear(ColourDesired fore_, ColourDesired back_,
|
||||
int size_,
|
||||
const char *fontName_, int characterSet_,
|
||||
bool bold_, bool italic_, bool eolFilled_,
|
||||
bool underline_, ecaseForced caseForce_, bool visible_);
|
||||
bool underline_, ecaseForced caseForce_,
|
||||
bool visible_, bool changeable_);
|
||||
void ClearTo(const Style &source);
|
||||
bool EquivalentFontTo(const Style *other) const;
|
||||
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0);
|
||||
bool IsProtected() { return !(changeable && visible);} ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -55,9 +55,10 @@ public:
|
||||
styler.ColourTo(currentPos - 1, state);
|
||||
}
|
||||
bool More() {
|
||||
return currentPos <= endPos;
|
||||
return currentPos < endPos;
|
||||
}
|
||||
void Forward() {
|
||||
if (currentPos < endPos) {
|
||||
atLineStart = atLineEnd;
|
||||
// A lot of this is repeated from the constructor - TODO: merge code
|
||||
chPrev = ch;
|
||||
@@ -74,6 +75,13 @@ public:
|
||||
// Avoid triggering two times on Dos/Win
|
||||
// End of line
|
||||
atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos);
|
||||
} else {
|
||||
atLineStart = false;
|
||||
chPrev = ' ';
|
||||
ch = ' ';
|
||||
chNext = ' ';
|
||||
atLineEnd = true;
|
||||
}
|
||||
}
|
||||
void ChangeState(int state_) {
|
||||
state = state_;
|
||||
@@ -113,6 +121,20 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool MatchIgnoreCase(const char *s) {
|
||||
if (tolower(ch) != *s)
|
||||
return false;
|
||||
s++;
|
||||
if (tolower(chNext) != *s)
|
||||
return false;
|
||||
s++;
|
||||
for (int n=2; *s; n++) {
|
||||
if (*s != tolower((styler.SafeGetCharAt(currentPos+n))))
|
||||
return false;
|
||||
s++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Non-inline
|
||||
void GetCurrent(char *s, int len);
|
||||
void GetCurrentLowered(char *s, int len);
|
||||
|
@@ -52,9 +52,6 @@ unsigned int UCS2Length(const char *s, unsigned int len) {
|
||||
}
|
||||
|
||||
unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
|
||||
#ifdef USE_API
|
||||
return ::MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, tlen);
|
||||
#else
|
||||
unsigned int ui=0;
|
||||
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
|
||||
unsigned int i=0;
|
||||
@@ -76,5 +73,4 @@ unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsign
|
||||
ui++;
|
||||
}
|
||||
return ui;
|
||||
#endif
|
||||
}
|
||||
|
@@ -103,11 +103,11 @@ void ViewStyle::Init() {
|
||||
ResetDefaultStyle();
|
||||
|
||||
indicators[0].style = INDIC_SQUIGGLE;
|
||||
indicators[0].fore = Colour(0, 0x7f, 0);
|
||||
indicators[0].fore = ColourDesired(0, 0x7f, 0);
|
||||
indicators[1].style = INDIC_TT;
|
||||
indicators[1].fore = Colour(0, 0, 0xff);
|
||||
indicators[1].fore = ColourDesired(0, 0, 0xff);
|
||||
indicators[2].style = INDIC_PLAIN;
|
||||
indicators[2].fore = Colour(0xff, 0, 0);
|
||||
indicators[2].fore = ColourDesired(0xff, 0, 0);
|
||||
|
||||
lineHeight = 1;
|
||||
maxAscent = 1;
|
||||
@@ -116,18 +116,18 @@ void ViewStyle::Init() {
|
||||
spaceWidth = 8;
|
||||
|
||||
selforeset = false;
|
||||
selforeground.desired = Colour(0xff, 0, 0);
|
||||
selforeground.desired = ColourDesired(0xff, 0, 0);
|
||||
selbackset = true;
|
||||
selbackground.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
selbackground2.desired = Colour(0xb0, 0xb0, 0xb0);
|
||||
selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
|
||||
selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
|
||||
selbar.desired = Platform::Chrome();
|
||||
selbarlight.desired = Platform::ChromeHighlight();
|
||||
styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0);
|
||||
styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
|
||||
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
|
||||
caretcolour.desired = Colour(0, 0, 0);
|
||||
caretcolour.desired = ColourDesired(0, 0, 0);
|
||||
showCaretLineBackground = false;
|
||||
caretLineBackground.desired = Colour(0xff, 0xff, 0);
|
||||
edgecolour.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
|
||||
edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
|
||||
edgeState = EDGE_NONE;
|
||||
caretWidth = 1;
|
||||
|
||||
@@ -215,10 +215,11 @@ void ViewStyle::Refresh(Surface &surface) {
|
||||
}
|
||||
|
||||
void ViewStyle::ResetDefaultStyle() {
|
||||
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||
styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
|
||||
ColourDesired(0xff,0xff,0xff),
|
||||
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
|
||||
SC_CHARSET_DEFAULT,
|
||||
false, false, false, false, Style::caseMixed, true);
|
||||
false, false, false, false, Style::caseMixed, true, true);
|
||||
}
|
||||
|
||||
void ViewStyle::ClearStyles() {
|
||||
|
@@ -20,22 +20,14 @@
|
||||
WindowAccessor::~WindowAccessor() {
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool WindowAccessor::InternalIsLeadByte(char ch) {
|
||||
if (SC_CP_UTF8 == codePage)
|
||||
// For lexing, all characters >= 0x80 are treated the
|
||||
// same so none is considered a lead byte.
|
||||
return false;
|
||||
else
|
||||
return IsDBCSLeadByteEx(codePage, ch);
|
||||
return Platform::IsDBCSLeadByte(codePage, ch);
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool WindowAccessor::InternalIsLeadByte(char) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void WindowAccessor::Fill(int position) {
|
||||
if (lenDoc == -1)
|
||||
|
@@ -22,53 +22,6 @@
|
||||
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
// 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)
|
||||
|
||||
int wxForceScintillaLexers(void)
|
||||
{
|
||||
extern LexerModule lmAda;
|
||||
extern LexerModule lmAVE;
|
||||
extern LexerModule lmConf;
|
||||
extern LexerModule lmCPP;
|
||||
extern LexerModule lmNncrontab;
|
||||
extern LexerModule lmEiffel;
|
||||
extern LexerModule lmHTML;
|
||||
extern LexerModule lmLISP;
|
||||
extern LexerModule lmLua;
|
||||
extern LexerModule lmBatch; // In LexOthers.cxx
|
||||
extern LexerModule lmPascal;
|
||||
extern LexerModule lmPerl;
|
||||
extern LexerModule lmPython;
|
||||
extern LexerModule lmRuby;
|
||||
extern LexerModule lmSQL;
|
||||
extern LexerModule lmVB;
|
||||
|
||||
if ( &lmAda
|
||||
&& &lmAVE
|
||||
&& &lmConf
|
||||
&& &lmCPP
|
||||
&& &lmNncrontab
|
||||
&& &lmEiffel
|
||||
&& &lmHTML
|
||||
&& &lmLISP
|
||||
&& &lmLua
|
||||
&& &lmBatch
|
||||
&& &lmPascal
|
||||
&& &lmPerl
|
||||
&& &lmPython
|
||||
&& &lmRuby
|
||||
&& &lmSQL
|
||||
&& &lmVB )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -130,6 +83,9 @@ END_EVENT_TABLE()
|
||||
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
|
||||
|
||||
// forces the linking of the lexer modules
|
||||
int Scintilla_LinkLexers();
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Constructor and Destructor
|
||||
|
||||
@@ -143,7 +99,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
|
||||
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
|
||||
wxDefaultValidator, name)
|
||||
{
|
||||
wxForceScintillaLexers();
|
||||
Scintilla_LinkLexers();
|
||||
m_swx = new ScintillaWX(this);
|
||||
m_stopWatch.Start();
|
||||
m_lastKeyDownConsumed = FALSE;
|
||||
@@ -431,7 +387,7 @@ void wxStyledTextCtrl::SetCodePage(int codePage) {
|
||||
}
|
||||
|
||||
// Set the symbol used for a particular marker number,
|
||||
// and optionally the for and background colours.
|
||||
// and optionally the fore and background colours.
|
||||
void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground,
|
||||
const wxColour& background) {
|
||||
@@ -453,9 +409,9 @@ void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& bac
|
||||
SendMsg(2042, markerNumber, wxColourAsLong(back));
|
||||
}
|
||||
|
||||
// Add a marker to a line.
|
||||
void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
|
||||
SendMsg(2043, line, markerNumber);
|
||||
// Add a marker to a line, returning an ID which can be used to find or delete the marker.
|
||||
int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
|
||||
return SendMsg(2043, line, markerNumber);
|
||||
}
|
||||
|
||||
// Delete a marker from a line
|
||||
@@ -698,7 +654,7 @@ bool wxStyledTextCtrl::GetCaretLineVisible() {
|
||||
return SendMsg(2095, 0, 0) != 0;
|
||||
}
|
||||
|
||||
// Display the background of the line containing the caret in a different colour.
|
||||
// Dsplay the background of the line containing the caret in a different colour.
|
||||
void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
|
||||
SendMsg(2096, show, 0);
|
||||
}
|
||||
@@ -714,6 +670,12 @@ void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
|
||||
SendMsg(2098, wxColourAsLong(back), 0);
|
||||
}
|
||||
|
||||
// Set a style to be changeable or not (read only).
|
||||
// Experimental feature, currently buggy.
|
||||
void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
|
||||
SendMsg(2099, style, changeable);
|
||||
}
|
||||
|
||||
// Display a auto-completion list.
|
||||
// The lenEntered parameter indicates how many characters before
|
||||
// the caret should be used to provide context.
|
||||
@@ -774,7 +736,8 @@ bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
|
||||
return SendMsg(2111, 0, 0) != 0;
|
||||
}
|
||||
|
||||
// Define a set of character that when typed fills up the selected word.
|
||||
// Define a set of characters that when typed will cause the autocompletion to
|
||||
// choose the selected item.
|
||||
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
|
||||
SendMsg(2112, 0, (long)characterSet.c_str());
|
||||
}
|
||||
@@ -814,6 +777,16 @@ bool wxStyledTextCtrl::AutoCompGetAutoHide() {
|
||||
return SendMsg(2119, 0, 0) != 0;
|
||||
}
|
||||
|
||||
// Set whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
|
||||
SendMsg(2270, dropRestOfWord, 0);
|
||||
}
|
||||
|
||||
// Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
|
||||
return SendMsg(2271, 0, 0) != 0;
|
||||
}
|
||||
|
||||
// Set the number of spaces used for one level of indentation.
|
||||
void wxStyledTextCtrl::SetIndent(int indentSize) {
|
||||
SendMsg(2122, indentSize, 0);
|
||||
@@ -1405,6 +1378,42 @@ int wxStyledTextCtrl::GetMouseDwellTime() {
|
||||
return SendMsg(2265, 0, 0);
|
||||
}
|
||||
|
||||
// Get position of start of word
|
||||
int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
|
||||
return SendMsg(2266, pos, onlyWordCharacters);
|
||||
}
|
||||
|
||||
// Get position of end of word
|
||||
int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
|
||||
return SendMsg(2267, pos, onlyWordCharacters);
|
||||
}
|
||||
|
||||
// Sets whether text is word wrapped
|
||||
void wxStyledTextCtrl::SetWrapMode(int mode) {
|
||||
SendMsg(2268, mode, 0);
|
||||
}
|
||||
|
||||
// Retrieve whether text is word wrapped
|
||||
int wxStyledTextCtrl::GetWrapMode() {
|
||||
return SendMsg(2269, 0, 0);
|
||||
}
|
||||
|
||||
// Sets the degree of caching of layout information
|
||||
void wxStyledTextCtrl::SetLayoutCache(int mode) {
|
||||
SendMsg(2272, mode, 0);
|
||||
}
|
||||
|
||||
// Retrieve the degree of caching of layout information
|
||||
int wxStyledTextCtrl::GetLayoutCache() {
|
||||
return SendMsg(2273, 0, 0);
|
||||
}
|
||||
|
||||
// Delete the selection or if no selection, the character before the caret.
|
||||
// Will not delete the chraacter before at the start of a line.
|
||||
void wxStyledTextCtrl::DeleteBackNotLine() {
|
||||
SendMsg(2344, 0, 0);
|
||||
}
|
||||
|
||||
// Move the caret inside current view if it's not there already
|
||||
void wxStyledTextCtrl::MoveCaretInsideView() {
|
||||
SendMsg(2401, 0, 0);
|
||||
@@ -1598,6 +1607,17 @@ int wxStyledTextCtrl::GetCursor() {
|
||||
return SendMsg(2387, 0, 0);
|
||||
}
|
||||
|
||||
// Change the way control characters are displayed:
|
||||
// If symbol is < 32, keep the drawn way, else, use the given character
|
||||
void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
|
||||
SendMsg(2388, symbol, 0);
|
||||
}
|
||||
|
||||
// Get the way control characters are displayed
|
||||
int wxStyledTextCtrl::GetControlCharSymbol() {
|
||||
return SendMsg(2389, 0, 0);
|
||||
}
|
||||
|
||||
// Move to the previous change in capitalistion
|
||||
void wxStyledTextCtrl::WordPartLeft() {
|
||||
SendMsg(2390, 0, 0);
|
||||
@@ -1633,6 +1653,14 @@ void wxStyledTextCtrl::DelLineRight() {
|
||||
SendMsg(2396, 0, 0);
|
||||
}
|
||||
|
||||
// Get and Set the xOffset (ie, horizonal scroll position)
|
||||
void wxStyledTextCtrl::SetXOffset(int newOffset) {
|
||||
SendMsg(2397, newOffset, 0);
|
||||
}
|
||||
int wxStyledTextCtrl::GetXOffset() {
|
||||
return SendMsg(2398, 0, 0);
|
||||
}
|
||||
|
||||
// Start notifying the container of all key presses and commands.
|
||||
void wxStyledTextCtrl::StartRecord() {
|
||||
SendMsg(3001, 0, 0);
|
||||
@@ -2029,10 +2057,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
|
||||
evt.SetLength(scn.length);
|
||||
break;
|
||||
|
||||
case SCN_POSCHANGED:
|
||||
evt.SetEventType(wxEVT_STC_POSCHANGED);
|
||||
break;
|
||||
|
||||
case SCN_PAINTED:
|
||||
evt.SetEventType(wxEVT_STC_PAINTED);
|
||||
break;
|
||||
|
@@ -22,53 +22,6 @@
|
||||
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
// 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)
|
||||
|
||||
int wxForceScintillaLexers(void)
|
||||
{
|
||||
extern LexerModule lmAda;
|
||||
extern LexerModule lmAVE;
|
||||
extern LexerModule lmConf;
|
||||
extern LexerModule lmCPP;
|
||||
extern LexerModule lmNncrontab;
|
||||
extern LexerModule lmEiffel;
|
||||
extern LexerModule lmHTML;
|
||||
extern LexerModule lmLISP;
|
||||
extern LexerModule lmLua;
|
||||
extern LexerModule lmBatch; // In LexOthers.cxx
|
||||
extern LexerModule lmPascal;
|
||||
extern LexerModule lmPerl;
|
||||
extern LexerModule lmPython;
|
||||
extern LexerModule lmRuby;
|
||||
extern LexerModule lmSQL;
|
||||
extern LexerModule lmVB;
|
||||
|
||||
if ( &lmAda
|
||||
&& &lmAVE
|
||||
&& &lmConf
|
||||
&& &lmCPP
|
||||
&& &lmNncrontab
|
||||
&& &lmEiffel
|
||||
&& &lmHTML
|
||||
&& &lmLISP
|
||||
&& &lmLua
|
||||
&& &lmBatch
|
||||
&& &lmPascal
|
||||
&& &lmPerl
|
||||
&& &lmPython
|
||||
&& &lmRuby
|
||||
&& &lmSQL
|
||||
&& &lmVB )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -130,6 +83,9 @@ END_EVENT_TABLE()
|
||||
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
|
||||
|
||||
// forces the linking of the lexer modules
|
||||
int Scintilla_LinkLexers();
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Constructor and Destructor
|
||||
|
||||
@@ -143,7 +99,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
|
||||
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
|
||||
wxDefaultValidator, name)
|
||||
{
|
||||
wxForceScintillaLexers();
|
||||
Scintilla_LinkLexers();
|
||||
m_swx = new ScintillaWX(this);
|
||||
m_stopWatch.Start();
|
||||
m_lastKeyDownConsumed = FALSE;
|
||||
@@ -558,10 +514,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
|
||||
evt.SetLength(scn.length);
|
||||
break;
|
||||
|
||||
case SCN_POSCHANGED:
|
||||
evt.SetEventType(wxEVT_STC_POSCHANGED);
|
||||
break;
|
||||
|
||||
case SCN_PAINTED:
|
||||
evt.SetEventType(wxEVT_STC_PAINTED);
|
||||
break;
|
||||
|
@@ -32,20 +32,6 @@
|
||||
%(VALUES)s
|
||||
|
||||
// END of generated section
|
||||
//----------------------------------------------------------------------
|
||||
// Others
|
||||
|
||||
#define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEROPEN) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERSUB) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERTAIL) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERMIDTAIL) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEROPENMID) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEREND))
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ScintillaWX; // forward declare
|
||||
|
@@ -73,6 +73,9 @@
|
||||
#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
|
||||
#define wxSTC_MARK_CIRCLEMINUS 20
|
||||
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
|
||||
|
||||
// Invisible mark that only sets the line background color
|
||||
#define wxSTC_MARK_BACKGROUND 22
|
||||
#define wxSTC_MARK_CHARACTER 10000
|
||||
|
||||
// Markers used for outlining column
|
||||
@@ -83,6 +86,7 @@
|
||||
#define wxSTC_MARKNUM_FOLDERSUB 29
|
||||
#define wxSTC_MARKNUM_FOLDER 30
|
||||
#define wxSTC_MARKNUM_FOLDEROPEN 31
|
||||
#define wxSTC_MASK_FOLDERS 0xFE000000
|
||||
#define wxSTC_MARGIN_SYMBOL 0
|
||||
#define wxSTC_MARGIN_NUMBER 1
|
||||
|
||||
@@ -127,10 +131,10 @@
|
||||
#define wxSTC_INDIC_TT 2
|
||||
#define wxSTC_INDIC_DIAGONAL 3
|
||||
#define wxSTC_INDIC_STRIKE 4
|
||||
#define wxSTC_INDIC0_MASK 32
|
||||
#define wxSTC_INDIC1_MASK 64
|
||||
#define wxSTC_INDIC2_MASK 128
|
||||
#define wxSTC_INDICS_MASK 224
|
||||
#define wxSTC_INDIC0_MASK 0x20
|
||||
#define wxSTC_INDIC1_MASK 0x40
|
||||
#define wxSTC_INDIC2_MASK 0x80
|
||||
#define wxSTC_INDICS_MASK 0xE0
|
||||
|
||||
// PrintColourMode - use same colours as screen.
|
||||
#define wxSTC_PRINT_NORMAL 0
|
||||
@@ -159,6 +163,12 @@
|
||||
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000
|
||||
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
|
||||
#define wxSTC_TIME_FOREVER 10000000
|
||||
#define wxSTC_WRAP_NONE 0
|
||||
#define wxSTC_WRAP_WORD 1
|
||||
#define wxSTC_CACHE_NONE 0
|
||||
#define wxSTC_CACHE_CARET 1
|
||||
#define wxSTC_CACHE_PAGE 2
|
||||
#define wxSTC_CACHE_DOCUMENT 3
|
||||
#define wxSTC_CMD_LINEDOWN 2300
|
||||
#define wxSTC_CMD_LINEDOWNEXTEND 2301
|
||||
#define wxSTC_CMD_LINEUP 2302
|
||||
@@ -203,6 +213,7 @@
|
||||
#define wxSTC_CMD_UPPERCASE 2341
|
||||
#define wxSTC_CMD_LINESCROLLDOWN 2342
|
||||
#define wxSTC_CMD_LINESCROLLUP 2343
|
||||
#define wxSTC_CMD_DELETEBACKNOTLINE 2344
|
||||
#define wxSTC_EDGE_NONE 0
|
||||
#define wxSTC_EDGE_LINE 1
|
||||
#define wxSTC_EDGE_BACKGROUND 2
|
||||
@@ -302,6 +313,12 @@
|
||||
#define wxSTC_LEX_EIFFELKW 24
|
||||
#define wxSTC_LEX_TCL 25
|
||||
#define wxSTC_LEX_NNCRONTAB 26
|
||||
#define wxSTC_LEX_BULLANT 27
|
||||
#define wxSTC_LEX_VBSCRIPT 28
|
||||
#define wxSTC_LEX_ASP 29
|
||||
#define wxSTC_LEX_PHP 30
|
||||
#define wxSTC_LEX_BAAN 31
|
||||
#define wxSTC_LEX_MATLAB 32
|
||||
|
||||
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
// value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
@@ -323,7 +340,7 @@
|
||||
#define wxSTC_P_COMMENTBLOCK 12
|
||||
#define wxSTC_P_STRINGEOL 13
|
||||
|
||||
// Lexical states for SCLEX_CPP, SCLEX_VB
|
||||
// Lexical states for SCLEX_CPP
|
||||
#define wxSTC_C_DEFAULT 0
|
||||
#define wxSTC_C_COMMENT 1
|
||||
#define wxSTC_C_COMMENTLINE 2
|
||||
@@ -344,6 +361,17 @@
|
||||
#define wxSTC_C_COMMENTDOCKEYWORD 17
|
||||
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
|
||||
|
||||
// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
|
||||
#define wxSTC_B_DEFAULT 0
|
||||
#define wxSTC_B_COMMENT 1
|
||||
#define wxSTC_B_NUMBER 2
|
||||
#define wxSTC_B_KEYWORD 3
|
||||
#define wxSTC_B_STRING 4
|
||||
#define wxSTC_B_PREPROCESSOR 5
|
||||
#define wxSTC_B_OPERATOR 6
|
||||
#define wxSTC_B_IDENTIFIER 7
|
||||
#define wxSTC_B_DATE 8
|
||||
|
||||
// Lexical states for SCLEX_HTML, SCLEX_XML
|
||||
#define wxSTC_H_DEFAULT 0
|
||||
#define wxSTC_H_TAG 1
|
||||
@@ -531,6 +559,11 @@
|
||||
#define wxSTC_LUA_OPERATOR 10
|
||||
#define wxSTC_LUA_IDENTIFIER 11
|
||||
#define wxSTC_LUA_STRINGEOL 12
|
||||
#define wxSTC_LUA_WORD2 13
|
||||
#define wxSTC_LUA_WORD3 14
|
||||
#define wxSTC_LUA_WORD4 15
|
||||
#define wxSTC_LUA_WORD5 16
|
||||
#define wxSTC_LUA_WORD6 17
|
||||
|
||||
// Lexical states for SCLEX_ERRORLIST
|
||||
#define wxSTC_ERR_DEFAULT 0
|
||||
@@ -602,6 +635,19 @@
|
||||
#define wxSTC_ADA_IDENTIFIER 7
|
||||
#define wxSTC_ADA_STRINGEOL 8
|
||||
|
||||
// Lexical states for SCLEX_BAAN
|
||||
#define wxSTC_BAAN_DEFAULT 0
|
||||
#define wxSTC_BAAN_COMMENT 1
|
||||
#define wxSTC_BAAN_COMMENTDOC 2
|
||||
#define wxSTC_BAAN_NUMBER 3
|
||||
#define wxSTC_BAAN_WORD 4
|
||||
#define wxSTC_BAAN_STRING 5
|
||||
#define wxSTC_BAAN_PREPROCESSOR 6
|
||||
#define wxSTC_BAAN_OPERATOR 7
|
||||
#define wxSTC_BAAN_IDENTIFIER 8
|
||||
#define wxSTC_BAAN_STRINGEOL 9
|
||||
#define wxSTC_BAAN_WORD2 10
|
||||
|
||||
// Lexical states for SCLEX_LISP
|
||||
#define wxSTC_LISP_DEFAULT 0
|
||||
#define wxSTC_LISP_COMMENT 1
|
||||
@@ -636,21 +682,17 @@
|
||||
#define wxSTC_NNCRONTAB_ENVIRONMENT 9
|
||||
#define wxSTC_NNCRONTAB_IDENTIFIER 10
|
||||
|
||||
// Lexical states for SCLEX_MATLAB
|
||||
#define wxSTC_MATLAB_DEFAULT 0
|
||||
#define wxSTC_MATLAB_COMMENT 1
|
||||
#define wxSTC_MATLAB_COMMAND 2
|
||||
#define wxSTC_MATLAB_NUMBER 3
|
||||
#define wxSTC_MATLAB_KEYWORD 4
|
||||
#define wxSTC_MATLAB_STRING 5
|
||||
#define wxSTC_MATLAB_OPERATOR 6
|
||||
#define wxSTC_MATLAB_IDENTIFIER 7
|
||||
|
||||
// END of generated section
|
||||
//----------------------------------------------------------------------
|
||||
// Others
|
||||
|
||||
#define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEROPEN) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERSUB) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERTAIL) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDERMIDTAIL) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEROPENMID) | \
|
||||
(1 << wxSTC_MARKNUM_FOLDEREND))
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ScintillaWX; // forward declare
|
||||
@@ -821,7 +863,7 @@ public:
|
||||
void SetCodePage(int codePage);
|
||||
|
||||
// Set the symbol used for a particular marker number,
|
||||
// and optionally the for and background colours.
|
||||
// and optionally the fore and background colours.
|
||||
void MarkerDefine(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground = wxNullColour,
|
||||
const wxColour& background = wxNullColour);
|
||||
@@ -832,8 +874,8 @@ public:
|
||||
// Set the background colour used for a particular marker number.
|
||||
void MarkerSetBackground(int markerNumber, const wxColour& back);
|
||||
|
||||
// Add a marker to a line.
|
||||
void MarkerAdd(int line, int markerNumber);
|
||||
// Add a marker to a line, returning an ID which can be used to find or delete the marker.
|
||||
int MarkerAdd(int line, int markerNumber);
|
||||
|
||||
// Delete a marker from a line
|
||||
void MarkerDelete(int line, int markerNumber);
|
||||
@@ -980,7 +1022,7 @@ public:
|
||||
// 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.
|
||||
// Dsplay 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.
|
||||
@@ -989,6 +1031,10 @@ public:
|
||||
// Set the colour of the background of the line containing the caret.
|
||||
void SetCaretLineBack(const wxColour& back);
|
||||
|
||||
// Set a style to be changeable or not (read only).
|
||||
// Experimental feature, currently buggy.
|
||||
void StyleSetChangeable(int style, bool changeable);
|
||||
|
||||
// Display a auto-completion list.
|
||||
// The lenEntered parameter indicates how many characters before
|
||||
// the caret should be used to provide context.
|
||||
@@ -1027,7 +1073,8 @@ public:
|
||||
// Retrieve whether auto-completion cancelled by backspacing before start.
|
||||
bool AutoCompGetCancelAtStart();
|
||||
|
||||
// Define a set of character that when typed fills up the selected word.
|
||||
// Define a set of characters that when typed will cause the autocompletion to
|
||||
// choose the selected item.
|
||||
void AutoCompSetFillUps(const wxString& characterSet);
|
||||
|
||||
// Should a single item auto-completion list automatically choose the item.
|
||||
@@ -1051,6 +1098,12 @@ public:
|
||||
// Retrieve whether or not autocompletion is hidden automatically when nothing matches
|
||||
bool AutoCompGetAutoHide();
|
||||
|
||||
// Set whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
void AutoCompSetDropRestOfWord(bool dropRestOfWord);
|
||||
|
||||
// Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
bool AutoCompGetDropRestOfWord();
|
||||
|
||||
// Set the number of spaces used for one level of indentation.
|
||||
void SetIndent(int indentSize);
|
||||
|
||||
@@ -1369,6 +1422,28 @@ public:
|
||||
// Retrieve the time the mouse must sit still to generate a mouse dwell event
|
||||
int GetMouseDwellTime();
|
||||
|
||||
// Get position of start of word
|
||||
int WordStartPosition(int pos, bool onlyWordCharacters);
|
||||
|
||||
// Get position of end of word
|
||||
int WordEndPosition(int pos, bool onlyWordCharacters);
|
||||
|
||||
// Sets whether text is word wrapped
|
||||
void SetWrapMode(int mode);
|
||||
|
||||
// Retrieve whether text is word wrapped
|
||||
int GetWrapMode();
|
||||
|
||||
// Sets the degree of caching of layout information
|
||||
void SetLayoutCache(int mode);
|
||||
|
||||
// Retrieve the degree of caching of layout information
|
||||
int GetLayoutCache();
|
||||
|
||||
// Delete the selection or if no selection, the character before the caret.
|
||||
// Will not delete the chraacter before at the start of a line.
|
||||
void DeleteBackNotLine();
|
||||
|
||||
// Move the caret inside current view if it's not there already
|
||||
void MoveCaretInsideView();
|
||||
|
||||
@@ -1487,6 +1562,13 @@ public:
|
||||
// Get cursor type
|
||||
int GetCursor();
|
||||
|
||||
// Change the way control characters are displayed:
|
||||
// If symbol is < 32, keep the drawn way, else, use the given character
|
||||
void SetControlCharSymbol(int symbol);
|
||||
|
||||
// Get the way control characters are displayed
|
||||
int GetControlCharSymbol();
|
||||
|
||||
// Move to the previous change in capitalistion
|
||||
void WordPartLeft();
|
||||
|
||||
@@ -1508,6 +1590,10 @@ public:
|
||||
// Delete forwards from the current position to the end of the line
|
||||
void DelLineRight();
|
||||
|
||||
// Get and Set the xOffset (ie, horizonal scroll position)
|
||||
void SetXOffset(int newOffset);
|
||||
int GetXOffset();
|
||||
|
||||
// Start notifying the container of all key presses and commands.
|
||||
void StartRecord();
|
||||
|
||||
|
@@ -34,6 +34,9 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
KeyMap.o \
|
||||
KeyWords.o \
|
||||
LexAVE.o \
|
||||
LexBaan.o \
|
||||
LexBullant.o \
|
||||
LexMatlab.o \
|
||||
LexAda.o \
|
||||
LexCPP.o \
|
||||
LexConf.o \
|
||||
@@ -61,7 +64,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
||||
|
||||
DEPFILES=$(OBJECTS:.o=.d)
|
||||
|
||||
APPEXTRADEFS=-D__WX__ -DSCI_LEXER -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
|
||||
APPEXTRADEFS=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
|
||||
|
||||
include $(top_builddir)/src/makelib.env
|
||||
|
||||
|
@@ -6,7 +6,10 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "PlatWX.h"
|
||||
#include "wx/stc/stc.h"
|
||||
|
||||
|
||||
@@ -14,6 +17,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
|
||||
Point Point::FromLong(long lpoint) {
|
||||
return Point(lpoint & 0xFFFF, lpoint >> 16);
|
||||
}
|
||||
@@ -29,35 +33,12 @@ PRectangle PRectangleFromwxRect(wxRect rc) {
|
||||
rc.GetRight()+1, rc.GetBottom()+1);
|
||||
}
|
||||
|
||||
Colour::Colour(long lcol) {
|
||||
co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff);
|
||||
wxColour wxColourFromCA(const ColourAllocated& ca) {
|
||||
ColourDesired cd(ca.AsLong());
|
||||
return wxColour(cd.GetRed(), cd.GetGreen(), cd.GetBlue());
|
||||
}
|
||||
|
||||
Colour::Colour(unsigned int red, unsigned int green, unsigned int blue) {
|
||||
co.Set(red, green, blue);
|
||||
}
|
||||
|
||||
bool Colour::operator==(const Colour &other) const {
|
||||
return co == other.co;
|
||||
}
|
||||
|
||||
long Colour::AsLong() const {
|
||||
return (((long)co.Blue() << 16) |
|
||||
((long)co.Green() << 8) |
|
||||
((long)co.Red()));
|
||||
}
|
||||
|
||||
unsigned int Colour::GetRed() {
|
||||
return co.Red();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetGreen() {
|
||||
return co.Green();
|
||||
}
|
||||
|
||||
unsigned int Colour::GetBlue() {
|
||||
return co.Blue();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Palette::Palette() {
|
||||
used = 0;
|
||||
@@ -84,7 +65,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
|
||||
|
||||
if (used < numEntries) {
|
||||
entries[used].desired = cp.desired;
|
||||
entries[used].allocated = cp.desired;
|
||||
entries[used].allocated.Set(cp.desired.AsLong());
|
||||
used++;
|
||||
}
|
||||
} else {
|
||||
@@ -94,7 +75,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
cp.allocated = cp.desired;
|
||||
cp.allocated.Set(cp.desired.AsLong());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +85,8 @@ void Palette::Allocate(Window &) {
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Font::Font() {
|
||||
id = 0;
|
||||
ascent = 0;
|
||||
@@ -113,36 +96,172 @@ Font::~Font() {
|
||||
}
|
||||
|
||||
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
|
||||
// TODO: what to do about the characterSet?
|
||||
wxFontEncoding encoding;
|
||||
|
||||
Release();
|
||||
|
||||
switch (characterSet) {
|
||||
default:
|
||||
case wxSTC_CHARSET_ANSI:
|
||||
case wxSTC_CHARSET_DEFAULT:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_BALTIC:
|
||||
encoding = wxFONTENCODING_ISO8859_13;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_CHINESEBIG5:
|
||||
encoding = wxFONTENCODING_CP950;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_EASTEUROPE:
|
||||
encoding = wxFONTENCODING_ISO8859_2;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_GB2312:
|
||||
encoding = wxFONTENCODING_CP936;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_GREEK:
|
||||
encoding = wxFONTENCODING_ISO8859_7;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_HANGUL:
|
||||
encoding = wxFONTENCODING_CP949;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_MAC:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_OEM:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_RUSSIAN:
|
||||
encoding = wxFONTENCODING_KOI8;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_SHIFTJIS:
|
||||
encoding = wxFONTENCODING_CP932;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_SYMBOL:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_TURKISH:
|
||||
encoding = wxFONTENCODING_ISO8859_9;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_JOHAB:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_HEBREW:
|
||||
encoding = wxFONTENCODING_ISO8859_8;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_ARABIC:
|
||||
encoding = wxFONTENCODING_ISO8859_6;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_VIETNAMESE:
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
break;
|
||||
|
||||
case wxSTC_CHARSET_THAI:
|
||||
encoding = wxFONTENCODING_ISO8859_11;
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Use wxFontMapper and wxEncodingConverter if encoding not available.
|
||||
|
||||
id = new wxFont(size,
|
||||
wxDEFAULT,
|
||||
italic ? wxITALIC : wxNORMAL,
|
||||
bold ? wxBOLD : wxNORMAL,
|
||||
false,
|
||||
faceName,
|
||||
wxFONTENCODING_DEFAULT);
|
||||
encoding);
|
||||
}
|
||||
|
||||
|
||||
void Font::Release() {
|
||||
if (id)
|
||||
delete id;
|
||||
delete (wxFont*)id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Surface::Surface() :
|
||||
class SurfaceImpl : public Surface {
|
||||
private:
|
||||
wxDC* hdc;
|
||||
bool hdcOwned;
|
||||
wxBitmap* bitmap;
|
||||
int x;
|
||||
int y;
|
||||
bool unicodeMode;
|
||||
|
||||
public:
|
||||
SurfaceImpl();
|
||||
~SurfaceImpl();
|
||||
|
||||
void Init();
|
||||
void Init(SurfaceID sid);
|
||||
void InitPixMap(int width, int height, Surface *surface_);
|
||||
|
||||
void Release();
|
||||
bool Initialised();
|
||||
void PenColour(ColourAllocated fore);
|
||||
int LogPixelsY();
|
||||
int DeviceHeightFont(int points);
|
||||
void MoveTo(int x_, int y_);
|
||||
void LineTo(int x_, int y_);
|
||||
void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
|
||||
void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
|
||||
void FillRectangle(PRectangle rc, ColourAllocated back);
|
||||
void FillRectangle(PRectangle rc, Surface &surfacePattern);
|
||||
void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
|
||||
void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
|
||||
void Copy(PRectangle rc, Point from, Surface &surfaceSource);
|
||||
|
||||
void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
|
||||
void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
|
||||
void MeasureWidths(Font &font_, const char *s, int len, int *positions);
|
||||
int WidthText(Font &font_, const char *s, int len);
|
||||
int WidthChar(Font &font_, char ch);
|
||||
int Ascent(Font &font_);
|
||||
int Descent(Font &font_);
|
||||
int InternalLeading(Font &font_);
|
||||
int ExternalLeading(Font &font_);
|
||||
int Height(Font &font_);
|
||||
int AverageCharWidth(Font &font_);
|
||||
|
||||
int SetPalette(Palette *pal, bool inBackGround);
|
||||
void SetClip(PRectangle rc);
|
||||
void FlushCachedState();
|
||||
|
||||
void SetUnicodeMode(bool unicodeMode_);
|
||||
|
||||
void BrushColour(ColourAllocated back);
|
||||
void SetFont(Font &font_);
|
||||
};
|
||||
|
||||
|
||||
|
||||
SurfaceImpl::SurfaceImpl() :
|
||||
hdc(0), hdcOwned(0), bitmap(0),
|
||||
x(0), y(0) {
|
||||
}
|
||||
x(0), y(0), unicodeMode(0)
|
||||
{}
|
||||
|
||||
Surface::~Surface() {
|
||||
SurfaceImpl::~SurfaceImpl() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Surface::Release() {
|
||||
void SurfaceImpl::Release() {
|
||||
if (bitmap) {
|
||||
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
|
||||
delete bitmap;
|
||||
@@ -156,24 +275,24 @@ void Surface::Release() {
|
||||
}
|
||||
|
||||
|
||||
bool Surface::Initialised() {
|
||||
bool SurfaceImpl::Initialised() {
|
||||
return hdc != 0;
|
||||
}
|
||||
|
||||
void Surface::Init() {
|
||||
void SurfaceImpl::Init() {
|
||||
Release();
|
||||
hdc = new wxMemoryDC();
|
||||
hdcOwned = true;
|
||||
}
|
||||
|
||||
void Surface::Init(SurfaceID hdc_) {
|
||||
void SurfaceImpl::Init(SurfaceID hdc_) {
|
||||
Release();
|
||||
hdc = hdc_;
|
||||
hdc = (wxDC*)hdc_;
|
||||
}
|
||||
|
||||
void Surface::InitPixMap(int width, int height, Surface *surface_) {
|
||||
void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_) {
|
||||
Release();
|
||||
hdc = new wxMemoryDC(surface_->hdc);
|
||||
hdc = new wxMemoryDC();
|
||||
hdcOwned = true;
|
||||
if (width < 1) width = 1;
|
||||
if (height < 1) height = 1;
|
||||
@@ -181,64 +300,63 @@ void Surface::InitPixMap(int width, int height, Surface *surface_) {
|
||||
((wxMemoryDC*)hdc)->SelectObject(*bitmap);
|
||||
}
|
||||
|
||||
void Surface::PenColour(Colour fore) {
|
||||
hdc->SetPen(wxPen(fore.co, 1, wxSOLID));
|
||||
void SurfaceImpl::PenColour(ColourAllocated fore) {
|
||||
hdc->SetPen(wxPen(wxColourFromCA(fore), 1, wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::BrushColor(Colour back) {
|
||||
hdc->SetBrush(wxBrush(back.co, wxSOLID));
|
||||
void SurfaceImpl::BrushColour(ColourAllocated back) {
|
||||
hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID));
|
||||
}
|
||||
|
||||
void Surface::SetFont(Font &font_) {
|
||||
void SurfaceImpl::SetFont(Font &font_) {
|
||||
if (font_.GetID()) {
|
||||
hdc->SetFont(*font_.GetID());
|
||||
hdc->SetFont(*((wxFont*)font_.GetID()));
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::LogPixelsY() {
|
||||
int SurfaceImpl::LogPixelsY() {
|
||||
return hdc->GetPPI().y;
|
||||
}
|
||||
|
||||
|
||||
int Surface::DeviceHeightFont(int points) {
|
||||
int SurfaceImpl::DeviceHeightFont(int points) {
|
||||
return points;
|
||||
// int logPix = LogPixelsY();
|
||||
// return (points * logPix + logPix / 2) / 72;
|
||||
}
|
||||
|
||||
|
||||
void Surface::MoveTo(int x_, int y_) {
|
||||
void SurfaceImpl::MoveTo(int x_, int y_) {
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::LineTo(int x_, int y_) {
|
||||
void SurfaceImpl::LineTo(int x_, int y_) {
|
||||
hdc->DrawLine(x,y, x_,y_);
|
||||
x = x_;
|
||||
y = y_;
|
||||
}
|
||||
|
||||
void Surface::Polygon(Point *pts, int npts, Colour fore,
|
||||
Colour back) {
|
||||
void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawPolygon(npts, (wxPoint*)pts);
|
||||
}
|
||||
|
||||
void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
|
||||
void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Colour back) {
|
||||
BrushColor(back);
|
||||
void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
|
||||
BrushColour(back);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
wxBrush br;
|
||||
if (surfacePattern.bitmap)
|
||||
br = wxBrush(*surfacePattern.bitmap);
|
||||
if (((SurfaceImpl&)surfacePattern).bitmap)
|
||||
br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap);
|
||||
else // Something is wrong so display in red
|
||||
br = wxBrush(*wxRED, wxSOLID);
|
||||
hdc->SetPen(*wxTRANSPARENT_PEN);
|
||||
@@ -246,79 +364,112 @@ void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
|
||||
hdc->DrawRectangle(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
|
||||
void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4);
|
||||
}
|
||||
|
||||
void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
|
||||
void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
|
||||
PenColour(fore);
|
||||
BrushColor(back);
|
||||
BrushColour(back);
|
||||
hdc->DrawEllipse(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
|
||||
void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
hdc->Blit(r.x, r.y, r.width, r.height,
|
||||
surfaceSource.hdc, from.x, from.y, wxCOPY);
|
||||
((SurfaceImpl&)surfaceSource).hdc,
|
||||
from.x, from.y, wxCOPY);
|
||||
}
|
||||
|
||||
void Surface::DrawText(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len, Colour fore, Colour back) {
|
||||
void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len,
|
||||
ColourAllocated fore, ColourAllocated back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
hdc->SetTextForeground(wxColourFromCA(fore));
|
||||
hdc->SetTextBackground(wxColourFromCA(back));
|
||||
FillRectangle(rc, back);
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
// ybase is where the baseline should be, but wxWin uses the upper left
|
||||
// corner, so I need to calculate the real position for the text...
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
hdc->DrawText(str, rc.left, ybase - font.ascent);
|
||||
}
|
||||
|
||||
void Surface::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, Colour fore, Colour back) {
|
||||
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
|
||||
const char *s, int len,
|
||||
ColourAllocated fore, ColourAllocated back) {
|
||||
SetFont(font);
|
||||
hdc->SetTextForeground(fore.co);
|
||||
hdc->SetTextBackground(back.co);
|
||||
hdc->SetTextForeground(wxColourFromCA(fore));
|
||||
hdc->SetTextBackground(wxColourFromCA(back));
|
||||
FillRectangle(rc, back);
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
// see comments above
|
||||
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
|
||||
hdc->DrawText(str, rc.left, ybase - font.ascent);
|
||||
hdc->DestroyClippingRegion();
|
||||
}
|
||||
|
||||
int Surface::WidthText(Font &font, const char *s, int len) {
|
||||
int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(wxString(s, len), &w, &h);
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
hdc->GetTextExtent(str, &w, &h);
|
||||
return w;
|
||||
}
|
||||
|
||||
void Surface::MeasureWidths(Font &font, const char *s, int len, int *positions) {
|
||||
void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
wxString str = wxString(s, len);
|
||||
#endif
|
||||
|
||||
SetFont(font);
|
||||
int totalWidth = 0;
|
||||
for (int i=0; i<len; i++) {
|
||||
for (size_t i=0; i<(size_t)len; i++) {
|
||||
int w;
|
||||
int h;
|
||||
hdc->GetTextExtent(s[i], &w, &h);
|
||||
hdc->GetTextExtent(str[i], &w, &h);
|
||||
totalWidth += w;
|
||||
positions[i] = totalWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int Surface::WidthChar(Font &font, char ch) {
|
||||
int SurfaceImpl::WidthChar(Font &font, char ch) {
|
||||
SetFont(font);
|
||||
int w;
|
||||
int h;
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this... Convert s from UTF-8.
|
||||
#else
|
||||
hdc->GetTextExtent(ch, &w, &h);
|
||||
#endif
|
||||
return w;
|
||||
}
|
||||
|
||||
#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
#define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
int Surface::Ascent(Font &font) {
|
||||
int SurfaceImpl::Ascent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
@@ -326,66 +477,81 @@ int Surface::Ascent(Font &font) {
|
||||
return font.ascent;
|
||||
}
|
||||
|
||||
int Surface::Descent(Font &font) {
|
||||
int SurfaceImpl::Descent(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return d;
|
||||
}
|
||||
|
||||
int Surface::InternalLeading(Font &font) {
|
||||
int SurfaceImpl::InternalLeading(Font &font) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Surface::ExternalLeading(Font &font) {
|
||||
int SurfaceImpl::ExternalLeading(Font &font) {
|
||||
SetFont(font);
|
||||
int w, h, d, e;
|
||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||
return e;
|
||||
}
|
||||
|
||||
int Surface::Height(Font &font) {
|
||||
int SurfaceImpl::Height(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharHeight();
|
||||
}
|
||||
|
||||
int Surface::AverageCharWidth(Font &font) {
|
||||
int SurfaceImpl::AverageCharWidth(Font &font) {
|
||||
SetFont(font);
|
||||
return hdc->GetCharWidth();
|
||||
}
|
||||
|
||||
int Surface::SetPalette(Palette *pal, bool inBackGround) {
|
||||
int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Surface::SetClip(PRectangle rc) {
|
||||
void SurfaceImpl::SetClip(PRectangle rc) {
|
||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||
}
|
||||
|
||||
void Surface::FlushCachedState() {
|
||||
void SurfaceImpl::FlushCachedState() {
|
||||
}
|
||||
|
||||
void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
|
||||
// TODO: Make this jive with wxUSE_UNICODE
|
||||
unicodeMode=unicodeMode_;
|
||||
}
|
||||
|
||||
Surface *Surface::Allocate() {
|
||||
return new SurfaceImpl;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
inline wxWindow* GETWIN(WindowID id) { return (wxWindow*)id; }
|
||||
|
||||
Window::~Window() {
|
||||
}
|
||||
|
||||
void Window::Destroy() {
|
||||
if (id)
|
||||
id->Destroy();
|
||||
GETWIN(id)->Destroy();
|
||||
id = 0;
|
||||
}
|
||||
|
||||
bool Window::HasFocus() {
|
||||
return wxWindow::FindFocus() == id;
|
||||
return wxWindow::FindFocus() == GETWIN(id);
|
||||
}
|
||||
|
||||
PRectangle Window::GetPosition() {
|
||||
wxRect rc(id->GetPosition(), id->GetSize());
|
||||
wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize());
|
||||
return PRectangleFromwxRect(rc);
|
||||
}
|
||||
|
||||
void Window::SetPosition(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->SetSize(r);
|
||||
GETWIN(id)->SetSize(r);
|
||||
}
|
||||
|
||||
void Window::SetPositionRelative(PRectangle rc, Window) {
|
||||
@@ -393,25 +559,25 @@ void Window::SetPositionRelative(PRectangle rc, Window) {
|
||||
}
|
||||
|
||||
PRectangle Window::GetClientPosition() {
|
||||
wxSize sz = id->GetClientSize();
|
||||
wxSize sz = GETWIN(id)->GetClientSize();
|
||||
return PRectangle(0, 0, sz.x, sz.y);
|
||||
}
|
||||
|
||||
void Window::Show(bool show) {
|
||||
id->Show(show);
|
||||
GETWIN(id)->Show(show);
|
||||
}
|
||||
|
||||
void Window::InvalidateAll() {
|
||||
id->Refresh(false);
|
||||
GETWIN(id)->Refresh(false);
|
||||
}
|
||||
|
||||
void Window::InvalidateRectangle(PRectangle rc) {
|
||||
wxRect r = wxRectFromPRectangle(rc);
|
||||
id->Refresh(false, &r);
|
||||
GETWIN(id)->Refresh(false, &r);
|
||||
}
|
||||
|
||||
void Window::SetFont(Font &font) {
|
||||
id->SetFont(*font.GetID());
|
||||
GETWIN(id)->SetFont(*((wxFont*)font.GetID()));
|
||||
}
|
||||
|
||||
void Window::SetCursor(Cursor curs) {
|
||||
@@ -444,19 +610,23 @@ void Window::SetCursor(Cursor curs) {
|
||||
break;
|
||||
}
|
||||
|
||||
id->SetCursor(wxCursor(cursorId));
|
||||
GETWIN(id)->SetCursor(wxCursor(cursorId));
|
||||
}
|
||||
|
||||
|
||||
void Window::SetTitle(const char *s) {
|
||||
id->SetTitle(s);
|
||||
#if wxUSE_UNICODE
|
||||
#error Fix this...
|
||||
#else
|
||||
GETWIN(id)->SetTitle(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper classes for ListBox
|
||||
|
||||
// A wxListBox that gives focus to its parent if it gets it.
|
||||
// A wxListBox that gives focus back to its parent if it gets it.
|
||||
class wxSTCListBox : public wxListBox {
|
||||
public:
|
||||
wxSTCListBox(wxWindow* parent, wxWindowID id)
|
||||
@@ -532,7 +702,9 @@ BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
#define GETLB(win) (((wxSTCListBoxWin*)win)->GetLB())
|
||||
inline wxListBox* GETLB(WindowID win) {
|
||||
return (((wxSTCListBoxWin*)win)->GetLB());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -543,7 +715,7 @@ ListBox::~ListBox() {
|
||||
}
|
||||
|
||||
void ListBox::Create(Window &parent, int ctrlID) {
|
||||
id = new wxSTCListBoxWin(parent.id, ctrlID);
|
||||
id = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID);
|
||||
}
|
||||
|
||||
void ListBox::SetVisibleRows(int rows) {
|
||||
@@ -569,7 +741,7 @@ void ListBox::SetAverageCharWidth(int width) {
|
||||
}
|
||||
|
||||
void ListBox::SetFont(Font &font) {
|
||||
GETLB(id)->SetFont(*font.GetID());
|
||||
GETLB(id)->SetFont(*((wxFont*)font.GetID()));
|
||||
}
|
||||
|
||||
void ListBox::Clear() {
|
||||
@@ -605,14 +777,18 @@ int ListBox::Find(const char *prefix) {
|
||||
}
|
||||
|
||||
void ListBox::GetValue(int n, char *value, int len) {
|
||||
#if wxUSE_UNICODE
|
||||
#error fix this...
|
||||
wxString text = GETLB(id)->GetString(n);
|
||||
strncpy(value, text.c_str(), len);
|
||||
value[len-1] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBox::Sort() {
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Menu::Menu() : id(0) {
|
||||
}
|
||||
@@ -624,26 +800,27 @@ void Menu::CreatePopUp() {
|
||||
|
||||
void Menu::Destroy() {
|
||||
if (id)
|
||||
delete id;
|
||||
delete (wxMenu*)id;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
void Menu::Show(Point pt, Window &w) {
|
||||
w.GetID()->PopupMenu(id, pt.x - 4, pt.y);
|
||||
GETWIN(w.GetID())->PopupMenu((wxMenu*)id, pt.x - 4, pt.y);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Colour Platform::Chrome() {
|
||||
ColourDesired Platform::Chrome() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
return ColourDesired(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
Colour Platform::ChromeHighlight() {
|
||||
ColourDesired Platform::ChromeHighlight() {
|
||||
wxColour c;
|
||||
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
|
||||
return Colour(c.Red(), c.Green(), c.Blue());
|
||||
return ColourDesired(c.Red(), c.Green(), c.Blue());
|
||||
}
|
||||
|
||||
const char *Platform::DefaultFont() {
|
||||
@@ -744,6 +921,26 @@ int Platform::Clamp(int val, int minVal, int maxVal) {
|
||||
}
|
||||
|
||||
|
||||
bool Platform::IsDBCSLeadByte(int codePage, char ch) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
ElapsedTime::ElapsedTime() {
|
||||
wxStartTimer();
|
||||
}
|
||||
|
||||
double ElapsedTime::Duration(bool reset) {
|
||||
double result = wxGetElapsedTime(reset);
|
||||
result /= 1000.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
8
src/stc/PlatWX.h
Normal file
8
src/stc/PlatWX.h
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
wxRect wxRectFromPRectangle(PRectangle prc);
|
||||
PRectangle PRectangleFromwxRect(wxRect rc);
|
||||
wxColour wxColourFromCA(const ColourAllocated& ca);
|
||||
|
@@ -14,10 +14,10 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ScintillaWX.h"
|
||||
#include "wx/stc/stc.h"
|
||||
#include "PlatWX.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -82,10 +82,10 @@ public:
|
||||
|
||||
void OnPaint(wxPaintEvent& evt) {
|
||||
wxPaintDC dc(this);
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(&dc);
|
||||
m_ct->PaintCT(&surfaceWindow);
|
||||
surfaceWindow.Release();
|
||||
Surface* surfaceWindow = Surface::Allocate();
|
||||
surfaceWindow->Init(&dc);
|
||||
m_ct->PaintCT(surfaceWindow);
|
||||
delete surfaceWindow;
|
||||
}
|
||||
|
||||
#if wxUSE_POPUPWIN
|
||||
@@ -184,7 +184,7 @@ void ScintillaWX::SetTicking(bool on) {
|
||||
if (timer.ticking) {
|
||||
steTimer = new wxSTCTimer(this);
|
||||
steTimer->Start(timer.tickSize);
|
||||
timer.tickerID = (int)steTimer;
|
||||
timer.tickerID = steTimer;
|
||||
} else {
|
||||
steTimer = (wxSTCTimer*)timer.tickerID;
|
||||
steTimer->Stop();
|
||||
@@ -343,12 +343,12 @@ void ScintillaWX::CreateCallTipWindow(PRectangle) {
|
||||
|
||||
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
||||
if (!label[0])
|
||||
popup.GetID()->AppendSeparator();
|
||||
((wxMenu*)popup.GetID())->AppendSeparator();
|
||||
else
|
||||
popup.GetID()->Append(cmd, label);
|
||||
((wxMenu*)popup.GetID())->Append(cmd, label);
|
||||
|
||||
if (!enabled)
|
||||
popup.GetID()->Enable(cmd, enabled);
|
||||
((wxMenu*)popup.GetID())->Enable(cmd, enabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -379,13 +379,13 @@ long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lPar
|
||||
void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
|
||||
|
||||
paintState = painting;
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(dc);
|
||||
Surface* surfaceWindow = Surface::Allocate();
|
||||
surfaceWindow->Init(dc);
|
||||
PRectangle rcPaint = PRectangleFromwxRect(rect);
|
||||
dc->BeginDrawing();
|
||||
Paint(&surfaceWindow, rcPaint);
|
||||
Paint(surfaceWindow, rcPaint);
|
||||
dc->EndDrawing();
|
||||
surfaceWindow.Release();
|
||||
delete surfaceWindow;
|
||||
if (paintState == paintAbandoned) {
|
||||
// Painting area was insufficient to cover new styling or brace highlight positions
|
||||
FullPaint();
|
||||
@@ -466,9 +466,10 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int
|
||||
|
||||
|
||||
void ScintillaWX::DoSize(int width, int height) {
|
||||
PRectangle rcClient(0,0,width,height);
|
||||
SetScrollBarsTo(rcClient);
|
||||
DropGraphics();
|
||||
// PRectangle rcClient(0,0,width,height);
|
||||
// SetScrollBarsTo(rcClient);
|
||||
// DropGraphics();
|
||||
ChangeSize();
|
||||
}
|
||||
|
||||
void ScintillaWX::DoLoseFocus(){
|
||||
@@ -622,10 +623,10 @@ void ScintillaWX::FullPaint() {
|
||||
rcPaint = GetTextRectangle();
|
||||
paintingAllText = true;
|
||||
wxClientDC dc(stc);
|
||||
Surface surfaceWindow;
|
||||
surfaceWindow.Init(&dc);
|
||||
Paint(&surfaceWindow, rcPaint);
|
||||
surfaceWindow.Release();
|
||||
Surface* surfaceWindow = Surface::Allocate();
|
||||
surfaceWindow->Init(&dc);
|
||||
Paint(surfaceWindow, rcPaint);
|
||||
delete surfaceWindow;
|
||||
|
||||
// stc->Refresh(FALSE);
|
||||
|
||||
|
@@ -19,6 +19,11 @@
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Scintilla.h"
|
||||
|
@@ -187,6 +187,18 @@ SOURCE=.\scintilla\src\LexAVE.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexBaan.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexBullant.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexMatlab.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scintilla\src\LexConf.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -154,7 +154,7 @@ methodOverrideMap = {
|
||||
MarkerSetBackground(markerNumber, background);''',
|
||||
|
||||
('Set the symbol used for a particular marker number,',
|
||||
'and optionally the for and background colours.')),
|
||||
'and optionally the fore and background colours.')),
|
||||
|
||||
'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
|
||||
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
|
||||
@@ -226,6 +226,8 @@ methodOverrideMap = {
|
||||
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
|
||||
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
|
||||
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
|
||||
'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
|
||||
'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
|
||||
|
||||
|
||||
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
|
||||
|
@@ -17,7 +17,7 @@ SCINTILLA=.\scintilla
|
||||
|
||||
S=$(SCINTILLA)\src
|
||||
|
||||
STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S)
|
||||
STCEXTRACPPFLAGS=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S)
|
||||
|
||||
LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
|
||||
|
||||
@@ -34,6 +34,9 @@ OBJECTS = \
|
||||
KeyWords.obj \
|
||||
LexAVE.obj \
|
||||
LexAda.obj \
|
||||
LexBaan.obj \
|
||||
LexBullant.obj \
|
||||
LexMatlab.obj \
|
||||
LexCPP.obj \
|
||||
LexConf.obj \
|
||||
LexCrontab.obj \
|
||||
|
@@ -7,7 +7,7 @@ WXDIR = ../../..
|
||||
|
||||
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
|
||||
S=$(SCINTILLA)/src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
|
||||
|
||||
OBJECTS = \
|
||||
$(S)/AutoComplete.$(OBJSUFF) \
|
||||
@@ -22,6 +22,9 @@ OBJECTS = \
|
||||
$(S)/KeyWords.$(OBJSUFF) \
|
||||
$(S)/LexAVE.$(OBJSUFF) \
|
||||
$(S)/LexAda.$(OBJSUFF) \
|
||||
$(S)/LexBaan.$(OBJSUFF) \
|
||||
$(S)/LexBullant.$(OBJSUFF) \
|
||||
$(S)/LexMatlab.$(OBJSUFF) \
|
||||
$(S)/LexCPP.$(OBJSUFF) \
|
||||
$(S)/LexConf.$(OBJSUFF) \
|
||||
$(S)/LexCrontab.$(OBJSUFF) \
|
||||
|
@@ -9,7 +9,7 @@
|
||||
WXDIR = $(WXWIN)
|
||||
SCINTILLA=.\scintilla
|
||||
S=$(SCINTILLA)\src
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
|
||||
EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
|
||||
NOPCH=1
|
||||
|
||||
!include $(WXDIR)\src\makevc.env
|
||||
@@ -27,6 +27,9 @@ OBJECTS = \
|
||||
$(D)\KeyWords.obj \
|
||||
$(D)\LexAVE.obj \
|
||||
$(D)\LexAda.obj \
|
||||
$(D)\LexBaan.obj \
|
||||
$(D)\LexBullant.obj \
|
||||
$(D)\LexMatlab.obj \
|
||||
$(D)\LexCPP.obj \
|
||||
$(D)\LexConf.obj \
|
||||
$(D)\LexCrontab.obj \
|
||||
|
@@ -3,5 +3,5 @@ scintilla/include directories from the Scintilla/SCiTE source
|
||||
distribution. All other code needed to implement Scintilla on top of
|
||||
wxWindows is located in the directory above this one.
|
||||
|
||||
The current version of the Scintilla code is 1.40
|
||||
The current version of the Scintilla code is 1.45
|
||||
|
||||
|
@@ -15,25 +15,25 @@ typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyl
|
||||
*/
|
||||
class LexerModule {
|
||||
protected:
|
||||
LexerModule *next;
|
||||
const LexerModule *next;
|
||||
int language;
|
||||
const char *languageName;
|
||||
LexerFunction fnLexer;
|
||||
LexerFunction fnFolder;
|
||||
|
||||
static LexerModule *base;
|
||||
static const LexerModule *base;
|
||||
static int nextLanguage;
|
||||
|
||||
public:
|
||||
const char *languageName;
|
||||
LexerModule(int language_, LexerFunction fnLexer_,
|
||||
const char *languageName_=0, LexerFunction fnFolder_=0);
|
||||
int GetLanguage() { return language; }
|
||||
int GetLanguage() const { return language; }
|
||||
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler);
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
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);
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
static const LexerModule *Find(int language);
|
||||
static const LexerModule *Find(const char *languageName);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,7 @@
|
||||
** 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.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef PLATFORM_H
|
||||
@@ -18,8 +18,13 @@
|
||||
#define PLAT_GTK_WIN32 0
|
||||
#define PLAT_WIN 0
|
||||
#define PLAT_WX 0
|
||||
#define PLAT_FOX 0
|
||||
|
||||
#if defined(__WX__)
|
||||
#if defined(FOX)
|
||||
#undef PLAT_FOX
|
||||
#define PLAT_FOX 1
|
||||
|
||||
#elif defined(__WX__)
|
||||
#undef PLAT_WX
|
||||
#define PLAT_WX 1
|
||||
|
||||
@@ -39,79 +44,14 @@
|
||||
#endif
|
||||
|
||||
|
||||
// Include the main header for each platform
|
||||
|
||||
#if PLAT_GTK
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4505 4514 4710 4800)
|
||||
#endif
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#endif
|
||||
|
||||
#if PLAT_WIN
|
||||
#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out
|
||||
// Vassili Bourdo: shut up annoying Visual C++ warnings:
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4244 4309 4710 4800)
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#endif
|
||||
|
||||
#if PLAT_WX
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#define ColourID scColourID
|
||||
#define FontID scFontID
|
||||
#define SurfaceID scSurfaceID
|
||||
#define WindowID scWindowID
|
||||
#define MenuID scMenuID
|
||||
#define Point scPoint
|
||||
#define PRectangle scPRectangle
|
||||
#define Colour scColour
|
||||
#define ColourPair scColourPair
|
||||
#define Window scWindow
|
||||
#define Palette scPalette
|
||||
#define Font scFont
|
||||
#define Surface scSurface
|
||||
#define Window scWindow
|
||||
#define ListBox scListBox
|
||||
#define Menu scMenu
|
||||
#define Platform scPlatform
|
||||
#define TextRange scTextRange
|
||||
#define KeyMap scKeyMap
|
||||
#define Style scStyle
|
||||
|
||||
|
||||
// Underlying the implementation of the platform classes are platform specific types.
|
||||
// Sometimes these need to be passed around by client code so they are defined here
|
||||
|
||||
#if PLAT_GTK
|
||||
typedef GdkColor ColourID;
|
||||
typedef GdkFont* FontID;
|
||||
typedef GdkDrawable* SurfaceID;
|
||||
typedef GtkWidget* WindowID;
|
||||
typedef GtkItemFactory* MenuID;
|
||||
#endif
|
||||
|
||||
#if PLAT_WIN
|
||||
typedef COLORREF ColourID;
|
||||
typedef HFONT FontID;
|
||||
typedef HDC SurfaceID;
|
||||
typedef HWND WindowID;
|
||||
typedef HMENU MenuID;
|
||||
#endif
|
||||
|
||||
#if PLAT_WX
|
||||
typedef wxColour ColourID;
|
||||
typedef wxFont* FontID;
|
||||
typedef wxDC* SurfaceID;
|
||||
typedef wxWindow* WindowID;
|
||||
typedef wxMenu* MenuID;
|
||||
#endif
|
||||
typedef void *FontID;
|
||||
typedef void *SurfaceID;
|
||||
typedef void *WindowID;
|
||||
typedef void *MenuID;
|
||||
typedef void *TickerID;
|
||||
|
||||
/**
|
||||
* A geometric point class.
|
||||
@@ -168,42 +108,88 @@ public:
|
||||
int Height() { return bottom - top; }
|
||||
};
|
||||
|
||||
#if PLAT_WX
|
||||
wxRect wxRectFromPRectangle(PRectangle prc);
|
||||
PRectangle PRectangleFromwxRect(wxRect rc);
|
||||
#endif
|
||||
/**
|
||||
* In some circumstances, including Win32 in paletted mode and GTK+, each colour
|
||||
* must be allocated before use. The desired colours are held in the ColourDesired class,
|
||||
* and after allocation the allocation entry is stored in the ColourAllocated class. In other
|
||||
* circumstances, such as Win32 in true colour mode, the allocation process just copies
|
||||
* the RGB values from the desired to the allocated class.
|
||||
* As each desired colour requires allocation before it can be used, the ColourPair class
|
||||
* holds both a ColourDesired and a ColourAllocated
|
||||
* The Palette class is responsible for managing the palette of colours which contains a
|
||||
* list of ColourPair objects and performs the allocation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A colour class.
|
||||
* Holds a desired RGB colour.
|
||||
*/
|
||||
class Colour {
|
||||
ColourID co;
|
||||
class ColourDesired {
|
||||
long co;
|
||||
public:
|
||||
Colour(long lcol=0);
|
||||
Colour(unsigned int red, unsigned int green, unsigned int blue);
|
||||
bool operator==(const Colour &other) const;
|
||||
long AsLong() const;
|
||||
unsigned int GetRed();
|
||||
unsigned int GetGreen();
|
||||
unsigned int GetBlue();
|
||||
ColourDesired(long lcol=0) {
|
||||
co = lcol;
|
||||
}
|
||||
|
||||
friend class Surface;
|
||||
friend class Palette;
|
||||
ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
|
||||
co = red | (green << 8) | (blue << 16);
|
||||
}
|
||||
|
||||
bool operator==(const ColourDesired &other) const {
|
||||
return co == other.co;
|
||||
}
|
||||
|
||||
void Set(long lcol) {
|
||||
co = lcol;
|
||||
}
|
||||
|
||||
long AsLong() const {
|
||||
return co;
|
||||
}
|
||||
|
||||
unsigned int GetRed() {
|
||||
return co & 0xff;
|
||||
}
|
||||
|
||||
unsigned int GetGreen() {
|
||||
return (co >> 8) & 0xff;
|
||||
}
|
||||
|
||||
unsigned int GetBlue() {
|
||||
return (co >> 16) & 0xff;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Colour pairs hold a desired colour and the colour that the graphics engine
|
||||
* allocates to approximate the desired colour.
|
||||
* To make palette management more automatic, ColourPairs could register at
|
||||
* construction time with a palette management object.
|
||||
* Holds an allocated RGB colour which may be an approximation to the desired colour.
|
||||
*/
|
||||
class ColourAllocated {
|
||||
long coAllocated;
|
||||
|
||||
public:
|
||||
|
||||
ColourAllocated(long lcol=0) {
|
||||
coAllocated = lcol;
|
||||
}
|
||||
|
||||
void Set(long lcol) {
|
||||
coAllocated = lcol;
|
||||
}
|
||||
|
||||
long AsLong() const {
|
||||
return coAllocated;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Colour pairs hold a desired colour and an allocated colour.
|
||||
*/
|
||||
struct ColourPair {
|
||||
Colour desired;
|
||||
Colour allocated;
|
||||
ColourDesired desired;
|
||||
ColourAllocated allocated;
|
||||
|
||||
ColourPair(Colour desired_=Colour(0,0,0)) {
|
||||
ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
|
||||
desired = desired_;
|
||||
allocated = desired;
|
||||
allocated.Set(desired.AsLong());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -217,14 +203,13 @@ class Palette {
|
||||
enum {numEntries = 100};
|
||||
ColourPair entries[numEntries];
|
||||
#if PLAT_GTK
|
||||
GdkColor *allocatedPalette;
|
||||
void *allocatedPalette; // GdkColor *
|
||||
int allocatedLen;
|
||||
#elif PLAT_WIN
|
||||
HPALETTE hpal;
|
||||
#elif PLAT_WX
|
||||
// wxPalette* pal; // **** Is this needed?
|
||||
#endif
|
||||
public:
|
||||
#if PLAT_WIN
|
||||
void *hpal;
|
||||
#endif
|
||||
bool allowRealization;
|
||||
|
||||
Palette();
|
||||
@@ -240,8 +225,6 @@ public:
|
||||
void WantFind(ColourPair &cp, bool want);
|
||||
|
||||
void Allocate(Window &w);
|
||||
|
||||
friend class Surface;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -267,6 +250,7 @@ public:
|
||||
// Alias another font - caller guarantees not to Release
|
||||
void SetID(FontID id_) { id = id_; }
|
||||
friend class Surface;
|
||||
friend class SurfaceImpl;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -274,97 +258,67 @@ public:
|
||||
*/
|
||||
class Surface {
|
||||
private:
|
||||
bool unicodeMode;
|
||||
#if PLAT_GTK
|
||||
GdkDrawable *drawable;
|
||||
GdkGC *gc;
|
||||
GdkPixmap *ppixmap;
|
||||
int x;
|
||||
int y;
|
||||
bool inited;
|
||||
bool createdGC;
|
||||
#elif PLAT_WIN
|
||||
HDC hdc;
|
||||
bool hdcOwned;
|
||||
HPEN pen;
|
||||
HPEN penOld;
|
||||
HBRUSH brush;
|
||||
HBRUSH brushOld;
|
||||
HFONT font;
|
||||
HFONT fontOld;
|
||||
HBITMAP bitmap;
|
||||
HBITMAP bitmapOld;
|
||||
HPALETTE paletteOld;
|
||||
#elif PLAT_WX
|
||||
wxDC* hdc;
|
||||
bool hdcOwned;
|
||||
wxBitmap* bitmap;
|
||||
int x;
|
||||
int y;
|
||||
#endif
|
||||
|
||||
// Private so Surface objects can not be copied
|
||||
Surface(const Surface &) {}
|
||||
Surface &operator=(const Surface &) { return *this; }
|
||||
#if PLAT_WIN || PLAT_WX
|
||||
void BrushColor(Colour back);
|
||||
void SetFont(Font &font_);
|
||||
#endif
|
||||
public:
|
||||
Surface();
|
||||
~Surface();
|
||||
Surface() {};
|
||||
virtual ~Surface() {};
|
||||
static Surface *Allocate();
|
||||
|
||||
void Init();
|
||||
void Init(SurfaceID hdc_);
|
||||
void InitPixMap(int width, int height, Surface *surface_);
|
||||
virtual void Init()=0;
|
||||
virtual void Init(SurfaceID sid)=0;
|
||||
virtual void InitPixMap(int width, int height, Surface *surface_)=0;
|
||||
|
||||
void Release();
|
||||
bool Initialised();
|
||||
void PenColour(Colour fore);
|
||||
int LogPixelsY();
|
||||
int DeviceHeightFont(int points);
|
||||
void MoveTo(int x_, int y_);
|
||||
void LineTo(int x_, int y_);
|
||||
void Polygon(Point *pts, int npts, Colour fore, Colour back);
|
||||
void RectangleDraw(PRectangle rc, Colour fore, Colour back);
|
||||
void FillRectangle(PRectangle rc, Colour back);
|
||||
void FillRectangle(PRectangle rc, Surface &surfacePattern);
|
||||
void RoundedRectangle(PRectangle rc, Colour fore, Colour back);
|
||||
void Ellipse(PRectangle rc, Colour fore, Colour back);
|
||||
void Copy(PRectangle rc, Point from, Surface &surfaceSource);
|
||||
virtual void Release()=0;
|
||||
virtual bool Initialised()=0;
|
||||
virtual void PenColour(ColourAllocated fore)=0;
|
||||
virtual int LogPixelsY()=0;
|
||||
virtual int DeviceHeightFont(int points)=0;
|
||||
virtual void MoveTo(int x_, int y_)=0;
|
||||
virtual void LineTo(int x_, int y_)=0;
|
||||
virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
|
||||
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
|
||||
virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
|
||||
|
||||
void DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
|
||||
void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
|
||||
void MeasureWidths(Font &font_, const char *s, int len, int *positions);
|
||||
int WidthText(Font &font_, const char *s, int len);
|
||||
int WidthChar(Font &font_, char ch);
|
||||
int Ascent(Font &font_);
|
||||
int Descent(Font &font_);
|
||||
int InternalLeading(Font &font_);
|
||||
int ExternalLeading(Font &font_);
|
||||
int Height(Font &font_);
|
||||
int AverageCharWidth(Font &font_);
|
||||
virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
|
||||
virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
|
||||
virtual int WidthText(Font &font_, const char *s, int len)=0;
|
||||
virtual int WidthChar(Font &font_, char ch)=0;
|
||||
virtual int Ascent(Font &font_)=0;
|
||||
virtual int Descent(Font &font_)=0;
|
||||
virtual int InternalLeading(Font &font_)=0;
|
||||
virtual int ExternalLeading(Font &font_)=0;
|
||||
virtual int Height(Font &font_)=0;
|
||||
virtual int AverageCharWidth(Font &font_)=0;
|
||||
|
||||
int SetPalette(Palette *pal, bool inBackGround);
|
||||
void SetClip(PRectangle rc);
|
||||
void FlushCachedState();
|
||||
virtual int SetPalette(Palette *pal, bool inBackGround)=0;
|
||||
virtual void SetClip(PRectangle rc)=0;
|
||||
virtual void FlushCachedState()=0;
|
||||
|
||||
void SetUnicodeMode(bool unicodeMode_) {
|
||||
unicodeMode=unicodeMode_;
|
||||
}
|
||||
virtual void SetUnicodeMode(bool unicodeMode_)=0;
|
||||
};
|
||||
|
||||
/**
|
||||
* A simple callback action passing one piece of untyped user data.
|
||||
*/
|
||||
typedef void (*CallBackAction)(void*);
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
friend class ListBox;
|
||||
protected:
|
||||
WindowID id;
|
||||
public:
|
||||
Window() : id(0) {}
|
||||
Window(const Window &source) : id(source.id) {}
|
||||
Window() : id(0), cursorLast(cursorInvalid) {}
|
||||
Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
|
||||
virtual ~Window();
|
||||
Window &operator=(WindowID id_) {
|
||||
id = id_;
|
||||
@@ -382,20 +336,19 @@ public:
|
||||
void InvalidateAll();
|
||||
void InvalidateRectangle(PRectangle rc);
|
||||
virtual void SetFont(Font &font);
|
||||
enum Cursor { cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
|
||||
enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
|
||||
void SetCursor(Cursor curs);
|
||||
void SetTitle(const char *s);
|
||||
#if PLAT_WIN
|
||||
LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0);
|
||||
int GetDlgCtrlID();
|
||||
HINSTANCE GetInstance();
|
||||
#endif
|
||||
private:
|
||||
Cursor cursorLast;
|
||||
};
|
||||
|
||||
/**
|
||||
* Listbox management.
|
||||
*/
|
||||
|
||||
class ListBox : public Window {
|
||||
private:
|
||||
#if PLAT_GTK
|
||||
WindowID list;
|
||||
WindowID scroller;
|
||||
@@ -404,6 +357,9 @@ class ListBox : public Window {
|
||||
int desiredVisibleRows;
|
||||
unsigned int maxItemCharacters;
|
||||
unsigned int aveCharWidth;
|
||||
public:
|
||||
CallBackAction doubleClickAction;
|
||||
void *doubleClickActionData;
|
||||
public:
|
||||
ListBox();
|
||||
virtual ~ListBox();
|
||||
@@ -420,6 +376,10 @@ public:
|
||||
int Find(const char *prefix);
|
||||
void GetValue(int n, char *value, int len);
|
||||
void Sort();
|
||||
void SetDoubleClickAction(CallBackAction action, void *data) {
|
||||
doubleClickAction = action;
|
||||
doubleClickActionData = data;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -435,6 +395,14 @@ public:
|
||||
void Show(Point pt, Window &w);
|
||||
};
|
||||
|
||||
class ElapsedTime {
|
||||
long bigBit;
|
||||
long littleBit;
|
||||
public:
|
||||
ElapsedTime();
|
||||
double Duration(bool reset=false);
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -448,8 +416,8 @@ public:
|
||||
// but gcc warns about this
|
||||
Platform() {}
|
||||
~Platform() {}
|
||||
static Colour Chrome();
|
||||
static Colour ChromeHighlight();
|
||||
static ColourDesired Chrome();
|
||||
static ColourDesired ChromeHighlight();
|
||||
static const char *DefaultFont();
|
||||
static int DefaultFontSize();
|
||||
static unsigned int DoubleClickTime();
|
||||
@@ -457,6 +425,7 @@ public:
|
||||
static bool IsKeyDown(int key);
|
||||
static long SendScintilla(
|
||||
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
|
||||
static bool IsDBCSLeadByte(int codePage, char ch);
|
||||
|
||||
// These are utility functions not really tied to a platform
|
||||
static int Minimum(int a, int b);
|
||||
@@ -483,4 +452,9 @@ public:
|
||||
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
|
||||
#endif
|
||||
|
||||
// Shut up annoying Visual C++ warnings:
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4244 4309 4514 4710)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file PropSet.h
|
||||
** A Java style properties file module.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef PROPSET_H
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
SString Expand(const char *withVars);
|
||||
int GetInt(const char *key, int defaultValue=0);
|
||||
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();
|
||||
char *ToString(); // Caller must delete[] the return value
|
||||
bool GetFirst(char **key, char **val);
|
||||
@@ -70,7 +70,8 @@ public:
|
||||
char *Allocate(int size);
|
||||
void SetFromAllocated();
|
||||
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, SString wordCharacters="");
|
||||
char *GetNearestWords(const char *wordStart, int searchLen=-1,
|
||||
bool ignoreCase=false, char otherSeparator='\0');
|
||||
};
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#ifndef SSTRING_H
|
||||
#define SSTRING_H
|
||||
|
||||
// These functions are implemented because each platform calls them something different
|
||||
// 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);
|
||||
@@ -17,93 +17,48 @@ bool EqualCaseInsensitive(const char *a, const char *b);
|
||||
// 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;
|
||||
/** Type of string lengths (sizes) and positions (indexes). */
|
||||
typedef unsigned int lenpos_t;
|
||||
/** Out of bounds value indicating that the string argument should be measured. */
|
||||
enum { measure_length=0xffffffffU};
|
||||
|
||||
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
|
||||
private:
|
||||
char *s; ///< The C string
|
||||
lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
|
||||
lenpos_t sLen; ///< The size of the string in s
|
||||
lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
|
||||
enum { sizeGrowthDefault = 64 };
|
||||
bool grow(lenpos_t lenNew) {
|
||||
while (sizeGrowth * 6 < lenNew) {
|
||||
sizeGrowth *= 2;
|
||||
}
|
||||
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) {
|
||||
char *sNew = new char[lenNew + sizeGrowth + 1];
|
||||
if (sNew) {
|
||||
if (s) {
|
||||
*s = '\0';
|
||||
memcpy(sNew, s, sLen);
|
||||
delete []s;
|
||||
}
|
||||
sLen = 0;
|
||||
s = sNew;
|
||||
s[sLen] = '\0';
|
||||
sSize = lenNew + sizeGrowth;
|
||||
}
|
||||
/** Size of buffer. */
|
||||
size_type size(void) const { ///<
|
||||
if (s)
|
||||
return sSize;
|
||||
else
|
||||
return 0;
|
||||
return sNew != 0;
|
||||
}
|
||||
/** Size of string in buffer. */
|
||||
int length() const {
|
||||
return sLen;
|
||||
}
|
||||
SString &assign(const char* sOther, int sSize_ = -1) {
|
||||
|
||||
SString &assign(const char *sOther, lenpos_t sSize_=measure_length) {
|
||||
if (!sOther) {
|
||||
sSize_ = 0;
|
||||
}
|
||||
if (sSize_ < 0) {
|
||||
} else if (sSize_ == measure_length) {
|
||||
sSize_ = strlen(sOther);
|
||||
}
|
||||
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
|
||||
@@ -114,7 +69,7 @@ public:
|
||||
sLen = sSize_;
|
||||
} else {
|
||||
delete []s;
|
||||
s = StringDup(sOther, sSize_);
|
||||
s = StringAllocate(sOther, sSize_);
|
||||
if (s) {
|
||||
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
|
||||
sLen = strlen(s);
|
||||
@@ -124,8 +79,56 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SString &assign(const SString& sOther, int sSize_ = -1) {
|
||||
return assign(sOther.s, sSize_);
|
||||
|
||||
public:
|
||||
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
|
||||
}
|
||||
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(source.s);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(s_);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(const char *s_, lenpos_t first, lenpos_t last) : sizeGrowth(sizeGrowthDefault) {
|
||||
s = StringAllocate(s_ + first, last - first);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(int i) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%0d", i);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
SString(double d, int precision) : sizeGrowth(sizeGrowthDefault) {
|
||||
char number[32];
|
||||
sprintf(number, "%.*f", precision, d);
|
||||
s = StringAllocate(number);
|
||||
sSize = sLen = (s) ? strlen(s) : 0;
|
||||
}
|
||||
~SString() {
|
||||
delete []s;
|
||||
s = 0;
|
||||
sSize = 0;
|
||||
sLen = 0;
|
||||
}
|
||||
void clear() {
|
||||
if (s) {
|
||||
*s = '\0';
|
||||
}
|
||||
sLen = 0;
|
||||
}
|
||||
/** Size of buffer. */
|
||||
lenpos_t size() const {
|
||||
if (s)
|
||||
return sSize;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
/** Size of string in buffer. */
|
||||
lenpos_t length() const {
|
||||
return sLen;
|
||||
}
|
||||
SString &operator=(const char *source) {
|
||||
return assign(source);
|
||||
@@ -162,7 +165,7 @@ public:
|
||||
else
|
||||
return false;
|
||||
}
|
||||
void setsizegrowth(int sizeGrowth_) {
|
||||
void setsizegrowth(lenpos_t sizeGrowth_) {
|
||||
sizeGrowth = sizeGrowth_;
|
||||
}
|
||||
const char *c_str() const {
|
||||
@@ -179,77 +182,167 @@ public:
|
||||
sLen = 0;
|
||||
return sRet;
|
||||
}
|
||||
char operator[](int i) const {
|
||||
char operator[](lenpos_t 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)
|
||||
SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') {
|
||||
if (!sOther) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
int lenSep = 0;
|
||||
if (sLen && sep) // Only add a separator if not empty
|
||||
if (sLen && sep) { // Only add a separator if not empty
|
||||
lenSep = 1;
|
||||
int lenNew = sLen + sLenOther + lenSep;
|
||||
if (lenNew + 1 < sSize) {
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther + lenSep;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew + 1 < sSize) || (grow(lenNew))) {
|
||||
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;
|
||||
}
|
||||
s[sLen] = '\0';
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
SString &operator +=(const char *sOther) {
|
||||
return append(sOther, -1);
|
||||
SString &operator+=(const char *sOther) {
|
||||
return append(sOther, static_cast<lenpos_t>(measure_length));
|
||||
}
|
||||
SString &operator +=(const SString &sOther) {
|
||||
SString &operator+=(const SString &sOther) {
|
||||
return append(sOther.s, sOther.sSize);
|
||||
}
|
||||
SString &operator +=(char ch) {
|
||||
SString &operator+=(char ch) {
|
||||
return append(&ch, 1);
|
||||
}
|
||||
SString &appendwithseparator(const char* sOther, char sep) {
|
||||
SString &appendwithseparator(const char *sOther, char sep) {
|
||||
return append(sOther, strlen(sOther), sep);
|
||||
}
|
||||
SString &insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther=measure_length) {
|
||||
if (!sOther) {
|
||||
return *this;
|
||||
}
|
||||
if (sLenOther == measure_length) {
|
||||
sLenOther = strlen(sOther);
|
||||
}
|
||||
lenpos_t lenNew = sLen + sLenOther;
|
||||
// Conservative about growing the buffer: don't do it, unless really needed
|
||||
if ((lenNew + 1 < sSize) || grow(lenNew)) {
|
||||
lenpos_t moveChars = sLen - pos + 1;
|
||||
for (lenpos_t i = moveChars; i > 0; i--) {
|
||||
s[pos + sLenOther + i - 1] = s[pos + i - 1];
|
||||
}
|
||||
memcpy(s + pos, sOther, sLenOther);
|
||||
sLen = lenNew;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/** Remove @a len characters from the @a pos position, included.
|
||||
* Characters at pos + len and beyond replace characters at pos.
|
||||
* If @a len is 0, or greater than the length of the string
|
||||
* starting at @a pos, the string is just truncated at @a pos.
|
||||
*/
|
||||
void remove(lenpos_t pos, lenpos_t len) {
|
||||
if (len < 1 || pos + len >= sLen) {
|
||||
s[pos] = '\0';
|
||||
sLen = pos;
|
||||
} else {
|
||||
for (lenpos_t i = pos; i < sLen - len + 1; i++) {
|
||||
s[i] = s[i+len];
|
||||
}
|
||||
sLen -= len;
|
||||
}
|
||||
}
|
||||
/** Read an integral numeric value from the string. */
|
||||
int value() const {
|
||||
if (s)
|
||||
return atoi(s);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
void substitute(char find, char replace) {
|
||||
int search(const char *sFind, lenpos_t start=0) {
|
||||
if (start < sLen) {
|
||||
const char *sFound = strstr(s + start, sFind);
|
||||
if (sFound) {
|
||||
return sFound - s;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
bool contains(const char *sFind) {
|
||||
return search(sFind) >= 0;
|
||||
}
|
||||
int substitute(char chFind, char chReplace) {
|
||||
int c = 0;
|
||||
char *t = s;
|
||||
while (t) {
|
||||
t = strchr(t, find);
|
||||
t = strchr(t, chFind);
|
||||
if (t) {
|
||||
*t = replace;
|
||||
*t = chReplace;
|
||||
t++;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
int substitute(const char *sFind, const char *sReplace) {
|
||||
int c = 0;
|
||||
lenpos_t lenFind = strlen(sFind);
|
||||
lenpos_t lenReplace = strlen(sReplace);
|
||||
int posFound = search(sFind);
|
||||
while (posFound >= 0) {
|
||||
remove(posFound, lenFind);
|
||||
insert(posFound, sReplace, lenReplace);
|
||||
posFound = search(sFind, posFound + lenReplace);
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
int remove(const char *sFind) {
|
||||
return substitute(sFind, "");
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
static char *StringAllocate(
|
||||
const char *s, ///< The string to duplicate
|
||||
lenpos_t len=measure_length) ///< The length of memory to allocate. Optional.
|
||||
{
|
||||
if (s == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (len == measure_length) {
|
||||
len = strlen(s);
|
||||
}
|
||||
char *sNew = new char[len + 1];
|
||||
if (sNew) {
|
||||
strncpy(sNew, s, len);
|
||||
sNew[len] = '\0';
|
||||
}
|
||||
return sNew;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
SString::lenpos_t len=SString::measure_length) ///< The length of memory to allocate. Optional.
|
||||
{
|
||||
return SString::StringAllocate(s, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file SciLexer.h
|
||||
** Interface to the added lexer functions in the SciLexer version of the edit control.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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
|
||||
@@ -41,6 +41,12 @@
|
||||
#define SCLEX_EIFFELKW 24
|
||||
#define SCLEX_TCL 25
|
||||
#define SCLEX_NNCRONTAB 26
|
||||
#define SCLEX_BULLANT 27
|
||||
#define SCLEX_VBSCRIPT 28
|
||||
#define SCLEX_ASP 29
|
||||
#define SCLEX_PHP 30
|
||||
#define SCLEX_BAAN 31
|
||||
#define SCLEX_MATLAB 32
|
||||
#define SCLEX_AUTOMATIC 1000
|
||||
#define SCE_P_DEFAULT 0
|
||||
#define SCE_P_COMMENTLINE 1
|
||||
@@ -75,6 +81,15 @@
|
||||
#define SCE_C_WORD2 16
|
||||
#define SCE_C_COMMENTDOCKEYWORD 17
|
||||
#define SCE_C_COMMENTDOCKEYWORDERROR 18
|
||||
#define SCE_B_DEFAULT 0
|
||||
#define SCE_B_COMMENT 1
|
||||
#define SCE_B_NUMBER 2
|
||||
#define SCE_B_KEYWORD 3
|
||||
#define SCE_B_STRING 4
|
||||
#define SCE_B_PREPROCESSOR 5
|
||||
#define SCE_B_OPERATOR 6
|
||||
#define SCE_B_IDENTIFIER 7
|
||||
#define SCE_B_DATE 8
|
||||
#define SCE_H_DEFAULT 0
|
||||
#define SCE_H_TAG 1
|
||||
#define SCE_H_TAGUNKNOWN 2
|
||||
@@ -233,6 +248,11 @@
|
||||
#define SCE_LUA_OPERATOR 10
|
||||
#define SCE_LUA_IDENTIFIER 11
|
||||
#define SCE_LUA_STRINGEOL 12
|
||||
#define SCE_LUA_WORD2 13
|
||||
#define SCE_LUA_WORD3 14
|
||||
#define SCE_LUA_WORD4 15
|
||||
#define SCE_LUA_WORD5 16
|
||||
#define SCE_LUA_WORD6 17
|
||||
#define SCE_ERR_DEFAULT 0
|
||||
#define SCE_ERR_PYTHON 1
|
||||
#define SCE_ERR_GCC 2
|
||||
@@ -291,6 +311,17 @@
|
||||
#define SCE_ADA_OPERATOR 6
|
||||
#define SCE_ADA_IDENTIFIER 7
|
||||
#define SCE_ADA_STRINGEOL 8
|
||||
#define SCE_BAAN_DEFAULT 0
|
||||
#define SCE_BAAN_COMMENT 1
|
||||
#define SCE_BAAN_COMMENTDOC 2
|
||||
#define SCE_BAAN_NUMBER 3
|
||||
#define SCE_BAAN_WORD 4
|
||||
#define SCE_BAAN_STRING 5
|
||||
#define SCE_BAAN_PREPROCESSOR 6
|
||||
#define SCE_BAAN_OPERATOR 7
|
||||
#define SCE_BAAN_IDENTIFIER 8
|
||||
#define SCE_BAAN_STRINGEOL 9
|
||||
#define SCE_BAAN_WORD2 10
|
||||
#define SCE_LISP_DEFAULT 0
|
||||
#define SCE_LISP_COMMENT 1
|
||||
#define SCE_LISP_NUMBER 2
|
||||
@@ -319,6 +350,14 @@
|
||||
#define SCE_NNCRONTAB_STRING 8
|
||||
#define SCE_NNCRONTAB_ENVIRONMENT 9
|
||||
#define SCE_NNCRONTAB_IDENTIFIER 10
|
||||
#define SCE_MATLAB_DEFAULT 0
|
||||
#define SCE_MATLAB_COMMENT 1
|
||||
#define SCE_MATLAB_COMMAND 2
|
||||
#define SCE_MATLAB_NUMBER 3
|
||||
#define SCE_MATLAB_KEYWORD 4
|
||||
#define SCE_MATLAB_STRING 5
|
||||
#define SCE_MATLAB_OPERATOR 6
|
||||
#define SCE_MATLAB_IDENTIFIER 7
|
||||
//--Autogenerated -- end of section automatically generated from Scintilla.iface
|
||||
|
||||
#endif
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file Scintilla.h
|
||||
** Interface to the edit control.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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
|
||||
@@ -12,10 +12,11 @@
|
||||
#define SCINTILLA_H
|
||||
|
||||
#if PLAT_WIN
|
||||
#ifdef STATIC_BUILD
|
||||
void Scintilla_RegisterClasses(HINSTANCE hInstance);
|
||||
#endif
|
||||
// Return false on failure:
|
||||
bool Scintilla_RegisterClasses(void *hInstance);
|
||||
bool Scintilla_ReleaseResources();
|
||||
#endif
|
||||
int Scintilla_LinkLexers();
|
||||
|
||||
// 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.
|
||||
@@ -99,6 +100,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_MARK_CIRCLEPLUSCONNECTED 19
|
||||
#define SC_MARK_CIRCLEMINUS 20
|
||||
#define SC_MARK_CIRCLEMINUSCONNECTED 21
|
||||
#define SC_MARK_BACKGROUND 22
|
||||
#define SC_MARK_CHARACTER 10000
|
||||
#define SC_MARKNUM_FOLDEREND 25
|
||||
#define SC_MARKNUM_FOLDEROPENMID 26
|
||||
@@ -107,6 +109,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_MARKNUM_FOLDERSUB 29
|
||||
#define SC_MARKNUM_FOLDER 30
|
||||
#define SC_MARKNUM_FOLDEROPEN 31
|
||||
#define SC_MASK_FOLDERS 0xFE000000
|
||||
#define SCI_MARKERDEFINE 2040
|
||||
#define SCI_MARKERSETFORE 2041
|
||||
#define SCI_MARKERSETBACK 2042
|
||||
@@ -187,10 +190,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define INDIC_TT 2
|
||||
#define INDIC_DIAGONAL 3
|
||||
#define INDIC_STRIKE 4
|
||||
#define INDIC0_MASK 32
|
||||
#define INDIC1_MASK 64
|
||||
#define INDIC2_MASK 128
|
||||
#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
|
||||
#define INDIC0_MASK 0x20
|
||||
#define INDIC1_MASK 0x40
|
||||
#define INDIC2_MASK 0x80
|
||||
#define INDICS_MASK 0xE0
|
||||
#define SCI_INDICSETSTYLE 2080
|
||||
#define SCI_INDICGETSTYLE 2081
|
||||
#define SCI_INDICSETFORE 2082
|
||||
@@ -204,6 +207,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_SETCARETLINEVISIBLE 2096
|
||||
#define SCI_GETCARETLINEBACK 2097
|
||||
#define SCI_SETCARETLINEBACK 2098
|
||||
#define SCI_STYLESETCHANGEABLE 2099
|
||||
#define SCI_AUTOCSHOW 2100
|
||||
#define SCI_AUTOCCANCEL 2101
|
||||
#define SCI_AUTOCACTIVE 2102
|
||||
@@ -223,6 +227,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_USERLISTSHOW 2117
|
||||
#define SCI_AUTOCSETAUTOHIDE 2118
|
||||
#define SCI_AUTOCGETAUTOHIDE 2119
|
||||
#define SCI_AUTOCSETDROPRESTOFWORD 2270
|
||||
#define SCI_AUTOCGETDROPRESTOFWORD 2271
|
||||
#define SCI_SETINDENT 2122
|
||||
#define SCI_GETINDENT 2123
|
||||
#define SCI_SETUSETABS 2124
|
||||
@@ -341,6 +347,18 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_TIME_FOREVER 10000000
|
||||
#define SCI_SETMOUSEDWELLTIME 2264
|
||||
#define SCI_GETMOUSEDWELLTIME 2265
|
||||
#define SCI_WORDSTARTPOSITION 2266
|
||||
#define SCI_WORDENDPOSITION 2267
|
||||
#define SC_WRAP_NONE 0
|
||||
#define SC_WRAP_WORD 1
|
||||
#define SCI_SETWRAPMODE 2268
|
||||
#define SCI_GETWRAPMODE 2269
|
||||
#define SC_CACHE_NONE 0
|
||||
#define SC_CACHE_CARET 1
|
||||
#define SC_CACHE_PAGE 2
|
||||
#define SC_CACHE_DOCUMENT 3
|
||||
#define SCI_SETLAYOUTCACHE 2272
|
||||
#define SCI_GETLAYOUTCACHE 2273
|
||||
#define SCI_LINEDOWN 2300
|
||||
#define SCI_LINEDOWNEXTEND 2301
|
||||
#define SCI_LINEUP 2302
|
||||
@@ -385,6 +403,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_UPPERCASE 2341
|
||||
#define SCI_LINESCROLLDOWN 2342
|
||||
#define SCI_LINESCROLLUP 2343
|
||||
#define SCI_DELETEBACKNOTLINE 2344
|
||||
#define SCI_MOVECARETINSIDEVIEW 2401
|
||||
#define SCI_LINELENGTH 2350
|
||||
#define SCI_BRACEHIGHLIGHT 2351
|
||||
@@ -432,6 +451,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SC_CURSORWAIT 3
|
||||
#define SCI_SETCURSOR 2386
|
||||
#define SCI_GETCURSOR 2387
|
||||
#define SCI_SETCONTROLCHARSYMBOL 2388
|
||||
#define SCI_GETCONTROLCHARSYMBOL 2389
|
||||
#define SCI_WORDPARTLEFT 2390
|
||||
#define SCI_WORDPARTLEFTEXTEND 2391
|
||||
#define SCI_WORDPARTRIGHT 2392
|
||||
@@ -441,6 +462,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCI_SETVISIBLEPOLICY 2394
|
||||
#define SCI_DELLINELEFT 2395
|
||||
#define SCI_DELLINERIGHT 2396
|
||||
#define SCI_SETXOFFSET 2397
|
||||
#define SCI_GETXOFFSET 2398
|
||||
#define SCI_GRABFOCUS 2400
|
||||
#define SCI_STARTRECORD 3001
|
||||
#define SCI_STOPRECORD 3002
|
||||
@@ -493,12 +516,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
||||
#define SCN_KEY 2005
|
||||
#define SCN_DOUBLECLICK 2006
|
||||
#define SCN_UPDATEUI 2007
|
||||
#define SCN_CHECKBRACE 2007
|
||||
#define SCN_MODIFIED 2008
|
||||
#define SCN_MACRORECORD 2009
|
||||
#define SCN_MARGINCLICK 2010
|
||||
#define SCN_NEEDSHOWN 2011
|
||||
#define SCN_POSCHANGED 2012
|
||||
#define SCN_PAINTED 2013
|
||||
#define SCN_USERLISTSELECTION 2014
|
||||
#define SCN_URIDROPPED 2015
|
||||
@@ -571,20 +592,15 @@ struct SCNotification {
|
||||
int y; // SCN_DWELLSTART, SCN_DWELLEND
|
||||
};
|
||||
|
||||
#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
|
||||
// will be removed completely in a future version.
|
||||
// To enable these features define INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||
|
||||
#define SCN_POSCHANGED 2012
|
||||
#define SCN_CHECKBRACE 2007
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
## This file defines the interface to Scintilla
|
||||
|
||||
## Copyright 2000-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
## The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
## A line starting with ## is a pure comment and should be stripped by readers.
|
||||
## A line starting with #! is for future shbang use
|
||||
## A line starting with # followed by a space is a documentation comment and refers
|
||||
@@ -25,6 +28,9 @@
|
||||
## The syntax for evt is <featureType><ws><returnType><ws><name>[=<number]([<param>[,<param>]*])
|
||||
## Feature names that contain an underscore are defined by Windows, so in these
|
||||
## cases, using the Windows definition is preferred where available.
|
||||
## The feature numbers are stable so features will not be renumbered.
|
||||
## Features may be removed but they will go through a period of deprecation
|
||||
## before removal which is signalled by moving them into the Deprecated category.
|
||||
|
||||
## Types:
|
||||
## void
|
||||
@@ -35,20 +41,27 @@
|
||||
## string -> pointer to const character
|
||||
## stringresult -> pointer to character
|
||||
## cells -> pointer to array of cells, each cell containing a style byte and character byte
|
||||
## textrange -> range of a min and a max position with an output string
|
||||
## findtext -> searchrange, text -> foundposition
|
||||
## keymod -> integer containing key in low half and modifiers in high half
|
||||
## formatrange
|
||||
## Types no longer used:
|
||||
## findtextex -> searchrange
|
||||
## charrange -> range of a min and a max position
|
||||
## charrangeresult -> like charrange, but output param
|
||||
## textrange -> charrange + output string
|
||||
## findtext -> searchrange, text -> foundposition
|
||||
## findtextex -> searchrange
|
||||
## keymod -> integer containing key in low half and modifiers in high half
|
||||
## countedstring
|
||||
## formatrange
|
||||
## point -> x,y
|
||||
## pointresult -> like point, but output param
|
||||
## rectangle -> left,top,right,bottom
|
||||
## Client code should ignore definitions containing types it does not understand, except
|
||||
## for possibly #defining the constants
|
||||
|
||||
## String arguments may contain NUL ('\0') characters where the calls provide a length
|
||||
## argument and retrieve NUL characters. All retrieved strings except for those retrieved
|
||||
## by GetLine also have a NUL appended but client code should calculate the size that
|
||||
## will be returned rather than relying upon the NUL whenever possible. Allow for the
|
||||
## extra NUL character when allocating buffers.
|
||||
|
||||
cat Basics
|
||||
|
||||
################################################
|
||||
@@ -229,6 +242,9 @@ val SC_MARK_CIRCLEPLUSCONNECTED=19
|
||||
val SC_MARK_CIRCLEMINUS=20
|
||||
val SC_MARK_CIRCLEMINUSCONNECTED=21
|
||||
|
||||
# Invisible mark that only sets the line background color
|
||||
val SC_MARK_BACKGROUND=22
|
||||
|
||||
val SC_MARK_CHARACTER=10000
|
||||
|
||||
# Markers used for outlining column
|
||||
@@ -240,6 +256,8 @@ val SC_MARKNUM_FOLDERSUB=29
|
||||
val SC_MARKNUM_FOLDER=30
|
||||
val SC_MARKNUM_FOLDEROPEN=31
|
||||
|
||||
val SC_MASK_FOLDERS=0xFE000000
|
||||
|
||||
# Set the symbol used for a particular marker number.
|
||||
fun void MarkerDefine=2040(int markerNumber, int markerSymbol)
|
||||
|
||||
@@ -249,8 +267,8 @@ fun void MarkerSetFore=2041(int markerNumber, colour fore)
|
||||
# Set the background colour used for a particular marker number.
|
||||
fun void MarkerSetBack=2042(int markerNumber, colour back)
|
||||
|
||||
# Add a marker to a line.
|
||||
fun void MarkerAdd=2043(int line, int markerNumber)
|
||||
# Add a marker to a line, returning an ID which can be used to find or delete the marker.
|
||||
fun int MarkerAdd=2043(int line, int markerNumber)
|
||||
|
||||
# Delete a marker from a line
|
||||
fun void MarkerDelete=2044(int line, int markerNumber)
|
||||
@@ -413,11 +431,10 @@ val INDIC_SQUIGGLE=1
|
||||
val INDIC_TT=2
|
||||
val INDIC_DIAGONAL=3
|
||||
val INDIC_STRIKE=4
|
||||
val INDIC0_MASK=32
|
||||
val INDIC1_MASK=64
|
||||
val INDIC2_MASK=128
|
||||
val INDICS_MASK=224
|
||||
##INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
|
||||
val INDIC0_MASK=0x20
|
||||
val INDIC1_MASK=0x40
|
||||
val INDIC2_MASK=0x80
|
||||
val INDICS_MASK=0xE0
|
||||
|
||||
# Set an indicator to plain, squiggle or TT.
|
||||
set void IndicSetStyle=2080(int indic, int style)
|
||||
@@ -451,7 +468,7 @@ 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.
|
||||
# Dsplay 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.
|
||||
@@ -460,6 +477,10 @@ get colour GetCaretLineBack=2097(,)
|
||||
# Set the colour of the background of the line containing the caret.
|
||||
set void SetCaretLineBack=2098(colour back,)
|
||||
|
||||
# Set a style to be changeable or not (read only).
|
||||
# Experimental feature, currently buggy.
|
||||
set void StyleSetChangeable=2099(int style, bool changeable)
|
||||
|
||||
# Display a auto-completion list.
|
||||
# The lenEntered parameter indicates how many characters before
|
||||
# the caret should be used to provide context.
|
||||
@@ -498,7 +519,8 @@ set void AutoCSetCancelAtStart=2110(bool cancel,)
|
||||
# Retrieve whether auto-completion cancelled by backspacing before start.
|
||||
get bool AutoCGetCancelAtStart=2111(,)
|
||||
|
||||
# Define a set of character that when typed fills up the selected word.
|
||||
# Define a set of characters that when typed will cause the autocompletion to
|
||||
# choose the selected item.
|
||||
set void AutoCSetFillUps=2112(, string characterSet)
|
||||
|
||||
# Should a single item auto-completion list automatically choose the item.
|
||||
@@ -522,6 +544,12 @@ set void AutoCSetAutoHide=2118(bool autoHide,)
|
||||
# Retrieve whether or not autocompletion is hidden automatically when nothing matches
|
||||
get bool AutoCGetAutoHide=2119(,)
|
||||
|
||||
# Set whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,)
|
||||
|
||||
# Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
|
||||
get bool AutoCGetDropRestOfWord=2271(,)
|
||||
|
||||
# Set the number of spaces used for one level of indentation.
|
||||
set void SetIndent=2122(int indentSize,)
|
||||
|
||||
@@ -878,6 +906,32 @@ set void SetMouseDwellTime=2264(int periodMilliseconds,)
|
||||
# Retrieve the time the mouse must sit still to generate a mouse dwell event
|
||||
get int GetMouseDwellTime=2265(,)
|
||||
|
||||
# Get position of start of word
|
||||
fun int WordStartPosition=2266(position pos, bool onlyWordCharacters)
|
||||
|
||||
# Get position of end of word
|
||||
fun int WordEndPosition=2267(position pos, bool onlyWordCharacters)
|
||||
|
||||
val SC_WRAP_NONE=0
|
||||
val SC_WRAP_WORD=1
|
||||
|
||||
# Sets whether text is word wrapped
|
||||
set void SetWrapMode=2268(int mode,)
|
||||
|
||||
# Retrieve whether text is word wrapped
|
||||
get int GetWrapMode=2269(,)
|
||||
|
||||
val SC_CACHE_NONE=0
|
||||
val SC_CACHE_CARET=1
|
||||
val SC_CACHE_PAGE=2
|
||||
val SC_CACHE_DOCUMENT=3
|
||||
|
||||
# Sets the degree of caching of layout information
|
||||
set void SetLayoutCache=2272(int mode,)
|
||||
|
||||
# Retrieve the degree of caching of layout information
|
||||
get int GetLayoutCache=2273(,)
|
||||
|
||||
## Start of key messages
|
||||
# Move caret down one line.
|
||||
fun void LineDown=2300(,)
|
||||
@@ -1014,6 +1068,10 @@ fun void LineScrollDown=2342(,)
|
||||
# Scroll the document up, keeping the caret visible.
|
||||
fun void LineScrollUp=2343(,)
|
||||
|
||||
# Delete the selection or if no selection, the character before the caret.
|
||||
# Will not delete the chraacter before at the start of a line.
|
||||
fun void DeleteBackNotLine=2344(,)
|
||||
|
||||
# Move the caret inside current view if it's not there already
|
||||
fun void MoveCaretInsideView=2401(,)
|
||||
|
||||
@@ -1146,6 +1204,12 @@ set void SetCursor=2386(int cursorType,)
|
||||
# Get cursor type
|
||||
get int GetCursor=2387(,)
|
||||
|
||||
# Change the way control characters are displayed:
|
||||
# If symbol is < 32, keep the drawn way, else, use the given character
|
||||
set void SetControlCharSymbol=2388(int symbol,)
|
||||
# Get the way control characters are displayed
|
||||
get int GetControlCharSymbol=2389(,)
|
||||
|
||||
# Move to the previous change in capitalistion
|
||||
fun void WordPartLeft=2390(,)
|
||||
# Move to the previous change in capitalistion extending selection to new caret position.
|
||||
@@ -1167,6 +1231,10 @@ fun void DelLineLeft=2395(,)
|
||||
# Delete forwards from the current position to the end of the line
|
||||
fun void DelLineRight=2396(,)
|
||||
|
||||
# Get and Set the xOffset (ie, horizonal scroll position)
|
||||
set void SetXOffset=2397(int newOffset,)
|
||||
get int GetXOffset=2398(,)
|
||||
|
||||
# Set the focus to this Scintilla widget.
|
||||
# GTK+ Specific
|
||||
fun void GrabFocus=2400(,)
|
||||
@@ -1273,6 +1341,13 @@ val SCLEX_EIFFEL=23
|
||||
val SCLEX_EIFFELKW=24
|
||||
val SCLEX_TCL=25
|
||||
val SCLEX_NNCRONTAB=26
|
||||
val SCLEX_BULLANT=27
|
||||
val SCLEX_VBSCRIPT=28
|
||||
val SCLEX_ASP=29
|
||||
val SCLEX_PHP=30
|
||||
val SCLEX_BAAN=31
|
||||
val SCLEX_MATLAB=32
|
||||
|
||||
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
val SCLEX_AUTOMATIC=1000
|
||||
@@ -1291,7 +1366,7 @@ val SCE_P_OPERATOR=10
|
||||
val SCE_P_IDENTIFIER=11
|
||||
val SCE_P_COMMENTBLOCK=12
|
||||
val SCE_P_STRINGEOL=13
|
||||
# Lexical states for SCLEX_CPP, SCLEX_VB
|
||||
# Lexical states for SCLEX_CPP
|
||||
val SCE_C_DEFAULT=0
|
||||
val SCE_C_COMMENT=1
|
||||
val SCE_C_COMMENTLINE=2
|
||||
@@ -1311,6 +1386,16 @@ val SCE_C_COMMENTLINEDOC=15
|
||||
val SCE_C_WORD2=16
|
||||
val SCE_C_COMMENTDOCKEYWORD=17
|
||||
val SCE_C_COMMENTDOCKEYWORDERROR=18
|
||||
# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
|
||||
val SCE_B_DEFAULT=0
|
||||
val SCE_B_COMMENT=1
|
||||
val SCE_B_NUMBER=2
|
||||
val SCE_B_KEYWORD=3
|
||||
val SCE_B_STRING=4
|
||||
val SCE_B_PREPROCESSOR=5
|
||||
val SCE_B_OPERATOR=6
|
||||
val SCE_B_IDENTIFIER=7
|
||||
val SCE_B_DATE=8
|
||||
# Lexical states for SCLEX_HTML, SCLEX_XML
|
||||
val SCE_H_DEFAULT=0
|
||||
val SCE_H_TAG=1
|
||||
@@ -1484,6 +1569,11 @@ val SCE_LUA_PREPROCESSOR=9
|
||||
val SCE_LUA_OPERATOR=10
|
||||
val SCE_LUA_IDENTIFIER=11
|
||||
val SCE_LUA_STRINGEOL=12
|
||||
val SCE_LUA_WORD2=13
|
||||
val SCE_LUA_WORD3=14
|
||||
val SCE_LUA_WORD4=15
|
||||
val SCE_LUA_WORD5=16
|
||||
val SCE_LUA_WORD6=17
|
||||
# Lexical states for SCLEX_ERRORLIST
|
||||
val SCE_ERR_DEFAULT=0
|
||||
val SCE_ERR_PYTHON=1
|
||||
@@ -1548,6 +1638,18 @@ val SCE_ADA_CHARACTER=5
|
||||
val SCE_ADA_OPERATOR=6
|
||||
val SCE_ADA_IDENTIFIER=7
|
||||
val SCE_ADA_STRINGEOL=8
|
||||
# Lexical states for SCLEX_BAAN
|
||||
val SCE_BAAN_DEFAULT=0
|
||||
val SCE_BAAN_COMMENT=1
|
||||
val SCE_BAAN_COMMENTDOC=2
|
||||
val SCE_BAAN_NUMBER=3
|
||||
val SCE_BAAN_WORD=4
|
||||
val SCE_BAAN_STRING=5
|
||||
val SCE_BAAN_PREPROCESSOR=6
|
||||
val SCE_BAAN_OPERATOR=7
|
||||
val SCE_BAAN_IDENTIFIER=8
|
||||
val SCE_BAAN_STRINGEOL=9
|
||||
val SCE_BAAN_WORD2=10
|
||||
# Lexical states for SCLEX_LISP
|
||||
val SCE_LISP_DEFAULT=0
|
||||
val SCE_LISP_COMMENT=1
|
||||
@@ -1579,6 +1681,15 @@ val SCE_NNCRONTAB_NUMBER=7
|
||||
val SCE_NNCRONTAB_STRING=8
|
||||
val SCE_NNCRONTAB_ENVIRONMENT=9
|
||||
val SCE_NNCRONTAB_IDENTIFIER=10
|
||||
# Lexical states for SCLEX_MATLAB
|
||||
val SCE_MATLAB_DEFAULT=0
|
||||
val SCE_MATLAB_COMMENT=1
|
||||
val SCE_MATLAB_COMMAND=2
|
||||
val SCE_MATLAB_NUMBER=3
|
||||
val SCE_MATLAB_KEYWORD=4
|
||||
val SCE_MATLAB_STRING=5
|
||||
val SCE_MATLAB_OPERATOR=6
|
||||
val SCE_MATLAB_IDENTIFIER=7
|
||||
|
||||
# Events
|
||||
|
||||
@@ -1591,14 +1702,10 @@ evt void ModifyAttemptRO=2004(void)
|
||||
evt void Key=2005(int ch, int modifiers)
|
||||
evt void DoubleClick=2006(void)
|
||||
evt void UpdateUI=2007(void)
|
||||
# The old name for SCN_UPDATEUI
|
||||
val SCN_CHECKBRACE=2007
|
||||
evt void Modified=2008(int position, int modificationType, string text, int length, int linesAdded, int line, int foldLevelNow, int foldLevelPrev)
|
||||
# Optional module for macro recording
|
||||
evt void MacroRecord=2009(int message, int wParam, int lParam)
|
||||
evt void MarginClick=2010(int modifiers, int position, int margin)
|
||||
evt void NeedShown=2011(int position, int length)
|
||||
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)
|
||||
@@ -1606,3 +1713,7 @@ evt void DwellStart=2016(int position)
|
||||
evt void DwellEnd=2017(int position)
|
||||
|
||||
cat Deprecated
|
||||
|
||||
# The old name for SCN_UPDATEUI
|
||||
val SCN_CHECKBRACE=2007
|
||||
evt void PosChanged=2012(int position)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file AutoComplete.cxx
|
||||
** Defines the auto completion list box.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -22,7 +22,8 @@ AutoComplete::AutoComplete() :
|
||||
posStart(0),
|
||||
startLen(0),
|
||||
cancelAtStartPos(true),
|
||||
autoHide(true) {
|
||||
autoHide(true),
|
||||
dropRestOfWord(false) {
|
||||
stopChars[0] = '\0';
|
||||
fillUpChars[0] = '\0';
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file AutoComplete.h
|
||||
** Defines the auto completion list box.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef AUTOCOMPLETE_H
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
/// Should autocompletion be canceled if editor's currentPos <= startPos?
|
||||
bool cancelAtStartPos;
|
||||
bool autoHide;
|
||||
bool dropRestOfWord;
|
||||
|
||||
AutoComplete();
|
||||
~AutoComplete();
|
||||
|
@@ -21,11 +21,11 @@ CallTip::CallTip() {
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
|
||||
colourBG.desired = Colour(0xff, 0xff, 0xff);
|
||||
colourUnSel.desired = Colour(0x80, 0x80, 0x80);
|
||||
colourSel.desired = Colour(0, 0, 0x80);
|
||||
colourShade.desired = Colour(0, 0, 0);
|
||||
colourLight.desired = Colour(0xc0, 0xc0, 0xc0);
|
||||
colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
|
||||
colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
|
||||
colourSel.desired = ColourDesired(0, 0, 0x80);
|
||||
colourShade.desired = ColourDesired(0, 0, 0);
|
||||
colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
|
||||
}
|
||||
|
||||
CallTip::~CallTip() {
|
||||
@@ -81,7 +81,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
rcClient.left = x;
|
||||
rcClient.top = ytext - ascent - 1;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
|
||||
chunkVal, thisStartHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
@@ -91,7 +91,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
rcClient.top = ytext;
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
|
||||
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
|
||||
colourSel.allocated, colourBG.allocated);
|
||||
x = xEnd;
|
||||
@@ -100,7 +100,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
chunkLength - thisEndHighlight);
|
||||
rcClient.left = x;
|
||||
rcClient.right = xEnd;
|
||||
surfaceWindow->DrawText(rcClient, font, ytext,
|
||||
surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
|
||||
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
|
||||
colourUnSel.allocated, colourBG.allocated);
|
||||
chunkVal = chunkEnd + 1;
|
||||
@@ -117,21 +117,25 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||
}
|
||||
|
||||
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size) {
|
||||
Surface surfaceMeasure;
|
||||
surfaceMeasure.Init();
|
||||
int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
|
||||
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
|
||||
const char *faceName, int size, bool unicodeMode_) {
|
||||
if (val)
|
||||
delete []val;
|
||||
val = new char[strlen(defn) + 1];
|
||||
if (!val)
|
||||
return PRectangle();
|
||||
strcpy(val, defn);
|
||||
unicodeMode = unicodeMode_;
|
||||
Surface *surfaceMeasure = Surface::Allocate();
|
||||
if (!surfaceMeasure)
|
||||
return PRectangle();
|
||||
surfaceMeasure->Init();
|
||||
surfaceMeasure->SetUnicodeMode(unicodeMode);
|
||||
startHighlight = 0;
|
||||
endHighlight = 0;
|
||||
inCallTipMode = true;
|
||||
posStartCallTip = pos;
|
||||
int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
|
||||
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
|
||||
// Look for multiple lines in the text
|
||||
// Only support \n here - simply means container must avoid \r!
|
||||
int width = 0;
|
||||
@@ -139,16 +143,17 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *newline;
|
||||
const char *look = val;
|
||||
while ((newline = strchr(look, '\n')) != NULL) {
|
||||
int thisWidth = surfaceMeasure.WidthText(font, look, newline - look);
|
||||
int thisWidth = surfaceMeasure->WidthText(font, look, newline - look);
|
||||
width = Platform::Maximum(width, thisWidth);
|
||||
look = newline + 1;
|
||||
numLines++;
|
||||
}
|
||||
int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look));
|
||||
int lastWidth = surfaceMeasure->WidthText(font, look, strlen(look));
|
||||
width = Platform::Maximum(width, lastWidth) + 10;
|
||||
int lineHeight = surfaceMeasure.Height(font);
|
||||
int lineHeight = surfaceMeasure->Height(font);
|
||||
// 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;
|
||||
delete surfaceMeasure;
|
||||
return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ public:
|
||||
ColourPair colourSel;
|
||||
ColourPair colourShade;
|
||||
ColourPair colourLight;
|
||||
bool unicodeMode;
|
||||
|
||||
CallTip();
|
||||
~CallTip();
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
|
||||
/// Setup the calltip and return a rectangle of the area required.
|
||||
PRectangle CallTipStart(int pos, Point pt, const char *defn,
|
||||
const char *faceName, int size);
|
||||
const char *faceName, int size, bool unicodeMode_);
|
||||
|
||||
void CallTipCancel();
|
||||
|
||||
|
@@ -11,8 +11,9 @@
|
||||
|
||||
OneLine::OneLine() {
|
||||
displayLine = 0;
|
||||
docLine = 0;
|
||||
//docLine = 0;
|
||||
visible = true;
|
||||
height = 1;
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
@@ -22,6 +23,8 @@ ContractionState::ContractionState() {
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
valid = false;
|
||||
docLines = 0;
|
||||
sizeDocLines = 0;
|
||||
}
|
||||
|
||||
ContractionState::~ContractionState() {
|
||||
@@ -32,12 +35,32 @@ void ContractionState::MakeValid() const {
|
||||
if (!valid) {
|
||||
// Could be cleverer by keeping the index of the last still valid entry
|
||||
// rather than invalidating all.
|
||||
int lineDisplay = 0;
|
||||
linesInDisplay = 0;
|
||||
for (int lineInDoc=0; lineInDoc<linesInDoc; lineInDoc++) {
|
||||
lines[lineInDoc].displayLine = linesInDisplay;
|
||||
if (lines[lineInDoc].visible) {
|
||||
linesInDisplay += lines[lineInDoc].height;
|
||||
}
|
||||
}
|
||||
if (sizeDocLines < linesInDisplay) {
|
||||
delete []docLines;
|
||||
int *docLinesNew = new int[linesInDisplay + growSize];
|
||||
if (!docLinesNew) {
|
||||
docLines = 0;
|
||||
sizeDocLines = 0;
|
||||
return;
|
||||
}
|
||||
docLines = docLinesNew;
|
||||
sizeDocLines = linesInDisplay + growSize;
|
||||
}
|
||||
|
||||
int lineInDisplay=0;
|
||||
for (int line=0; line<linesInDoc; line++) {
|
||||
lines[line].displayLine = lineDisplay;
|
||||
if (lines[line].visible) {
|
||||
lines[lineDisplay].docLine = line;
|
||||
lineDisplay++;
|
||||
for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
|
||||
docLines[lineInDisplay] = line;
|
||||
lineInDisplay++;
|
||||
}
|
||||
}
|
||||
}
|
||||
valid = true;
|
||||
@@ -50,6 +73,9 @@ void ContractionState::Clear() {
|
||||
size = 0;
|
||||
linesInDoc = 1;
|
||||
linesInDisplay = 1;
|
||||
delete []docLines;
|
||||
docLines = 0;
|
||||
sizeDocLines = 0;
|
||||
}
|
||||
|
||||
int ContractionState::LinesInDoc() const {
|
||||
@@ -57,6 +83,9 @@ int ContractionState::LinesInDoc() const {
|
||||
}
|
||||
|
||||
int ContractionState::LinesDisplayed() const {
|
||||
if (size != 0) {
|
||||
MakeValid();
|
||||
}
|
||||
return linesInDisplay;
|
||||
}
|
||||
|
||||
@@ -75,11 +104,15 @@ int ContractionState::DocFromDisplay(int lineDisplay) const {
|
||||
if (lineDisplay <= 0)
|
||||
return 0;
|
||||
if (lineDisplay >= linesInDisplay)
|
||||
return linesInDoc-1;
|
||||
return linesInDoc;
|
||||
if (size == 0)
|
||||
return lineDisplay;
|
||||
MakeValid();
|
||||
return lines[lineDisplay].docLine;
|
||||
if (docLines) { // Valid allocation
|
||||
return docLines[lineDisplay];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::Grow(int sizeNew) {
|
||||
@@ -113,13 +146,15 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
|
||||
Grow(linesInDoc + lineCount + growSize);
|
||||
}
|
||||
linesInDoc += lineCount;
|
||||
linesInDisplay += lineCount;
|
||||
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
|
||||
lines[i].visible = lines[i - lineCount].visible;
|
||||
lines[i].height = lines[i - lineCount].height;
|
||||
linesInDisplay += lines[i].height;
|
||||
lines[i].expanded = lines[i - lineCount].expanded;
|
||||
}
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
|
||||
lines[lineDoc+d].height = 1;
|
||||
lines[lineDoc+d].expanded = true;
|
||||
}
|
||||
valid = false;
|
||||
@@ -134,7 +169,7 @@ void ContractionState::DeleteLines(int lineDoc, int lineCount) {
|
||||
int deltaDisplayed = 0;
|
||||
for (int d=0;d<lineCount;d++) {
|
||||
if (lines[lineDoc+d].visible)
|
||||
deltaDisplayed--;
|
||||
deltaDisplayed -= lines[lineDoc+d].height;
|
||||
}
|
||||
for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
|
||||
if (i != 0) // Line zero is always visible
|
||||
@@ -170,7 +205,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible
|
||||
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
|
||||
for (int line=lineDocStart; line <= lineDocEnd; line++) {
|
||||
if (lines[line].visible != visible) {
|
||||
delta += visible ? 1 : -1;
|
||||
delta += visible ? lines[line].height : -lines[line].height;
|
||||
lines[line].visible = visible;
|
||||
}
|
||||
}
|
||||
@@ -192,6 +227,11 @@ bool ContractionState::GetExpanded(int lineDoc) const {
|
||||
|
||||
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||
if (size == 0) {
|
||||
if (expanded) {
|
||||
// If in completely expanded state then setting
|
||||
// one line to expanded has no effect.
|
||||
return false;
|
||||
}
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
@@ -203,6 +243,38 @@ bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ContractionState::GetHeight(int lineDoc) const {
|
||||
if (size == 0)
|
||||
return 1;
|
||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||
return lines[lineDoc].height;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the number of display lines needed for this line.
|
||||
// Return true if this is a change.
|
||||
bool ContractionState::SetHeight(int lineDoc, int height) {
|
||||
if (lineDoc > linesInDoc)
|
||||
return false;
|
||||
if (size == 0) {
|
||||
if (height == 1) {
|
||||
// If in completely expanded state then all lines
|
||||
// assumed to have height of one so no effect here.
|
||||
return false;
|
||||
}
|
||||
Grow(linesInDoc + growSize);
|
||||
}
|
||||
if (lines[lineDoc].height != height) {
|
||||
lines[lineDoc].height = height;
|
||||
valid = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::ShowAll() {
|
||||
delete []lines;
|
||||
lines = 0;
|
||||
|
@@ -13,7 +13,8 @@
|
||||
class OneLine {
|
||||
public:
|
||||
int displayLine; ///< Position within set of visible lines
|
||||
int docLine; ///< Inverse of @a displayLine
|
||||
//int docLine; ///< Inverse of @a displayLine
|
||||
int height; ///< Number of display lines needed to show all of the line
|
||||
bool visible;
|
||||
bool expanded;
|
||||
|
||||
@@ -27,9 +28,11 @@ class ContractionState {
|
||||
void Grow(int sizeNew);
|
||||
enum { growSize = 4000 };
|
||||
int linesInDoc;
|
||||
int linesInDisplay;
|
||||
mutable int linesInDisplay;
|
||||
mutable OneLine *lines;
|
||||
int size;
|
||||
mutable int *docLines;
|
||||
mutable int sizeDocLines;
|
||||
mutable bool valid;
|
||||
void MakeValid() const;
|
||||
|
||||
@@ -53,6 +56,9 @@ public:
|
||||
bool GetExpanded(int lineDoc) const;
|
||||
bool SetExpanded(int lineDoc, bool expanded);
|
||||
|
||||
int GetHeight(int lineDoc) const;
|
||||
bool SetHeight(int lineDoc, int height);
|
||||
|
||||
void ShowAll();
|
||||
};
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file Document.cxx
|
||||
** Text document that handles notifications, DBCS, styling, words and end of line.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "RESearch.h"
|
||||
|
||||
// This is ASCII specific but is safe with chars >= 0x80
|
||||
inline bool isspacechar(unsigned char ch) {
|
||||
static inline bool isspacechar(unsigned char ch) {
|
||||
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
|
||||
}
|
||||
|
||||
@@ -34,10 +34,9 @@ Document::Document() {
|
||||
stylingBits = 5;
|
||||
stylingBitsMask = 0x1F;
|
||||
stylingMask = 0;
|
||||
for (int ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = isalnum(ch) || ch == '_';
|
||||
}
|
||||
SetWordChars(0);
|
||||
endStyled = 0;
|
||||
styleClock = 0;
|
||||
enteredCount = 0;
|
||||
enteredReadOnlyCount = 0;
|
||||
tabInChars = 8;
|
||||
@@ -219,7 +218,6 @@ bool Document::IsCrLf(int pos) {
|
||||
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool Document::IsDBCS(int pos) {
|
||||
if (dbcsCodePage) {
|
||||
if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
@@ -232,7 +230,7 @@ bool Document::IsDBCS(int pos) {
|
||||
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
|
||||
startLine--;
|
||||
while (startLine <= pos) {
|
||||
if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) {
|
||||
if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine))) {
|
||||
startLine++;
|
||||
if (startLine >= pos)
|
||||
return true;
|
||||
@@ -243,13 +241,6 @@ bool Document::IsDBCS(int pos) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool Document::IsDBCS(int) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
int Document::LenChar(int pos) {
|
||||
if (IsCrLf(pos)) {
|
||||
@@ -302,7 +293,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
|
||||
// Not between CR and LF
|
||||
|
||||
#if PLAT_WIN
|
||||
if (dbcsCodePage) {
|
||||
if (SC_CP_UTF8 == dbcsCodePage) {
|
||||
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
|
||||
@@ -324,12 +314,11 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
while (startLine < pos) {
|
||||
if (atLeadByte)
|
||||
atLeadByte = false;
|
||||
else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine)))
|
||||
else if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine)))
|
||||
atLeadByte = true;
|
||||
else
|
||||
atLeadByte = false;
|
||||
startLine++;
|
||||
//Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +331,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return pos;
|
||||
}
|
||||
@@ -634,21 +622,46 @@ int Document::GetColumn(int pos) {
|
||||
int column = 0;
|
||||
int line = LineFromPosition(pos);
|
||||
if ((line >= 0) && (line < LinesTotal())) {
|
||||
for (int i = LineStart(line);i < pos;i++) {
|
||||
for (int i = LineStart(line);i < pos;) {
|
||||
char ch = cb.CharAt(i);
|
||||
if (ch == '\t')
|
||||
if (ch == '\t') {
|
||||
column = NextTab(column, tabInChars);
|
||||
else if (ch == '\r')
|
||||
i++;
|
||||
} else if (ch == '\r') {
|
||||
return column;
|
||||
else if (ch == '\n')
|
||||
} else if (ch == '\n') {
|
||||
return column;
|
||||
else
|
||||
} else {
|
||||
column++;
|
||||
i = MovePositionOutsideChar(i + 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
int Document::FindColumn(int line, int column) {
|
||||
int position = LineStart(line);
|
||||
int columnCurrent = 0;
|
||||
if ((line >= 0) && (line < LinesTotal())) {
|
||||
while (columnCurrent < column) {
|
||||
char ch = cb.CharAt(position);
|
||||
if (ch == '\t') {
|
||||
columnCurrent = NextTab(columnCurrent, tabInChars);
|
||||
position++;
|
||||
} else if (ch == '\r') {
|
||||
return position;
|
||||
} else if (ch == '\n') {
|
||||
return position;
|
||||
} else {
|
||||
columnCurrent++;
|
||||
position = MovePositionOutsideChar(position + 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
void Document::Indent(bool forwards, int lineBottom, int lineTop) {
|
||||
// Dedent - suck white space off the front of the line to dedent by equivalent of a tab
|
||||
for (int line = lineBottom; line >= lineTop; line--) {
|
||||
@@ -700,72 +713,88 @@ void Document::ConvertLineEnds(int eolModeSet) {
|
||||
EndUndoAction();
|
||||
}
|
||||
|
||||
bool Document::IsWordChar(unsigned char ch) {
|
||||
if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80))
|
||||
return true;
|
||||
return wordchars[ch];
|
||||
Document::charClassification Document::WordCharClass(unsigned char ch) {
|
||||
if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80))
|
||||
return ccWord;
|
||||
return charClass[ch];
|
||||
}
|
||||
|
||||
int Document::ExtendWordSelect(int pos, int delta) {
|
||||
/**
|
||||
* Used by commmands that want to select whole words.
|
||||
* Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0.
|
||||
*/
|
||||
int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) {
|
||||
charClassification ccStart = ccWord;
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && IsWordChar(cb.CharAt(pos - 1)))
|
||||
if (!onlyWordCharacters)
|
||||
ccStart = WordCharClass(cb.CharAt(pos-1));
|
||||
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
|
||||
pos--;
|
||||
} else {
|
||||
while (pos < (Length()) && IsWordChar(cb.CharAt(pos)))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
int Document::NextWordStart(int pos, int delta) {
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))
|
||||
pos--;
|
||||
if (isspacechar(cb.CharAt(pos - 1))) { // Back up to previous line
|
||||
while (pos > 0 && isspacechar(cb.CharAt(pos - 1)))
|
||||
pos--;
|
||||
} else {
|
||||
bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1));
|
||||
while (pos > 0 && !isspacechar(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1))))
|
||||
pos--;
|
||||
}
|
||||
} else {
|
||||
bool startAtWordChar = IsWordChar(cb.CharAt(pos));
|
||||
while (pos < (Length()) && isspacechar(cb.CharAt(pos)))
|
||||
pos++;
|
||||
while (pos < (Length()) && !isspacechar(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos))))
|
||||
pos++;
|
||||
while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))
|
||||
if (!onlyWordCharacters)
|
||||
ccStart = WordCharClass(cb.CharAt(pos));
|
||||
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the character before the given position
|
||||
* is not a word character.
|
||||
* Find the start of the next word in either a forward (delta >= 0) or backwards direction
|
||||
* (delta < 0).
|
||||
* This is looking for a transition between character classes although there is also some
|
||||
* additional movement to transit white space.
|
||||
* Used by cursor movement by word commands.
|
||||
*/
|
||||
int Document::NextWordStart(int pos, int delta) {
|
||||
if (delta < 0) {
|
||||
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccSpace))
|
||||
pos--;
|
||||
if (pos > 0) {
|
||||
charClassification ccStart = WordCharClass(cb.CharAt(pos-1));
|
||||
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) {
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
charClassification ccStart = WordCharClass(cb.CharAt(pos));
|
||||
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
|
||||
pos++;
|
||||
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccSpace))
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the character at the given position is a word or punctuation character and that
|
||||
* the previous character is of a different character class.
|
||||
*/
|
||||
bool Document::IsWordStartAt(int pos) {
|
||||
if (pos > 0) {
|
||||
return !IsWordChar(CharAt(pos - 1));
|
||||
charClassification ccPos = WordCharClass(CharAt(pos));
|
||||
return (ccPos == ccWord || ccPos == ccPunctuation) &&
|
||||
(ccPos != WordCharClass(CharAt(pos - 1)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the character after the given position
|
||||
* is not a word character.
|
||||
* Check that the character at the given position is a word or punctuation character and that
|
||||
* the next character is of a different character class.
|
||||
*/
|
||||
bool Document::IsWordEndAt(int pos) {
|
||||
if (pos < Length() - 1) {
|
||||
return !IsWordChar(CharAt(pos));
|
||||
charClassification ccPrev = WordCharClass(CharAt(pos-1));
|
||||
return (ccPrev == ccWord || ccPrev == ccPunctuation) &&
|
||||
(ccPrev != WordCharClass(CharAt(pos)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the given range is delimited by
|
||||
* non word characters.
|
||||
* Check that the given range is has transitions between character classes at both
|
||||
* ends and where the characters on the inside are word or punctuation characters.
|
||||
*/
|
||||
bool Document::IsWordAt(int start, int end) {
|
||||
return IsWordStartAt(start) && IsWordEndAt(end);
|
||||
@@ -1018,16 +1047,22 @@ void Document::ChangeCase(Range r, bool makeUpperCase) {
|
||||
void Document::SetWordChars(unsigned char *chars) {
|
||||
int ch;
|
||||
for (ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = false;
|
||||
if (ch == '\r' || ch == '\n')
|
||||
charClass[ch] = ccNewLine;
|
||||
else if (ch < 0x20 || ch == ' ')
|
||||
charClass[ch] = ccSpace;
|
||||
else
|
||||
charClass[ch] = ccPunctuation;
|
||||
}
|
||||
if (chars) {
|
||||
while (*chars) {
|
||||
wordchars[*chars] = true;
|
||||
charClass[*chars] = ccWord;
|
||||
chars++;
|
||||
}
|
||||
} else {
|
||||
for (ch = 0; ch < 256; ch++) {
|
||||
wordchars[ch] = isalnum(ch) || ch == '_';
|
||||
if (ch >= 0x80 || isalnum(ch) || ch == '_')
|
||||
charClass[ch] = ccWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1066,6 +1101,7 @@ void Document::SetStyles(int length, char *styles) {
|
||||
int prevEndStyled = endStyled;
|
||||
bool didChange = false;
|
||||
for (int iPos = 0; iPos < length; iPos++, endStyled++) {
|
||||
PLATFORM_ASSERT(endStyled < Length());
|
||||
if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
|
||||
didChange = true;
|
||||
}
|
||||
@@ -1080,6 +1116,12 @@ void Document::SetStyles(int length, char *styles) {
|
||||
}
|
||||
|
||||
bool Document::EnsureStyledTo(int pos) {
|
||||
if (pos > GetEndStyled()) {
|
||||
styleClock++;
|
||||
if (styleClock > 0x100000) {
|
||||
styleClock = 0;
|
||||
}
|
||||
}
|
||||
// Ask the watchers to style, and stop as soon as one responds.
|
||||
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
|
||||
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
|
||||
@@ -1149,7 +1191,7 @@ void Document::NotifyModified(DocModification mh) {
|
||||
}
|
||||
|
||||
bool Document::IsWordPartSeparator(char ch) {
|
||||
return ispunct(ch) && IsWordChar(ch);
|
||||
return ispunct(ch) && (WordCharClass(ch) == ccWord);
|
||||
}
|
||||
|
||||
int Document::WordPartLeft(int pos) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/** @file Document.h
|
||||
** Text document that handles notifications, DBCS, styling, words and end of line.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef DOCUMENT_H
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
return (start != invalidPosition) && (end != invalidPosition);
|
||||
}
|
||||
|
||||
// Is the position within the range?
|
||||
bool Contains(Position pos) const {
|
||||
if (start < end) {
|
||||
return (pos >= start && pos <= end);
|
||||
@@ -45,6 +46,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Is the character after pos within the range?
|
||||
bool ContainsCharacter(Position pos) const {
|
||||
if (start < end) {
|
||||
return (pos >= start && pos < end);
|
||||
} else {
|
||||
return (pos < start && pos >= end);
|
||||
}
|
||||
}
|
||||
|
||||
bool Contains(Range other) const {
|
||||
return Contains(other.start) && Contains(other.end);
|
||||
}
|
||||
@@ -81,9 +91,11 @@ public:
|
||||
private:
|
||||
int refCount;
|
||||
CellBuffer cb;
|
||||
bool wordchars[256];
|
||||
enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
|
||||
charClassification charClass[256];
|
||||
char stylingMask;
|
||||
int endStyled;
|
||||
int styleClock;
|
||||
int enteredCount;
|
||||
int enteredReadOnlyCount;
|
||||
|
||||
@@ -140,6 +152,7 @@ public:
|
||||
void SetLineIndentation(int line, int indent);
|
||||
int GetLineIndentPosition(int line);
|
||||
int GetColumn(int position);
|
||||
int FindColumn(int line, int column);
|
||||
void Indent(bool forwards, int lineBottom, int lineTop);
|
||||
void ConvertLineEnds(int eolModeSet);
|
||||
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
|
||||
@@ -175,7 +188,7 @@ public:
|
||||
int GetFoldParent(int line);
|
||||
|
||||
void Indent(bool forwards);
|
||||
int ExtendWordSelect(int pos, int delta);
|
||||
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
|
||||
int NextWordStart(int pos, int delta);
|
||||
int Length() { return cb.Length(); }
|
||||
long FindText(int minPos, int maxPos, const char *s,
|
||||
@@ -193,6 +206,7 @@ public:
|
||||
void SetStyles(int length, char *styles);
|
||||
int GetEndStyled() { return endStyled; }
|
||||
bool EnsureStyledTo(int pos);
|
||||
int GetStyleClock() { return styleClock; }
|
||||
|
||||
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
||||
int GetLineState(int line) { return cb.GetLineState(line); }
|
||||
@@ -209,7 +223,7 @@ public:
|
||||
|
||||
private:
|
||||
bool IsDBCS(int pos);
|
||||
bool IsWordChar(unsigned char ch);
|
||||
charClassification WordCharClass(unsigned char ch);
|
||||
bool IsWordStartAt(int pos);
|
||||
bool IsWordEndAt(int pos);
|
||||
bool IsWordAt(int start, int end);
|
||||
|
@@ -23,22 +23,14 @@
|
||||
DocumentAccessor::~DocumentAccessor() {
|
||||
}
|
||||
|
||||
#if PLAT_WIN
|
||||
bool DocumentAccessor::InternalIsLeadByte(char ch) {
|
||||
if (SC_CP_UTF8 == codePage)
|
||||
// For lexing, all characters >= 0x80 are treated the
|
||||
// same so none is considered a lead byte.
|
||||
return false;
|
||||
else
|
||||
return IsDBCSLeadByteEx(codePage, ch);
|
||||
return Platform::IsDBCSLeadByte(codePage, ch);
|
||||
}
|
||||
#else
|
||||
// PLAT_GTK or PLAT_WX
|
||||
// TODO: support DBCS under GTK+ and WX
|
||||
bool DocumentAccessor::InternalIsLeadByte(char) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void DocumentAccessor::Fill(int position) {
|
||||
if (lenDoc == -1)
|
||||
@@ -88,6 +80,7 @@ int DocumentAccessor::SetLineState(int line, int state) {
|
||||
|
||||
void DocumentAccessor::StartAt(unsigned int start, char chMask) {
|
||||
pdoc->StartStyling(start, chMask);
|
||||
startPosStyling = start;
|
||||
}
|
||||
|
||||
void DocumentAccessor::StartSegment(unsigned int pos) {
|
||||
@@ -111,6 +104,7 @@ void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
|
||||
chFlags = 0;
|
||||
chAttr |= chFlags;
|
||||
for (unsigned int i = startSeg; i <= pos; i++) {
|
||||
PLATFORM_ASSERT((startPosStyling + validLen) < Length());
|
||||
styleBuf[validLen++] = static_cast<char>(chAttr);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +122,7 @@ void DocumentAccessor::Flush() {
|
||||
if (validLen > 0) {
|
||||
pdoc->SetStyles(validLen, styleBuf);
|
||||
validLen = 0;
|
||||
startPosStyling += validLen;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@ protected:
|
||||
char chFlags;
|
||||
char chWhile;
|
||||
unsigned int startSeg;
|
||||
int startPosStyling;
|
||||
|
||||
bool InternalIsLeadByte(char ch);
|
||||
void Fill(int position);
|
||||
@@ -33,7 +34,8 @@ protected:
|
||||
public:
|
||||
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
|
||||
Accessor(), pdoc(pdoc_), props(props_), id(id_),
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
|
||||
lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
|
||||
startSeg(0), startPosStyling(0) {
|
||||
}
|
||||
~DocumentAccessor();
|
||||
char StyleAt(int position);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
/** @file Editor.h
|
||||
** Defines the main editor class.
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#ifndef EDITOR_H
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
bool ticking;
|
||||
int ticksToWait;
|
||||
enum {tickSize = 100};
|
||||
int tickerID;
|
||||
TickerID tickerID;
|
||||
|
||||
Timer();
|
||||
};
|
||||
@@ -34,20 +34,81 @@ public:
|
||||
/**
|
||||
*/
|
||||
class LineLayout {
|
||||
public:
|
||||
private:
|
||||
friend class LineLayoutCache;
|
||||
int *lineStarts;
|
||||
int lenLineStarts;
|
||||
/// Drawing is only performed for @a maxLineLength characters on each line.
|
||||
enum {maxLineLength = 4000};
|
||||
int lineNumber;
|
||||
bool inCache;
|
||||
public:
|
||||
enum { wrapWidthInfinite = 0x7ffffff };
|
||||
int maxLineLength;
|
||||
int numCharsInLine;
|
||||
enum validLevel { llInvalid, llPositions, llLines } validity;
|
||||
int xHighlightGuide;
|
||||
bool highlightColumn;
|
||||
int selStart;
|
||||
int selEnd;
|
||||
bool containsCaret;
|
||||
int edgeColumn;
|
||||
char chars[maxLineLength+1];
|
||||
char styles[maxLineLength+1];
|
||||
char indicators[maxLineLength+1];
|
||||
int positions[maxLineLength+1];
|
||||
char *chars;
|
||||
char *styles;
|
||||
char *indicators;
|
||||
int *positions;
|
||||
char bracePreviousStyles[2];
|
||||
|
||||
// Wrapped line support
|
||||
int widthLine;
|
||||
int lines;
|
||||
|
||||
LineLayout(int maxLineLength_);
|
||||
virtual ~LineLayout();
|
||||
void Resize(int maxLineLength_);
|
||||
void Free();
|
||||
void Invalidate(validLevel validity_);
|
||||
int LineStart(int line) {
|
||||
if (line <= 0) {
|
||||
return 0;
|
||||
} else if ((line >= lines) || !lineStarts) {
|
||||
return numCharsInLine;
|
||||
} else {
|
||||
return lineStarts[line];
|
||||
}
|
||||
}
|
||||
void SetLineStart(int line, int start);
|
||||
void SetBracesHighlight(Range rangeLine, Position braces[],
|
||||
char bracesMatchStyle, int xHighlight);
|
||||
void RestoreBracesHighlight(Range rangeLine, Position braces[]);
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class LineLayoutCache {
|
||||
int level;
|
||||
int length;
|
||||
int size;
|
||||
LineLayout **cache;
|
||||
bool allInvalidated;
|
||||
int styleClock;
|
||||
void Allocate(int length_);
|
||||
void AllocateForLevel(int linesOnScreen, int linesInDoc);
|
||||
public:
|
||||
LineLayoutCache();
|
||||
virtual ~LineLayoutCache();
|
||||
void Deallocate();
|
||||
enum {
|
||||
llcNone=SC_CACHE_NONE,
|
||||
llcCaret=SC_CACHE_CARET,
|
||||
llcPage=SC_CACHE_PAGE,
|
||||
llcDocument=SC_CACHE_DOCUMENT
|
||||
};
|
||||
void Invalidate(LineLayout::validLevel validity_);
|
||||
void SetLevel(int level_);
|
||||
int GetLevel() { return level; }
|
||||
LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
|
||||
int linesOnScreen, int linesInDoc);
|
||||
void Dispose(LineLayout *ll);
|
||||
};
|
||||
|
||||
class SelectionText {
|
||||
@@ -70,6 +131,38 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A smart pointer class to ensure Surfaces are set up and deleted correctly.
|
||||
*/
|
||||
class AutoSurface {
|
||||
private:
|
||||
Surface *surf;
|
||||
public:
|
||||
AutoSurface(bool unicodeMode) {
|
||||
surf = Surface::Allocate();
|
||||
if (surf) {
|
||||
surf->Init();
|
||||
surf->SetUnicodeMode(unicodeMode);
|
||||
}
|
||||
}
|
||||
AutoSurface(SurfaceID sid, bool unicodeMode) {
|
||||
surf = Surface::Allocate();
|
||||
if (surf) {
|
||||
surf->Init(sid);
|
||||
surf->SetUnicodeMode(unicodeMode);
|
||||
}
|
||||
}
|
||||
~AutoSurface() {
|
||||
delete surf;
|
||||
}
|
||||
Surface *operator->() const {
|
||||
return surf;
|
||||
}
|
||||
operator Surface *() const {
|
||||
return surf;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class Editor : public DocWatcher {
|
||||
@@ -92,6 +185,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int printMagnification;
|
||||
int printColourMode;
|
||||
int cursorMode;
|
||||
int controlCharSymbol;
|
||||
|
||||
bool hasFocus;
|
||||
bool hideSelection;
|
||||
@@ -107,11 +201,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
|
||||
bool horizontalScrollBarVisible;
|
||||
|
||||
Surface pixmapLine;
|
||||
Surface pixmapSelMargin;
|
||||
Surface pixmapSelPattern;
|
||||
Surface pixmapIndentGuide;
|
||||
Surface pixmapIndentGuideHighlight;
|
||||
Surface *pixmapLine;
|
||||
Surface *pixmapSelMargin;
|
||||
Surface *pixmapSelPattern;
|
||||
Surface *pixmapIndentGuide;
|
||||
Surface *pixmapIndentGuideHighlight;
|
||||
|
||||
LineLayoutCache llc;
|
||||
|
||||
KeyMap kmap;
|
||||
|
||||
@@ -174,6 +270,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
int foldFlags;
|
||||
ContractionState cs;
|
||||
|
||||
// Wrapping support
|
||||
enum { eWrapNone, eWrapWord } wrapState;
|
||||
int wrapWidth;
|
||||
int docLineLastWrapped;
|
||||
|
||||
Document *pdoc;
|
||||
|
||||
Editor();
|
||||
@@ -223,16 +324,22 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual void ScrollText(int linesToMove);
|
||||
void HorizontalScrollTo(int xPos);
|
||||
void MoveCaretInsideView();
|
||||
int DisplayFromPosition(int pos);
|
||||
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
|
||||
void ShowCaretAtCurrentPosition();
|
||||
void DropCaret();
|
||||
void InvalidateCaret();
|
||||
|
||||
void NeedWrapping(int docLineStartWrapping=0);
|
||||
bool WrapLines();
|
||||
|
||||
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
|
||||
void PaintSelMargin(Surface *surface, PRectangle &rc);
|
||||
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll);
|
||||
LineLayout *RetrieveLineLayout(int lineNumber);
|
||||
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
|
||||
int width=LineLayout::wrapWidthInfinite);
|
||||
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
|
||||
PRectangle rcLine, LineLayout &ll);
|
||||
PRectangle rcLine, LineLayout *ll, int subLine=0);
|
||||
void Paint(Surface *surfaceWindow, PRectangle rcArea);
|
||||
long FormatRange(bool draw, RangeToFormat *pfr);
|
||||
|
||||
@@ -240,11 +347,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual void SetHorizontalScrollPos() = 0;
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
|
||||
virtual void ReconfigureScrollBars();
|
||||
void SetScrollBarsTo(PRectangle rsClient);
|
||||
void SetScrollBars();
|
||||
void ChangeSize();
|
||||
|
||||
void AddChar(char ch);
|
||||
virtual void AddCharUTF(char *s, unsigned int len);
|
||||
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
void ClearSelection();
|
||||
void ClearAll();
|
||||
void ClearDocumentStyle();
|
||||
@@ -258,11 +365,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
void Undo();
|
||||
void Redo();
|
||||
void DelChar();
|
||||
void DelCharBack();
|
||||
void DelCharBack(bool allowLineStartDeletion);
|
||||
virtual void ClaimSelection() = 0;
|
||||
|
||||
virtual void NotifyChange() = 0;
|
||||
virtual void NotifyFocus(bool focus);
|
||||
virtual int GetCtrlID() { return ctrlID; }
|
||||
virtual void NotifyParent(SCNotification scn) = 0;
|
||||
virtual void NotifyStyleToNeeded(int endStyleNeeded);
|
||||
void NotifyChar(int ch);
|
||||
@@ -278,6 +386,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
void NotifyModifyAttempt(Document *document, void *userData);
|
||||
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
||||
void CheckModificationForWrap(DocModification mh);
|
||||
void NotifyModified(Document *document, DocModification mh, void *userData);
|
||||
void NotifyDeleted(Document *document, void *userData);
|
||||
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
|
||||
@@ -339,9 +448,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
|
||||
|
||||
public:
|
||||
// Public so scintilla_send_message can use it
|
||||
// Public so the COM thunks can access it.
|
||||
bool IsUnicodeMode() const;
|
||||
// Public so scintilla_send_message can use it.
|
||||
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;
|
||||
};
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user