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:
Robin Dunn
2002-03-18 22:31:01 +00:00
parent e9159fe8e8
commit 1a2fb4cd61
144 changed files with 9535 additions and 4139 deletions

View File

@@ -73,6 +73,9 @@
#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19 #define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
#define wxSTC_MARK_CIRCLEMINUS 20 #define wxSTC_MARK_CIRCLEMINUS 20
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21 #define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
// Invisible mark that only sets the line background color
#define wxSTC_MARK_BACKGROUND 22
#define wxSTC_MARK_CHARACTER 10000 #define wxSTC_MARK_CHARACTER 10000
// Markers used for outlining column // Markers used for outlining column
@@ -83,6 +86,7 @@
#define wxSTC_MARKNUM_FOLDERSUB 29 #define wxSTC_MARKNUM_FOLDERSUB 29
#define wxSTC_MARKNUM_FOLDER 30 #define wxSTC_MARKNUM_FOLDER 30
#define wxSTC_MARKNUM_FOLDEROPEN 31 #define wxSTC_MARKNUM_FOLDEROPEN 31
#define wxSTC_MASK_FOLDERS 0xFE000000
#define wxSTC_MARGIN_SYMBOL 0 #define wxSTC_MARGIN_SYMBOL 0
#define wxSTC_MARGIN_NUMBER 1 #define wxSTC_MARGIN_NUMBER 1
@@ -127,10 +131,10 @@
#define wxSTC_INDIC_TT 2 #define wxSTC_INDIC_TT 2
#define wxSTC_INDIC_DIAGONAL 3 #define wxSTC_INDIC_DIAGONAL 3
#define wxSTC_INDIC_STRIKE 4 #define wxSTC_INDIC_STRIKE 4
#define wxSTC_INDIC0_MASK 32 #define wxSTC_INDIC0_MASK 0x20
#define wxSTC_INDIC1_MASK 64 #define wxSTC_INDIC1_MASK 0x40
#define wxSTC_INDIC2_MASK 128 #define wxSTC_INDIC2_MASK 0x80
#define wxSTC_INDICS_MASK 224 #define wxSTC_INDICS_MASK 0xE0
// PrintColourMode - use same colours as screen. // PrintColourMode - use same colours as screen.
#define wxSTC_PRINT_NORMAL 0 #define wxSTC_PRINT_NORMAL 0
@@ -159,6 +163,12 @@
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000 #define wxSTC_FOLDLEVELHEADERFLAG 0x2000
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF #define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
#define wxSTC_TIME_FOREVER 10000000 #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_LINEDOWN 2300
#define wxSTC_CMD_LINEDOWNEXTEND 2301 #define wxSTC_CMD_LINEDOWNEXTEND 2301
#define wxSTC_CMD_LINEUP 2302 #define wxSTC_CMD_LINEUP 2302
@@ -203,6 +213,7 @@
#define wxSTC_CMD_UPPERCASE 2341 #define wxSTC_CMD_UPPERCASE 2341
#define wxSTC_CMD_LINESCROLLDOWN 2342 #define wxSTC_CMD_LINESCROLLDOWN 2342
#define wxSTC_CMD_LINESCROLLUP 2343 #define wxSTC_CMD_LINESCROLLUP 2343
#define wxSTC_CMD_DELETEBACKNOTLINE 2344
#define wxSTC_EDGE_NONE 0 #define wxSTC_EDGE_NONE 0
#define wxSTC_EDGE_LINE 1 #define wxSTC_EDGE_LINE 1
#define wxSTC_EDGE_BACKGROUND 2 #define wxSTC_EDGE_BACKGROUND 2
@@ -302,6 +313,12 @@
#define wxSTC_LEX_EIFFELKW 24 #define wxSTC_LEX_EIFFELKW 24
#define wxSTC_LEX_TCL 25 #define wxSTC_LEX_TCL 25
#define wxSTC_LEX_NNCRONTAB 26 #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 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1. // value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -323,7 +340,7 @@
#define wxSTC_P_COMMENTBLOCK 12 #define wxSTC_P_COMMENTBLOCK 12
#define wxSTC_P_STRINGEOL 13 #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_DEFAULT 0
#define wxSTC_C_COMMENT 1 #define wxSTC_C_COMMENT 1
#define wxSTC_C_COMMENTLINE 2 #define wxSTC_C_COMMENTLINE 2
@@ -344,6 +361,17 @@
#define wxSTC_C_COMMENTDOCKEYWORD 17 #define wxSTC_C_COMMENTDOCKEYWORD 17
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18 #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 // Lexical states for SCLEX_HTML, SCLEX_XML
#define wxSTC_H_DEFAULT 0 #define wxSTC_H_DEFAULT 0
#define wxSTC_H_TAG 1 #define wxSTC_H_TAG 1
@@ -531,6 +559,11 @@
#define wxSTC_LUA_OPERATOR 10 #define wxSTC_LUA_OPERATOR 10
#define wxSTC_LUA_IDENTIFIER 11 #define wxSTC_LUA_IDENTIFIER 11
#define wxSTC_LUA_STRINGEOL 12 #define wxSTC_LUA_STRINGEOL 12
#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 // Lexical states for SCLEX_ERRORLIST
#define wxSTC_ERR_DEFAULT 0 #define wxSTC_ERR_DEFAULT 0
@@ -602,6 +635,19 @@
#define wxSTC_ADA_IDENTIFIER 7 #define wxSTC_ADA_IDENTIFIER 7
#define wxSTC_ADA_STRINGEOL 8 #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 // Lexical states for SCLEX_LISP
#define wxSTC_LISP_DEFAULT 0 #define wxSTC_LISP_DEFAULT 0
#define wxSTC_LISP_COMMENT 1 #define wxSTC_LISP_COMMENT 1
@@ -636,21 +682,17 @@
#define wxSTC_NNCRONTAB_ENVIRONMENT 9 #define wxSTC_NNCRONTAB_ENVIRONMENT 9
#define wxSTC_NNCRONTAB_IDENTIFIER 10 #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 // 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 class ScintillaWX; // forward declare
@@ -821,7 +863,7 @@ public:
void SetCodePage(int codePage); void SetCodePage(int codePage);
// Set the symbol used for a particular marker number, // 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, void MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground = wxNullColour, const wxColour& foreground = wxNullColour,
const wxColour& background = wxNullColour); const wxColour& background = wxNullColour);
@@ -832,8 +874,8 @@ public:
// Set the background colour used for a particular marker number. // Set the background colour used for a particular marker number.
void MarkerSetBackground(int markerNumber, const wxColour& back); void MarkerSetBackground(int markerNumber, const wxColour& back);
// Add a marker to a line. // Add a marker to a line, returning an ID which can be used to find or delete the marker.
void MarkerAdd(int line, int markerNumber); int MarkerAdd(int line, int markerNumber);
// Delete a marker from a line // Delete a marker from a line
void MarkerDelete(int line, int markerNumber); void MarkerDelete(int line, int markerNumber);
@@ -980,7 +1022,7 @@ public:
// Is the background of the line containing the caret in a different colour? // Is the background of the line containing the caret in a different colour?
bool GetCaretLineVisible(); 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); void SetCaretLineVisible(bool show);
// Get the colour of the background of the line containing the caret. // 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. // Set the colour of the background of the line containing the caret.
void SetCaretLineBack(const wxColour& back); 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. // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
@@ -1027,7 +1073,8 @@ public:
// Retrieve whether auto-completion cancelled by backspacing before start. // Retrieve whether auto-completion cancelled by backspacing before start.
bool AutoCompGetCancelAtStart(); 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); void AutoCompSetFillUps(const wxString& characterSet);
// Should a single item auto-completion list automatically choose the item. // 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 // Retrieve whether or not autocompletion is hidden automatically when nothing matches
bool AutoCompGetAutoHide(); 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. // Set the number of spaces used for one level of indentation.
void SetIndent(int indentSize); void SetIndent(int indentSize);
@@ -1369,6 +1422,28 @@ public:
// Retrieve the time the mouse must sit still to generate a mouse dwell event // Retrieve the time the mouse must sit still to generate a mouse dwell event
int GetMouseDwellTime(); 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 // Move the caret inside current view if it's not there already
void MoveCaretInsideView(); void MoveCaretInsideView();
@@ -1487,6 +1562,13 @@ public:
// Get cursor type // Get cursor type
int GetCursor(); 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 // Move to the previous change in capitalistion
void WordPartLeft(); void WordPartLeft();
@@ -1508,6 +1590,10 @@ public:
// Delete forwards from the current position to the end of the line // Delete forwards from the current position to the end of the line
void DelLineRight(); 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. // Start notifying the container of all key presses and commands.
void StartRecord(); void StartRecord();

View File

@@ -34,6 +34,9 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
KeyMap.o \ KeyMap.o \
KeyWords.o \ KeyWords.o \
LexAVE.o \ LexAVE.o \
LexBaan.o \
LexBullant.o \
LexMatlab.o \
LexAda.o \ LexAda.o \
LexCPP.o \ LexCPP.o \
LexConf.o \ LexConf.o \
@@ -61,7 +64,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
DEPFILES=$(OBJECTS:.o=.d) 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 include $(top_builddir)/src/makelib.env

View File

@@ -6,7 +6,10 @@
#include <ctype.h> #include <ctype.h>
#include <wx/wx.h>
#include "Platform.h" #include "Platform.h"
#include "PlatWX.h"
#include "wx/stc/stc.h" #include "wx/stc/stc.h"
@@ -14,6 +17,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#endif #endif
Point Point::FromLong(long lpoint) { Point Point::FromLong(long lpoint) {
return Point(lpoint & 0xFFFF, lpoint >> 16); return Point(lpoint & 0xFFFF, lpoint >> 16);
} }
@@ -29,35 +33,12 @@ PRectangle PRectangleFromwxRect(wxRect rc) {
rc.GetRight()+1, rc.GetBottom()+1); rc.GetRight()+1, rc.GetBottom()+1);
} }
Colour::Colour(long lcol) { wxColour wxColourFromCA(const ColourAllocated& ca) {
co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff); 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() { Palette::Palette() {
used = 0; used = 0;
@@ -84,7 +65,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
if (used < numEntries) { if (used < numEntries) {
entries[used].desired = cp.desired; entries[used].desired = cp.desired;
entries[used].allocated = cp.desired; entries[used].allocated.Set(cp.desired.AsLong());
used++; used++;
} }
} else { } else {
@@ -94,7 +75,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
return; return;
} }
} }
cp.allocated = cp.desired; cp.allocated.Set(cp.desired.AsLong());
} }
} }
@@ -104,6 +85,8 @@ void Palette::Allocate(Window &) {
} }
//----------------------------------------------------------------------
Font::Font() { Font::Font() {
id = 0; id = 0;
ascent = 0; ascent = 0;
@@ -113,36 +96,172 @@ Font::~Font() {
} }
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) { void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
// TODO: what to do about the characterSet? wxFontEncoding encoding;
Release(); 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, id = new wxFont(size,
wxDEFAULT, wxDEFAULT,
italic ? wxITALIC : wxNORMAL, italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL, bold ? wxBOLD : wxNORMAL,
false, false,
faceName, faceName,
wxFONTENCODING_DEFAULT); encoding);
} }
void Font::Release() { void Font::Release() {
if (id) if (id)
delete id; delete (wxFont*)id;
id = 0; 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), hdc(0), hdcOwned(0), bitmap(0),
x(0), y(0) { x(0), y(0), unicodeMode(0)
} {}
Surface::~Surface() { SurfaceImpl::~SurfaceImpl() {
Release(); Release();
} }
void Surface::Release() { void SurfaceImpl::Release() {
if (bitmap) { if (bitmap) {
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap); ((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
delete bitmap; delete bitmap;
@@ -156,24 +275,24 @@ void Surface::Release() {
} }
bool Surface::Initialised() { bool SurfaceImpl::Initialised() {
return hdc != 0; return hdc != 0;
} }
void Surface::Init() { void SurfaceImpl::Init() {
Release(); Release();
hdc = new wxMemoryDC(); hdc = new wxMemoryDC();
hdcOwned = true; hdcOwned = true;
} }
void Surface::Init(SurfaceID hdc_) { void SurfaceImpl::Init(SurfaceID hdc_) {
Release(); 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(); Release();
hdc = new wxMemoryDC(surface_->hdc); hdc = new wxMemoryDC();
hdcOwned = true; hdcOwned = true;
if (width < 1) width = 1; if (width < 1) width = 1;
if (height < 1) height = 1; if (height < 1) height = 1;
@@ -181,64 +300,63 @@ void Surface::InitPixMap(int width, int height, Surface *surface_) {
((wxMemoryDC*)hdc)->SelectObject(*bitmap); ((wxMemoryDC*)hdc)->SelectObject(*bitmap);
} }
void Surface::PenColour(Colour fore) { void SurfaceImpl::PenColour(ColourAllocated fore) {
hdc->SetPen(wxPen(fore.co, 1, wxSOLID)); hdc->SetPen(wxPen(wxColourFromCA(fore), 1, wxSOLID));
} }
void Surface::BrushColor(Colour back) { void SurfaceImpl::BrushColour(ColourAllocated back) {
hdc->SetBrush(wxBrush(back.co, wxSOLID)); hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID));
} }
void Surface::SetFont(Font &font_) { void SurfaceImpl::SetFont(Font &font_) {
if (font_.GetID()) { if (font_.GetID()) {
hdc->SetFont(*font_.GetID()); hdc->SetFont(*((wxFont*)font_.GetID()));
} }
} }
int Surface::LogPixelsY() { int SurfaceImpl::LogPixelsY() {
return hdc->GetPPI().y; return hdc->GetPPI().y;
} }
int SurfaceImpl::DeviceHeightFont(int points) {
int Surface::DeviceHeightFont(int points) {
return points; return points;
// int logPix = LogPixelsY();
// return (points * logPix + logPix / 2) / 72;
} }
void SurfaceImpl::MoveTo(int x_, int y_) {
void Surface::MoveTo(int x_, int y_) {
x = x_; x = x_;
y = y_; y = y_;
} }
void Surface::LineTo(int x_, int y_) { void SurfaceImpl::LineTo(int x_, int y_) {
hdc->DrawLine(x,y, x_,y_); hdc->DrawLine(x,y, x_,y_);
x = x_; x = x_;
y = y_; y = y_;
} }
void Surface::Polygon(Point *pts, int npts, Colour fore, void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
Colour back) {
PenColour(fore); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawPolygon(npts, (wxPoint*)pts); 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); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawRectangle(wxRectFromPRectangle(rc)); hdc->DrawRectangle(wxRectFromPRectangle(rc));
} }
void Surface::FillRectangle(PRectangle rc, Colour back) { void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
BrushColor(back); BrushColour(back);
hdc->SetPen(*wxTRANSPARENT_PEN); hdc->SetPen(*wxTRANSPARENT_PEN);
hdc->DrawRectangle(wxRectFromPRectangle(rc)); hdc->DrawRectangle(wxRectFromPRectangle(rc));
} }
void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) { void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
wxBrush br; wxBrush br;
if (surfacePattern.bitmap) if (((SurfaceImpl&)surfacePattern).bitmap)
br = wxBrush(*surfacePattern.bitmap); br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap);
else // Something is wrong so display in red else // Something is wrong so display in red
br = wxBrush(*wxRED, wxSOLID); br = wxBrush(*wxRED, wxSOLID);
hdc->SetPen(*wxTRANSPARENT_PEN); hdc->SetPen(*wxTRANSPARENT_PEN);
@@ -246,79 +364,112 @@ void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
hdc->DrawRectangle(wxRectFromPRectangle(rc)); hdc->DrawRectangle(wxRectFromPRectangle(rc));
} }
void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) { void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4); 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); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawEllipse(wxRectFromPRectangle(rc)); 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); wxRect r = wxRectFromPRectangle(rc);
hdc->Blit(r.x, r.y, r.width, r.height, 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, void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
const char *s, int len, Colour fore, Colour back) { const char *s, int len,
ColourAllocated fore, ColourAllocated back) {
SetFont(font); SetFont(font);
hdc->SetTextForeground(fore.co); hdc->SetTextForeground(wxColourFromCA(fore));
hdc->SetTextBackground(back.co); hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, 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 // 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... // 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); SetFont(font);
hdc->SetTextForeground(fore.co); hdc->SetTextForeground(wxColourFromCA(fore));
hdc->SetTextBackground(back.co); hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back); FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc)); 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 // see comments above
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent); hdc->DrawText(str, rc.left, ybase - font.ascent);
hdc->DestroyClippingRegion(); hdc->DestroyClippingRegion();
} }
int Surface::WidthText(Font &font, const char *s, int len) { int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
SetFont(font); SetFont(font);
int w; int w;
int h; 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; 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); SetFont(font);
int totalWidth = 0; int totalWidth = 0;
for (int i=0; i<len; i++) { for (size_t i=0; i<(size_t)len; i++) {
int w; int w;
int h; int h;
hdc->GetTextExtent(s[i], &w, &h); hdc->GetTextExtent(str[i], &w, &h);
totalWidth += w; totalWidth += w;
positions[i] = totalWidth; positions[i] = totalWidth;
} }
} }
int Surface::WidthChar(Font &font, char ch) { int SurfaceImpl::WidthChar(Font &font, char ch) {
SetFont(font); SetFont(font);
int w; int w;
int h; int h;
#if wxUSE_UNICODE
#error fix this... Convert s from UTF-8.
#else
hdc->GetTextExtent(ch, &w, &h); hdc->GetTextExtent(ch, &w, &h);
#endif
return w; return w;
} }
#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" #define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
int Surface::Ascent(Font &font) { int SurfaceImpl::Ascent(Font &font) {
SetFont(font); SetFont(font);
int w, h, d, e; int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
@@ -326,66 +477,81 @@ int Surface::Ascent(Font &font) {
return font.ascent; return font.ascent;
} }
int Surface::Descent(Font &font) { int SurfaceImpl::Descent(Font &font) {
SetFont(font); SetFont(font);
int w, h, d, e; int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return d; return d;
} }
int Surface::InternalLeading(Font &font) { int SurfaceImpl::InternalLeading(Font &font) {
return 0; return 0;
} }
int Surface::ExternalLeading(Font &font) { int SurfaceImpl::ExternalLeading(Font &font) {
SetFont(font); SetFont(font);
int w, h, d, e; int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return e; return e;
} }
int Surface::Height(Font &font) { int SurfaceImpl::Height(Font &font) {
SetFont(font); SetFont(font);
return hdc->GetCharHeight(); return hdc->GetCharHeight();
} }
int Surface::AverageCharWidth(Font &font) { int SurfaceImpl::AverageCharWidth(Font &font) {
SetFont(font); SetFont(font);
return hdc->GetCharWidth(); return hdc->GetCharWidth();
} }
int Surface::SetPalette(Palette *pal, bool inBackGround) { int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
return 0; return 0;
} }
void Surface::SetClip(PRectangle rc) { void SurfaceImpl::SetClip(PRectangle rc) {
hdc->SetClippingRegion(wxRectFromPRectangle(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() { Window::~Window() {
} }
void Window::Destroy() { void Window::Destroy() {
if (id) if (id)
id->Destroy(); GETWIN(id)->Destroy();
id = 0; id = 0;
} }
bool Window::HasFocus() { bool Window::HasFocus() {
return wxWindow::FindFocus() == id; return wxWindow::FindFocus() == GETWIN(id);
} }
PRectangle Window::GetPosition() { PRectangle Window::GetPosition() {
wxRect rc(id->GetPosition(), id->GetSize()); wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize());
return PRectangleFromwxRect(rc); return PRectangleFromwxRect(rc);
} }
void Window::SetPosition(PRectangle rc) { void Window::SetPosition(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc); wxRect r = wxRectFromPRectangle(rc);
id->SetSize(r); GETWIN(id)->SetSize(r);
} }
void Window::SetPositionRelative(PRectangle rc, Window) { void Window::SetPositionRelative(PRectangle rc, Window) {
@@ -393,25 +559,25 @@ void Window::SetPositionRelative(PRectangle rc, Window) {
} }
PRectangle Window::GetClientPosition() { PRectangle Window::GetClientPosition() {
wxSize sz = id->GetClientSize(); wxSize sz = GETWIN(id)->GetClientSize();
return PRectangle(0, 0, sz.x, sz.y); return PRectangle(0, 0, sz.x, sz.y);
} }
void Window::Show(bool show) { void Window::Show(bool show) {
id->Show(show); GETWIN(id)->Show(show);
} }
void Window::InvalidateAll() { void Window::InvalidateAll() {
id->Refresh(false); GETWIN(id)->Refresh(false);
} }
void Window::InvalidateRectangle(PRectangle rc) { void Window::InvalidateRectangle(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc); wxRect r = wxRectFromPRectangle(rc);
id->Refresh(false, &r); GETWIN(id)->Refresh(false, &r);
} }
void Window::SetFont(Font &font) { void Window::SetFont(Font &font) {
id->SetFont(*font.GetID()); GETWIN(id)->SetFont(*((wxFont*)font.GetID()));
} }
void Window::SetCursor(Cursor curs) { void Window::SetCursor(Cursor curs) {
@@ -444,19 +610,23 @@ void Window::SetCursor(Cursor curs) {
break; break;
} }
id->SetCursor(wxCursor(cursorId)); GETWIN(id)->SetCursor(wxCursor(cursorId));
} }
void Window::SetTitle(const char *s) { 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 // 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 { class wxSTCListBox : public wxListBox {
public: public:
wxSTCListBox(wxWindow* parent, wxWindowID id) wxSTCListBox(wxWindow* parent, wxWindowID id)
@@ -532,7 +702,9 @@ BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase)
END_EVENT_TABLE() 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) { 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) { void ListBox::SetVisibleRows(int rows) {
@@ -569,7 +741,7 @@ void ListBox::SetAverageCharWidth(int width) {
} }
void ListBox::SetFont(Font &font) { void ListBox::SetFont(Font &font) {
GETLB(id)->SetFont(*font.GetID()); GETLB(id)->SetFont(*((wxFont*)font.GetID()));
} }
void ListBox::Clear() { void ListBox::Clear() {
@@ -605,14 +777,18 @@ int ListBox::Find(const char *prefix) {
} }
void ListBox::GetValue(int n, char *value, int len) { void ListBox::GetValue(int n, char *value, int len) {
#if wxUSE_UNICODE
#error fix this...
wxString text = GETLB(id)->GetString(n); wxString text = GETLB(id)->GetString(n);
strncpy(value, text.c_str(), len); strncpy(value, text.c_str(), len);
value[len-1] = '\0'; value[len-1] = '\0';
#endif
} }
void ListBox::Sort() { void ListBox::Sort() {
} }
//----------------------------------------------------------------------
Menu::Menu() : id(0) { Menu::Menu() : id(0) {
} }
@@ -624,26 +800,27 @@ void Menu::CreatePopUp() {
void Menu::Destroy() { void Menu::Destroy() {
if (id) if (id)
delete id; delete (wxMenu*)id;
id = 0; id = 0;
} }
void Menu::Show(Point pt, Window &w) { 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(); Destroy();
} }
//----------------------------------------------------------------------
Colour Platform::Chrome() { ColourDesired Platform::Chrome() {
wxColour c; wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); 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; wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT); 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() { 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
View File

@@ -0,0 +1,8 @@
wxRect wxRectFromPRectangle(PRectangle prc);
PRectangle PRectangleFromwxRect(wxRect rc);
wxColour wxColourFromCA(const ColourAllocated& ca);

View File

@@ -14,10 +14,10 @@
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include <ctype.h>
#include "ScintillaWX.h" #include "ScintillaWX.h"
#include "wx/stc/stc.h" #include "wx/stc/stc.h"
#include "PlatWX.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -82,10 +82,10 @@ public:
void OnPaint(wxPaintEvent& evt) { void OnPaint(wxPaintEvent& evt) {
wxPaintDC dc(this); wxPaintDC dc(this);
Surface surfaceWindow; Surface* surfaceWindow = Surface::Allocate();
surfaceWindow.Init(&dc); surfaceWindow->Init(&dc);
m_ct->PaintCT(&surfaceWindow); m_ct->PaintCT(surfaceWindow);
surfaceWindow.Release(); delete surfaceWindow;
} }
#if wxUSE_POPUPWIN #if wxUSE_POPUPWIN
@@ -184,7 +184,7 @@ void ScintillaWX::SetTicking(bool on) {
if (timer.ticking) { if (timer.ticking) {
steTimer = new wxSTCTimer(this); steTimer = new wxSTCTimer(this);
steTimer->Start(timer.tickSize); steTimer->Start(timer.tickSize);
timer.tickerID = (int)steTimer; timer.tickerID = steTimer;
} else { } else {
steTimer = (wxSTCTimer*)timer.tickerID; steTimer = (wxSTCTimer*)timer.tickerID;
steTimer->Stop(); steTimer->Stop();
@@ -343,12 +343,12 @@ void ScintillaWX::CreateCallTipWindow(PRectangle) {
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) { void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
if (!label[0]) if (!label[0])
popup.GetID()->AppendSeparator(); ((wxMenu*)popup.GetID())->AppendSeparator();
else else
popup.GetID()->Append(cmd, label); ((wxMenu*)popup.GetID())->Append(cmd, label);
if (!enabled) 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) { void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
paintState = painting; paintState = painting;
Surface surfaceWindow; Surface* surfaceWindow = Surface::Allocate();
surfaceWindow.Init(dc); surfaceWindow->Init(dc);
PRectangle rcPaint = PRectangleFromwxRect(rect); PRectangle rcPaint = PRectangleFromwxRect(rect);
dc->BeginDrawing(); dc->BeginDrawing();
Paint(&surfaceWindow, rcPaint); Paint(surfaceWindow, rcPaint);
dc->EndDrawing(); dc->EndDrawing();
surfaceWindow.Release(); delete surfaceWindow;
if (paintState == paintAbandoned) { if (paintState == paintAbandoned) {
// Painting area was insufficient to cover new styling or brace highlight positions // Painting area was insufficient to cover new styling or brace highlight positions
FullPaint(); FullPaint();
@@ -466,9 +466,10 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int
void ScintillaWX::DoSize(int width, int height) { void ScintillaWX::DoSize(int width, int height) {
PRectangle rcClient(0,0,width,height); // PRectangle rcClient(0,0,width,height);
SetScrollBarsTo(rcClient); // SetScrollBarsTo(rcClient);
DropGraphics(); // DropGraphics();
ChangeSize();
} }
void ScintillaWX::DoLoseFocus(){ void ScintillaWX::DoLoseFocus(){
@@ -622,10 +623,10 @@ void ScintillaWX::FullPaint() {
rcPaint = GetTextRectangle(); rcPaint = GetTextRectangle();
paintingAllText = true; paintingAllText = true;
wxClientDC dc(stc); wxClientDC dc(stc);
Surface surfaceWindow; Surface* surfaceWindow = Surface::Allocate();
surfaceWindow.Init(&dc); surfaceWindow->Init(&dc);
Paint(&surfaceWindow, rcPaint); Paint(surfaceWindow, rcPaint);
surfaceWindow.Release(); delete surfaceWindow;
// stc->Refresh(FALSE); // stc->Refresh(FALSE);

View File

@@ -19,6 +19,11 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "Platform.h" #include "Platform.h"
#include "Scintilla.h" #include "Scintilla.h"

View File

@@ -7,19 +7,19 @@
CFG=StcVC - Win32 Debug CFG=StcVC - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run !MESSAGE use the Export Makefile command and run
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "StcVC.mak". !MESSAGE NMAKE /f "StcVC.mak".
!MESSAGE !MESSAGE
!MESSAGE You can specify a configuration when running NMAKE !MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug" !MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug"
!MESSAGE !MESSAGE
!MESSAGE Possible choices for configuration are: !MESSAGE Possible choices for configuration are:
!MESSAGE !MESSAGE
!MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE !MESSAGE
# Begin Project # Begin Project
# PROP AllowPerConfigDependencies 0 # PROP AllowPerConfigDependencies 0
@@ -76,7 +76,7 @@ LIB32=link.exe -lib
# ADD BASE LIB32 /nologo # ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\lib\stcd.lib" # ADD LIB32 /nologo /out:"..\..\lib\stcd.lib"
!ENDIF !ENDIF
# Begin Target # Begin Target
@@ -187,6 +187,18 @@ SOURCE=.\scintilla\src\LexAVE.cxx
# End Source File # End Source File
# Begin 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 SOURCE=.\scintilla\src\LexConf.cxx
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -154,7 +154,7 @@ methodOverrideMap = {
MarkerSetBackground(markerNumber, background);''', MarkerSetBackground(markerNumber, background);''',
('Set the symbol used for a particular marker number,', ('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), 'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0), 'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
@@ -226,6 +226,8 @@ methodOverrideMap = {
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0), 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0), 'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0), 'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0), 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),

View File

@@ -17,7 +17,7 @@ SCINTILLA=.\scintilla
S=$(SCINTILLA)\src 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 LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
@@ -34,6 +34,9 @@ OBJECTS = \
KeyWords.obj \ KeyWords.obj \
LexAVE.obj \ LexAVE.obj \
LexAda.obj \ LexAda.obj \
LexBaan.obj \
LexBullant.obj \
LexMatlab.obj \
LexCPP.obj \ LexCPP.obj \
LexConf.obj \ LexConf.obj \
LexCrontab.obj \ LexCrontab.obj \

View File

@@ -7,7 +7,7 @@ WXDIR = ../../..
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
S=$(SCINTILLA)/src 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 = \ OBJECTS = \
$(S)/AutoComplete.$(OBJSUFF) \ $(S)/AutoComplete.$(OBJSUFF) \
@@ -22,6 +22,9 @@ OBJECTS = \
$(S)/KeyWords.$(OBJSUFF) \ $(S)/KeyWords.$(OBJSUFF) \
$(S)/LexAVE.$(OBJSUFF) \ $(S)/LexAVE.$(OBJSUFF) \
$(S)/LexAda.$(OBJSUFF) \ $(S)/LexAda.$(OBJSUFF) \
$(S)/LexBaan.$(OBJSUFF) \
$(S)/LexBullant.$(OBJSUFF) \
$(S)/LexMatlab.$(OBJSUFF) \
$(S)/LexCPP.$(OBJSUFF) \ $(S)/LexCPP.$(OBJSUFF) \
$(S)/LexConf.$(OBJSUFF) \ $(S)/LexConf.$(OBJSUFF) \
$(S)/LexCrontab.$(OBJSUFF) \ $(S)/LexCrontab.$(OBJSUFF) \

View File

@@ -9,7 +9,7 @@
WXDIR = $(WXWIN) WXDIR = $(WXWIN)
SCINTILLA=.\scintilla SCINTILLA=.\scintilla
S=$(SCINTILLA)\src 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 NOPCH=1
!include $(WXDIR)\src\makevc.env !include $(WXDIR)\src\makevc.env
@@ -27,6 +27,9 @@ OBJECTS = \
$(D)\KeyWords.obj \ $(D)\KeyWords.obj \
$(D)\LexAVE.obj \ $(D)\LexAVE.obj \
$(D)\LexAda.obj \ $(D)\LexAda.obj \
$(D)\LexBaan.obj \
$(D)\LexBullant.obj \
$(D)\LexMatlab.obj \
$(D)\LexCPP.obj \ $(D)\LexCPP.obj \
$(D)\LexConf.obj \ $(D)\LexConf.obj \
$(D)\LexCrontab.obj \ $(D)\LexCrontab.obj \

View File

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

View File

@@ -15,25 +15,25 @@ typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyl
*/ */
class LexerModule { class LexerModule {
protected: protected:
LexerModule *next; const LexerModule *next;
int language; int language;
const char *languageName;
LexerFunction fnLexer; LexerFunction fnLexer;
LexerFunction fnFolder; LexerFunction fnFolder;
static LexerModule *base; static const LexerModule *base;
static int nextLanguage; static int nextLanguage;
public: public:
const char *languageName;
LexerModule(int language_, LexerFunction fnLexer_, LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_=0, LexerFunction fnFolder_=0); 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, 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, virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler); WordList *keywordlists[], Accessor &styler) const;
static LexerModule *Find(int language); static const LexerModule *Find(int language);
static LexerModule *Find(const char *languageName); static const LexerModule *Find(const char *languageName);
}; };
/** /**

View File

@@ -3,7 +3,7 @@
** Interface to platform facilities. Also includes some basic utilities. ** Interface to platform facilities. Also includes some basic utilities.
** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows. ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
**/ **/
// Copyright 1998-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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PLATFORM_H #ifndef PLATFORM_H
@@ -18,8 +18,13 @@
#define PLAT_GTK_WIN32 0 #define PLAT_GTK_WIN32 0
#define PLAT_WIN 0 #define PLAT_WIN 0
#define PLAT_WX 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 #undef PLAT_WX
#define PLAT_WX 1 #define PLAT_WX 1
@@ -39,79 +44,14 @@
#endif #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. // 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 // Sometimes these need to be passed around by client code so they are defined here
#if PLAT_GTK typedef void *FontID;
typedef GdkColor ColourID; typedef void *SurfaceID;
typedef GdkFont* FontID; typedef void *WindowID;
typedef GdkDrawable* SurfaceID; typedef void *MenuID;
typedef GtkWidget* WindowID; typedef void *TickerID;
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
/** /**
* A geometric point class. * A geometric point class.
@@ -168,42 +108,88 @@ public:
int Height() { return bottom - top; } int Height() { return bottom - top; }
}; };
#if PLAT_WX /**
wxRect wxRectFromPRectangle(PRectangle prc); * In some circumstances, including Win32 in paletted mode and GTK+, each colour
PRectangle PRectangleFromwxRect(wxRect rc); * must be allocated before use. The desired colours are held in the ColourDesired class,
#endif * 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 { class ColourDesired {
ColourID co; long co;
public: public:
Colour(long lcol=0); ColourDesired(long lcol=0) {
Colour(unsigned int red, unsigned int green, unsigned int blue); co = lcol;
bool operator==(const Colour &other) const; }
long AsLong() const;
unsigned int GetRed();
unsigned int GetGreen();
unsigned int GetBlue();
friend class Surface; ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
friend class Palette; 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 * Holds an allocated RGB colour which may be an approximation to the desired colour.
* allocates to approximate the desired colour. */
* To make palette management more automatic, ColourPairs could register at class ColourAllocated {
* construction time with a palette management object. 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 { struct ColourPair {
Colour desired; ColourDesired desired;
Colour allocated; ColourAllocated allocated;
ColourPair(Colour desired_=Colour(0,0,0)) { ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
desired = desired_; desired = desired_;
allocated = desired; allocated.Set(desired.AsLong());
} }
}; };
@@ -217,14 +203,13 @@ class Palette {
enum {numEntries = 100}; enum {numEntries = 100};
ColourPair entries[numEntries]; ColourPair entries[numEntries];
#if PLAT_GTK #if PLAT_GTK
GdkColor *allocatedPalette; void *allocatedPalette; // GdkColor *
int allocatedLen; int allocatedLen;
#elif PLAT_WIN
HPALETTE hpal;
#elif PLAT_WX
// wxPalette* pal; // **** Is this needed?
#endif #endif
public: public:
#if PLAT_WIN
void *hpal;
#endif
bool allowRealization; bool allowRealization;
Palette(); Palette();
@@ -240,8 +225,6 @@ public:
void WantFind(ColourPair &cp, bool want); void WantFind(ColourPair &cp, bool want);
void Allocate(Window &w); void Allocate(Window &w);
friend class Surface;
}; };
/** /**
@@ -267,6 +250,7 @@ public:
// Alias another font - caller guarantees not to Release // Alias another font - caller guarantees not to Release
void SetID(FontID id_) { id = id_; } void SetID(FontID id_) { id = id_; }
friend class Surface; friend class Surface;
friend class SurfaceImpl;
}; };
/** /**
@@ -274,97 +258,67 @@ public:
*/ */
class Surface { class Surface {
private: 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 // Private so Surface objects can not be copied
Surface(const Surface &) {} Surface(const Surface &) {}
Surface &operator=(const Surface &) { return *this; } Surface &operator=(const Surface &) { return *this; }
#if PLAT_WIN || PLAT_WX
void BrushColor(Colour back);
void SetFont(Font &font_);
#endif
public: public:
Surface(); Surface() {};
~Surface(); virtual ~Surface() {};
static Surface *Allocate();
void Init(); virtual void Init()=0;
void Init(SurfaceID hdc_); virtual void Init(SurfaceID sid)=0;
void InitPixMap(int width, int height, Surface *surface_); virtual void InitPixMap(int width, int height, Surface *surface_)=0;
void Release(); virtual void Release()=0;
bool Initialised(); virtual bool Initialised()=0;
void PenColour(Colour fore); virtual void PenColour(ColourAllocated fore)=0;
int LogPixelsY(); virtual int LogPixelsY()=0;
int DeviceHeightFont(int points); virtual int DeviceHeightFont(int points)=0;
void MoveTo(int x_, int y_); virtual void MoveTo(int x_, int y_)=0;
void LineTo(int x_, int y_); virtual void LineTo(int x_, int y_)=0;
void Polygon(Point *pts, int npts, Colour fore, Colour back); virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
void RectangleDraw(PRectangle rc, Colour fore, Colour back); virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
void FillRectangle(PRectangle rc, Colour back); virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
void FillRectangle(PRectangle rc, Surface &surfacePattern); virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
void RoundedRectangle(PRectangle rc, Colour fore, Colour back); virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
void Ellipse(PRectangle rc, Colour fore, Colour back); virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
void Copy(PRectangle rc, Point from, Surface &surfaceSource); 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); virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back); virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
void MeasureWidths(Font &font_, const char *s, int len, int *positions); virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
int WidthText(Font &font_, const char *s, int len); virtual int WidthText(Font &font_, const char *s, int len)=0;
int WidthChar(Font &font_, char ch); virtual int WidthChar(Font &font_, char ch)=0;
int Ascent(Font &font_); virtual int Ascent(Font &font_)=0;
int Descent(Font &font_); virtual int Descent(Font &font_)=0;
int InternalLeading(Font &font_); virtual int InternalLeading(Font &font_)=0;
int ExternalLeading(Font &font_); virtual int ExternalLeading(Font &font_)=0;
int Height(Font &font_); virtual int Height(Font &font_)=0;
int AverageCharWidth(Font &font_); virtual int AverageCharWidth(Font &font_)=0;
int SetPalette(Palette *pal, bool inBackGround); virtual int SetPalette(Palette *pal, bool inBackGround)=0;
void SetClip(PRectangle rc); virtual void SetClip(PRectangle rc)=0;
void FlushCachedState(); virtual void FlushCachedState()=0;
void SetUnicodeMode(bool unicodeMode_) { virtual void SetUnicodeMode(bool unicodeMode_)=0;
unicodeMode=unicodeMode_;
}
}; };
/**
* A simple callback action passing one piece of untyped user data.
*/
typedef void (*CallBackAction)(void*);
/** /**
* Class to hide the details of window manipulation. * Class to hide the details of window manipulation.
* Does not own the window which will normally have a longer life than this object. * Does not own the window which will normally have a longer life than this object.
*/ */
class Window { class Window {
friend class ListBox;
protected: protected:
WindowID id; WindowID id;
public: public:
Window() : id(0) {} Window() : id(0), cursorLast(cursorInvalid) {}
Window(const Window &source) : id(source.id) {} Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
virtual ~Window(); virtual ~Window();
Window &operator=(WindowID id_) { Window &operator=(WindowID id_) {
id = id_; id = id_;
@@ -382,20 +336,19 @@ public:
void InvalidateAll(); void InvalidateAll();
void InvalidateRectangle(PRectangle rc); void InvalidateRectangle(PRectangle rc);
virtual void SetFont(Font &font); 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 SetCursor(Cursor curs);
void SetTitle(const char *s); void SetTitle(const char *s);
#if PLAT_WIN private:
LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0); Cursor cursorLast;
int GetDlgCtrlID();
HINSTANCE GetInstance();
#endif
}; };
/** /**
* Listbox management. * Listbox management.
*/ */
class ListBox : public Window { class ListBox : public Window {
private:
#if PLAT_GTK #if PLAT_GTK
WindowID list; WindowID list;
WindowID scroller; WindowID scroller;
@@ -404,6 +357,9 @@ class ListBox : public Window {
int desiredVisibleRows; int desiredVisibleRows;
unsigned int maxItemCharacters; unsigned int maxItemCharacters;
unsigned int aveCharWidth; unsigned int aveCharWidth;
public:
CallBackAction doubleClickAction;
void *doubleClickActionData;
public: public:
ListBox(); ListBox();
virtual ~ListBox(); virtual ~ListBox();
@@ -420,6 +376,10 @@ public:
int Find(const char *prefix); int Find(const char *prefix);
void GetValue(int n, char *value, int len); void GetValue(int n, char *value, int len);
void Sort(); void Sort();
void SetDoubleClickAction(CallBackAction action, void *data) {
doubleClickAction = action;
doubleClickActionData = data;
}
}; };
/** /**
@@ -435,6 +395,14 @@ public:
void Show(Point pt, Window &w); 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 * 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. * and chrome colour. Not a creatable object, more of a module with several functions.
@@ -448,8 +416,8 @@ public:
// but gcc warns about this // but gcc warns about this
Platform() {} Platform() {}
~Platform() {} ~Platform() {}
static Colour Chrome(); static ColourDesired Chrome();
static Colour ChromeHighlight(); static ColourDesired ChromeHighlight();
static const char *DefaultFont(); static const char *DefaultFont();
static int DefaultFontSize(); static int DefaultFontSize();
static unsigned int DoubleClickTime(); static unsigned int DoubleClickTime();
@@ -457,6 +425,7 @@ public:
static bool IsKeyDown(int key); static bool IsKeyDown(int key);
static long SendScintilla( static long SendScintilla(
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0); WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
static bool IsDBCSLeadByte(int codePage, char ch);
// These are utility functions not really tied to a platform // These are utility functions not really tied to a platform
static int Minimum(int a, int b); static int Minimum(int a, int b);
@@ -483,4 +452,9 @@ public:
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__)) #define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif #endif
// Shut up annoying Visual C++ warnings:
#ifdef _MSC_VER
#pragma warning(disable: 4244 4309 4514 4710)
#endif
#endif #endif

View File

@@ -2,7 +2,7 @@
/** @file PropSet.h /** @file PropSet.h
** A Java style properties file module. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PROPSET_H #ifndef PROPSET_H
@@ -41,7 +41,7 @@ public:
SString Expand(const char *withVars); SString Expand(const char *withVars);
int GetInt(const char *key, int defaultValue=0); int GetInt(const char *key, int defaultValue=0);
SString GetWild(const char *keybase, const char *filename); SString GetWild(const char *keybase, const char *filename);
SString GetNewExpand(const char *keybase, const char *filename); SString GetNewExpand(const char *keybase, const char *filename="");
void Clear(); void Clear();
char *ToString(); // Caller must delete[] the return value char *ToString(); // Caller must delete[] the return value
bool GetFirst(char **key, char **val); bool GetFirst(char **key, char **val);
@@ -70,7 +70,8 @@ public:
char *Allocate(int size); char *Allocate(int size);
void SetFromAllocated(); void SetFromAllocated();
bool InList(const char *s); bool InList(const char *s);
const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false); const char *GetNearestWord(const char *wordStart, int searchLen = -1,
bool ignoreCase = false, SString wordCharacters="");
char *GetNearestWords(const char *wordStart, int searchLen=-1, char *GetNearestWords(const char *wordStart, int searchLen=-1,
bool ignoreCase=false, char otherSeparator='\0'); bool ignoreCase=false, char otherSeparator='\0');
}; };

View File

@@ -8,7 +8,7 @@
#ifndef SSTRING_H #ifndef SSTRING_H
#define 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 CompareCaseInsensitive(const char *a, const char *b);
int CompareNCaseInsensitive(const char *a, const char *b, int len); int CompareNCaseInsensitive(const char *a, const char *b, int len);
bool EqualCaseInsensitive(const char *a, const char *b); 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. // While it would be 'better' to use std::string, that doubles the executable size.
// An SString may contain embedded nul characters. // 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. * @brief A simple string class.
*
* Hold the length of the string for quick operations, * 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. * 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 * 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. * functions to allow reliable manipulations of these strings.
**/ **/
class SString { 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: 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
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) { lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
s = StringDup(source.s); lenpos_t sLen; ///< The size of the string in s
sSize = sLen = (s) ? strlen(s) : 0; lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
} enum { sizeGrowthDefault = 64 };
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) { bool grow(lenpos_t lenNew) {
s = StringDup(s_); while (sizeGrowth * 6 < lenNew) {
sSize = sLen = (s) ? strlen(s) : 0; sizeGrowth *= 2;
}
SString(const char *s_, int first, int last) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(s_ + first, last - first);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(int i) : sizeGrowth(sizeGrowthDefault) {
char number[32];
sprintf(number, "%0d", i);
s = StringDup(number);
sSize = sLen = (s) ? strlen(s) : 0;
}
~SString() {
delete []s;
s = 0;
sSize = 0;
sLen = 0;
}
void clear(void) {
if (s) {
*s = '\0';
} }
sLen = 0; char *sNew = new char[lenNew + sizeGrowth + 1];
if (sNew) {
if (s) {
memcpy(sNew, s, sLen);
delete []s;
}
s = sNew;
s[sLen] = '\0';
sSize = lenNew + sizeGrowth;
}
return sNew != 0;
} }
/** Size of buffer. */
size_type size(void) const { ///< SString &assign(const char *sOther, lenpos_t sSize_=measure_length) {
if (s)
return sSize;
else
return 0;
}
/** Size of string in buffer. */
int length() const {
return sLen;
}
SString &assign(const char* sOther, int sSize_ = -1) {
if (!sOther) { if (!sOther) {
sSize_ = 0; sSize_ = 0;
} } else if (sSize_ == measure_length) {
if (sSize_ < 0) {
sSize_ = strlen(sOther); sSize_ = strlen(sOther);
} }
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
@@ -114,7 +69,7 @@ public:
sLen = sSize_; sLen = sSize_;
} else { } else {
delete []s; delete []s;
s = StringDup(sOther, sSize_); s = StringAllocate(sOther, sSize_);
if (s) { if (s) {
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
sLen = strlen(s); sLen = strlen(s);
@@ -124,8 +79,56 @@ public:
} }
return *this; 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) { SString &operator=(const char *source) {
return assign(source); return assign(source);
@@ -162,7 +165,7 @@ public:
else else
return false; return false;
} }
void setsizegrowth(int sizeGrowth_) { void setsizegrowth(lenpos_t sizeGrowth_) {
sizeGrowth = sizeGrowth_; sizeGrowth = sizeGrowth_;
} }
const char *c_str() const { const char *c_str() const {
@@ -179,77 +182,167 @@ public:
sLen = 0; sLen = 0;
return sRet; 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 if (s && i < sSize) // Or < sLen? Depends on the use, both are OK
return s[i]; return s[i];
else else
return '\0'; return '\0';
} }
SString &append(const char* sOther, int sLenOther=-1, char sep=0) { SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') {
if (sLenOther < 0) if (!sOther) {
return *this;
}
if (sLenOther == measure_length) {
sLenOther = strlen(sOther); sLenOther = strlen(sOther);
}
int lenSep = 0; 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; 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 // Conservative about growing the buffer: don't do it, unless really needed
if ((lenNew + 1 < sSize) || (grow(lenNew))) {
if (lenSep) { if (lenSep) {
s[sLen] = sep; s[sLen] = sep;
sLen++; sLen++;
} }
strncpy(&s[sLen], sOther, sLenOther); strncpy(&s[sLen], sOther, sLenOther);
s[sLen + sLenOther] = '\0';
sLen += sLenOther; sLen += sLenOther;
} else { s[sLen] = '\0';
// Grow the buffer bigger than really needed, to have room for other appends
char *sNew = new char[lenNew + sizeGrowth + 1];
if (sNew) {
if (s) {
memcpy(sNew, s, sLen);
delete []s;
}
s = sNew;
sSize = lenNew + sizeGrowth;
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
sNew[sLen + sLenOther] = '\0';
sLen += sLenOther;
}
} }
return *this; return *this;
} }
SString &operator +=(const char *sOther) { SString &operator+=(const char *sOther) {
return append(sOther, -1); 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); return append(sOther.s, sOther.sSize);
} }
SString &operator +=(char ch) { SString &operator+=(char ch) {
return append(&ch, 1); return append(&ch, 1);
} }
SString &appendwithseparator(const char* sOther, char sep) { SString &appendwithseparator(const char *sOther, char sep) {
return append(sOther, strlen(sOther), 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 { int value() const {
if (s) if (s)
return atoi(s); return atoi(s);
else else
return 0; return 0;
} }
void substitute(char find, char replace) { int search(const char *sFind, lenpos_t start=0) {
char *t = s; if (start < sLen) {
while (t) { const char *sFound = strstr(s + start, sFind);
t = strchr(t, find); if (sFound) {
if (t) { return sFound - s;
*t = replace;
t++;
} }
} }
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, chFind);
if (t) {
*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 #endif

View File

@@ -2,7 +2,7 @@
/** @file SciLexer.h /** @file SciLexer.h
** Interface to the added lexer functions in the SciLexer version of the edit control. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -41,6 +41,12 @@
#define SCLEX_EIFFELKW 24 #define SCLEX_EIFFELKW 24
#define SCLEX_TCL 25 #define SCLEX_TCL 25
#define SCLEX_NNCRONTAB 26 #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 SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0 #define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1 #define SCE_P_COMMENTLINE 1
@@ -75,6 +81,15 @@
#define SCE_C_WORD2 16 #define SCE_C_WORD2 16
#define SCE_C_COMMENTDOCKEYWORD 17 #define SCE_C_COMMENTDOCKEYWORD 17
#define SCE_C_COMMENTDOCKEYWORDERROR 18 #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_DEFAULT 0
#define SCE_H_TAG 1 #define SCE_H_TAG 1
#define SCE_H_TAGUNKNOWN 2 #define SCE_H_TAGUNKNOWN 2
@@ -233,6 +248,11 @@
#define SCE_LUA_OPERATOR 10 #define SCE_LUA_OPERATOR 10
#define SCE_LUA_IDENTIFIER 11 #define SCE_LUA_IDENTIFIER 11
#define SCE_LUA_STRINGEOL 12 #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_DEFAULT 0
#define SCE_ERR_PYTHON 1 #define SCE_ERR_PYTHON 1
#define SCE_ERR_GCC 2 #define SCE_ERR_GCC 2
@@ -291,6 +311,17 @@
#define SCE_ADA_OPERATOR 6 #define SCE_ADA_OPERATOR 6
#define SCE_ADA_IDENTIFIER 7 #define SCE_ADA_IDENTIFIER 7
#define SCE_ADA_STRINGEOL 8 #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_DEFAULT 0
#define SCE_LISP_COMMENT 1 #define SCE_LISP_COMMENT 1
#define SCE_LISP_NUMBER 2 #define SCE_LISP_NUMBER 2
@@ -319,6 +350,14 @@
#define SCE_NNCRONTAB_STRING 8 #define SCE_NNCRONTAB_STRING 8
#define SCE_NNCRONTAB_ENVIRONMENT 9 #define SCE_NNCRONTAB_ENVIRONMENT 9
#define SCE_NNCRONTAB_IDENTIFIER 10 #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 //--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif #endif

View File

@@ -2,7 +2,7 @@
/** @file Scintilla.h /** @file Scintilla.h
** Interface to the edit control. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -12,10 +12,11 @@
#define SCINTILLA_H #define SCINTILLA_H
#if PLAT_WIN #if PLAT_WIN
#ifdef STATIC_BUILD // Return false on failure:
void Scintilla_RegisterClasses(HINSTANCE hInstance); bool Scintilla_RegisterClasses(void *hInstance);
#endif bool Scintilla_ReleaseResources();
#endif #endif
int Scintilla_LinkLexers();
// Here should be placed typedefs for uptr_t, an unsigned integer type large enough to // 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. // 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_CIRCLEPLUSCONNECTED 19
#define SC_MARK_CIRCLEMINUS 20 #define SC_MARK_CIRCLEMINUS 20
#define SC_MARK_CIRCLEMINUSCONNECTED 21 #define SC_MARK_CIRCLEMINUSCONNECTED 21
#define SC_MARK_BACKGROUND 22
#define SC_MARK_CHARACTER 10000 #define SC_MARK_CHARACTER 10000
#define SC_MARKNUM_FOLDEREND 25 #define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26 #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_FOLDERSUB 29
#define SC_MARKNUM_FOLDER 30 #define SC_MARKNUM_FOLDER 30
#define SC_MARKNUM_FOLDEROPEN 31 #define SC_MARKNUM_FOLDEROPEN 31
#define SC_MASK_FOLDERS 0xFE000000
#define SCI_MARKERDEFINE 2040 #define SCI_MARKERDEFINE 2040
#define SCI_MARKERSETFORE 2041 #define SCI_MARKERSETFORE 2041
#define SCI_MARKERSETBACK 2042 #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_TT 2
#define INDIC_DIAGONAL 3 #define INDIC_DIAGONAL 3
#define INDIC_STRIKE 4 #define INDIC_STRIKE 4
#define INDIC0_MASK 32 #define INDIC0_MASK 0x20
#define INDIC1_MASK 64 #define INDIC1_MASK 0x40
#define INDIC2_MASK 128 #define INDIC2_MASK 0x80
#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK #define INDICS_MASK 0xE0
#define SCI_INDICSETSTYLE 2080 #define SCI_INDICSETSTYLE 2080
#define SCI_INDICGETSTYLE 2081 #define SCI_INDICGETSTYLE 2081
#define SCI_INDICSETFORE 2082 #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_SETCARETLINEVISIBLE 2096
#define SCI_GETCARETLINEBACK 2097 #define SCI_GETCARETLINEBACK 2097
#define SCI_SETCARETLINEBACK 2098 #define SCI_SETCARETLINEBACK 2098
#define SCI_STYLESETCHANGEABLE 2099
#define SCI_AUTOCSHOW 2100 #define SCI_AUTOCSHOW 2100
#define SCI_AUTOCCANCEL 2101 #define SCI_AUTOCCANCEL 2101
#define SCI_AUTOCACTIVE 2102 #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_USERLISTSHOW 2117
#define SCI_AUTOCSETAUTOHIDE 2118 #define SCI_AUTOCSETAUTOHIDE 2118
#define SCI_AUTOCGETAUTOHIDE 2119 #define SCI_AUTOCGETAUTOHIDE 2119
#define SCI_AUTOCSETDROPRESTOFWORD 2270
#define SCI_AUTOCGETDROPRESTOFWORD 2271
#define SCI_SETINDENT 2122 #define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123 #define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124 #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 SC_TIME_FOREVER 10000000
#define SCI_SETMOUSEDWELLTIME 2264 #define SCI_SETMOUSEDWELLTIME 2264
#define SCI_GETMOUSEDWELLTIME 2265 #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_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301 #define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302 #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_UPPERCASE 2341
#define SCI_LINESCROLLDOWN 2342 #define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343 #define SCI_LINESCROLLUP 2343
#define SCI_DELETEBACKNOTLINE 2344
#define SCI_MOVECARETINSIDEVIEW 2401 #define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350 #define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351 #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 SC_CURSORWAIT 3
#define SCI_SETCURSOR 2386 #define SCI_SETCURSOR 2386
#define SCI_GETCURSOR 2387 #define SCI_GETCURSOR 2387
#define SCI_SETCONTROLCHARSYMBOL 2388
#define SCI_GETCONTROLCHARSYMBOL 2389
#define SCI_WORDPARTLEFT 2390 #define SCI_WORDPARTLEFT 2390
#define SCI_WORDPARTLEFTEXTEND 2391 #define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392 #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_SETVISIBLEPOLICY 2394
#define SCI_DELLINELEFT 2395 #define SCI_DELLINELEFT 2395
#define SCI_DELLINERIGHT 2396 #define SCI_DELLINERIGHT 2396
#define SCI_SETXOFFSET 2397
#define SCI_GETXOFFSET 2398
#define SCI_GRABFOCUS 2400 #define SCI_GRABFOCUS 2400
#define SCI_STARTRECORD 3001 #define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002 #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_KEY 2005
#define SCN_DOUBLECLICK 2006 #define SCN_DOUBLECLICK 2006
#define SCN_UPDATEUI 2007 #define SCN_UPDATEUI 2007
#define SCN_CHECKBRACE 2007
#define SCN_MODIFIED 2008 #define SCN_MODIFIED 2008
#define SCN_MACRORECORD 2009 #define SCN_MACRORECORD 2009
#define SCN_MARGINCLICK 2010 #define SCN_MARGINCLICK 2010
#define SCN_NEEDSHOWN 2011 #define SCN_NEEDSHOWN 2011
#define SCN_POSCHANGED 2012
#define SCN_PAINTED 2013 #define SCN_PAINTED 2013
#define SCN_USERLISTSELECTION 2014 #define SCN_USERLISTSELECTION 2014
#define SCN_URIDROPPED 2015 #define SCN_URIDROPPED 2015
@@ -528,7 +549,7 @@ struct TextToFind {
#ifdef PLATFORM_H #ifdef PLATFORM_H
// This structure is used in printing and requires some of the graphics types // This structure is used in printing and requires some of the graphics types
// from Platform.h. Not needed by most client code. // from Platform.h. Not needed by most client code.
struct RangeToFormat { struct RangeToFormat {
@@ -545,7 +566,7 @@ struct NotifyHeader {
// hwndFrom is really an environment specifc window handle or pointer // hwndFrom is really an environment specifc window handle or pointer
// but most clients of Scintilla.h do not have this type visible. // but most clients of Scintilla.h do not have this type visible.
//WindowID hwndFrom; //WindowID hwndFrom;
void *hwndFrom; void *hwndFrom;
unsigned int idFrom; unsigned int idFrom;
unsigned int code; unsigned int code;
}; };
@@ -571,20 +592,15 @@ struct SCNotification {
int y; // SCN_DWELLSTART, SCN_DWELLEND 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 // Deprecation section listing all API features that are deprecated and will
// will be removed completely in a future version. // will be removed completely in a future version.
// To enable these features define INCLUDE_DEPRECATED_FEATURES // To enable these features define INCLUDE_DEPRECATED_FEATURES
#ifdef INCLUDE_DEPRECATED_FEATURES #ifdef INCLUDE_DEPRECATED_FEATURES
#define SCN_POSCHANGED 2012
#define SCN_CHECKBRACE 2007
#endif #endif
#endif #endif

View File

@@ -2,6 +2,9 @@
## This file defines the interface to Scintilla ## 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 a pure comment and should be stripped by readers.
## A line starting with #! is for future shbang use ## A line starting with #! is for future shbang use
## A line starting with # followed by a space is a documentation comment and refers ## 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>]*]) ## 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 ## Feature names that contain an underscore are defined by Windows, so in these
## cases, using the Windows definition is preferred where available. ## 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: ## Types:
## void ## void
@@ -35,20 +41,27 @@
## string -> pointer to const character ## string -> pointer to const character
## stringresult -> pointer to character ## stringresult -> pointer to character
## cells -> pointer to array of cells, each cell containing a style byte and character byte ## 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 ## charrange -> range of a min and a max position
## charrangeresult -> like charrange, but output param ## 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 ## countedstring
## formatrange
## point -> x,y ## point -> x,y
## pointresult -> like point, but output param ## pointresult -> like point, but output param
## rectangle -> left,top,right,bottom ## rectangle -> left,top,right,bottom
## Client code should ignore definitions containing types it does not understand, except ## Client code should ignore definitions containing types it does not understand, except
## for possibly #defining the constants ## 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 cat Basics
################################################ ################################################
@@ -229,6 +242,9 @@ val SC_MARK_CIRCLEPLUSCONNECTED=19
val SC_MARK_CIRCLEMINUS=20 val SC_MARK_CIRCLEMINUS=20
val SC_MARK_CIRCLEMINUSCONNECTED=21 val SC_MARK_CIRCLEMINUSCONNECTED=21
# Invisible mark that only sets the line background color
val SC_MARK_BACKGROUND=22
val SC_MARK_CHARACTER=10000 val SC_MARK_CHARACTER=10000
# Markers used for outlining column # Markers used for outlining column
@@ -240,6 +256,8 @@ val SC_MARKNUM_FOLDERSUB=29
val SC_MARKNUM_FOLDER=30 val SC_MARKNUM_FOLDER=30
val SC_MARKNUM_FOLDEROPEN=31 val SC_MARKNUM_FOLDEROPEN=31
val SC_MASK_FOLDERS=0xFE000000
# Set the symbol used for a particular marker number. # Set the symbol used for a particular marker number.
fun void MarkerDefine=2040(int markerNumber, int markerSymbol) 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. # Set the background colour used for a particular marker number.
fun void MarkerSetBack=2042(int markerNumber, colour back) fun void MarkerSetBack=2042(int markerNumber, colour back)
# Add a marker to a line. # Add a marker to a line, returning an ID which can be used to find or delete the marker.
fun void MarkerAdd=2043(int line, int markerNumber) fun int MarkerAdd=2043(int line, int markerNumber)
# Delete a marker from a line # Delete a marker from a line
fun void MarkerDelete=2044(int line, int markerNumber) fun void MarkerDelete=2044(int line, int markerNumber)
@@ -413,11 +431,10 @@ val INDIC_SQUIGGLE=1
val INDIC_TT=2 val INDIC_TT=2
val INDIC_DIAGONAL=3 val INDIC_DIAGONAL=3
val INDIC_STRIKE=4 val INDIC_STRIKE=4
val INDIC0_MASK=32 val INDIC0_MASK=0x20
val INDIC1_MASK=64 val INDIC1_MASK=0x40
val INDIC2_MASK=128 val INDIC2_MASK=0x80
val INDICS_MASK=224 val INDICS_MASK=0xE0
##INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
# Set an indicator to plain, squiggle or TT. # Set an indicator to plain, squiggle or TT.
set void IndicSetStyle=2080(int indic, int style) 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? # Is the background of the line containing the caret in a different colour?
get bool GetCaretLineVisible=2095(,) 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,) set void SetCaretLineVisible=2096(bool show,)
# Get the colour of the background of the line containing the caret. # 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 the colour of the background of the line containing the caret.
set void SetCaretLineBack=2098(colour back,) 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. # Display a auto-completion list.
# The lenEntered parameter indicates how many characters before # The lenEntered parameter indicates how many characters before
# the caret should be used to provide context. # the caret should be used to provide context.
@@ -498,7 +519,8 @@ set void AutoCSetCancelAtStart=2110(bool cancel,)
# Retrieve whether auto-completion cancelled by backspacing before start. # Retrieve whether auto-completion cancelled by backspacing before start.
get bool AutoCGetCancelAtStart=2111(,) 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) set void AutoCSetFillUps=2112(, string characterSet)
# Should a single item auto-completion list automatically choose the item. # 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 # Retrieve whether or not autocompletion is hidden automatically when nothing matches
get bool AutoCGetAutoHide=2119(,) 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 the number of spaces used for one level of indentation.
set void SetIndent=2122(int indentSize,) 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 # Retrieve the time the mouse must sit still to generate a mouse dwell event
get int GetMouseDwellTime=2265(,) 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 ## Start of key messages
# Move caret down one line. # Move caret down one line.
fun void LineDown=2300(,) fun void LineDown=2300(,)
@@ -1014,6 +1068,10 @@ fun void LineScrollDown=2342(,)
# Scroll the document up, keeping the caret visible. # Scroll the document up, keeping the caret visible.
fun void LineScrollUp=2343(,) fun void LineScrollUp=2343(,)
# 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 # Move the caret inside current view if it's not there already
fun void MoveCaretInsideView=2401(,) fun void MoveCaretInsideView=2401(,)
@@ -1146,6 +1204,12 @@ set void SetCursor=2386(int cursorType,)
# Get cursor type # Get cursor type
get int GetCursor=2387(,) 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 # Move to the previous change in capitalistion
fun void WordPartLeft=2390(,) fun void WordPartLeft=2390(,)
# Move to the previous change in capitalistion extending selection to new caret position. # 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 # Delete forwards from the current position to the end of the line
fun void DelLineRight=2396(,) 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. # Set the focus to this Scintilla widget.
# GTK+ Specific # GTK+ Specific
fun void GrabFocus=2400(,) fun void GrabFocus=2400(,)
@@ -1273,6 +1341,13 @@ val SCLEX_EIFFEL=23
val SCLEX_EIFFELKW=24 val SCLEX_EIFFELKW=24
val SCLEX_TCL=25 val SCLEX_TCL=25
val SCLEX_NNCRONTAB=26 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 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1. # value assigned in sequence from SCLEX_AUTOMATIC+1.
val SCLEX_AUTOMATIC=1000 val SCLEX_AUTOMATIC=1000
@@ -1291,7 +1366,7 @@ val SCE_P_OPERATOR=10
val SCE_P_IDENTIFIER=11 val SCE_P_IDENTIFIER=11
val SCE_P_COMMENTBLOCK=12 val SCE_P_COMMENTBLOCK=12
val SCE_P_STRINGEOL=13 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_DEFAULT=0
val SCE_C_COMMENT=1 val SCE_C_COMMENT=1
val SCE_C_COMMENTLINE=2 val SCE_C_COMMENTLINE=2
@@ -1311,6 +1386,16 @@ val SCE_C_COMMENTLINEDOC=15
val SCE_C_WORD2=16 val SCE_C_WORD2=16
val SCE_C_COMMENTDOCKEYWORD=17 val SCE_C_COMMENTDOCKEYWORD=17
val SCE_C_COMMENTDOCKEYWORDERROR=18 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 # Lexical states for SCLEX_HTML, SCLEX_XML
val SCE_H_DEFAULT=0 val SCE_H_DEFAULT=0
val SCE_H_TAG=1 val SCE_H_TAG=1
@@ -1484,6 +1569,11 @@ val SCE_LUA_PREPROCESSOR=9
val SCE_LUA_OPERATOR=10 val SCE_LUA_OPERATOR=10
val SCE_LUA_IDENTIFIER=11 val SCE_LUA_IDENTIFIER=11
val SCE_LUA_STRINGEOL=12 val SCE_LUA_STRINGEOL=12
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 # Lexical states for SCLEX_ERRORLIST
val SCE_ERR_DEFAULT=0 val SCE_ERR_DEFAULT=0
val SCE_ERR_PYTHON=1 val SCE_ERR_PYTHON=1
@@ -1548,6 +1638,18 @@ val SCE_ADA_CHARACTER=5
val SCE_ADA_OPERATOR=6 val SCE_ADA_OPERATOR=6
val SCE_ADA_IDENTIFIER=7 val SCE_ADA_IDENTIFIER=7
val SCE_ADA_STRINGEOL=8 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 # Lexical states for SCLEX_LISP
val SCE_LISP_DEFAULT=0 val SCE_LISP_DEFAULT=0
val SCE_LISP_COMMENT=1 val SCE_LISP_COMMENT=1
@@ -1579,6 +1681,15 @@ val SCE_NNCRONTAB_NUMBER=7
val SCE_NNCRONTAB_STRING=8 val SCE_NNCRONTAB_STRING=8
val SCE_NNCRONTAB_ENVIRONMENT=9 val SCE_NNCRONTAB_ENVIRONMENT=9
val SCE_NNCRONTAB_IDENTIFIER=10 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 # Events
@@ -1591,14 +1702,10 @@ evt void ModifyAttemptRO=2004(void)
evt void Key=2005(int ch, int modifiers) evt void Key=2005(int ch, int modifiers)
evt void DoubleClick=2006(void) evt void DoubleClick=2006(void)
evt void UpdateUI=2007(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) 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 MacroRecord=2009(int message, int wParam, int lParam)
evt void MarginClick=2010(int modifiers, int position, int margin) evt void MarginClick=2010(int modifiers, int position, int margin)
evt void NeedShown=2011(int position, int length) evt void NeedShown=2011(int position, int length)
evt void PosChanged=2012(int position)
evt void Painted=2013(void) evt void Painted=2013(void)
evt void UserListSelection=2014(int listType, string text) evt void UserListSelection=2014(int listType, string text)
evt void URIDropped=2015(string text) evt void URIDropped=2015(string text)
@@ -1606,3 +1713,7 @@ evt void DwellStart=2016(int position)
evt void DwellEnd=2017(int position) evt void DwellEnd=2017(int position)
cat Deprecated cat Deprecated
# The old name for SCN_UPDATEUI
val SCN_CHECKBRACE=2007
evt void PosChanged=2012(int position)

View File

@@ -2,7 +2,7 @@
/** @file AutoComplete.cxx /** @file AutoComplete.cxx
** Defines the auto completion list box. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -22,7 +22,8 @@ AutoComplete::AutoComplete() :
posStart(0), posStart(0),
startLen(0), startLen(0),
cancelAtStartPos(true), cancelAtStartPos(true),
autoHide(true) { autoHide(true),
dropRestOfWord(false) {
stopChars[0] = '\0'; stopChars[0] = '\0';
fillUpChars[0] = '\0'; fillUpChars[0] = '\0';
} }

View File

@@ -2,7 +2,7 @@
/** @file AutoComplete.h /** @file AutoComplete.h
** Defines the auto completion list box. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef AUTOCOMPLETE_H #ifndef AUTOCOMPLETE_H
@@ -25,6 +25,7 @@ public:
/// Should autocompletion be canceled if editor's currentPos <= startPos? /// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos; bool cancelAtStartPos;
bool autoHide; bool autoHide;
bool dropRestOfWord;
AutoComplete(); AutoComplete();
~AutoComplete(); ~AutoComplete();

View File

@@ -21,11 +21,11 @@ CallTip::CallTip() {
startHighlight = 0; startHighlight = 0;
endHighlight = 0; endHighlight = 0;
colourBG.desired = Colour(0xff, 0xff, 0xff); colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
colourUnSel.desired = Colour(0x80, 0x80, 0x80); colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
colourSel.desired = Colour(0, 0, 0x80); colourSel.desired = ColourDesired(0, 0, 0x80);
colourShade.desired = Colour(0, 0, 0); colourShade.desired = ColourDesired(0, 0, 0);
colourLight.desired = Colour(0xc0, 0xc0, 0xc0); colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
} }
CallTip::~CallTip() { CallTip::~CallTip() {
@@ -81,7 +81,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
rcClient.left = x; rcClient.left = x;
rcClient.top = ytext - ascent - 1; rcClient.top = ytext - ascent - 1;
rcClient.right = xEnd; rcClient.right = xEnd;
surfaceWindow->DrawText(rcClient, font, ytext, surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal, thisStartHighlight, chunkVal, thisStartHighlight,
colourUnSel.allocated, colourBG.allocated); colourUnSel.allocated, colourBG.allocated);
x = xEnd; x = xEnd;
@@ -91,7 +91,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
rcClient.top = ytext; rcClient.top = ytext;
rcClient.left = x; rcClient.left = x;
rcClient.right = xEnd; rcClient.right = xEnd;
surfaceWindow->DrawText(rcClient, font, ytext, surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight, chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
colourSel.allocated, colourBG.allocated); colourSel.allocated, colourBG.allocated);
x = xEnd; x = xEnd;
@@ -100,7 +100,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
chunkLength - thisEndHighlight); chunkLength - thisEndHighlight);
rcClient.left = x; rcClient.left = x;
rcClient.right = xEnd; rcClient.right = xEnd;
surfaceWindow->DrawText(rcClient, font, ytext, surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight, chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
colourUnSel.allocated, colourBG.allocated); colourUnSel.allocated, colourBG.allocated);
chunkVal = chunkEnd + 1; chunkVal = chunkEnd + 1;
@@ -117,21 +117,25 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
} }
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size) { const char *faceName, int size, bool unicodeMode_) {
Surface surfaceMeasure;
surfaceMeasure.Init();
int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
if (val) if (val)
delete []val; delete []val;
val = new char[strlen(defn) + 1]; val = new char[strlen(defn) + 1];
if (!val) if (!val)
return PRectangle(); return PRectangle();
strcpy(val, defn); strcpy(val, defn);
unicodeMode = unicodeMode_;
Surface *surfaceMeasure = Surface::Allocate();
if (!surfaceMeasure)
return PRectangle();
surfaceMeasure->Init();
surfaceMeasure->SetUnicodeMode(unicodeMode);
startHighlight = 0; startHighlight = 0;
endHighlight = 0; endHighlight = 0;
inCallTipMode = true; inCallTipMode = true;
posStartCallTip = pos; posStartCallTip = pos;
int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
// Look for multiple lines in the text // Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r! // Only support \n here - simply means container must avoid \r!
int width = 0; int width = 0;
@@ -139,16 +143,17 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *newline; const char *newline;
const char *look = val; const char *look = val;
while ((newline = strchr(look, '\n')) != NULL) { 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); width = Platform::Maximum(width, thisWidth);
look = newline + 1; look = newline + 1;
numLines++; numLines++;
} }
int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look)); int lastWidth = surfaceMeasure->WidthText(font, look, strlen(look));
width = Platform::Maximum(width, lastWidth) + 10; 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 // 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); return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
} }

View File

@@ -29,6 +29,7 @@ public:
ColourPair colourSel; ColourPair colourSel;
ColourPair colourShade; ColourPair colourShade;
ColourPair colourLight; ColourPair colourLight;
bool unicodeMode;
CallTip(); CallTip();
~CallTip(); ~CallTip();
@@ -40,7 +41,7 @@ public:
/// Setup the calltip and return a rectangle of the area required. /// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(int pos, Point pt, const char *defn, PRectangle CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size); const char *faceName, int size, bool unicodeMode_);
void CallTipCancel(); void CallTipCancel();

View File

@@ -11,8 +11,9 @@
OneLine::OneLine() { OneLine::OneLine() {
displayLine = 0; displayLine = 0;
docLine = 0; //docLine = 0;
visible = true; visible = true;
height = 1;
expanded = true; expanded = true;
} }
@@ -22,6 +23,8 @@ ContractionState::ContractionState() {
linesInDoc = 1; linesInDoc = 1;
linesInDisplay = 1; linesInDisplay = 1;
valid = false; valid = false;
docLines = 0;
sizeDocLines = 0;
} }
ContractionState::~ContractionState() { ContractionState::~ContractionState() {
@@ -30,14 +33,34 @@ ContractionState::~ContractionState() {
void ContractionState::MakeValid() const { void ContractionState::MakeValid() const {
if (!valid) { if (!valid) {
// Could be cleverer by keeping the index of the last still valid entry // Could be cleverer by keeping the index of the last still valid entry
// rather than invalidating all. // 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++) { for (int line=0; line<linesInDoc; line++) {
lines[line].displayLine = lineDisplay;
if (lines[line].visible) { if (lines[line].visible) {
lines[lineDisplay].docLine = line; for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
lineDisplay++; docLines[lineInDisplay] = line;
lineInDisplay++;
}
} }
} }
valid = true; valid = true;
@@ -50,6 +73,9 @@ void ContractionState::Clear() {
size = 0; size = 0;
linesInDoc = 1; linesInDoc = 1;
linesInDisplay = 1; linesInDisplay = 1;
delete []docLines;
docLines = 0;
sizeDocLines = 0;
} }
int ContractionState::LinesInDoc() const { int ContractionState::LinesInDoc() const {
@@ -57,6 +83,9 @@ int ContractionState::LinesInDoc() const {
} }
int ContractionState::LinesDisplayed() const { int ContractionState::LinesDisplayed() const {
if (size != 0) {
MakeValid();
}
return linesInDisplay; return linesInDisplay;
} }
@@ -75,11 +104,15 @@ int ContractionState::DocFromDisplay(int lineDisplay) const {
if (lineDisplay <= 0) if (lineDisplay <= 0)
return 0; return 0;
if (lineDisplay >= linesInDisplay) if (lineDisplay >= linesInDisplay)
return linesInDoc-1; return linesInDoc;
if (size == 0) if (size == 0)
return lineDisplay; return lineDisplay;
MakeValid(); MakeValid();
return lines[lineDisplay].docLine; if (docLines) { // Valid allocation
return docLines[lineDisplay];
} else {
return 0;
}
} }
void ContractionState::Grow(int sizeNew) { void ContractionState::Grow(int sizeNew) {
@@ -113,13 +146,15 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
Grow(linesInDoc + lineCount + growSize); Grow(linesInDoc + lineCount + growSize);
} }
linesInDoc += lineCount; linesInDoc += lineCount;
linesInDisplay += lineCount;
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) { for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
lines[i].visible = lines[i - lineCount].visible; 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; lines[i].expanded = lines[i - lineCount].expanded;
} }
for (int d=0;d<lineCount;d++) { for (int d=0;d<lineCount;d++) {
lines[lineDoc+d].visible = true; // Should inherit visibility from context ? lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
lines[lineDoc+d].height = 1;
lines[lineDoc+d].expanded = true; lines[lineDoc+d].expanded = true;
} }
valid = false; valid = false;
@@ -134,7 +169,7 @@ void ContractionState::DeleteLines(int lineDoc, int lineCount) {
int deltaDisplayed = 0; int deltaDisplayed = 0;
for (int d=0;d<lineCount;d++) { for (int d=0;d<lineCount;d++) {
if (lines[lineDoc+d].visible) if (lines[lineDoc+d].visible)
deltaDisplayed--; deltaDisplayed -= lines[lineDoc+d].height;
} }
for (int i = lineDoc; i < linesInDoc-lineCount; i++) { for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
if (i != 0) // Line zero is always visible if (i != 0) // Line zero is always visible
@@ -157,10 +192,10 @@ bool ContractionState::GetVisible(int lineDoc) const {
} }
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) { bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
if (lineDocStart == 0) if (lineDocStart == 0)
lineDocStart++; lineDocStart++;
if (lineDocStart > lineDocEnd) if (lineDocStart > lineDocEnd)
return false; return false;
if (size == 0) { if (size == 0) {
Grow(linesInDoc + growSize); Grow(linesInDoc + growSize);
} }
@@ -170,7 +205,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) { if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
for (int line=lineDocStart; line <= lineDocEnd; line++) { for (int line=lineDocStart; line <= lineDocEnd; line++) {
if (lines[line].visible != visible) { if (lines[line].visible != visible) {
delta += visible ? 1 : -1; delta += visible ? lines[line].height : -lines[line].height;
lines[line].visible = visible; lines[line].visible = visible;
} }
} }
@@ -181,7 +216,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible
} }
bool ContractionState::GetExpanded(int lineDoc) const { bool ContractionState::GetExpanded(int lineDoc) const {
if (size == 0) if (size == 0)
return true; return true;
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
return lines[lineDoc].expanded; return lines[lineDoc].expanded;
@@ -192,6 +227,11 @@ bool ContractionState::GetExpanded(int lineDoc) const {
bool ContractionState::SetExpanded(int lineDoc, bool expanded) { bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
if (size == 0) { if (size == 0) {
if (expanded) {
// If in completely expanded state then setting
// one line to expanded has no effect.
return false;
}
Grow(linesInDoc + growSize); Grow(linesInDoc + growSize);
} }
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
@@ -203,6 +243,38 @@ bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
return false; 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() { void ContractionState::ShowAll() {
delete []lines; delete []lines;
lines = 0; lines = 0;

View File

@@ -13,10 +13,11 @@
class OneLine { class OneLine {
public: public:
int displayLine; ///< Position within set of visible lines int displayLine; ///< Position within set of visible lines
int docLine; ///< Inverse of @a displayLine //int docLine; ///< Inverse of @a displayLine
int height; ///< Number of display lines needed to show all of the line
bool visible; bool visible;
bool expanded; bool expanded;
OneLine(); OneLine();
virtual ~OneLine() {} virtual ~OneLine() {}
}; };
@@ -27,33 +28,38 @@ class ContractionState {
void Grow(int sizeNew); void Grow(int sizeNew);
enum { growSize = 4000 }; enum { growSize = 4000 };
int linesInDoc; int linesInDoc;
int linesInDisplay; mutable int linesInDisplay;
mutable OneLine *lines; mutable OneLine *lines;
int size; int size;
mutable int *docLines;
mutable int sizeDocLines;
mutable bool valid; mutable bool valid;
void MakeValid() const; void MakeValid() const;
public: public:
ContractionState(); ContractionState();
virtual ~ContractionState(); virtual ~ContractionState();
void Clear(); void Clear();
int LinesInDoc() const; int LinesInDoc() const;
int LinesDisplayed() const; int LinesDisplayed() const;
int DisplayFromDoc(int lineDoc) const; int DisplayFromDoc(int lineDoc) const;
int DocFromDisplay(int lineDisplay) const; int DocFromDisplay(int lineDisplay) const;
void InsertLines(int lineDoc, int lineCount); void InsertLines(int lineDoc, int lineCount);
void DeleteLines(int lineDoc, int lineCount); void DeleteLines(int lineDoc, int lineCount);
bool GetVisible(int lineDoc) const; bool GetVisible(int lineDoc) const;
bool SetVisible(int lineDocStart, int lineDocEnd, bool visible); bool SetVisible(int lineDocStart, int lineDocEnd, bool visible);
bool GetExpanded(int lineDoc) const; bool GetExpanded(int lineDoc) const;
bool SetExpanded(int lineDoc, bool expanded); bool SetExpanded(int lineDoc, bool expanded);
void ShowAll(); int GetHeight(int lineDoc) const;
bool SetHeight(int lineDoc, int height);
void ShowAll();
}; };
#endif #endif

View File

@@ -2,7 +2,7 @@
/** @file Document.cxx /** @file Document.cxx
** Text document that handles notifications, DBCS, styling, words and end of line. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -19,7 +19,7 @@
#include "RESearch.h" #include "RESearch.h"
// This is ASCII specific but is safe with chars >= 0x80 // 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)); return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
} }
@@ -34,10 +34,9 @@ Document::Document() {
stylingBits = 5; stylingBits = 5;
stylingBitsMask = 0x1F; stylingBitsMask = 0x1F;
stylingMask = 0; stylingMask = 0;
for (int ch = 0; ch < 256; ch++) { SetWordChars(0);
wordchars[ch] = isalnum(ch) || ch == '_';
}
endStyled = 0; endStyled = 0;
styleClock = 0;
enteredCount = 0; enteredCount = 0;
enteredReadOnlyCount = 0; enteredReadOnlyCount = 0;
tabInChars = 8; tabInChars = 8;
@@ -219,7 +218,6 @@ bool Document::IsCrLf(int pos) {
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n'); return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
} }
#if PLAT_WIN
bool Document::IsDBCS(int pos) { bool Document::IsDBCS(int pos) {
if (dbcsCodePage) { if (dbcsCodePage) {
if (SC_CP_UTF8 == 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') while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
startLine--; startLine--;
while (startLine <= pos) { while (startLine <= pos) {
if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) { if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine))) {
startLine++; startLine++;
if (startLine >= pos) if (startLine >= pos)
return true; return true;
@@ -243,13 +241,6 @@ bool Document::IsDBCS(int pos) {
} }
return false; 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) { int Document::LenChar(int pos) {
if (IsCrLf(pos)) { if (IsCrLf(pos)) {
@@ -302,7 +293,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
// Not between CR and LF // Not between CR and LF
#if PLAT_WIN
if (dbcsCodePage) { if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) { if (SC_CP_UTF8 == dbcsCodePage) {
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos)); 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) { while (startLine < pos) {
if (atLeadByte) if (atLeadByte)
atLeadByte = false; atLeadByte = false;
else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) else if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine)))
atLeadByte = true; atLeadByte = true;
else else
atLeadByte = false; atLeadByte = false;
startLine++; startLine++;
//Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
} }
@@ -342,7 +331,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
} }
} }
} }
#endif
return pos; return pos;
} }
@@ -634,21 +622,46 @@ int Document::GetColumn(int pos) {
int column = 0; int column = 0;
int line = LineFromPosition(pos); int line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) { if ((line >= 0) && (line < LinesTotal())) {
for (int i = LineStart(line);i < pos;i++) { for (int i = LineStart(line);i < pos;) {
char ch = cb.CharAt(i); char ch = cb.CharAt(i);
if (ch == '\t') if (ch == '\t') {
column = NextTab(column, tabInChars); column = NextTab(column, tabInChars);
else if (ch == '\r') i++;
} else if (ch == '\r') {
return column; return column;
else if (ch == '\n') } else if (ch == '\n') {
return column; return column;
else } else {
column++; column++;
i = MovePositionOutsideChar(i + 1, 1);
}
} }
} }
return column; 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) { 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 // Dedent - suck white space off the front of the line to dedent by equivalent of a tab
for (int line = lineBottom; line >= lineTop; line--) { for (int line = lineBottom; line >= lineTop; line--) {
@@ -700,72 +713,88 @@ void Document::ConvertLineEnds(int eolModeSet) {
EndUndoAction(); EndUndoAction();
} }
bool Document::IsWordChar(unsigned char ch) { Document::charClassification Document::WordCharClass(unsigned char ch) {
if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80)) if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80))
return true; return ccWord;
return wordchars[ch]; 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) { 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--; pos--;
} else { } else {
while (pos < (Length()) && IsWordChar(cb.CharAt(pos))) if (!onlyWordCharacters)
pos++; ccStart = WordCharClass(cb.CharAt(pos));
} while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
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'))
pos++; pos++;
} }
return pos; return pos;
} }
/** /**
* Check that the character before the given position * Find the start of the next word in either a forward (delta >= 0) or backwards direction
* is not a word character. * (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) { bool Document::IsWordStartAt(int pos) {
if (pos > 0) { 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; return true;
} }
/** /**
* Check that the character after the given position * Check that the character at the given position is a word or punctuation character and that
* is not a word character. * the next character is of a different character class.
*/ */
bool Document::IsWordEndAt(int pos) { bool Document::IsWordEndAt(int pos) {
if (pos < Length() - 1) { 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; return true;
} }
/** /**
* Check that the given range is delimited by * Check that the given range is has transitions between character classes at both
* non word characters. * ends and where the characters on the inside are word or punctuation characters.
*/ */
bool Document::IsWordAt(int start, int end) { bool Document::IsWordAt(int start, int end) {
return IsWordStartAt(start) && IsWordEndAt(end); return IsWordStartAt(start) && IsWordEndAt(end);
@@ -1018,16 +1047,22 @@ void Document::ChangeCase(Range r, bool makeUpperCase) {
void Document::SetWordChars(unsigned char *chars) { void Document::SetWordChars(unsigned char *chars) {
int ch; int ch;
for (ch = 0; ch < 256; 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) { if (chars) {
while (*chars) { while (*chars) {
wordchars[*chars] = true; charClass[*chars] = ccWord;
chars++; chars++;
} }
} else { } else {
for (ch = 0; ch < 256; ch++) { 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; int prevEndStyled = endStyled;
bool didChange = false; bool didChange = false;
for (int iPos = 0; iPos < length; iPos++, endStyled++) { for (int iPos = 0; iPos < length; iPos++, endStyled++) {
PLATFORM_ASSERT(endStyled < Length());
if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) { if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
didChange = true; didChange = true;
} }
@@ -1080,6 +1116,12 @@ void Document::SetStyles(int length, char *styles) {
} }
bool Document::EnsureStyledTo(int pos) { 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. // Ask the watchers to style, and stop as soon as one responds.
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++) for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos); watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
@@ -1149,7 +1191,7 @@ void Document::NotifyModified(DocModification mh) {
} }
bool Document::IsWordPartSeparator(char ch) { bool Document::IsWordPartSeparator(char ch) {
return ispunct(ch) && IsWordChar(ch); return ispunct(ch) && (WordCharClass(ch) == ccWord);
} }
int Document::WordPartLeft(int pos) { int Document::WordPartLeft(int pos) {

View File

@@ -2,7 +2,7 @@
/** @file Document.h /** @file Document.h
** Text document that handles notifications, DBCS, styling, words and end of line. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef DOCUMENT_H #ifndef DOCUMENT_H
@@ -37,6 +37,7 @@ public:
return (start != invalidPosition) && (end != invalidPosition); return (start != invalidPosition) && (end != invalidPosition);
} }
// Is the position within the range?
bool Contains(Position pos) const { bool Contains(Position pos) const {
if (start < end) { if (start < end) {
return (pos >= start && pos <= end); return (pos >= start && pos <= end);
@@ -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 { bool Contains(Range other) const {
return Contains(other.start) && Contains(other.end); return Contains(other.start) && Contains(other.end);
} }
@@ -81,9 +91,11 @@ public:
private: private:
int refCount; int refCount;
CellBuffer cb; CellBuffer cb;
bool wordchars[256]; enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
charClassification charClass[256];
char stylingMask; char stylingMask;
int endStyled; int endStyled;
int styleClock;
int enteredCount; int enteredCount;
int enteredReadOnlyCount; int enteredReadOnlyCount;
@@ -140,6 +152,7 @@ public:
void SetLineIndentation(int line, int indent); void SetLineIndentation(int line, int indent);
int GetLineIndentPosition(int line); int GetLineIndentPosition(int line);
int GetColumn(int position); int GetColumn(int position);
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop); void Indent(bool forwards, int lineBottom, int lineTop);
void ConvertLineEnds(int eolModeSet); void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); } void SetReadOnly(bool set) { cb.SetReadOnly(set); }
@@ -175,7 +188,7 @@ public:
int GetFoldParent(int line); int GetFoldParent(int line);
void Indent(bool forwards); 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 NextWordStart(int pos, int delta);
int Length() { return cb.Length(); } int Length() { return cb.Length(); }
long FindText(int minPos, int maxPos, const char *s, long FindText(int minPos, int maxPos, const char *s,
@@ -193,6 +206,7 @@ public:
void SetStyles(int length, char *styles); void SetStyles(int length, char *styles);
int GetEndStyled() { return endStyled; } int GetEndStyled() { return endStyled; }
bool EnsureStyledTo(int pos); bool EnsureStyledTo(int pos);
int GetStyleClock() { return styleClock; }
int SetLineState(int line, int state) { return cb.SetLineState(line, state); } int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); } int GetLineState(int line) { return cb.GetLineState(line); }
@@ -209,7 +223,7 @@ public:
private: private:
bool IsDBCS(int pos); bool IsDBCS(int pos);
bool IsWordChar(unsigned char ch); charClassification WordCharClass(unsigned char ch);
bool IsWordStartAt(int pos); bool IsWordStartAt(int pos);
bool IsWordEndAt(int pos); bool IsWordEndAt(int pos);
bool IsWordAt(int start, int end); bool IsWordAt(int start, int end);

View File

@@ -23,22 +23,14 @@
DocumentAccessor::~DocumentAccessor() { DocumentAccessor::~DocumentAccessor() {
} }
#if PLAT_WIN
bool DocumentAccessor::InternalIsLeadByte(char ch) { bool DocumentAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage) if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the // For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte. // same so none is considered a lead byte.
return false; return false;
else else
return IsDBCSLeadByteEx(codePage, ch); return 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) { void DocumentAccessor::Fill(int position) {
if (lenDoc == -1) if (lenDoc == -1)
@@ -88,6 +80,7 @@ int DocumentAccessor::SetLineState(int line, int state) {
void DocumentAccessor::StartAt(unsigned int start, char chMask) { void DocumentAccessor::StartAt(unsigned int start, char chMask) {
pdoc->StartStyling(start, chMask); pdoc->StartStyling(start, chMask);
startPosStyling = start;
} }
void DocumentAccessor::StartSegment(unsigned int pos) { void DocumentAccessor::StartSegment(unsigned int pos) {
@@ -111,6 +104,7 @@ void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
chFlags = 0; chFlags = 0;
chAttr |= chFlags; chAttr |= chFlags;
for (unsigned int i = startSeg; i <= pos; i++) { for (unsigned int i = startSeg; i <= pos; i++) {
PLATFORM_ASSERT((startPosStyling + validLen) < Length());
styleBuf[validLen++] = static_cast<char>(chAttr); styleBuf[validLen++] = static_cast<char>(chAttr);
} }
} }
@@ -128,6 +122,7 @@ void DocumentAccessor::Flush() {
if (validLen > 0) { if (validLen > 0) {
pdoc->SetStyles(validLen, styleBuf); pdoc->SetStyles(validLen, styleBuf);
validLen = 0; validLen = 0;
startPosStyling += validLen;
} }
} }

View File

@@ -26,6 +26,7 @@ protected:
char chFlags; char chFlags;
char chWhile; char chWhile;
unsigned int startSeg; unsigned int startSeg;
int startPosStyling;
bool InternalIsLeadByte(char ch); bool InternalIsLeadByte(char ch);
void Fill(int position); void Fill(int position);
@@ -33,7 +34,8 @@ protected:
public: public:
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) : DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), id(id_), 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(); ~DocumentAccessor();
char StyleAt(int position); char StyleAt(int position);

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
/** @file Editor.h /** @file Editor.h
** Defines the main editor class. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef EDITOR_H #ifndef EDITOR_H
@@ -15,7 +15,7 @@ public:
bool active; bool active;
bool on; bool on;
int period; int period;
Caret(); Caret();
}; };
@@ -26,28 +26,89 @@ public:
bool ticking; bool ticking;
int ticksToWait; int ticksToWait;
enum {tickSize = 100}; enum {tickSize = 100};
int tickerID; TickerID tickerID;
Timer(); Timer();
}; };
/** /**
*/ */
class LineLayout { class LineLayout {
public: private:
friend class LineLayoutCache;
int *lineStarts;
int lenLineStarts;
/// Drawing is only performed for @a maxLineLength characters on each line. /// 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; int numCharsInLine;
enum validLevel { llInvalid, llPositions, llLines } validity;
int xHighlightGuide; int xHighlightGuide;
bool highlightColumn; bool highlightColumn;
int selStart; int selStart;
int selEnd; int selEnd;
bool containsCaret; bool containsCaret;
int edgeColumn; int edgeColumn;
char chars[maxLineLength+1]; char *chars;
char styles[maxLineLength+1]; char *styles;
char indicators[maxLineLength+1]; char *indicators;
int positions[maxLineLength+1]; 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 { 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 { class Editor : public DocWatcher {
@@ -85,20 +178,21 @@ protected: // ScintillaBase subclass needs access to much of Editor
/** Style resources may be expensive to allocate so are cached between uses. /** Style resources may be expensive to allocate so are cached between uses.
* When a style attribute is changed, this cache is flushed. */ * When a style attribute is changed, this cache is flushed. */
bool stylesValid; bool stylesValid;
ViewStyle vs; ViewStyle vs;
Palette palette; Palette palette;
int printMagnification; int printMagnification;
int printColourMode; int printColourMode;
int cursorMode; int cursorMode;
int controlCharSymbol;
bool hasFocus; bool hasFocus;
bool hideSelection; bool hideSelection;
bool inOverstrike; bool inOverstrike;
int errorStatus; int errorStatus;
bool mouseDownCaptures; bool mouseDownCaptures;
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
* the screen. This avoids flashing but is about 30% slower. */ * the screen. This avoids flashing but is about 30% slower. */
bool bufferedDraw; bool bufferedDraw;
@@ -106,12 +200,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
int xOffset; ///< Horizontal scrolled amount in pixels int xOffset; ///< Horizontal scrolled amount in pixels
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
bool horizontalScrollBarVisible; bool horizontalScrollBarVisible;
Surface pixmapLine; Surface *pixmapLine;
Surface pixmapSelMargin; Surface *pixmapSelMargin;
Surface pixmapSelPattern; Surface *pixmapSelPattern;
Surface pixmapIndentGuide; Surface *pixmapIndentGuide;
Surface pixmapIndentGuideHighlight; Surface *pixmapIndentGuideHighlight;
LineLayoutCache llc;
KeyMap kmap; KeyMap kmap;
@@ -141,32 +237,32 @@ protected: // ScintillaBase subclass needs access to much of Editor
int searchFlags; int searchFlags;
int topLine; int topLine;
int posTopLine; int posTopLine;
bool needUpdateUI; bool needUpdateUI;
Position braces[2]; Position braces[2];
int bracesMatchStyle; int bracesMatchStyle;
int highlightGuideColumn; int highlightGuideColumn;
int theEdge; int theEdge;
enum { notPainting, painting, paintAbandoned } paintState; enum { notPainting, painting, paintAbandoned } paintState;
PRectangle rcPaint; PRectangle rcPaint;
bool paintingAllText; bool paintingAllText;
int modEventMask; int modEventMask;
SelectionText drag; SelectionText drag;
enum { selStream, selRectangle, selRectangleFixed } selType; enum { selStream, selRectangle, selRectangleFixed } selType;
int xStartSelect; int xStartSelect;
int xEndSelect; int xEndSelect;
bool primarySelection; bool primarySelection;
int caretPolicy; int caretPolicy;
int caretSlop; int caretSlop;
int visiblePolicy; int visiblePolicy;
int visibleSlop; int visibleSlop;
int searchAnchor; int searchAnchor;
bool recordingMacro; bool recordingMacro;
@@ -174,6 +270,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
int foldFlags; int foldFlags;
ContractionState cs; ContractionState cs;
// Wrapping support
enum { eWrapNone, eWrapWord } wrapState;
int wrapWidth;
int docLineLastWrapped;
Document *pdoc; Document *pdoc;
Editor(); Editor();
@@ -189,7 +290,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual PRectangle GetClientRectangle(); virtual PRectangle GetClientRectangle();
PRectangle GetTextRectangle(); PRectangle GetTextRectangle();
int LinesOnScreen(); int LinesOnScreen();
int LinesToScroll(); int LinesToScroll();
int MaxScrollPos(); int MaxScrollPos();
@@ -200,13 +301,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
int PositionFromLineX(int line, int x); int PositionFromLineX(int line, int x);
int LineFromLocation(Point pt); int LineFromLocation(Point pt);
void SetTopLine(int topLineNew); void SetTopLine(int topLineNew);
void RedrawRect(PRectangle rc); void RedrawRect(PRectangle rc);
void Redraw(); void Redraw();
void RedrawSelMargin(); void RedrawSelMargin();
PRectangle RectangleFromRange(int start, int end); PRectangle RectangleFromRange(int start, int end);
void InvalidateRange(int start, int end); void InvalidateRange(int start, int end);
int CurrentPosition(); int CurrentPosition();
bool SelectionEmpty(); bool SelectionEmpty();
int SelectionStart(int line=-1); int SelectionStart(int line=-1);
@@ -223,16 +324,22 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void ScrollText(int linesToMove); virtual void ScrollText(int linesToMove);
void HorizontalScrollTo(int xPos); void HorizontalScrollTo(int xPos);
void MoveCaretInsideView(); void MoveCaretInsideView();
int DisplayFromPosition(int pos);
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true); void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
void ShowCaretAtCurrentPosition(); void ShowCaretAtCurrentPosition();
void DropCaret(); void DropCaret();
void InvalidateCaret(); void InvalidateCaret();
void NeedWrapping(int docLineStartWrapping=0);
bool WrapLines();
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault); int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
void PaintSelMargin(Surface *surface, PRectangle &rc); void PaintSelMargin(Surface *surface, PRectangle &rc);
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll); LineLayout *RetrieveLineLayout(int lineNumber);
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
PRectangle rcLine, LineLayout &ll); int width=LineLayout::wrapWidthInfinite);
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine=0);
void Paint(Surface *surfaceWindow, PRectangle rcArea); void Paint(Surface *surfaceWindow, PRectangle rcArea);
long FormatRange(bool draw, RangeToFormat *pfr); long FormatRange(bool draw, RangeToFormat *pfr);
@@ -240,11 +347,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void SetHorizontalScrollPos() = 0; virtual void SetHorizontalScrollPos() = 0;
virtual bool ModifyScrollBars(int nMax, int nPage) = 0; virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
virtual void ReconfigureScrollBars(); virtual void ReconfigureScrollBars();
void SetScrollBarsTo(PRectangle rsClient);
void SetScrollBars(); void SetScrollBars();
void ChangeSize();
void AddChar(char ch); 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 ClearSelection();
void ClearAll(); void ClearAll();
void ClearDocumentStyle(); void ClearDocumentStyle();
@@ -258,11 +365,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
void Undo(); void Undo();
void Redo(); void Redo();
void DelChar(); void DelChar();
void DelCharBack(); void DelCharBack(bool allowLineStartDeletion);
virtual void ClaimSelection() = 0; virtual void ClaimSelection() = 0;
virtual void NotifyChange() = 0; virtual void NotifyChange() = 0;
virtual void NotifyFocus(bool focus); virtual void NotifyFocus(bool focus);
virtual int GetCtrlID() { return ctrlID; }
virtual void NotifyParent(SCNotification scn) = 0; virtual void NotifyParent(SCNotification scn) = 0;
virtual void NotifyStyleToNeeded(int endStyleNeeded); virtual void NotifyStyleToNeeded(int endStyleNeeded);
void NotifyChar(int ch); void NotifyChar(int ch);
@@ -275,9 +383,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
void NotifyNeedShown(int pos, int len); void NotifyNeedShown(int pos, int len);
void NotifyDwelling(Point pt, bool state); void NotifyDwelling(Point pt, bool state);
void NotifyModifyAttempt(Document *document, void *userData); void NotifyModifyAttempt(Document *document, void *userData);
void NotifySavePoint(Document *document, void *userData, bool atSavePoint); void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
void CheckModificationForWrap(DocModification mh);
void NotifyModified(Document *document, DocModification mh, void *userData); void NotifyModified(Document *document, DocModification mh, void *userData);
void NotifyDeleted(Document *document, void *userData); void NotifyDeleted(Document *document, void *userData);
void NotifyStyleNeeded(Document *doc, void *userData, int endPos); void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
@@ -328,21 +437,23 @@ protected: // ScintillaBase subclass needs access to much of Editor
void CheckForChangeOutsidePaint(Range r); void CheckForChangeOutsidePaint(Range r);
int BraceMatch(int position, int maxReStyle); int BraceMatch(int position, int maxReStyle);
void SetBraceHighlight(Position pos0, Position pos1, int matchStyle); void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
void SetDocPointer(Document *document); void SetDocPointer(Document *document);
void Expand(int &line, bool doExpand); void Expand(int &line, bool doExpand);
void ToggleContraction(int line); void ToggleContraction(int line);
void EnsureLineVisible(int lineDoc, bool enforcePolicy); void EnsureLineVisible(int lineDoc, bool enforcePolicy);
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
public: public:
// Public so scintilla_send_message can use it // Public so 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); virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
// Public so scintilla_set_id can use it // Public so scintilla_set_id can use it.
int ctrlID; int ctrlID;
}; };
#endif #endif

View File

@@ -14,7 +14,7 @@ class Indicator {
public: public:
int style; int style;
ColourPair fore; 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); void Draw(Surface *surface, PRectangle &rc);
}; };

View File

@@ -62,7 +62,7 @@ unsigned int KeyMap::Find(int key, int modifiers) {
return 0; return 0;
} }
KeyToCommand KeyMap::MapDefault[] = { const KeyToCommand KeyMap::MapDefault[] = {
{SCK_DOWN, SCI_NORM, SCI_LINEDOWN}, {SCK_DOWN, SCI_NORM, SCI_LINEDOWN},
{SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND}, {SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND},
{SCK_DOWN, SCI_CTRL, SCI_LINESCROLLDOWN}, {SCK_DOWN, SCI_CTRL, SCI_LINESCROLLDOWN},

View File

@@ -30,7 +30,7 @@ class KeyMap {
KeyToCommand *kmap; KeyToCommand *kmap;
int len; int len;
int alloc; int alloc;
static KeyToCommand MapDefault[]; static const KeyToCommand MapDefault[];
public: public:
KeyMap(); KeyMap();

View File

@@ -2,7 +2,7 @@
/** @file KeyWords.cxx /** @file KeyWords.cxx
** Colourise for particular languages. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -19,15 +19,15 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
LexerModule *LexerModule::base = 0; const LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1; int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
LexerModule::LexerModule(int language_, LexerFunction fnLexer_, LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_, LexerFunction fnFolder_) : const char *languageName_, LexerFunction fnFolder_) :
language(language_), language(language_),
languageName(languageName_),
fnLexer(fnLexer_), fnLexer(fnLexer_),
fnFolder(fnFolder_) { fnFolder(fnFolder_),
languageName(languageName_) {
next = base; next = base;
base = this; base = this;
if (language == SCLEX_AUTOMATIC) { if (language == SCLEX_AUTOMATIC) {
@@ -36,8 +36,8 @@ LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
} }
} }
LexerModule *LexerModule::Find(int language) { const LexerModule *LexerModule::Find(int language) {
LexerModule *lm = base; const LexerModule *lm = base;
while (lm) { while (lm) {
if (lm->language == language) { if (lm->language == language) {
return lm; return lm;
@@ -47,9 +47,9 @@ LexerModule *LexerModule::Find(int language) {
return 0; return 0;
} }
LexerModule *LexerModule::Find(const char *languageName) { const LexerModule *LexerModule::Find(const char *languageName) {
if (languageName) { if (languageName) {
LexerModule *lm = base; const LexerModule *lm = base;
while (lm) { while (lm) {
if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) { if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
return lm; return lm;
@@ -61,13 +61,13 @@ LexerModule *LexerModule::Find(const char *languageName) {
} }
void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle, void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) { WordList *keywordlists[], Accessor &styler) const {
if (fnLexer) if (fnLexer)
fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler); fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
} }
void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle, void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) { WordList *keywordlists[], Accessor &styler) const {
if (fnFolder) { if (fnFolder) {
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
// Move back one line in case deletion wrecked current line fold state // 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"); LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
#ifdef __vms #ifdef __vms
#define LINK_LEXERS
#endif
#ifdef LINK_LEXERS
// The following code forces a reference to all of the Scintilla 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" // 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. // Taken from wxWindow's stc.cpp. Walter.
int wxForceScintillaLexers(void) { int wxForceScintillaLexers(void) {
return Scintilla_LinkLexers();
}
int Scintilla_LinkLexers() {
extern LexerModule lmAda; extern LexerModule lmAda;
extern LexerModule lmAVE; extern LexerModule lmAVE;
extern LexerModule lmBaan;
extern LexerModule lmBatch; extern LexerModule lmBatch;
extern LexerModule lmConf; extern LexerModule lmConf;
extern LexerModule lmCPP; extern LexerModule lmCPP;
@@ -120,6 +129,7 @@ int wxForceScintillaLexers(void) {
extern LexerModule lmLISP; extern LexerModule lmLISP;
extern LexerModule lmLua; extern LexerModule lmLua;
extern LexerModule lmMake; extern LexerModule lmMake;
extern LexerModule lmMatlab;
extern LexerModule lmPascal; extern LexerModule lmPascal;
extern LexerModule lmPerl; extern LexerModule lmPerl;
extern LexerModule lmProps; extern LexerModule lmProps;
@@ -128,10 +138,12 @@ int wxForceScintillaLexers(void) {
extern LexerModule lmSQL; extern LexerModule lmSQL;
extern LexerModule lmVB; extern LexerModule lmVB;
extern LexerModule lmXML; extern LexerModule lmXML;
extern LexerModule lmBullant;
if ( if (
&lmAda &lmAda
&& &lmAVE && &lmAVE
&& &lmBaan
&& &lmConf && &lmConf
&& &lmDiff && &lmDiff
&& &lmLatex && &lmLatex
@@ -142,6 +154,7 @@ int wxForceScintillaLexers(void) {
&& &lmProps && &lmProps
&& &lmErrorList && &lmErrorList
&& &lmMake && &lmMake
&& &lmMatlab
&& &lmBatch && &lmBatch
&& &lmPerl && &lmPerl
&& &lmPython && &lmPython
@@ -153,6 +166,7 @@ int wxForceScintillaLexers(void) {
&& &lmLISP && &lmLISP
&& &lmLua && &lmLua
&& &lmNull && &lmNull
&& &lmBullant
) )
{ {
return 1; return 1;

View File

@@ -26,7 +26,7 @@ static void ColouriseAveDoc(unsigned int startPos, int length, int initStyle, Wo
styler.StartAt(startPos); styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold"); bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev; int levelCurrent = levelPrev;

View File

@@ -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 == ')' || if (ch == '&' || ch == '\'' || ch == '(' || ch == ')' ||
ch == '*' || ch == '+' || ch == ',' || ch == '-' || ch == '*' || ch == '+' || ch == ',' || ch == '-' ||

View 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);

View 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");

View File

@@ -2,7 +2,7 @@
/** @file LexCPP.cxx /** @file LexCPP.cxx
** Lexer for C++, C, Java, and Javascript. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -24,22 +24,22 @@ static bool IsOKBeforeRE(const int ch) {
return (ch == '(') || (ch == '=') || (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 == '_'); 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 == '_'); return (ch < 0x80) && (isalnum(ch) || ch == '_');
} }
inline bool IsADoxygenChar(const int ch) { static inline bool IsADoxygenChar(const int ch) {
return (islower(ch) || ch == '$' || ch == '@' || return (islower(ch) || ch == '$' || ch == '@' ||
ch == '\\' || ch == '&' || ch == '<' || ch == '\\' || ch == '&' || ch == '<' ||
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) || return ((state == SCE_C_COMMENT) ||
(state == SCE_C_COMMENTLINE) || (state == SCE_C_COMMENTLINE) ||
(state == SCE_C_COMMENTDOC) || (state == SCE_C_COMMENTDOC) ||
@@ -47,7 +47,7 @@ inline bool IsStateComment(const int state) {
(state == SCE_C_COMMENTDOCKEYWORDERROR)); (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)); 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 &keywords2 = *keywordlists[1];
WordList &keywords3 = *keywordlists[2]; 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 // Do not leak onto next line
if (initStyle == SCE_C_STRINGEOL) if (initStyle == SCE_C_STRINGEOL)
@@ -66,7 +66,6 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
int chPrevNonWhite = ' '; int chPrevNonWhite = ' ';
int visibleChars = 0; int visibleChars = 0;
int noDocChars = 0;
bool lastWordWasUUID = false; bool lastWordWasUUID = false;
StyleContext sc(startPos, length, initStyle, styler); StyleContext sc(startPos, length, initStyle, styler);
@@ -126,12 +125,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
if (sc.Match('*', '/')) { if (sc.Match('*', '/')) {
sc.Forward(); sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT); sc.ForwardSetState(SCE_C_DEFAULT);
} else if ((sc.ch == '@' || sc.ch == '\\') && (noDocChars == 0)) { } else if (sc.ch == '@' || sc.ch == '\\') {
sc.SetState(SCE_C_COMMENTDOCKEYWORD); 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) { } else if (sc.state == SCE_C_COMMENTLINE || sc.state == SCE_C_COMMENTLINEDOC) {
if (sc.atLineEnd) { if (sc.atLineEnd) {
@@ -219,7 +214,6 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
} }
} else if (sc.Match('/', '*')) { } else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
noDocChars = 0;
sc.SetState(SCE_C_COMMENTDOC); sc.SetState(SCE_C_COMMENTDOC);
} else { } else {
sc.SetState(SCE_C_COMMENT); 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 *[], static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
Accessor &styler) { Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment"); bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1); bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
unsigned int endPos = startPos + length; unsigned int endPos = startPos + length;
int visibleChars = 0; int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);

View File

@@ -172,6 +172,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k
} }
} }
delete []buffer;
} }
LexerModule lmConf(SCLEX_CONF, ColouriseConfDoc, "conf"); LexerModule lmConf(SCLEX_CONF, ColouriseConfDoc, "conf");

View File

@@ -199,6 +199,7 @@ static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordLi
break; break;
} }
} }
delete []buffer;
} }
LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab"); LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab");

View File

@@ -21,7 +21,7 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.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 // '.' left out as it is used to make up numbers
return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' || return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' ||
ch == '(' || ch == ')' || ch == '=' || ch == '(' || ch == ')' || ch == '=' ||
@@ -32,11 +32,11 @@ inline bool isEiffelOperator(unsigned int ch) {
ch == '!' || ch == '@' || ch == '?'; ch == '!' || ch == '@' || ch == '?';
} }
inline bool IsAWordChar(unsigned int ch) { static inline bool IsAWordChar(unsigned int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || 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 == '_'); return (ch < 0x80) && (isalnum(ch) || ch == '_');
} }

View File

@@ -1,8 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
/** @file LexHTML.cxx /** @file LexHTML.cxx
** Lexer for HTML. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -15,6 +15,7 @@
#include "PropSet.h" #include "PropSet.h"
#include "Accessor.h" #include "Accessor.h"
#include "StyleContext.h"
#include "KeyWords.h" #include "KeyWords.h"
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
@@ -23,10 +24,18 @@
#define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START) #define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
#define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START) #define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock }; enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc }; 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]; char s[30 + 1];
unsigned int i = 0; unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) { for (; i < end - start + 1 && i < 30; i++) {
@@ -67,7 +76,7 @@ static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, u
return iResult; return iResult;
} }
static int ScriptOfState(int state) { static script_type ScriptOfState(int state) {
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) { if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
return eScriptPython; return eScriptPython;
} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) { } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
@@ -76,7 +85,7 @@ static int ScriptOfState(int state) {
return eScriptJS; return eScriptJS;
} else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) { } else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
return eScriptPHP; 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; return eScriptSGML;
} else if (state == SCE_H_SGML_BLOCK_DEFAULT) { } else if (state == SCE_H_SGML_BLOCK_DEFAULT) {
return eScriptSGMLblock; 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; int StateToPrint;
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) { 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, 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; char chAttr = SCE_HJ_WORD;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber) if (wordIsNumber)
@@ -237,7 +246,7 @@ static void classifyWordHTJS(unsigned int start, unsigned int end,
styler.ColourTo(end, statePrintForState(chAttr, inScriptType)); 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; char chAttr = SCE_HB_IDENTIFIER;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber) if (wordIsNumber)
@@ -262,8 +271,8 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
return SCE_HB_DEFAULT; return SCE_HB_DEFAULT;
} }
static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) { static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) {
bool wordIsNumber = isdigit(styler[start]); bool wordIsNumber = isdigit(styler[start]) != 0;
char s[30 + 1]; char s[30 + 1];
unsigned int i = 0; unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) { 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 // Called when in a PHP word
static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char chAttr = SCE_HPHP_DEFAULT; char chAttr = SCE_HPHP_DEFAULT;
bool wordIsNumber = isdigit(styler[start]); bool wordIsNumber = isdigit(styler[start]) != 0;
if (wordIsNumber) if (wordIsNumber)
chAttr = SCE_HPHP_NUMBER; chAttr = SCE_HPHP_NUMBER;
else { else {
char s[30 + 1]; char s[100 + 1];
unsigned int i = 0; unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) { for (; i < end - start + 1 && i < 100; i++) {
s[i] = styler[start + i]; s[i] = static_cast<char>(tolower(styler[start + i]));
} }
s[i] = '\0'; s[i] = '\0';
if (keywords.InList(s)) 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 // Return the first state to reach when entering a scripting language
static int StateForScript(int scriptLanguage) { static int StateForScript(script_type scriptLanguage) {
int Result; int Result;
switch (scriptLanguage) { switch (scriptLanguage) {
case eScriptVBS: case eScriptVBS:
@@ -349,11 +358,11 @@ static int StateForScript(int scriptLanguage) {
return Result; return Result;
} }
inline bool ishtmlwordchar(char ch) { static inline bool ishtmlwordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || 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 == '['; 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 = eScriptJS << 8;
lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4; 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 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 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 script_type aspScript = script_type((lineState >> 4) & 0x0F); // 4 bits of script name
int clientScript = (lineState >> 8) & 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 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 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 levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev; int levelCurrent = levelPrev;
@@ -502,6 +511,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
} }
break; break;
default:
break;
} }
} }
@@ -729,8 +740,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
break; break;
case SCE_H_SGML_DEFAULT: case SCE_H_SGML_DEFAULT:
if (scriptLanguage == eScriptSGMLblock) case SCE_H_SGML_BLOCK_DEFAULT:
StateToPrint = SCE_H_SGML_BLOCK_DEFAULT; // if (scriptLanguage == eScriptSGMLblock)
// StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
if (ch == '\"') { if (ch == '\"') {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
@@ -750,6 +762,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} else if (ch == '[') { } else if (ch == '[') {
styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i - 1, StateToPrint);
scriptLanguage = eScriptSGMLblock; scriptLanguage = eScriptSGMLblock;
state = SCE_H_SGML_BLOCK_DEFAULT;
} else if (ch == ']') { } else if (ch == ']') {
if (scriptLanguage == eScriptSGMLblock) { if (scriptLanguage == eScriptSGMLblock) {
styler.ColourTo(i, StateToPrint); 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 - 1, StateToPrint);
styler.ColourTo(i, SCE_H_SGML_ERROR); styler.ColourTo(i, SCE_H_SGML_ERROR);
} }
state = SCE_H_SGML_DEFAULT;
} else if (scriptLanguage == eScriptSGMLblock) { } else if (scriptLanguage == eScriptSGMLblock) {
if ((ch == '!') && (chPrev == '<')) { if ((ch == '!') && (chPrev == '<')) {
styler.ColourTo(i - 2, StateToPrint); styler.ColourTo(i - 2, StateToPrint);
@@ -805,7 +819,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
i += size - 1; i += size - 1;
visibleChars += size - 1; visibleChars += size - 1;
ch = styler.SafeGetCharAt(i); ch = styler.SafeGetCharAt(i);
state = SCE_H_SGML_DEFAULT; if (scriptLanguage == eScriptSGMLblock) {
state = SCE_H_SGML_BLOCK_DEFAULT;
} else {
state = SCE_H_SGML_DEFAULT;
}
continue; continue;
} }
break; 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 lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml"); LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp");
LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php");

View File

@@ -21,7 +21,7 @@
#include "SciLexer.h" #include "SciLexer.h"
inline bool isLispoperator(char ch) { static inline bool isLispoperator(char ch) {
if (isascii(ch) && isalnum(ch)) if (isascii(ch) && isalnum(ch))
return false; return false;
if (ch == '\'' || ch == '(' || ch == ')' ) if (ch == '\'' || ch == '(' || ch == ')' )
@@ -29,7 +29,7 @@ inline bool isLispoperator(char ch) {
return false; return false;
} }
inline bool isLispwordstart(char ch) { static inline bool isLispwordstart(char ch) {
return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) && return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) &&
ch != '\n' && ch != '\r' && ch != '\"'; ch != '\n' && ch != '\r' && ch != '\"';
} }

View File

@@ -4,6 +4,7 @@
** **
** Written by Paul Winwood. ** Written by Paul Winwood.
** Folder by Alexey Yutkin. ** Folder by Alexey Yutkin.
** Modified by Marcos E. Wurzius
**/ **/
#include <stdlib.h> #include <stdlib.h>
@@ -17,216 +18,162 @@
#include "PropSet.h" #include "PropSet.h"
#include "Accessor.h" #include "Accessor.h"
#include "StyleContext.h"
#include "KeyWords.h" #include "KeyWords.h"
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.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) { inline bool isLuaOperator(char ch) {
if (isalnum(ch)) if (isalnum(ch))
return false; return false;
// '.' left out as it is used to make up numbers // '.' left out as it is used to make up numbers
if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||
ch == '(' || ch == ')' || ch == '=' || ch == '(' || ch == ')' || ch == '=' ||
ch == '{' || ch == '}' || ch == '~' || ch == '{' || ch == '}' || ch == '~' ||
ch == '[' || ch == ']' || ch == ';' || ch == '[' || ch == ']' || ch == ';' ||
ch == '<' || ch == '>' || ch == ',' || ch == '<' || ch == '>' || ch == ',' ||
ch == '.' || ch == '^' || ch == '%' || ch == ':') ch == '.' || ch == '^' || ch == '%' || ch == ':')
return true; return true;
return false; 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++) { static void ColouriseLuaDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
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[],
Accessor &styler) { Accessor &styler) {
WordList &keywords = *keywordlists[0]; 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); // Do not leak onto next line
styler.GetLine(startPos); if (initStyle == SCE_LUA_STRINGEOL)
initStyle = SCE_LUA_DEFAULT;
int state = initStyle; StyleContext sc(startPos, length, initStyle, styler);
char chPrev = ' '; if(startPos == 0 && sc.ch == '#') sc.SetState(SCE_LUA_COMMENTLINE);
char chNext = styler[startPos]; for (; sc.More(); sc.Forward()) {
unsigned int lengthDoc = startPos + length;
bool firstChar = true; // Handle line continuation generically.
if (sc.ch == '\\') {
/* Must initialize the literalString level, if we are inside such a string. if (sc.Match("\\\n")) {
* Note: this isn't enough, because literal strings can be nested, sc.Forward();
* we should go back to see at what level we are... sc.Forward();
*/ continue;
int literalString = (initStyle == SCE_LUA_LITERALSTRING) ? 1 : 0; }
if (sc.Match("\\\r\n")) {
styler.StartSegment(startPos); sc.Forward();
for (unsigned int i = startPos; i <= lengthDoc; i++) { sc.Forward();
char ch = chNext; sc.Forward();
chNext = styler.SafeGetCharAt(i + 1); continue;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_LUA_STRINGEOL) {
if (ch != '\r' && ch != '\n') {
styler.ColourTo(i - 1, state);
state = SCE_LUA_DEFAULT;
} }
} }
if (state == SCE_LUA_LITERALSTRING && ch == '[' && chNext == '[') { // Determine if the current state should terminate.
literalString++; if (sc.state == SCE_LUA_OPERATOR) {
} else if (state == SCE_LUA_DEFAULT) { sc.SetState(SCE_LUA_DEFAULT);
if (ch == '-' && chNext == '-') { } else if (sc.state == SCE_LUA_NUMBER) {
styler.ColourTo(i - 1, state); if (!IsAWordChar(sc.ch)) {
state = SCE_LUA_COMMENTLINE; sc.SetState(SCE_LUA_DEFAULT);
} else if (ch == '[' && chNext == '[') { }
state = SCE_LUA_LITERALSTRING; } 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++;
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; literalString = 1;
} else if (ch == '\"') { } else if (sc.ch == '-' && sc.chNext == '-') {
styler.ColourTo(i - 1, state); sc.SetState(SCE_LUA_COMMENTLINE);
state = SCE_LUA_STRING; } else if (isLuaOperator(static_cast<char>(sc.ch))) {
} else if (ch == '\'') { sc.SetState(SCE_LUA_OPERATOR);
styler.ColourTo(i - 1, state);
state = SCE_LUA_CHARACTER;
} else if (ch == '$' && firstChar) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_PREPROCESSOR;
} else if (ch == '#' && firstChar) // Should be only on the first line of the file! Cannot be tested here
{
styler.ColourTo(i - 1, state);
state = SCE_LUA_COMMENTLINE;
} else if (isLuaOperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_LUA_OPERATOR);
} else if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_WORD;
}
} else if (state == SCE_LUA_WORD) {
if (!iswordchar(ch)) {
classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_LUA_DEFAULT;
if (ch == '[' && chNext == '[') {
literalString = 1;
state = SCE_LUA_LITERALSTRING;
} else if (ch == '-' && chNext == '-') {
state = SCE_LUA_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_LUA_STRING;
} else if (ch == '\'') {
state = SCE_LUA_CHARACTER;
} else if (ch == '$' && firstChar) {
state = SCE_LUA_PREPROCESSOR;
} else if (isLuaOperator(ch)) {
styler.ColourTo(i, SCE_LUA_OPERATOR);
}
} else if (ch == '.' && chNext == '.') {
classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
styler.ColourTo(i, SCE_LUA_OPERATOR);
state = SCE_LUA_DEFAULT;
}
} else {
if (state == SCE_LUA_LITERALSTRING) {
if (ch == ']' && (chPrev == ']') && (--literalString == 0)) {
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
}
} else if (state == SCE_LUA_PREPROCESSOR) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_DEFAULT;
}
} else if (state == SCE_LUA_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_LUA_DEFAULT;
}
} else if (state == SCE_LUA_STRING) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_LUA_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_LUA_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_LUA_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
if (state == SCE_LUA_DEFAULT) {
if (ch == '-' && chNext == '-') {
state = SCE_LUA_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_LUA_STRING;
} else if (ch == '\'') {
state = SCE_LUA_CHARACTER;
} else if (ch == '$' && firstChar) {
state = SCE_LUA_PREPROCESSOR;
} else if (iswordstart(ch)) {
state = SCE_LUA_WORD;
} else if (isLuaOperator(ch)) {
styler.ColourTo(i, SCE_LUA_OPERATOR);
}
} }
} }
chPrev = ch;
firstChar = (ch == '\r' || ch == '\n');
} }
styler.ColourTo(lengthDoc - 1, state); sc.Complete();
} }
static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[], static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[],
Accessor &styler) { Accessor &styler) {
unsigned int lengthDoc = startPos + length; 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 levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev; int levelCurrent = levelPrev;
char chNext = styler[startPos]; char chNext = styler[startPos];
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
int styleNext = styler.StyleAt(startPos); int styleNext = styler.StyleAt(startPos);
char s[10]; char s[10];
for (unsigned int i = startPos; i < lengthDoc; i++) { 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; int style = styleNext;
styleNext = styler.StyleAt(i + 1); styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (style == SCE_LUA_WORD) if (style == SCE_LUA_WORD) {
if ( ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') { if ( ch == 'i' || ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') {
for (unsigned int j = 0; j < 8; j++) { 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] = styler[i + j];
s[j + 1] = '\0'; 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)) || (strcmp(s, "function") == 0))
levelCurrent++; 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) { if (atEOL) {
int lev = levelPrev; int lev = levelPrev;
if (visibleChars == 0) if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG; lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0)) if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG; lev |= SC_FOLDLEVELHEADERFLAG;
@@ -274,6 +233,7 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
visibleChars++; visibleChars++;
} }
// Fill in the real level of the next line, keeping the current flags as they will be filled in later // Fill in the real level of the next line, keeping the current flags as they will be filled in later
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, levelPrev | flagsNext); styler.SetLevel(lineCurrent, levelPrev | flagsNext);
} }

View 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);

View File

@@ -20,6 +20,11 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.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( static void ColouriseBatchLine(
char *lineBuffer, char *lineBuffer,
unsigned int lengthLine, unsigned int lengthLine,
@@ -31,13 +36,13 @@ static void ColouriseBatchLine(
unsigned int i = 0; unsigned int i = 0;
unsigned int state = SCE_BAT_DEFAULT; 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++; i++;
} }
if (lineBuffer[i] == '@') { // Hide command (ECHO OFF) if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
styler.ColourTo(startLine + i, SCE_BAT_HIDE); styler.ColourTo(startLine + i, SCE_BAT_HIDE);
i++; i++;
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip next spaces while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip next spaces
i++; i++;
} }
} }
@@ -130,23 +135,20 @@ static void ColouriseBatchDoc(
styler.StartAt(startPos); styler.StartAt(startPos);
styler.StartSegment(startPos); styler.StartSegment(startPos);
unsigned int linePos = 0, startLine = startPos; unsigned int linePos = 0;
for (unsigned int i = startPos; i <= startPos + length; i++) { unsigned int startLine = startPos;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i]; lineBuffer[linePos++] = styler[i];
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it // End of line (or of line buffer) met, colourise it
if (styler[i + 1] == '\n') {
lineBuffer[linePos++] = styler[++i];
}
lineBuffer[linePos] = '\0'; lineBuffer[linePos] = '\0';
ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler); ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
linePos = 0; linePos = 0;
startLine = i + 1; startLine = i + 1;
} }
} }
if (linePos > 0) { if (linePos > 0) { // Last line does not have ending characters
ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length, ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
keywords, styler); keywords, styler);
} }
} }
@@ -182,13 +184,16 @@ static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[
unsigned int linePos = 0; 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]; 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); ColouriseDiffLine(lineBuffer, i, styler);
linePos = 0; linePos = 0;
} }
} }
if (linePos > 0) if (linePos > 0) { // Last line does not have ending characters
ColouriseDiffLine(lineBuffer, startPos + length, styler); ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
}
} }
static void ColourisePropsLine( static void ColourisePropsLine(
@@ -199,28 +204,32 @@ static void ColourisePropsLine(
Accessor &styler) { Accessor &styler) {
unsigned int i = 0; unsigned int i = 0;
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
i++; i++;
if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') { if (i < lengthLine) {
styler.ColourTo(endPos, 1); if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
} else if (lineBuffer[i] == '[') { styler.ColourTo(endPos, 1);
styler.ColourTo(endPos, 2); } else if (lineBuffer[i] == '[') {
} else if (lineBuffer[i] == '@') { styler.ColourTo(endPos, 2);
styler.ColourTo(startLine + i, 4); } else if (lineBuffer[i] == '@') {
if (lineBuffer[++i] == '=') styler.ColourTo(startLine + i, 4);
styler.ColourTo(startLine + i, 3); if (lineBuffer[++i] == '=')
styler.ColourTo(endPos, 0); styler.ColourTo(startLine + i, 3);
} else {
// Search for the '=' character
while (lineBuffer[i] != '=' && (i < lengthLine - 1))
i++;
if (lineBuffer[i] == '=') {
styler.ColourTo(startLine + i - 1, 0);
styler.ColourTo(startLine + i, 3);
styler.ColourTo(endPos, 0); styler.ColourTo(endPos, 0);
} else { } else {
styler.ColourTo(endPos, 0); // Search for the '=' character
while ((i < lengthLine) && (lineBuffer[i] != '='))
i++;
if ((i < lengthLine) && (lineBuffer[i] == '=')) {
styler.ColourTo(startLine + i - 1, 0);
styler.ColourTo(startLine + i, 3);
styler.ColourTo(endPos, 0);
} else {
styler.ColourTo(endPos, 0);
}
} }
} else {
styler.ColourTo(endPos, 0);
} }
} }
@@ -228,20 +237,21 @@ static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *
char lineBuffer[1024]; char lineBuffer[1024];
styler.StartAt(startPos); styler.StartAt(startPos);
styler.StartSegment(startPos); styler.StartSegment(startPos);
unsigned int linePos = 0, startLine = startPos; unsigned int linePos = 0;
for (unsigned int i = startPos; i <= startPos + length; i++) { unsigned int startLine = startPos;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i]; lineBuffer[linePos++] = styler[i];
if ((styler[i] == '\r' && styler.SafeGetCharAt(i + 1) != '\n') || if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
styler[i] == '\n' || // End of line (or of line buffer) met, colourise it
(linePos >= sizeof(lineBuffer) - 1)) {
lineBuffer[linePos] = '\0'; lineBuffer[linePos] = '\0';
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler); ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0; linePos = 0;
startLine = i + 1; startLine = i + 1;
} }
} }
if (linePos > 0) if (linePos > 0) { // Last line does not have ending characters
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler); ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
}
} }
static void ColouriseMakeLine( static void ColouriseMakeLine(
@@ -256,7 +266,7 @@ static void ColouriseMakeLine(
unsigned int state = SCE_MAKE_DEFAULT; unsigned int state = SCE_MAKE_DEFAULT;
bool bSpecial = false; bool bSpecial = false;
// Skip initial spaces // Skip initial spaces
while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
i++; i++;
} }
if (lineBuffer[i] == '#') { // Comment if (lineBuffer[i] == '#') { // Comment
@@ -277,6 +287,8 @@ static void ColouriseMakeLine(
} }
if (!bSpecial) { if (!bSpecial) {
if (lineBuffer[i] == ':') { 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 + lastNonSpace, SCE_MAKE_TARGET);
styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT); styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR); styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
@@ -306,18 +318,20 @@ static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[
char lineBuffer[1024]; char lineBuffer[1024];
styler.StartAt(startPos); styler.StartAt(startPos);
styler.StartSegment(startPos); styler.StartSegment(startPos);
unsigned int linePos = 0, startLine = startPos; unsigned int linePos = 0;
for (unsigned int i = startPos; i <= startPos + length; i++) { unsigned int startLine = startPos;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i]; lineBuffer[linePos++] = styler[i];
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) { if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0'; lineBuffer[linePos] = '\0';
ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler); ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0; linePos = 0;
startLine = i + 1; startLine = i + 1;
} }
} }
if (linePos > 0) { if (linePos > 0) { // Last line does not have ending characters
ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length, styler); ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
} }
} }
@@ -347,15 +361,15 @@ static void ColouriseErrorListLine(
// Borland warning message // Borland warning message
styler.ColourTo(endPos, SCE_ERR_BORLAND); styler.ColourTo(endPos, SCE_ERR_BORLAND);
} else if (strstr(lineBuffer, "at line " ) && } else if (strstr(lineBuffer, "at line " ) &&
strstr(lineBuffer, "at line " ) < lineBuffer + lengthLine && (strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
strstr(lineBuffer, "file ") && strstr(lineBuffer, "file ") &&
strstr(lineBuffer, "file ") < lineBuffer + lengthLine) { (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
// Lua error message // Lua error message
styler.ColourTo(endPos, SCE_ERR_LUA); styler.ColourTo(endPos, SCE_ERR_LUA);
} else if (strstr(lineBuffer, " at " ) && } else if (strstr(lineBuffer, " at " ) &&
strstr(lineBuffer, " at " ) < lineBuffer + lengthLine && (strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
strstr(lineBuffer, " line ") && strstr(lineBuffer, " line ") &&
strstr(lineBuffer, " line ") < lineBuffer + lengthLine) { (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine))) {
// perl error message // perl error message
styler.ColourTo(endPos, SCE_ERR_PERL); styler.ColourTo(endPos, SCE_ERR_PERL);
} else if ((memcmp(lineBuffer, " at ", 6) == 0) && } else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
@@ -368,26 +382,26 @@ static void ColouriseErrorListLine(
// Look for <filename>(line,pos)message // Look for <filename>(line,pos)message
int state = 0; int state = 0;
for (unsigned int i = 0; i < lengthLine; i++) { for (unsigned int i = 0; i < lengthLine; i++) {
if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) { if ((state == 0) && (lineBuffer[i] == ':') && isdigit(lineBuffer[i + 1])) {
state = 1; state = 1;
} else if (state == 0 && lineBuffer[i] == '(') { } else if ((state == 0) && (lineBuffer[i] == '(')) {
state = 10; state = 10;
} else if (state == 1 && isdigit(lineBuffer[i])) { } else if ((state == 1) && isdigit(lineBuffer[i])) {
state = 2; state = 2;
} else if (state == 2 && lineBuffer[i] == ':') { } else if ((state == 2) && (lineBuffer[i] == ':')) {
state = 3; state = 3;
break; break;
} else if (state == 2 && !isdigit(lineBuffer[i])) { } else if ((state == 2) && !isdigit(lineBuffer[i])) {
state = 99; state = 99;
} else if (state == 10 && isdigit(lineBuffer[i])) { } else if ((state == 10) && isdigit(lineBuffer[i])) {
state = 11; state = 11;
} else if (state == 11 && lineBuffer[i] == ',') { } else if ((state == 11) && (lineBuffer[i] == ',')) {
state = 14; state = 14;
} else if (state == 11 && lineBuffer[i] == ')') { } else if ((state == 11) && (lineBuffer[i] == ')')) {
state = 12; state = 12;
} else if (state == 12 && lineBuffer[i] == ':') { } else if ((state == 12) && (lineBuffer[i] == ':')) {
state = 13; state = 13;
} else if (state == 14 && lineBuffer[i] == ')') { } else if ((state == 14) && (lineBuffer[i] == ')')) {
state = 15; state = 15;
break; break;
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) { } 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.StartAt(startPos);
styler.StartSegment(startPos); styler.StartSegment(startPos);
unsigned int linePos = 0; 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]; 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); ColouriseErrorListLine(lineBuffer, linePos, i, styler);
linePos = 0; linePos = 0;
} }
} }
if (linePos > 0) if (linePos > 0) { // Last line does not have ending characters
ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler); ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
}
} }
static int isSpecial(char s) { static int isSpecial(char s) {

View File

@@ -18,7 +18,6 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.h" #include "SciLexer.h"
static int classifyWordPascal(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { static int classifyWordPascal(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char s[100]; char s[100];
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { 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); styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold"); bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev; int levelCurrent = levelPrev;

View File

@@ -656,7 +656,7 @@ static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
} }
chPrev = ch; chPrev = ch;
} }
styler.ColourTo(lengthDoc, state); styler.ColourTo(lengthDoc - 1, state);
} }
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl"); LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl");

View File

@@ -1,8 +1,8 @@
// Scintilla source code edit control // Scintilla source code edit control
/** @file LexPython.cxx /** @file LexPython.cxx
** Lexer for Python. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -23,7 +23,7 @@
enum kwType { kwOther, kwClass, kwDef, kwImport }; enum kwType { kwOther, kwClass, kwDef, kwImport };
static bool IsPyComment(Accessor &styler, int pos, int len) { 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) { static bool IsPyStringStart(int ch, int chNext, int chNext2) {
@@ -51,8 +51,7 @@ static int GetPyStringState(Accessor &styler, int i, int *nextIndex) {
i++; i++;
ch = styler.SafeGetCharAt(i); ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1); chNext = styler.SafeGetCharAt(i + 1);
} } else if (ch == 'u' || ch == 'U') {
else if (ch == 'u' || ch == 'U') {
if (chNext == 'r' || chNext == 'R') if (chNext == 'r' || chNext == 'R')
i += 2; i += 2;
else else
@@ -83,16 +82,16 @@ 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 == '_'); return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
} }
inline bool IsAWordStart(int ch) { static inline bool IsAWordStart(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_'); return (ch < 0x80) && (isalnum(ch) || ch == '_');
} }
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) { WordList *keywordlists[], Accessor &styler) {
int endPos = startPos + length; int endPos = startPos + length;
@@ -100,11 +99,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
if (startPos > 0) { if (startPos > 0) {
if (lineCurrent > 0) { if (lineCurrent > 0) {
startPos = styler.LineStart(lineCurrent-1); startPos = styler.LineStart(lineCurrent - 1);
if (startPos == 0) if (startPos == 0)
initStyle = SCE_P_DEFAULT; initStyle = SCE_P_DEFAULT;
else else
initStyle = styler.StyleAt(startPos-1); initStyle = styler.StyleAt(startPos - 1);
} }
} }
@@ -120,10 +119,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
kwType kwLast = kwOther; kwType kwLast = kwOther;
int spaceFlags = 0; int spaceFlags = 0;
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment); styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
bool hexadecimal = false;
// Python uses a different mask because bad indentation is marked by oring with 32 // Python uses a different mask because bad indentation is marked by oring with 32
StyleContext sc(startPos, endPos-startPos, initStyle, styler, 0x7f); StyleContext sc(startPos, endPos - startPos, initStyle, styler, 0x7f);
for (; sc.More(); sc.Forward()) { for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) { if (sc.atLineStart) {
@@ -143,9 +143,9 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
} }
if (sc.atLineEnd) { if (sc.atLineEnd) {
if ((sc.state == SCE_P_DEFAULT) || if ((sc.state == SCE_P_DEFAULT) ||
(sc.state == SCE_P_TRIPLE) || (sc.state == SCE_P_TRIPLE) ||
(sc.state == SCE_P_TRIPLEDOUBLE)) { (sc.state == SCE_P_TRIPLEDOUBLE)) {
// Perform colourisation of white space and triple quoted strings at end of each line to allow // Perform colourisation of white space and triple quoted strings at end of each line to allow
// tab marking to work inside white space and triple quoted strings // tab marking to work inside white space and triple quoted strings
sc.ForwardSetState(sc.state); sc.ForwardSetState(sc.state);
@@ -156,6 +156,8 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
sc.ChangeState(SCE_P_STRINGEOL); sc.ChangeState(SCE_P_STRINGEOL);
sc.ForwardSetState(SCE_P_DEFAULT); sc.ForwardSetState(SCE_P_DEFAULT);
} }
if (!sc.More())
break;
} }
// Check for a state end // Check for a state end
@@ -163,10 +165,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
kwLast = kwOther; kwLast = kwOther;
sc.SetState(SCE_C_DEFAULT); sc.SetState(SCE_C_DEFAULT);
} else if (sc.state == SCE_P_NUMBER) { } 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); 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))) { if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) {
char s[100]; char s[100];
sc.GetCurrent(s, sizeof(s)); sc.GetCurrent(s, sizeof(s));
@@ -192,9 +195,9 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
else else
kwLast = kwOther; kwLast = kwOther;
} else if (style == SCE_P_CLASSNAME) { } else if (style == SCE_P_CLASSNAME) {
kwLast = kwOther; kwLast = kwOther;
} else if (style == SCE_P_DEFNAME) { } else if (style == SCE_P_DEFNAME) {
kwLast = kwOther; kwLast = kwOther;
} }
} }
} else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) { } else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) {
@@ -232,20 +235,25 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
// Check for a new state starting character // Check for a new state starting character
if (sc.state == SCE_P_DEFAULT) { 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); sc.SetState(SCE_P_OPERATOR);
} else if (sc.ch == '#') { } else if (sc.ch == '#') {
sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE); 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))) { } else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2))) {
int nextIndex = 0; int nextIndex = 0;
sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex)); sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex));
while (nextIndex > (sc.currentPos+1)) { while (nextIndex > (sc.currentPos + 1)) {
sc.Forward(); sc.Forward();
} }
} else if (IsAWordStart(sc.ch)) { } 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) { static bool IsCommentLine(int line, Accessor &styler) {
int pos = styler.LineStart(line); 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++) { for (int i = pos; i < eol_pos; i++) {
char ch = styler[i]; char ch = styler[i];
if (ch == '#') if (ch == '#')
@@ -267,18 +275,18 @@ static bool IsCommentLine(int line, Accessor &styler) {
static bool IsQuoteLine(int line, Accessor &styler) { static bool IsQuoteLine(int line, Accessor &styler) {
int style = styler.StyleAt(styler.LineStart(line)) & 31; 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*/, static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
WordList *[], Accessor &styler) { WordList *[], Accessor &styler) {
const int maxPos = startPos + length; 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 int docLines = styler.GetLine(styler.Length() - 1); // Available last line
const bool foldComment = styler.GetPropertyInt("fold.comment.python"); const bool foldComment = styler.GetPropertyInt("fold.comment.python") != 0;
const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python"); const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0;
// Backtrack to previous non-blank line so we can determine indent level // Backtrack to previous non-blank line so we can determine indent level
// for any white space lines (needed esp. within triple quoted strings) // for any white space lines (needed esp. within triple quoted strings)
// and so we can fix any preceding fold level (which is why we go back // and so we can fix any preceding fold level (which is why we go back
@@ -290,17 +298,17 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
lineCurrent--; lineCurrent--;
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) && if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) &&
(!IsCommentLine(lineCurrent, styler)) && (!IsCommentLine(lineCurrent, styler)) &&
(!IsQuoteLine(lineCurrent, styler))) (!IsQuoteLine(lineCurrent, styler)))
break; break;
} }
int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
// Set up initial loop state // Set up initial loop state
startPos = styler.LineStart(lineCurrent); startPos = styler.LineStart(lineCurrent);
int prev_state = SCE_P_DEFAULT & 31; int prev_state = SCE_P_DEFAULT & 31;
if (lineCurrent >= 1) 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 prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
int prevComment = 0; int prevComment = 0;
if (lineCurrent >= 1) if (lineCurrent >= 1)
@@ -320,13 +328,13 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
// Information about next line is only available if not at end of document // Information about next line is only available if not at end of document
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
int style = styler.StyleAt(styler.LineStart(lineNext)) & 31; 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_start = (quote && !prevQuote);
const int quote_continue = (quote && prevQuote); const int quote_continue = (quote && prevQuote);
const int comment = foldComment && IsCommentLine(lineCurrent, styler); const int comment = foldComment && IsCommentLine(lineCurrent, styler);
const int comment_start = (comment && !prevComment && (lineNext <= docLines) && const int comment_start = (comment && !prevComment && (lineNext <= docLines) &&
IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE)); IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
const int comment_continue = (comment && prevComment); const int comment_continue = (comment && prevComment);
if ((!quote || !prevQuote) && !comment) if ((!quote || !prevQuote) && !comment)
indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
@@ -354,9 +362,9 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
// than screwing up folding. // than screwing up folding.
const int saveIndentNext = indentNext; const int saveIndentNext = indentNext;
while (!quote && while (!quote &&
(lineNext < docLines) && (lineNext < docLines) &&
((indentNext & SC_FOLDLEVELWHITEFLAG) || ((indentNext & SC_FOLDLEVELWHITEFLAG) ||
(lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) { (lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) {
lineNext++; lineNext++;
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
@@ -365,8 +373,8 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
// Next compute max indent level of current line and next non-blank line. // Next compute max indent level of current line and next non-blank line.
// This is the level to which we set all the intervening blank or comment lines. // This is the level to which we set all the intervening blank or comment lines.
const int skip_level = Platform::Maximum(indentCurrentLevel, const int skip_level = Platform::Maximum(indentCurrentLevel,
indentNext & SC_FOLDLEVELNUMBERMASK); indentNext & SC_FOLDLEVELNUMBERMASK);
// Now set all the indent levels on the lines we skipped // Now set all the indent levels on the lines we skipped
int skipLine = lineCurrent + 1; int skipLine = lineCurrent + 1;
int skipIndentNext = saveIndentNext; int skipIndentNext = saveIndentNext;
@@ -378,7 +386,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
skipLine++; skipLine++;
skipIndentNext = styler.IndentAmount(skipLine, &spaceFlags, NULL); skipIndentNext = styler.IndentAmount(skipLine, &spaceFlags, NULL);
} }
// Set fold header on non-quote/non-comment line // Set fold header on non-quote/non-comment line
if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) { if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))

View File

@@ -21,7 +21,7 @@
static void ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) { static void ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
char s[100]; char s[100];
bool wordIsNumber = isdigit(styler[start]); bool wordIsNumber = isdigit(styler[start]) != 0;
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i]; s[i] = styler[start + i];
s[i + 1] = '\0'; s[i + 1] = '\0';
@@ -294,9 +294,9 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
chPrev = ch; chPrev = ch;
} }
if (state == SCE_P_WORD) { if (state == SCE_P_WORD) {
ClassifyWordRb(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord); ClassifyWordRb(styler.GetStartSegment(), lengthDoc-1, keywords, styler, prevWord);
} else { } else {
styler.ColourTo(lengthDoc, state); styler.ColourTo(lengthDoc-1, state);
} }
} }

View File

@@ -2,7 +2,7 @@
/** @file LexSQL.cxx /** @file LexSQL.cxx
** Lexer for SQL. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -43,7 +43,7 @@ static void ColouriseSQLDoc(unsigned int startPos, int length,
styler.StartAt(startPos); styler.StartAt(startPos);
bool fold = styler.GetPropertyInt("fold"); bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
int spaceFlags = 0; int spaceFlags = 0;

View File

@@ -15,136 +15,142 @@
#include "PropSet.h" #include "PropSet.h"
#include "Accessor.h" #include "Accessor.h"
#include "StyleContext.h"
#include "KeyWords.h" #include "KeyWords.h"
#include "Scintilla.h" #include "Scintilla.h"
#include "SciLexer.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) { static bool IsVBComment(Accessor &styler, int pos, int len) {
return len>0 && styler[pos]=='\''; 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, static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) { WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) {
WordList &keywords = *keywordlists[0]; WordList &keywords = *keywordlists[0];
styler.StartAt(startPos); styler.StartAt(startPos);
int visibleChars = 0; int visibleChars = 0;
int state = initStyle;
char chNext = styler[startPos]; StyleContext sc(startPos, length, initStyle, styler);
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)) { for (; sc.More(); sc.Forward()) {
chNext = styler.SafeGetCharAt(i + 2);
i += 1;
continue;
}
if (ch == '\r' || ch == '\n') { if (sc.state == SCE_B_OPERATOR) {
// End of line sc.SetState(SCE_B_DEFAULT);
if (state == SCE_C_COMMENTLINE || state == SCE_C_PREPROCESSOR) { } else if (sc.state == SCE_B_KEYWORD) {
styler.ColourTo(i - 1, state); if (!IsAWordChar(sc.ch)) {
state = SCE_C_DEFAULT; if (vbScriptSyntax || !IsTypeCharacter(sc.ch)) {
} if (sc.ch == ']')
visibleChars = 0; sc.Forward();
} char s[100];
if (!isspacechar(ch)) sc.GetCurrentLowered(s, sizeof(s));
visibleChars++; if (keywords.InList(s)) {
if (strcmp(s, "rem") == 0) {
if (state == SCE_C_DEFAULT) { sc.ChangeState(SCE_B_COMMENT);
if (iswordstart(ch)) { if (sc.atLineEnd) {
styler.ColourTo(i - 1, state); sc.SetState(SCE_B_DEFAULT);
state = SCE_C_WORD; }
} else if (ch == '\'') { } else {
styler.ColourTo(i - 1, state); sc.SetState(SCE_B_DEFAULT);
state = SCE_C_COMMENTLINE; }
} else if (ch == '\"') { } else {
styler.ColourTo(i - 1, state); sc.ChangeState(SCE_B_IDENTIFIER);
state = SCE_C_STRING; sc.SetState(SCE_B_DEFAULT);
} 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);
} }
} }
} }
} else { } else if (sc.state == SCE_B_NUMBER) {
if (state == SCE_C_STRING) { if (!IsAWordChar(sc.ch)) {
// VB doubles quotes to preserve them sc.SetState(SCE_B_DEFAULT);
if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} }
if (state == SCE_C_DEFAULT) { // One of the above succeeded } else if (sc.state == SCE_B_STRING) {
if (ch == '\'') { // VB doubles quotes to preserve them, so just end this string
state = SCE_C_COMMENTLINE; // state now as a following quote will start again
} else if (ch == '\"') { if (sc.ch == '\"') {
state = SCE_C_STRING; if (tolower(sc.chNext) == 'c') {
} else if (iswordstart(ch)) { sc.Forward();
state = SCE_C_WORD;
} }
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++;
}
} }
styler.ColourTo(lengthDoc, state); sc.Complete();
} }
static void FoldVBDoc(unsigned int startPos, int length, int initStyle, static void FoldVBDoc(unsigned int startPos, int length, int,
WordList *[], Accessor &styler) { WordList *[], Accessor &styler) {
int lengthDoc = startPos + length; int endPos = startPos + length;
// Backtrack to previous line in case need to fix its fold status // Backtrack to previous line in case need to fix its fold status
int lineCurrent = styler.GetLine(startPos); int lineCurrent = styler.GetLine(startPos);
@@ -152,28 +158,18 @@ static void FoldVBDoc(unsigned int startPos, int length, int initStyle,
if (lineCurrent > 0) { if (lineCurrent > 0) {
lineCurrent--; lineCurrent--;
startPos = styler.LineStart(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 spaceFlags = 0;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsVBComment); int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsVBComment);
if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
indentCurrent |= SC_FOLDLEVELWHITEFLAG;
char chNext = styler[startPos]; char chNext = styler[startPos];
for (int i = startPos; i < lengthDoc; i++) { for (int i = startPos; i < endPos; i++) {
char ch = chNext; char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1); 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 lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsVBComment); int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsVBComment);
if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE))
indentNext |= SC_FOLDLEVELWHITEFLAG;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers // Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) { 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);

View File

@@ -10,7 +10,7 @@
#include "Scintilla.h" #include "Scintilla.h"
#include "LineMarker.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; PRectangle rc;
rc.left = centreX - armSize; rc.left = centreX - armSize;
rc.top = centreY - 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); 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; PRectangle rcCircle;
rcCircle.left = centreX - armSize; rcCircle.left = centreX - armSize;
rcCircle.top = centreY - 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); 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); PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore); surface->FillRectangle(rcV, fore);
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1); PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore); 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); PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore); surface->FillRectangle(rcH, fore);
} }
@@ -123,7 +123,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
rcSmall.bottom = rc.bottom - 2; rcSmall.bottom = rc.bottom - 2;
surface->RectangleDraw(rcSmall, fore.allocated, back.allocated); surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
} else if (markType == SC_MARK_EMPTY) { } else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND) {
// An invisible marker so don't draw anything // An invisible marker so don't draw anything
} else if (markType == SC_MARK_VLINE) { } else if (markType == SC_MARK_VLINE) {

View File

@@ -17,8 +17,8 @@ public:
ColourPair back; ColourPair back;
LineMarker() { LineMarker() {
markType = SC_MARK_CIRCLE; markType = SC_MARK_CIRCLE;
fore = Colour(0,0,0); fore = ColourDesired(0,0,0);
back = Colour(0xff,0xff,0xff); back = ColourDesired(0xff,0xff,0xff);
} }
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter); void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
}; };

View File

@@ -2,7 +2,7 @@
/** @file PropSet.cxx /** @file PropSet.cxx
** A Java style properties file module. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
// Maintain a dictionary of properties // Maintain a dictionary of properties
@@ -27,45 +27,43 @@ static inline char MakeUpperCase(char ch) {
} }
static inline bool IsLetter(char ch) { static inline bool IsLetter(char ch) {
return ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')); return ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'));
} }
int CompareCaseInsensitive(const char *a, const char *b) { int CompareCaseInsensitive(const char *a, const char *b) {
while (*a && *b) { while (*a && *b) {
if (*a != *b) { if (*a != *b) {
char upperA = MakeUpperCase(*a); char upperA = MakeUpperCase(*a);
char upperB = MakeUpperCase(*b); char upperB = MakeUpperCase(*b);
if (upperA != upperB) if (upperA != upperB)
return upperA - upperB; return upperA - upperB;
} }
a++; a++;
b++; b++;
} }
// Either *a or *b is nul // Either *a or *b is nul
return *a - *b; return *a - *b;
} }
int CompareNCaseInsensitive(const char *a, const char *b, int len) { int CompareNCaseInsensitive(const char *a, const char *b, int len) {
while (*a && *b && len) { while (*a && *b && len) {
if (*a != *b) { if (*a != *b) {
char upperA = MakeUpperCase(*a); char upperA = MakeUpperCase(*a);
char upperB = MakeUpperCase(*b); char upperB = MakeUpperCase(*b);
if (upperA != upperB) if (upperA != upperB)
return upperA - upperB; return upperA - upperB;
} }
a++; a++;
b++; b++;
len--; len--;
} }
if (len == 0) if (len == 0)
return 0; return 0;
else else
// Either *a or *b is nul // Either *a or *b is nul
return *a - *b; return *a - *b;
} }
bool EqualCaseInsensitive(const char *a, const char *b) { bool EqualCaseInsensitive(const char *a, const char *b) {
return 0 == CompareCaseInsensitive(a, b); return 0 == CompareCaseInsensitive(a, b);
} }
@@ -100,8 +98,8 @@ void PropSet::Set(const char *key, const char *val, int lenKey, int lenVal) {
lenVal = strlen(val); lenVal = strlen(val);
unsigned int hash = HashString(key, lenKey); unsigned int hash = HashString(key, lenKey);
for (Property *p = props[hash % hashRoots]; p; p = p->next) { for (Property *p = props[hash % hashRoots]; p; p = p->next) {
if ((hash == p->hash) && if ((hash == p->hash) &&
((strlen(p->key) == static_cast<unsigned int>(lenKey)) && ((strlen(p->key) == static_cast<unsigned int>(lenKey)) &&
(0 == strncmp(p->key, key, lenKey)))) { (0 == strncmp(p->key, key, lenKey)))) {
// Replace current value // Replace current value
delete [](p->val); delete [](p->val);
@@ -561,7 +559,7 @@ bool WordList::InList(const char *s) {
* The length of the word to compare is passed too. * The length of the word to compare is passed too.
* Letter case can be ignored or preserved (default). * 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 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 end = len - 1; // upper bound of the api array block to search
int pivot; // index of api array element just being compared int pivot; // index of api array element just being compared
@@ -579,8 +577,8 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
pivot = (start + end) >> 1; pivot = (start + end) >> 1;
word = wordsNoCase[pivot]; word = wordsNoCase[pivot];
cond = CompareNCaseInsensitive(wordStart, word, searchLen); 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() return word; // result must not be freed with free()
else if (cond > 0) else if (cond > 0)
start = pivot + 1; start = pivot + 1;
else if (cond <= 0) else if (cond <= 0)
@@ -591,7 +589,7 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
pivot = (start + end) >> 1; pivot = (start + end) >> 1;
word = words[pivot]; word = words[pivot];
cond = strncmp(wordStart, word, searchLen); 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() return word; // result must not be freed with free()
else if (cond > 0) else if (cond > 0)
start = pivot + 1; start = pivot + 1;
@@ -666,13 +664,13 @@ char *WordList::GetNearestWords(
if (!cond) { if (!cond) {
// Find first match // Find first match
while ((pivot > start) && while ((pivot > start) &&
(0 == CompareNCaseInsensitive(wordStart, (0 == CompareNCaseInsensitive(wordStart,
wordsNoCase[pivot-1], searchLen))) { wordsNoCase[pivot-1], searchLen))) {
--pivot; --pivot;
} }
// Grab each match // Grab each match
while ((pivot <= end) && while ((pivot <= end) &&
(0 == CompareNCaseInsensitive(wordStart, (0 == CompareNCaseInsensitive(wordStart,
wordsNoCase[pivot], searchLen))) { wordsNoCase[pivot], searchLen))) {
wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1; wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1;
wordsNear.append(wordsNoCase[pivot], wordlen, ' '); wordsNear.append(wordsNoCase[pivot], wordlen, ' ');
@@ -692,14 +690,14 @@ char *WordList::GetNearestWords(
if (!cond) { if (!cond) {
// Find first match // Find first match
while ((pivot > start) && while ((pivot > start) &&
(0 == strncmp(wordStart, (0 == strncmp(wordStart,
words[pivot-1], searchLen))) { words[pivot-1], searchLen))) {
--pivot; --pivot;
} }
// Grab each match // Grab each match
while ((pivot <= end) && while ((pivot <= end) &&
(0 == strncmp(wordStart, (0 == strncmp(wordStart,
words[pivot], searchLen))) { words[pivot], searchLen))) {
wordlen = LengthWord(words[pivot], otherSeparator) + 1; wordlen = LengthWord(words[pivot], otherSeparator) + 1;
wordsNear.append(words[pivot], wordlen, ' '); wordsNear.append(words[pivot], wordlen, ' ');
++pivot; ++pivot;

View File

@@ -30,8 +30,8 @@
* Modification history: * Modification history:
* *
* $Log$ * $Log$
* Revision 1.2 2001/10/18 01:24:58 RD * Revision 1.3 2002/03/18 22:31:00 RD
* Updated to version 1.40 of Scintilla * Updated wxSTC from Scintilla 1.40 to Scintilla 1.45
* *
* Revision 1.6 2001/04/29 13:32:10 nyamatongwe * Revision 1.6 2001/04/29 13:32:10 nyamatongwe
* Addition of new target methods - versions of ReplaceTarget that take counted * Addition of new target methods - versions of ReplaceTarget that take counted

View File

@@ -2,7 +2,7 @@
/** @file ScintillaBase.cxx /** @file ScintillaBase.cxx
** An enhanced subclass of Editor with calltips, autocomplete and context menu. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -63,10 +63,10 @@ void ScintillaBase::RefreshColourPalette(Palette &pal, bool want) {
ct.RefreshColourPalette(pal, 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(); bool acActiveBeforeCharAdded = ac.Active();
if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s)) if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s))
Editor::AddCharUTF(s, len); Editor::AddCharUTF(s, len, treatAsDBCS);
if (acActiveBeforeCharAdded) if (acActiveBeforeCharAdded)
AutoCompleteChanged(s[0]); AutoCompleteChanged(s[0]);
} }
@@ -137,7 +137,12 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
AutoCompleteMove(5000); AutoCompleteMove(5000);
return 0; return 0;
case SCI_DELETEBACK: case SCI_DELETEBACK:
DelCharBack(); DelCharBack(true);
AutoCompleteChanged();
EnsureCaretVisible();
return 0;
case SCI_DELETEBACKNOTLINE:
DelCharBack(false);
AutoCompleteChanged(); AutoCompleteChanged();
EnsureCaretVisible(); EnsureCaretVisible();
return 0; return 0;
@@ -160,11 +165,12 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
(iMessage != SCI_CHARRIGHT) && (iMessage != SCI_CHARRIGHT) &&
(iMessage != SCI_CHARLEFTEXTEND) && (iMessage != SCI_CHARLEFTEXTEND) &&
(iMessage != SCI_EDITTOGGLEOVERTYPE) && (iMessage != SCI_EDITTOGGLEOVERTYPE) &&
(iMessage != SCI_DELETEBACK) (iMessage != SCI_DELETEBACK) &&
(iMessage != SCI_DELETEBACKNOTLINE)
) { ) {
ct.CallTipCancel(); ct.CallTipCancel();
} }
if (iMessage == SCI_DELETEBACK) { if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
if (currentPos <= ct.posStartCallTip) { if (currentPos <= ct.posStartCallTip) {
ct.CallTipCancel(); ct.CallTipCancel();
} }
@@ -173,6 +179,11 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
return Editor::KeyCommand(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) { void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
//Platform::DebugPrintf("AutoComplete %s\n", list); //Platform::DebugPrintf("AutoComplete %s\n", list);
ct.CallTipCancel(); ct.CallTipCancel();
@@ -190,7 +201,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
pdoc->InsertString(currentPos, list + lenEntered); pdoc->InsertString(currentPos, list + lenEntered);
SetEmptySelection(currentPos + strlen(list + lenEntered)); SetEmptySelection(currentPos + strlen(list + lenEntered));
} }
return ; return;
} }
} }
ac.Start(wMain, idAutoComplete, currentPos, lenEntered); 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.SetPositionRelative(rcac, wMain);
ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font); ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font);
ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth); ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth);
ac.lb.SetDoubleClickAction(AutoCompleteDoubleClick, this);
ac.SetList(list); ac.SetList(list);
@@ -295,14 +307,18 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
scn.lParam = 0; scn.lParam = 0;
scn.text = userListSelected.c_str(); scn.text = userListSelected.c_str();
NotifyParent(scn); NotifyParent(scn);
return ; return;
} }
Position firstPos = ac.posStart - ac.startLen; Position firstPos = ac.posStart - ac.startLen;
if (currentPos < firstPos) Position endPos = currentPos;
return ; if (ac.dropRestOfWord)
if (currentPos != firstPos) { endPos = pdoc->ExtendWordSelect(endPos, 1, true);
pdoc->DeleteChars(firstPos, currentPos - firstPos); if (endPos < firstPos)
return;
pdoc->BeginUndoAction();
if (endPos != firstPos) {
pdoc->DeleteChars(firstPos, endPos - firstPos);
} }
SetEmptySelection(ac.posStart); SetEmptySelection(ac.posStart);
if (item != -1) { if (item != -1) {
@@ -312,6 +328,7 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
pdoc->InsertString(firstPos, piece.c_str()); pdoc->InsertString(firstPos, piece.c_str());
SetEmptySelection(firstPos + piece.length()); SetEmptySelection(firstPos + piece.length());
} }
pdoc->EndUndoAction();
} }
void ScintillaBase::ContextMenu(Point pt) { void ScintillaBase::ContextMenu(Point pt) {
@@ -374,7 +391,7 @@ void ScintillaBase::Colourise(int start, int end) {
styleStart = styler.StyleAt(start - 1); styleStart = styler.StyleAt(start - 1);
styler.SetCodePage(pdoc->dbcsCodePage); 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); lexCurrent->Lex(start, len, styleStart, keyWordLists, styler);
styler.Flush(); styler.Flush();
if (styler.GetPropertyInt("fold")) { if (styler.GetPropertyInt("fold")) {
@@ -392,7 +409,7 @@ void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0); int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);
endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0); endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);
Colourise(endStyled, endStyleNeeded); Colourise(endStyled, endStyleNeeded);
return ; return;
} }
#endif #endif
Editor::NotifyStyleToNeeded(endStyleNeeded); Editor::NotifyStyleToNeeded(endStyleNeeded);
@@ -435,7 +452,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
break; break;
case SCI_AUTOCSETCANCELATSTART: case SCI_AUTOCSETCANCELATSTART:
ac.cancelAtStartPos = wParam; ac.cancelAtStartPos = wParam != 0;
break; break;
case SCI_AUTOCGETCANCELATSTART: case SCI_AUTOCGETCANCELATSTART:
@@ -446,14 +463,14 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
break; break;
case SCI_AUTOCSETCHOOSESINGLE: case SCI_AUTOCSETCHOOSESINGLE:
ac.chooseSingle = wParam; ac.chooseSingle = wParam != 0;
break; break;
case SCI_AUTOCGETCHOOSESINGLE: case SCI_AUTOCGETCHOOSESINGLE:
return ac.chooseSingle; return ac.chooseSingle;
case SCI_AUTOCSETIGNORECASE: case SCI_AUTOCSETIGNORECASE:
ac.ignoreCase = wParam; ac.ignoreCase = wParam != 0;
break; break;
case SCI_AUTOCGETIGNORECASE: case SCI_AUTOCGETIGNORECASE:
@@ -465,12 +482,19 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
break; break;
case SCI_AUTOCSETAUTOHIDE: case SCI_AUTOCSETAUTOHIDE:
ac.autoHide = wParam; ac.autoHide = wParam != 0;
break; break;
case SCI_AUTOCGETAUTOHIDE: case SCI_AUTOCGETAUTOHIDE:
return ac.autoHide; return ac.autoHide;
case SCI_AUTOCSETDROPRESTOFWORD:
ac.dropRestOfWord = wParam != 0;
break;
case SCI_AUTOCGETDROPRESTOFWORD:
return ac.dropRestOfWord;
case SCI_CALLTIPSHOW: { case SCI_CALLTIPSHOW: {
AutoCompleteCancel(); AutoCompleteCancel();
if (!ct.wCallTip.Created()) { 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, PRectangle rc = ct.CallTipStart(currentPos, pt,
reinterpret_cast<char *>(lParam), reinterpret_cast<char *>(lParam),
vs.styles[STYLE_DEFAULT].fontName, 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 // If the call-tip window would be out of the client
// space, adjust so it displays above the text. // space, adjust so it displays above the text.
PRectangle rcClient = GetClientRectangle(); PRectangle rcClient = GetClientRectangle();
@@ -511,12 +536,12 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
break; break;
case SCI_CALLTIPSETBACK: case SCI_CALLTIPSETBACK:
ct.colourBG = Colour(wParam); ct.colourBG = ColourDesired(wParam);
InvalidateStyleRedraw(); InvalidateStyleRedraw();
break; break;
case SCI_USEPOPUP: case SCI_USEPOPUP:
displayPopupMenu = wParam; displayPopupMenu = wParam != 0;
break; break;
#ifdef SCI_LEXER #ifdef SCI_LEXER

View File

@@ -2,7 +2,7 @@
/** @file ScintillaBase.h /** @file ScintillaBase.h
** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef SCINTILLABASE_H #ifndef SCINTILLABASE_H
@@ -20,7 +20,7 @@ protected:
enum { enum {
idCallTip=1, idCallTip=1,
idAutoComplete=2, idAutoComplete=2,
idcmdUndo=10, idcmdUndo=10,
idcmdRedo=11, idcmdRedo=11,
idcmdCut=12, idcmdCut=12,
@@ -38,10 +38,10 @@ protected:
int listType; ///< 0 is an autocomplete list int listType; ///< 0 is an autocomplete list
SString userListSelected; ///< Receives listbox selected string SString userListSelected; ///< Receives listbox selected string
#ifdef SCI_LEXER #ifdef SCI_LEXER
int lexLanguage; int lexLanguage;
LexerModule *lexCurrent; const LexerModule *lexCurrent;
PropSet props; PropSet props;
enum {numWordLists=6}; enum {numWordLists=6};
WordList *keyWordLists[numWordLists+1]; WordList *keyWordLists[numWordLists+1];
@@ -56,24 +56,25 @@ protected:
virtual void Finalise() = 0; virtual void Finalise() = 0;
virtual void RefreshColourPalette(Palette &pal, bool want); 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); void Command(int cmdId);
virtual void CancelModes(); virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage); virtual int KeyCommand(unsigned int iMessage);
void AutoCompleteStart(int lenEntered, const char *list); void AutoCompleteStart(int lenEntered, const char *list);
void AutoCompleteCancel(); void AutoCompleteCancel();
void AutoCompleteMove(int delta); void AutoCompleteMove(int delta);
void AutoCompleteChanged(char ch=0); void AutoCompleteChanged(char ch=0);
void AutoCompleteCompleted(char fillUp='\0'); void AutoCompleteCompleted(char fillUp='\0');
void AutoCompleteMoveToCurrentWord(); void AutoCompleteMoveToCurrentWord();
static void AutoCompleteDoubleClick(void* p);
virtual void CreateCallTipWindow(PRectangle rc) = 0; virtual void CreateCallTipWindow(PRectangle rc) = 0;
virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0; virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0;
void ContextMenu(Point pt); void ContextMenu(Point pt);
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
virtual void NotifyStyleToNeeded(int endStyleNeeded); virtual void NotifyStyleToNeeded(int endStyleNeeded);

View File

@@ -14,15 +14,15 @@
Style::Style() { Style::Style() {
aliasOfDefaultFont = true; 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, Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
false, false, false, false, caseMixed, true); false, false, false, false, caseMixed, true, true);
} }
Style::Style(const Style &source) { 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, 0, 0, 0,
false, false, false, false, caseMixed, true); false, false, false, false, caseMixed, true, true);
fore.desired = source.fore.desired; fore.desired = source.fore.desired;
back.desired = source.back.desired; back.desired = source.back.desired;
characterSet = source.characterSet; characterSet = source.characterSet;
@@ -33,6 +33,7 @@ Style::Style(const Style &source) {
underline = source.underline; underline = source.underline;
caseForce = source.caseForce; caseForce = source.caseForce;
visible = source.visible; visible = source.visible;
changeable = source.changeable;
} }
Style::~Style() { Style::~Style() {
@@ -46,9 +47,9 @@ Style::~Style() {
Style &Style::operator=(const Style &source) { Style &Style::operator=(const Style &source) {
if (this == &source) if (this == &source)
return * this; return * this;
Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff), Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, SC_CHARSET_DEFAULT, 0, 0, SC_CHARSET_DEFAULT,
false, false, false, false, caseMixed, true); false, false, false, false, caseMixed, true, true);
fore.desired = source.fore.desired; fore.desired = source.fore.desired;
back.desired = source.back.desired; back.desired = source.back.desired;
characterSet = source.characterSet; characterSet = source.characterSet;
@@ -59,13 +60,15 @@ Style &Style::operator=(const Style &source) {
underline = source.underline; underline = source.underline;
caseForce = source.caseForce; caseForce = source.caseForce;
visible = source.visible; visible = source.visible;
changeable = source.changeable;
return *this; 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_, const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_, bool bold_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_, bool visible_) { bool underline_, ecaseForced caseForce_,
bool visible_, bool changeable_) {
fore.desired = fore_; fore.desired = fore_;
back.desired = back_; back.desired = back_;
characterSet = characterSet_; characterSet = characterSet_;
@@ -77,6 +80,7 @@ void Style::Clear(Colour fore_, Colour back_, int size_,
underline = underline_; underline = underline_;
caseForce = caseForce_; caseForce = caseForce_;
visible = visible_; visible = visible_;
changeable = changeable_;
if (aliasOfDefaultFont) if (aliasOfDefaultFont)
font.SetID(0); font.SetID(0);
else else
@@ -96,7 +100,8 @@ void Style::ClearTo(const Style &source) {
source.eolFilled, source.eolFilled,
source.underline, source.underline,
source.caseForce, source.caseForce,
source.visible); source.visible,
source.changeable);
} }
bool Style::EquivalentFontTo(const Style *other) const { bool Style::EquivalentFontTo(const Style *other) const {

View File

@@ -25,6 +25,7 @@ public:
enum ecaseForced {caseMixed, caseUpper, caseLower}; enum ecaseForced {caseMixed, caseUpper, caseLower};
ecaseForced caseForce; ecaseForced caseForce;
bool visible; bool visible;
bool changeable;
Font font; Font font;
int sizeZoomed; int sizeZoomed;
@@ -39,14 +40,16 @@ public:
Style(const Style &source); Style(const Style &source);
~Style(); ~Style();
Style &operator=(const Style &source); Style &operator=(const Style &source);
void Clear(Colour fore_, Colour back_, void Clear(ColourDesired fore_, ColourDesired back_,
int size_, int size_,
const char *fontName_, int characterSet_, const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_, 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); void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const; bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0); void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0);
bool IsProtected() { return !(changeable && visible);} ;
}; };
#endif #endif

View File

@@ -55,25 +55,33 @@ public:
styler.ColourTo(currentPos - 1, state); styler.ColourTo(currentPos - 1, state);
} }
bool More() { bool More() {
return currentPos <= endPos; return currentPos < endPos;
} }
void Forward() { void Forward() {
atLineStart = atLineEnd; if (currentPos < endPos) {
// A lot of this is repeated from the constructor - TODO: merge code atLineStart = atLineEnd;
chPrev = ch; // A lot of this is repeated from the constructor - TODO: merge code
currentPos++; chPrev = ch;
if (ch >= 0x100)
currentPos++; currentPos++;
ch = chNext; if (ch >= 0x100)
chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1)); currentPos++;
if (styler.IsLeadByte(static_cast<char>(chNext))) { ch = chNext;
chNext = chNext << 8; chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2)); if (styler.IsLeadByte(static_cast<char>(chNext))) {
chNext = chNext << 8;
chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
}
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
// Avoid triggering two times on Dos/Win
// End of line
atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos);
} else {
atLineStart = false;
chPrev = ' ';
ch = ' ';
chNext = ' ';
atLineEnd = true;
} }
// 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
atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos);
} }
void ChangeState(int state_) { void ChangeState(int state_) {
state = state_; state = state_;
@@ -113,6 +121,20 @@ public:
} }
return true; 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 // Non-inline
void GetCurrent(char *s, int len); void GetCurrent(char *s, int len);
void GetCurrentLowered(char *s, int len); void GetCurrentLowered(char *s, int len);

View File

@@ -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) { 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; unsigned int ui=0;
const unsigned char *us = reinterpret_cast<const unsigned char *>(s); const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
unsigned int i=0; unsigned int i=0;
@@ -76,5 +73,4 @@ unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsign
ui++; ui++;
} }
return ui; return ui;
#endif
} }

View File

@@ -103,11 +103,11 @@ void ViewStyle::Init() {
ResetDefaultStyle(); ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE; 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].style = INDIC_TT;
indicators[1].fore = Colour(0, 0, 0xff); indicators[1].fore = ColourDesired(0, 0, 0xff);
indicators[2].style = INDIC_PLAIN; indicators[2].style = INDIC_PLAIN;
indicators[2].fore = Colour(0xff, 0, 0); indicators[2].fore = ColourDesired(0xff, 0, 0);
lineHeight = 1; lineHeight = 1;
maxAscent = 1; maxAscent = 1;
@@ -116,18 +116,18 @@ void ViewStyle::Init() {
spaceWidth = 8; spaceWidth = 8;
selforeset = false; selforeset = false;
selforeground.desired = Colour(0xff, 0, 0); selforeground.desired = ColourDesired(0xff, 0, 0);
selbackset = true; selbackset = true;
selbackground.desired = Colour(0xc0, 0xc0, 0xc0); selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
selbackground2.desired = Colour(0xb0, 0xb0, 0xb0); selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
selbar.desired = Platform::Chrome(); selbar.desired = Platform::Chrome();
selbarlight.desired = Platform::ChromeHighlight(); 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(); styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
caretcolour.desired = Colour(0, 0, 0); caretcolour.desired = ColourDesired(0, 0, 0);
showCaretLineBackground = false; showCaretLineBackground = false;
caretLineBackground.desired = Colour(0xff, 0xff, 0); caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
edgecolour.desired = Colour(0xc0, 0xc0, 0xc0); edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
edgeState = EDGE_NONE; edgeState = EDGE_NONE;
caretWidth = 1; caretWidth = 1;
@@ -215,10 +215,11 @@ void ViewStyle::Refresh(Surface &surface) {
} }
void ViewStyle::ResetDefaultStyle() { void ViewStyle::ResetDefaultStyle() {
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
ColourDesired(0xff,0xff,0xff),
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()), Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT, SC_CHARSET_DEFAULT,
false, false, false, false, Style::caseMixed, true); false, false, false, false, Style::caseMixed, true, true);
} }
void ViewStyle::ClearStyles() { void ViewStyle::ClearStyles() {

View File

@@ -20,22 +20,14 @@
WindowAccessor::~WindowAccessor() { WindowAccessor::~WindowAccessor() {
} }
#if PLAT_WIN
bool WindowAccessor::InternalIsLeadByte(char ch) { bool WindowAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage) if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the // For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte. // same so none is considered a lead byte.
return false; return false;
else else
return IsDBCSLeadByteEx(codePage, ch); return 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) { void WindowAccessor::Fill(int position) {
if (lenDoc == -1) if (lenDoc == -1)

View File

@@ -22,53 +22,6 @@
#include <wx/tokenzr.h> #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_CLASS(wxStyledTextCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
// forces the linking of the lexer modules
int Scintilla_LinkLexers();
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Constructor and Destructor // Constructor and Destructor
@@ -143,7 +99,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
wxDefaultValidator, name) wxDefaultValidator, name)
{ {
wxForceScintillaLexers(); Scintilla_LinkLexers();
m_swx = new ScintillaWX(this); m_swx = new ScintillaWX(this);
m_stopWatch.Start(); m_stopWatch.Start();
m_lastKeyDownConsumed = FALSE; m_lastKeyDownConsumed = FALSE;
@@ -431,7 +387,7 @@ void wxStyledTextCtrl::SetCodePage(int codePage) {
} }
// Set the symbol used for a particular marker number, // 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, void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground, const wxColour& foreground,
const wxColour& background) { const wxColour& background) {
@@ -453,9 +409,9 @@ void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& bac
SendMsg(2042, markerNumber, wxColourAsLong(back)); SendMsg(2042, markerNumber, wxColourAsLong(back));
} }
// Add a marker to a line. // Add a marker to a line, returning an ID which can be used to find or delete the marker.
void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) { int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
SendMsg(2043, line, markerNumber); return SendMsg(2043, line, markerNumber);
} }
// Delete a marker from a line // Delete a marker from a line
@@ -698,7 +654,7 @@ bool wxStyledTextCtrl::GetCaretLineVisible() {
return SendMsg(2095, 0, 0) != 0; 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) { void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
SendMsg(2096, show, 0); SendMsg(2096, show, 0);
} }
@@ -714,6 +670,12 @@ void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
SendMsg(2098, wxColourAsLong(back), 0); 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. // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
@@ -774,7 +736,8 @@ bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
return SendMsg(2111, 0, 0) != 0; 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) { void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
SendMsg(2112, 0, (long)characterSet.c_str()); SendMsg(2112, 0, (long)characterSet.c_str());
} }
@@ -814,6 +777,16 @@ bool wxStyledTextCtrl::AutoCompGetAutoHide() {
return SendMsg(2119, 0, 0) != 0; 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. // Set the number of spaces used for one level of indentation.
void wxStyledTextCtrl::SetIndent(int indentSize) { void wxStyledTextCtrl::SetIndent(int indentSize) {
SendMsg(2122, indentSize, 0); SendMsg(2122, indentSize, 0);
@@ -1405,6 +1378,42 @@ int wxStyledTextCtrl::GetMouseDwellTime() {
return SendMsg(2265, 0, 0); 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 // Move the caret inside current view if it's not there already
void wxStyledTextCtrl::MoveCaretInsideView() { void wxStyledTextCtrl::MoveCaretInsideView() {
SendMsg(2401, 0, 0); SendMsg(2401, 0, 0);
@@ -1598,6 +1607,17 @@ int wxStyledTextCtrl::GetCursor() {
return SendMsg(2387, 0, 0); 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 // Move to the previous change in capitalistion
void wxStyledTextCtrl::WordPartLeft() { void wxStyledTextCtrl::WordPartLeft() {
SendMsg(2390, 0, 0); SendMsg(2390, 0, 0);
@@ -1633,6 +1653,14 @@ void wxStyledTextCtrl::DelLineRight() {
SendMsg(2396, 0, 0); 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. // Start notifying the container of all key presses and commands.
void wxStyledTextCtrl::StartRecord() { void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0); SendMsg(3001, 0, 0);
@@ -2029,10 +2057,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
evt.SetLength(scn.length); evt.SetLength(scn.length);
break; break;
case SCN_POSCHANGED:
evt.SetEventType(wxEVT_STC_POSCHANGED);
break;
case SCN_PAINTED: case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED); evt.SetEventType(wxEVT_STC_PAINTED);
break; break;

View File

@@ -22,53 +22,6 @@
#include <wx/tokenzr.h> #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_CLASS(wxStyledTextCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
// forces the linking of the lexer modules
int Scintilla_LinkLexers();
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Constructor and Destructor // Constructor and Destructor
@@ -143,7 +99,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
wxDefaultValidator, name) wxDefaultValidator, name)
{ {
wxForceScintillaLexers(); Scintilla_LinkLexers();
m_swx = new ScintillaWX(this); m_swx = new ScintillaWX(this);
m_stopWatch.Start(); m_stopWatch.Start();
m_lastKeyDownConsumed = FALSE; m_lastKeyDownConsumed = FALSE;
@@ -558,10 +514,6 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
evt.SetLength(scn.length); evt.SetLength(scn.length);
break; break;
case SCN_POSCHANGED:
evt.SetEventType(wxEVT_STC_POSCHANGED);
break;
case SCN_PAINTED: case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED); evt.SetEventType(wxEVT_STC_PAINTED);
break; break;

View File

@@ -32,20 +32,6 @@
%(VALUES)s %(VALUES)s
// END of generated section // 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 class ScintillaWX; // forward declare

View File

@@ -73,6 +73,9 @@
#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19 #define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
#define wxSTC_MARK_CIRCLEMINUS 20 #define wxSTC_MARK_CIRCLEMINUS 20
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21 #define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
// Invisible mark that only sets the line background color
#define wxSTC_MARK_BACKGROUND 22
#define wxSTC_MARK_CHARACTER 10000 #define wxSTC_MARK_CHARACTER 10000
// Markers used for outlining column // Markers used for outlining column
@@ -83,6 +86,7 @@
#define wxSTC_MARKNUM_FOLDERSUB 29 #define wxSTC_MARKNUM_FOLDERSUB 29
#define wxSTC_MARKNUM_FOLDER 30 #define wxSTC_MARKNUM_FOLDER 30
#define wxSTC_MARKNUM_FOLDEROPEN 31 #define wxSTC_MARKNUM_FOLDEROPEN 31
#define wxSTC_MASK_FOLDERS 0xFE000000
#define wxSTC_MARGIN_SYMBOL 0 #define wxSTC_MARGIN_SYMBOL 0
#define wxSTC_MARGIN_NUMBER 1 #define wxSTC_MARGIN_NUMBER 1
@@ -127,10 +131,10 @@
#define wxSTC_INDIC_TT 2 #define wxSTC_INDIC_TT 2
#define wxSTC_INDIC_DIAGONAL 3 #define wxSTC_INDIC_DIAGONAL 3
#define wxSTC_INDIC_STRIKE 4 #define wxSTC_INDIC_STRIKE 4
#define wxSTC_INDIC0_MASK 32 #define wxSTC_INDIC0_MASK 0x20
#define wxSTC_INDIC1_MASK 64 #define wxSTC_INDIC1_MASK 0x40
#define wxSTC_INDIC2_MASK 128 #define wxSTC_INDIC2_MASK 0x80
#define wxSTC_INDICS_MASK 224 #define wxSTC_INDICS_MASK 0xE0
// PrintColourMode - use same colours as screen. // PrintColourMode - use same colours as screen.
#define wxSTC_PRINT_NORMAL 0 #define wxSTC_PRINT_NORMAL 0
@@ -159,6 +163,12 @@
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000 #define wxSTC_FOLDLEVELHEADERFLAG 0x2000
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF #define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
#define wxSTC_TIME_FOREVER 10000000 #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_LINEDOWN 2300
#define wxSTC_CMD_LINEDOWNEXTEND 2301 #define wxSTC_CMD_LINEDOWNEXTEND 2301
#define wxSTC_CMD_LINEUP 2302 #define wxSTC_CMD_LINEUP 2302
@@ -203,6 +213,7 @@
#define wxSTC_CMD_UPPERCASE 2341 #define wxSTC_CMD_UPPERCASE 2341
#define wxSTC_CMD_LINESCROLLDOWN 2342 #define wxSTC_CMD_LINESCROLLDOWN 2342
#define wxSTC_CMD_LINESCROLLUP 2343 #define wxSTC_CMD_LINESCROLLUP 2343
#define wxSTC_CMD_DELETEBACKNOTLINE 2344
#define wxSTC_EDGE_NONE 0 #define wxSTC_EDGE_NONE 0
#define wxSTC_EDGE_LINE 1 #define wxSTC_EDGE_LINE 1
#define wxSTC_EDGE_BACKGROUND 2 #define wxSTC_EDGE_BACKGROUND 2
@@ -302,6 +313,12 @@
#define wxSTC_LEX_EIFFELKW 24 #define wxSTC_LEX_EIFFELKW 24
#define wxSTC_LEX_TCL 25 #define wxSTC_LEX_TCL 25
#define wxSTC_LEX_NNCRONTAB 26 #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 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1. // value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -323,7 +340,7 @@
#define wxSTC_P_COMMENTBLOCK 12 #define wxSTC_P_COMMENTBLOCK 12
#define wxSTC_P_STRINGEOL 13 #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_DEFAULT 0
#define wxSTC_C_COMMENT 1 #define wxSTC_C_COMMENT 1
#define wxSTC_C_COMMENTLINE 2 #define wxSTC_C_COMMENTLINE 2
@@ -344,6 +361,17 @@
#define wxSTC_C_COMMENTDOCKEYWORD 17 #define wxSTC_C_COMMENTDOCKEYWORD 17
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18 #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 // Lexical states for SCLEX_HTML, SCLEX_XML
#define wxSTC_H_DEFAULT 0 #define wxSTC_H_DEFAULT 0
#define wxSTC_H_TAG 1 #define wxSTC_H_TAG 1
@@ -531,6 +559,11 @@
#define wxSTC_LUA_OPERATOR 10 #define wxSTC_LUA_OPERATOR 10
#define wxSTC_LUA_IDENTIFIER 11 #define wxSTC_LUA_IDENTIFIER 11
#define wxSTC_LUA_STRINGEOL 12 #define wxSTC_LUA_STRINGEOL 12
#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 // Lexical states for SCLEX_ERRORLIST
#define wxSTC_ERR_DEFAULT 0 #define wxSTC_ERR_DEFAULT 0
@@ -602,6 +635,19 @@
#define wxSTC_ADA_IDENTIFIER 7 #define wxSTC_ADA_IDENTIFIER 7
#define wxSTC_ADA_STRINGEOL 8 #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 // Lexical states for SCLEX_LISP
#define wxSTC_LISP_DEFAULT 0 #define wxSTC_LISP_DEFAULT 0
#define wxSTC_LISP_COMMENT 1 #define wxSTC_LISP_COMMENT 1
@@ -636,21 +682,17 @@
#define wxSTC_NNCRONTAB_ENVIRONMENT 9 #define wxSTC_NNCRONTAB_ENVIRONMENT 9
#define wxSTC_NNCRONTAB_IDENTIFIER 10 #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 // 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 class ScintillaWX; // forward declare
@@ -821,7 +863,7 @@ public:
void SetCodePage(int codePage); void SetCodePage(int codePage);
// Set the symbol used for a particular marker number, // 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, void MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground = wxNullColour, const wxColour& foreground = wxNullColour,
const wxColour& background = wxNullColour); const wxColour& background = wxNullColour);
@@ -832,8 +874,8 @@ public:
// Set the background colour used for a particular marker number. // Set the background colour used for a particular marker number.
void MarkerSetBackground(int markerNumber, const wxColour& back); void MarkerSetBackground(int markerNumber, const wxColour& back);
// Add a marker to a line. // Add a marker to a line, returning an ID which can be used to find or delete the marker.
void MarkerAdd(int line, int markerNumber); int MarkerAdd(int line, int markerNumber);
// Delete a marker from a line // Delete a marker from a line
void MarkerDelete(int line, int markerNumber); void MarkerDelete(int line, int markerNumber);
@@ -980,7 +1022,7 @@ public:
// Is the background of the line containing the caret in a different colour? // Is the background of the line containing the caret in a different colour?
bool GetCaretLineVisible(); 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); void SetCaretLineVisible(bool show);
// Get the colour of the background of the line containing the caret. // 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. // Set the colour of the background of the line containing the caret.
void SetCaretLineBack(const wxColour& back); 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. // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
@@ -1027,7 +1073,8 @@ public:
// Retrieve whether auto-completion cancelled by backspacing before start. // Retrieve whether auto-completion cancelled by backspacing before start.
bool AutoCompGetCancelAtStart(); 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); void AutoCompSetFillUps(const wxString& characterSet);
// Should a single item auto-completion list automatically choose the item. // 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 // Retrieve whether or not autocompletion is hidden automatically when nothing matches
bool AutoCompGetAutoHide(); 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. // Set the number of spaces used for one level of indentation.
void SetIndent(int indentSize); void SetIndent(int indentSize);
@@ -1369,6 +1422,28 @@ public:
// Retrieve the time the mouse must sit still to generate a mouse dwell event // Retrieve the time the mouse must sit still to generate a mouse dwell event
int GetMouseDwellTime(); 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 // Move the caret inside current view if it's not there already
void MoveCaretInsideView(); void MoveCaretInsideView();
@@ -1487,6 +1562,13 @@ public:
// Get cursor type // Get cursor type
int GetCursor(); 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 // Move to the previous change in capitalistion
void WordPartLeft(); void WordPartLeft();
@@ -1508,6 +1590,10 @@ public:
// Delete forwards from the current position to the end of the line // Delete forwards from the current position to the end of the line
void DelLineRight(); 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. // Start notifying the container of all key presses and commands.
void StartRecord(); void StartRecord();

View File

@@ -34,6 +34,9 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
KeyMap.o \ KeyMap.o \
KeyWords.o \ KeyWords.o \
LexAVE.o \ LexAVE.o \
LexBaan.o \
LexBullant.o \
LexMatlab.o \
LexAda.o \ LexAda.o \
LexCPP.o \ LexCPP.o \
LexConf.o \ LexConf.o \
@@ -61,7 +64,7 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
DEPFILES=$(OBJECTS:.o=.d) 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 include $(top_builddir)/src/makelib.env

View File

@@ -6,7 +6,10 @@
#include <ctype.h> #include <ctype.h>
#include <wx/wx.h>
#include "Platform.h" #include "Platform.h"
#include "PlatWX.h"
#include "wx/stc/stc.h" #include "wx/stc/stc.h"
@@ -14,6 +17,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#endif #endif
Point Point::FromLong(long lpoint) { Point Point::FromLong(long lpoint) {
return Point(lpoint & 0xFFFF, lpoint >> 16); return Point(lpoint & 0xFFFF, lpoint >> 16);
} }
@@ -29,35 +33,12 @@ PRectangle PRectangleFromwxRect(wxRect rc) {
rc.GetRight()+1, rc.GetBottom()+1); rc.GetRight()+1, rc.GetBottom()+1);
} }
Colour::Colour(long lcol) { wxColour wxColourFromCA(const ColourAllocated& ca) {
co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff); 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() { Palette::Palette() {
used = 0; used = 0;
@@ -84,7 +65,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
if (used < numEntries) { if (used < numEntries) {
entries[used].desired = cp.desired; entries[used].desired = cp.desired;
entries[used].allocated = cp.desired; entries[used].allocated.Set(cp.desired.AsLong());
used++; used++;
} }
} else { } else {
@@ -94,7 +75,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
return; return;
} }
} }
cp.allocated = cp.desired; cp.allocated.Set(cp.desired.AsLong());
} }
} }
@@ -104,6 +85,8 @@ void Palette::Allocate(Window &) {
} }
//----------------------------------------------------------------------
Font::Font() { Font::Font() {
id = 0; id = 0;
ascent = 0; ascent = 0;
@@ -113,36 +96,172 @@ Font::~Font() {
} }
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) { void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
// TODO: what to do about the characterSet? wxFontEncoding encoding;
Release(); 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, id = new wxFont(size,
wxDEFAULT, wxDEFAULT,
italic ? wxITALIC : wxNORMAL, italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL, bold ? wxBOLD : wxNORMAL,
false, false,
faceName, faceName,
wxFONTENCODING_DEFAULT); encoding);
} }
void Font::Release() { void Font::Release() {
if (id) if (id)
delete id; delete (wxFont*)id;
id = 0; 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), hdc(0), hdcOwned(0), bitmap(0),
x(0), y(0) { x(0), y(0), unicodeMode(0)
} {}
Surface::~Surface() { SurfaceImpl::~SurfaceImpl() {
Release(); Release();
} }
void Surface::Release() { void SurfaceImpl::Release() {
if (bitmap) { if (bitmap) {
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap); ((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
delete bitmap; delete bitmap;
@@ -156,24 +275,24 @@ void Surface::Release() {
} }
bool Surface::Initialised() { bool SurfaceImpl::Initialised() {
return hdc != 0; return hdc != 0;
} }
void Surface::Init() { void SurfaceImpl::Init() {
Release(); Release();
hdc = new wxMemoryDC(); hdc = new wxMemoryDC();
hdcOwned = true; hdcOwned = true;
} }
void Surface::Init(SurfaceID hdc_) { void SurfaceImpl::Init(SurfaceID hdc_) {
Release(); 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(); Release();
hdc = new wxMemoryDC(surface_->hdc); hdc = new wxMemoryDC();
hdcOwned = true; hdcOwned = true;
if (width < 1) width = 1; if (width < 1) width = 1;
if (height < 1) height = 1; if (height < 1) height = 1;
@@ -181,64 +300,63 @@ void Surface::InitPixMap(int width, int height, Surface *surface_) {
((wxMemoryDC*)hdc)->SelectObject(*bitmap); ((wxMemoryDC*)hdc)->SelectObject(*bitmap);
} }
void Surface::PenColour(Colour fore) { void SurfaceImpl::PenColour(ColourAllocated fore) {
hdc->SetPen(wxPen(fore.co, 1, wxSOLID)); hdc->SetPen(wxPen(wxColourFromCA(fore), 1, wxSOLID));
} }
void Surface::BrushColor(Colour back) { void SurfaceImpl::BrushColour(ColourAllocated back) {
hdc->SetBrush(wxBrush(back.co, wxSOLID)); hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID));
} }
void Surface::SetFont(Font &font_) { void SurfaceImpl::SetFont(Font &font_) {
if (font_.GetID()) { if (font_.GetID()) {
hdc->SetFont(*font_.GetID()); hdc->SetFont(*((wxFont*)font_.GetID()));
} }
} }
int Surface::LogPixelsY() { int SurfaceImpl::LogPixelsY() {
return hdc->GetPPI().y; return hdc->GetPPI().y;
} }
int SurfaceImpl::DeviceHeightFont(int points) {
int Surface::DeviceHeightFont(int points) {
return points; return points;
// int logPix = LogPixelsY();
// return (points * logPix + logPix / 2) / 72;
} }
void SurfaceImpl::MoveTo(int x_, int y_) {
void Surface::MoveTo(int x_, int y_) {
x = x_; x = x_;
y = y_; y = y_;
} }
void Surface::LineTo(int x_, int y_) { void SurfaceImpl::LineTo(int x_, int y_) {
hdc->DrawLine(x,y, x_,y_); hdc->DrawLine(x,y, x_,y_);
x = x_; x = x_;
y = y_; y = y_;
} }
void Surface::Polygon(Point *pts, int npts, Colour fore, void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
Colour back) {
PenColour(fore); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawPolygon(npts, (wxPoint*)pts); 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); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawRectangle(wxRectFromPRectangle(rc)); hdc->DrawRectangle(wxRectFromPRectangle(rc));
} }
void Surface::FillRectangle(PRectangle rc, Colour back) { void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
BrushColor(back); BrushColour(back);
hdc->SetPen(*wxTRANSPARENT_PEN); hdc->SetPen(*wxTRANSPARENT_PEN);
hdc->DrawRectangle(wxRectFromPRectangle(rc)); hdc->DrawRectangle(wxRectFromPRectangle(rc));
} }
void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) { void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
wxBrush br; wxBrush br;
if (surfacePattern.bitmap) if (((SurfaceImpl&)surfacePattern).bitmap)
br = wxBrush(*surfacePattern.bitmap); br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap);
else // Something is wrong so display in red else // Something is wrong so display in red
br = wxBrush(*wxRED, wxSOLID); br = wxBrush(*wxRED, wxSOLID);
hdc->SetPen(*wxTRANSPARENT_PEN); hdc->SetPen(*wxTRANSPARENT_PEN);
@@ -246,79 +364,112 @@ void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
hdc->DrawRectangle(wxRectFromPRectangle(rc)); hdc->DrawRectangle(wxRectFromPRectangle(rc));
} }
void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) { void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4); 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); PenColour(fore);
BrushColor(back); BrushColour(back);
hdc->DrawEllipse(wxRectFromPRectangle(rc)); 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); wxRect r = wxRectFromPRectangle(rc);
hdc->Blit(r.x, r.y, r.width, r.height, 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, void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
const char *s, int len, Colour fore, Colour back) { const char *s, int len,
ColourAllocated fore, ColourAllocated back) {
SetFont(font); SetFont(font);
hdc->SetTextForeground(fore.co); hdc->SetTextForeground(wxColourFromCA(fore));
hdc->SetTextBackground(back.co); hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, 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 // 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... // 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); SetFont(font);
hdc->SetTextForeground(fore.co); hdc->SetTextForeground(wxColourFromCA(fore));
hdc->SetTextBackground(back.co); hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back); FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc)); 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 // see comments above
hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent); hdc->DrawText(str, rc.left, ybase - font.ascent);
hdc->DestroyClippingRegion(); hdc->DestroyClippingRegion();
} }
int Surface::WidthText(Font &font, const char *s, int len) { int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
SetFont(font); SetFont(font);
int w; int w;
int h; 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; 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); SetFont(font);
int totalWidth = 0; int totalWidth = 0;
for (int i=0; i<len; i++) { for (size_t i=0; i<(size_t)len; i++) {
int w; int w;
int h; int h;
hdc->GetTextExtent(s[i], &w, &h); hdc->GetTextExtent(str[i], &w, &h);
totalWidth += w; totalWidth += w;
positions[i] = totalWidth; positions[i] = totalWidth;
} }
} }
int Surface::WidthChar(Font &font, char ch) { int SurfaceImpl::WidthChar(Font &font, char ch) {
SetFont(font); SetFont(font);
int w; int w;
int h; int h;
#if wxUSE_UNICODE
#error fix this... Convert s from UTF-8.
#else
hdc->GetTextExtent(ch, &w, &h); hdc->GetTextExtent(ch, &w, &h);
#endif
return w; return w;
} }
#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" #define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
int Surface::Ascent(Font &font) { int SurfaceImpl::Ascent(Font &font) {
SetFont(font); SetFont(font);
int w, h, d, e; int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
@@ -326,66 +477,81 @@ int Surface::Ascent(Font &font) {
return font.ascent; return font.ascent;
} }
int Surface::Descent(Font &font) { int SurfaceImpl::Descent(Font &font) {
SetFont(font); SetFont(font);
int w, h, d, e; int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return d; return d;
} }
int Surface::InternalLeading(Font &font) { int SurfaceImpl::InternalLeading(Font &font) {
return 0; return 0;
} }
int Surface::ExternalLeading(Font &font) { int SurfaceImpl::ExternalLeading(Font &font) {
SetFont(font); SetFont(font);
int w, h, d, e; int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e); hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return e; return e;
} }
int Surface::Height(Font &font) { int SurfaceImpl::Height(Font &font) {
SetFont(font); SetFont(font);
return hdc->GetCharHeight(); return hdc->GetCharHeight();
} }
int Surface::AverageCharWidth(Font &font) { int SurfaceImpl::AverageCharWidth(Font &font) {
SetFont(font); SetFont(font);
return hdc->GetCharWidth(); return hdc->GetCharWidth();
} }
int Surface::SetPalette(Palette *pal, bool inBackGround) { int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
return 0; return 0;
} }
void Surface::SetClip(PRectangle rc) { void SurfaceImpl::SetClip(PRectangle rc) {
hdc->SetClippingRegion(wxRectFromPRectangle(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() { Window::~Window() {
} }
void Window::Destroy() { void Window::Destroy() {
if (id) if (id)
id->Destroy(); GETWIN(id)->Destroy();
id = 0; id = 0;
} }
bool Window::HasFocus() { bool Window::HasFocus() {
return wxWindow::FindFocus() == id; return wxWindow::FindFocus() == GETWIN(id);
} }
PRectangle Window::GetPosition() { PRectangle Window::GetPosition() {
wxRect rc(id->GetPosition(), id->GetSize()); wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize());
return PRectangleFromwxRect(rc); return PRectangleFromwxRect(rc);
} }
void Window::SetPosition(PRectangle rc) { void Window::SetPosition(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc); wxRect r = wxRectFromPRectangle(rc);
id->SetSize(r); GETWIN(id)->SetSize(r);
} }
void Window::SetPositionRelative(PRectangle rc, Window) { void Window::SetPositionRelative(PRectangle rc, Window) {
@@ -393,25 +559,25 @@ void Window::SetPositionRelative(PRectangle rc, Window) {
} }
PRectangle Window::GetClientPosition() { PRectangle Window::GetClientPosition() {
wxSize sz = id->GetClientSize(); wxSize sz = GETWIN(id)->GetClientSize();
return PRectangle(0, 0, sz.x, sz.y); return PRectangle(0, 0, sz.x, sz.y);
} }
void Window::Show(bool show) { void Window::Show(bool show) {
id->Show(show); GETWIN(id)->Show(show);
} }
void Window::InvalidateAll() { void Window::InvalidateAll() {
id->Refresh(false); GETWIN(id)->Refresh(false);
} }
void Window::InvalidateRectangle(PRectangle rc) { void Window::InvalidateRectangle(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc); wxRect r = wxRectFromPRectangle(rc);
id->Refresh(false, &r); GETWIN(id)->Refresh(false, &r);
} }
void Window::SetFont(Font &font) { void Window::SetFont(Font &font) {
id->SetFont(*font.GetID()); GETWIN(id)->SetFont(*((wxFont*)font.GetID()));
} }
void Window::SetCursor(Cursor curs) { void Window::SetCursor(Cursor curs) {
@@ -444,19 +610,23 @@ void Window::SetCursor(Cursor curs) {
break; break;
} }
id->SetCursor(wxCursor(cursorId)); GETWIN(id)->SetCursor(wxCursor(cursorId));
} }
void Window::SetTitle(const char *s) { 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 // 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 { class wxSTCListBox : public wxListBox {
public: public:
wxSTCListBox(wxWindow* parent, wxWindowID id) wxSTCListBox(wxWindow* parent, wxWindowID id)
@@ -532,7 +702,9 @@ BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase)
END_EVENT_TABLE() 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) { 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) { void ListBox::SetVisibleRows(int rows) {
@@ -569,7 +741,7 @@ void ListBox::SetAverageCharWidth(int width) {
} }
void ListBox::SetFont(Font &font) { void ListBox::SetFont(Font &font) {
GETLB(id)->SetFont(*font.GetID()); GETLB(id)->SetFont(*((wxFont*)font.GetID()));
} }
void ListBox::Clear() { void ListBox::Clear() {
@@ -605,14 +777,18 @@ int ListBox::Find(const char *prefix) {
} }
void ListBox::GetValue(int n, char *value, int len) { void ListBox::GetValue(int n, char *value, int len) {
#if wxUSE_UNICODE
#error fix this...
wxString text = GETLB(id)->GetString(n); wxString text = GETLB(id)->GetString(n);
strncpy(value, text.c_str(), len); strncpy(value, text.c_str(), len);
value[len-1] = '\0'; value[len-1] = '\0';
#endif
} }
void ListBox::Sort() { void ListBox::Sort() {
} }
//----------------------------------------------------------------------
Menu::Menu() : id(0) { Menu::Menu() : id(0) {
} }
@@ -624,26 +800,27 @@ void Menu::CreatePopUp() {
void Menu::Destroy() { void Menu::Destroy() {
if (id) if (id)
delete id; delete (wxMenu*)id;
id = 0; id = 0;
} }
void Menu::Show(Point pt, Window &w) { 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(); Destroy();
} }
//----------------------------------------------------------------------
Colour Platform::Chrome() { ColourDesired Platform::Chrome() {
wxColour c; wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); 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; wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT); 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() { 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
View File

@@ -0,0 +1,8 @@
wxRect wxRectFromPRectangle(PRectangle prc);
PRectangle PRectangleFromwxRect(wxRect rc);
wxColour wxColourFromCA(const ColourAllocated& ca);

View File

@@ -14,10 +14,10 @@
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include <ctype.h>
#include "ScintillaWX.h" #include "ScintillaWX.h"
#include "wx/stc/stc.h" #include "wx/stc/stc.h"
#include "PlatWX.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -82,10 +82,10 @@ public:
void OnPaint(wxPaintEvent& evt) { void OnPaint(wxPaintEvent& evt) {
wxPaintDC dc(this); wxPaintDC dc(this);
Surface surfaceWindow; Surface* surfaceWindow = Surface::Allocate();
surfaceWindow.Init(&dc); surfaceWindow->Init(&dc);
m_ct->PaintCT(&surfaceWindow); m_ct->PaintCT(surfaceWindow);
surfaceWindow.Release(); delete surfaceWindow;
} }
#if wxUSE_POPUPWIN #if wxUSE_POPUPWIN
@@ -184,7 +184,7 @@ void ScintillaWX::SetTicking(bool on) {
if (timer.ticking) { if (timer.ticking) {
steTimer = new wxSTCTimer(this); steTimer = new wxSTCTimer(this);
steTimer->Start(timer.tickSize); steTimer->Start(timer.tickSize);
timer.tickerID = (int)steTimer; timer.tickerID = steTimer;
} else { } else {
steTimer = (wxSTCTimer*)timer.tickerID; steTimer = (wxSTCTimer*)timer.tickerID;
steTimer->Stop(); steTimer->Stop();
@@ -343,12 +343,12 @@ void ScintillaWX::CreateCallTipWindow(PRectangle) {
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) { void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
if (!label[0]) if (!label[0])
popup.GetID()->AppendSeparator(); ((wxMenu*)popup.GetID())->AppendSeparator();
else else
popup.GetID()->Append(cmd, label); ((wxMenu*)popup.GetID())->Append(cmd, label);
if (!enabled) 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) { void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
paintState = painting; paintState = painting;
Surface surfaceWindow; Surface* surfaceWindow = Surface::Allocate();
surfaceWindow.Init(dc); surfaceWindow->Init(dc);
PRectangle rcPaint = PRectangleFromwxRect(rect); PRectangle rcPaint = PRectangleFromwxRect(rect);
dc->BeginDrawing(); dc->BeginDrawing();
Paint(&surfaceWindow, rcPaint); Paint(surfaceWindow, rcPaint);
dc->EndDrawing(); dc->EndDrawing();
surfaceWindow.Release(); delete surfaceWindow;
if (paintState == paintAbandoned) { if (paintState == paintAbandoned) {
// Painting area was insufficient to cover new styling or brace highlight positions // Painting area was insufficient to cover new styling or brace highlight positions
FullPaint(); FullPaint();
@@ -466,9 +466,10 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int
void ScintillaWX::DoSize(int width, int height) { void ScintillaWX::DoSize(int width, int height) {
PRectangle rcClient(0,0,width,height); // PRectangle rcClient(0,0,width,height);
SetScrollBarsTo(rcClient); // SetScrollBarsTo(rcClient);
DropGraphics(); // DropGraphics();
ChangeSize();
} }
void ScintillaWX::DoLoseFocus(){ void ScintillaWX::DoLoseFocus(){
@@ -622,10 +623,10 @@ void ScintillaWX::FullPaint() {
rcPaint = GetTextRectangle(); rcPaint = GetTextRectangle();
paintingAllText = true; paintingAllText = true;
wxClientDC dc(stc); wxClientDC dc(stc);
Surface surfaceWindow; Surface* surfaceWindow = Surface::Allocate();
surfaceWindow.Init(&dc); surfaceWindow->Init(&dc);
Paint(&surfaceWindow, rcPaint); Paint(surfaceWindow, rcPaint);
surfaceWindow.Release(); delete surfaceWindow;
// stc->Refresh(FALSE); // stc->Refresh(FALSE);

View File

@@ -19,6 +19,11 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "Platform.h" #include "Platform.h"
#include "Scintilla.h" #include "Scintilla.h"

View File

@@ -7,19 +7,19 @@
CFG=StcVC - Win32 Debug CFG=StcVC - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run !MESSAGE use the Export Makefile command and run
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "StcVC.mak". !MESSAGE NMAKE /f "StcVC.mak".
!MESSAGE !MESSAGE
!MESSAGE You can specify a configuration when running NMAKE !MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug" !MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug"
!MESSAGE !MESSAGE
!MESSAGE Possible choices for configuration are: !MESSAGE Possible choices for configuration are:
!MESSAGE !MESSAGE
!MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE !MESSAGE
# Begin Project # Begin Project
# PROP AllowPerConfigDependencies 0 # PROP AllowPerConfigDependencies 0
@@ -76,7 +76,7 @@ LIB32=link.exe -lib
# ADD BASE LIB32 /nologo # ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\lib\stcd.lib" # ADD LIB32 /nologo /out:"..\..\lib\stcd.lib"
!ENDIF !ENDIF
# Begin Target # Begin Target
@@ -187,6 +187,18 @@ SOURCE=.\scintilla\src\LexAVE.cxx
# End Source File # End Source File
# Begin 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 SOURCE=.\scintilla\src\LexConf.cxx
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -154,7 +154,7 @@ methodOverrideMap = {
MarkerSetBackground(markerNumber, background);''', MarkerSetBackground(markerNumber, background);''',
('Set the symbol used for a particular marker number,', ('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), 'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0), 'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
@@ -226,6 +226,8 @@ methodOverrideMap = {
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0), 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0), 'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0), 'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0), 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),

View File

@@ -17,7 +17,7 @@ SCINTILLA=.\scintilla
S=$(SCINTILLA)\src 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 LIBTARGET=$(WXDIR)\contrib\lib\stc.lib
@@ -34,6 +34,9 @@ OBJECTS = \
KeyWords.obj \ KeyWords.obj \
LexAVE.obj \ LexAVE.obj \
LexAda.obj \ LexAda.obj \
LexBaan.obj \
LexBullant.obj \
LexMatlab.obj \
LexCPP.obj \ LexCPP.obj \
LexConf.obj \ LexConf.obj \
LexCrontab.obj \ LexCrontab.obj \

View File

@@ -7,7 +7,7 @@ WXDIR = ../../..
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
S=$(SCINTILLA)/src 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 = \ OBJECTS = \
$(S)/AutoComplete.$(OBJSUFF) \ $(S)/AutoComplete.$(OBJSUFF) \
@@ -22,6 +22,9 @@ OBJECTS = \
$(S)/KeyWords.$(OBJSUFF) \ $(S)/KeyWords.$(OBJSUFF) \
$(S)/LexAVE.$(OBJSUFF) \ $(S)/LexAVE.$(OBJSUFF) \
$(S)/LexAda.$(OBJSUFF) \ $(S)/LexAda.$(OBJSUFF) \
$(S)/LexBaan.$(OBJSUFF) \
$(S)/LexBullant.$(OBJSUFF) \
$(S)/LexMatlab.$(OBJSUFF) \
$(S)/LexCPP.$(OBJSUFF) \ $(S)/LexCPP.$(OBJSUFF) \
$(S)/LexConf.$(OBJSUFF) \ $(S)/LexConf.$(OBJSUFF) \
$(S)/LexCrontab.$(OBJSUFF) \ $(S)/LexCrontab.$(OBJSUFF) \

View File

@@ -9,7 +9,7 @@
WXDIR = $(WXWIN) WXDIR = $(WXWIN)
SCINTILLA=.\scintilla SCINTILLA=.\scintilla
S=$(SCINTILLA)\src 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 NOPCH=1
!include $(WXDIR)\src\makevc.env !include $(WXDIR)\src\makevc.env
@@ -27,6 +27,9 @@ OBJECTS = \
$(D)\KeyWords.obj \ $(D)\KeyWords.obj \
$(D)\LexAVE.obj \ $(D)\LexAVE.obj \
$(D)\LexAda.obj \ $(D)\LexAda.obj \
$(D)\LexBaan.obj \
$(D)\LexBullant.obj \
$(D)\LexMatlab.obj \
$(D)\LexCPP.obj \ $(D)\LexCPP.obj \
$(D)\LexConf.obj \ $(D)\LexConf.obj \
$(D)\LexCrontab.obj \ $(D)\LexCrontab.obj \

View File

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

View File

@@ -15,25 +15,25 @@ typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyl
*/ */
class LexerModule { class LexerModule {
protected: protected:
LexerModule *next; const LexerModule *next;
int language; int language;
const char *languageName;
LexerFunction fnLexer; LexerFunction fnLexer;
LexerFunction fnFolder; LexerFunction fnFolder;
static LexerModule *base; static const LexerModule *base;
static int nextLanguage; static int nextLanguage;
public: public:
const char *languageName;
LexerModule(int language_, LexerFunction fnLexer_, LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_=0, LexerFunction fnFolder_=0); 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, 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, virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler); WordList *keywordlists[], Accessor &styler) const;
static LexerModule *Find(int language); static const LexerModule *Find(int language);
static LexerModule *Find(const char *languageName); static const LexerModule *Find(const char *languageName);
}; };
/** /**

View File

@@ -3,7 +3,7 @@
** Interface to platform facilities. Also includes some basic utilities. ** Interface to platform facilities. Also includes some basic utilities.
** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows. ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
**/ **/
// Copyright 1998-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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PLATFORM_H #ifndef PLATFORM_H
@@ -18,8 +18,13 @@
#define PLAT_GTK_WIN32 0 #define PLAT_GTK_WIN32 0
#define PLAT_WIN 0 #define PLAT_WIN 0
#define PLAT_WX 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 #undef PLAT_WX
#define PLAT_WX 1 #define PLAT_WX 1
@@ -39,79 +44,14 @@
#endif #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. // 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 // Sometimes these need to be passed around by client code so they are defined here
#if PLAT_GTK typedef void *FontID;
typedef GdkColor ColourID; typedef void *SurfaceID;
typedef GdkFont* FontID; typedef void *WindowID;
typedef GdkDrawable* SurfaceID; typedef void *MenuID;
typedef GtkWidget* WindowID; typedef void *TickerID;
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
/** /**
* A geometric point class. * A geometric point class.
@@ -168,42 +108,88 @@ public:
int Height() { return bottom - top; } int Height() { return bottom - top; }
}; };
#if PLAT_WX /**
wxRect wxRectFromPRectangle(PRectangle prc); * In some circumstances, including Win32 in paletted mode and GTK+, each colour
PRectangle PRectangleFromwxRect(wxRect rc); * must be allocated before use. The desired colours are held in the ColourDesired class,
#endif * 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 { class ColourDesired {
ColourID co; long co;
public: public:
Colour(long lcol=0); ColourDesired(long lcol=0) {
Colour(unsigned int red, unsigned int green, unsigned int blue); co = lcol;
bool operator==(const Colour &other) const; }
long AsLong() const;
unsigned int GetRed();
unsigned int GetGreen();
unsigned int GetBlue();
friend class Surface; ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
friend class Palette; 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 * Holds an allocated RGB colour which may be an approximation to the desired colour.
* allocates to approximate the desired colour. */
* To make palette management more automatic, ColourPairs could register at class ColourAllocated {
* construction time with a palette management object. 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 { struct ColourPair {
Colour desired; ColourDesired desired;
Colour allocated; ColourAllocated allocated;
ColourPair(Colour desired_=Colour(0,0,0)) { ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
desired = desired_; desired = desired_;
allocated = desired; allocated.Set(desired.AsLong());
} }
}; };
@@ -217,14 +203,13 @@ class Palette {
enum {numEntries = 100}; enum {numEntries = 100};
ColourPair entries[numEntries]; ColourPair entries[numEntries];
#if PLAT_GTK #if PLAT_GTK
GdkColor *allocatedPalette; void *allocatedPalette; // GdkColor *
int allocatedLen; int allocatedLen;
#elif PLAT_WIN
HPALETTE hpal;
#elif PLAT_WX
// wxPalette* pal; // **** Is this needed?
#endif #endif
public: public:
#if PLAT_WIN
void *hpal;
#endif
bool allowRealization; bool allowRealization;
Palette(); Palette();
@@ -240,8 +225,6 @@ public:
void WantFind(ColourPair &cp, bool want); void WantFind(ColourPair &cp, bool want);
void Allocate(Window &w); void Allocate(Window &w);
friend class Surface;
}; };
/** /**
@@ -267,6 +250,7 @@ public:
// Alias another font - caller guarantees not to Release // Alias another font - caller guarantees not to Release
void SetID(FontID id_) { id = id_; } void SetID(FontID id_) { id = id_; }
friend class Surface; friend class Surface;
friend class SurfaceImpl;
}; };
/** /**
@@ -274,97 +258,67 @@ public:
*/ */
class Surface { class Surface {
private: 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 // Private so Surface objects can not be copied
Surface(const Surface &) {} Surface(const Surface &) {}
Surface &operator=(const Surface &) { return *this; } Surface &operator=(const Surface &) { return *this; }
#if PLAT_WIN || PLAT_WX
void BrushColor(Colour back);
void SetFont(Font &font_);
#endif
public: public:
Surface(); Surface() {};
~Surface(); virtual ~Surface() {};
static Surface *Allocate();
void Init(); virtual void Init()=0;
void Init(SurfaceID hdc_); virtual void Init(SurfaceID sid)=0;
void InitPixMap(int width, int height, Surface *surface_); virtual void InitPixMap(int width, int height, Surface *surface_)=0;
void Release(); virtual void Release()=0;
bool Initialised(); virtual bool Initialised()=0;
void PenColour(Colour fore); virtual void PenColour(ColourAllocated fore)=0;
int LogPixelsY(); virtual int LogPixelsY()=0;
int DeviceHeightFont(int points); virtual int DeviceHeightFont(int points)=0;
void MoveTo(int x_, int y_); virtual void MoveTo(int x_, int y_)=0;
void LineTo(int x_, int y_); virtual void LineTo(int x_, int y_)=0;
void Polygon(Point *pts, int npts, Colour fore, Colour back); virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
void RectangleDraw(PRectangle rc, Colour fore, Colour back); virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
void FillRectangle(PRectangle rc, Colour back); virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
void FillRectangle(PRectangle rc, Surface &surfacePattern); virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
void RoundedRectangle(PRectangle rc, Colour fore, Colour back); virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
void Ellipse(PRectangle rc, Colour fore, Colour back); virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
void Copy(PRectangle rc, Point from, Surface &surfaceSource); 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); virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back); virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
void MeasureWidths(Font &font_, const char *s, int len, int *positions); virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
int WidthText(Font &font_, const char *s, int len); virtual int WidthText(Font &font_, const char *s, int len)=0;
int WidthChar(Font &font_, char ch); virtual int WidthChar(Font &font_, char ch)=0;
int Ascent(Font &font_); virtual int Ascent(Font &font_)=0;
int Descent(Font &font_); virtual int Descent(Font &font_)=0;
int InternalLeading(Font &font_); virtual int InternalLeading(Font &font_)=0;
int ExternalLeading(Font &font_); virtual int ExternalLeading(Font &font_)=0;
int Height(Font &font_); virtual int Height(Font &font_)=0;
int AverageCharWidth(Font &font_); virtual int AverageCharWidth(Font &font_)=0;
int SetPalette(Palette *pal, bool inBackGround); virtual int SetPalette(Palette *pal, bool inBackGround)=0;
void SetClip(PRectangle rc); virtual void SetClip(PRectangle rc)=0;
void FlushCachedState(); virtual void FlushCachedState()=0;
void SetUnicodeMode(bool unicodeMode_) { virtual void SetUnicodeMode(bool unicodeMode_)=0;
unicodeMode=unicodeMode_;
}
}; };
/**
* A simple callback action passing one piece of untyped user data.
*/
typedef void (*CallBackAction)(void*);
/** /**
* Class to hide the details of window manipulation. * Class to hide the details of window manipulation.
* Does not own the window which will normally have a longer life than this object. * Does not own the window which will normally have a longer life than this object.
*/ */
class Window { class Window {
friend class ListBox;
protected: protected:
WindowID id; WindowID id;
public: public:
Window() : id(0) {} Window() : id(0), cursorLast(cursorInvalid) {}
Window(const Window &source) : id(source.id) {} Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
virtual ~Window(); virtual ~Window();
Window &operator=(WindowID id_) { Window &operator=(WindowID id_) {
id = id_; id = id_;
@@ -382,20 +336,19 @@ public:
void InvalidateAll(); void InvalidateAll();
void InvalidateRectangle(PRectangle rc); void InvalidateRectangle(PRectangle rc);
virtual void SetFont(Font &font); 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 SetCursor(Cursor curs);
void SetTitle(const char *s); void SetTitle(const char *s);
#if PLAT_WIN private:
LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0); Cursor cursorLast;
int GetDlgCtrlID();
HINSTANCE GetInstance();
#endif
}; };
/** /**
* Listbox management. * Listbox management.
*/ */
class ListBox : public Window { class ListBox : public Window {
private:
#if PLAT_GTK #if PLAT_GTK
WindowID list; WindowID list;
WindowID scroller; WindowID scroller;
@@ -404,6 +357,9 @@ class ListBox : public Window {
int desiredVisibleRows; int desiredVisibleRows;
unsigned int maxItemCharacters; unsigned int maxItemCharacters;
unsigned int aveCharWidth; unsigned int aveCharWidth;
public:
CallBackAction doubleClickAction;
void *doubleClickActionData;
public: public:
ListBox(); ListBox();
virtual ~ListBox(); virtual ~ListBox();
@@ -420,6 +376,10 @@ public:
int Find(const char *prefix); int Find(const char *prefix);
void GetValue(int n, char *value, int len); void GetValue(int n, char *value, int len);
void Sort(); void Sort();
void SetDoubleClickAction(CallBackAction action, void *data) {
doubleClickAction = action;
doubleClickActionData = data;
}
}; };
/** /**
@@ -435,6 +395,14 @@ public:
void Show(Point pt, Window &w); 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 * 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. * and chrome colour. Not a creatable object, more of a module with several functions.
@@ -448,8 +416,8 @@ public:
// but gcc warns about this // but gcc warns about this
Platform() {} Platform() {}
~Platform() {} ~Platform() {}
static Colour Chrome(); static ColourDesired Chrome();
static Colour ChromeHighlight(); static ColourDesired ChromeHighlight();
static const char *DefaultFont(); static const char *DefaultFont();
static int DefaultFontSize(); static int DefaultFontSize();
static unsigned int DoubleClickTime(); static unsigned int DoubleClickTime();
@@ -457,6 +425,7 @@ public:
static bool IsKeyDown(int key); static bool IsKeyDown(int key);
static long SendScintilla( static long SendScintilla(
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0); WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
static bool IsDBCSLeadByte(int codePage, char ch);
// These are utility functions not really tied to a platform // These are utility functions not really tied to a platform
static int Minimum(int a, int b); static int Minimum(int a, int b);
@@ -483,4 +452,9 @@ public:
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__)) #define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif #endif
// Shut up annoying Visual C++ warnings:
#ifdef _MSC_VER
#pragma warning(disable: 4244 4309 4514 4710)
#endif
#endif #endif

View File

@@ -2,7 +2,7 @@
/** @file PropSet.h /** @file PropSet.h
** A Java style properties file module. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef PROPSET_H #ifndef PROPSET_H
@@ -41,7 +41,7 @@ public:
SString Expand(const char *withVars); SString Expand(const char *withVars);
int GetInt(const char *key, int defaultValue=0); int GetInt(const char *key, int defaultValue=0);
SString GetWild(const char *keybase, const char *filename); SString GetWild(const char *keybase, const char *filename);
SString GetNewExpand(const char *keybase, const char *filename); SString GetNewExpand(const char *keybase, const char *filename="");
void Clear(); void Clear();
char *ToString(); // Caller must delete[] the return value char *ToString(); // Caller must delete[] the return value
bool GetFirst(char **key, char **val); bool GetFirst(char **key, char **val);
@@ -70,7 +70,8 @@ public:
char *Allocate(int size); char *Allocate(int size);
void SetFromAllocated(); void SetFromAllocated();
bool InList(const char *s); bool InList(const char *s);
const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false); const char *GetNearestWord(const char *wordStart, int searchLen = -1,
bool ignoreCase = false, SString wordCharacters="");
char *GetNearestWords(const char *wordStart, int searchLen=-1, char *GetNearestWords(const char *wordStart, int searchLen=-1,
bool ignoreCase=false, char otherSeparator='\0'); bool ignoreCase=false, char otherSeparator='\0');
}; };

View File

@@ -8,7 +8,7 @@
#ifndef SSTRING_H #ifndef SSTRING_H
#define 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 CompareCaseInsensitive(const char *a, const char *b);
int CompareNCaseInsensitive(const char *a, const char *b, int len); int CompareNCaseInsensitive(const char *a, const char *b, int len);
bool EqualCaseInsensitive(const char *a, const char *b); 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. // While it would be 'better' to use std::string, that doubles the executable size.
// An SString may contain embedded nul characters. // 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. * @brief A simple string class.
*
* Hold the length of the string for quick operations, * 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. * 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 * 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. * functions to allow reliable manipulations of these strings.
**/ **/
class SString { 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: 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
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) { lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
s = StringDup(source.s); lenpos_t sLen; ///< The size of the string in s
sSize = sLen = (s) ? strlen(s) : 0; lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
} enum { sizeGrowthDefault = 64 };
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) { bool grow(lenpos_t lenNew) {
s = StringDup(s_); while (sizeGrowth * 6 < lenNew) {
sSize = sLen = (s) ? strlen(s) : 0; sizeGrowth *= 2;
}
SString(const char *s_, int first, int last) : sizeGrowth(sizeGrowthDefault) {
s = StringDup(s_ + first, last - first);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(int i) : sizeGrowth(sizeGrowthDefault) {
char number[32];
sprintf(number, "%0d", i);
s = StringDup(number);
sSize = sLen = (s) ? strlen(s) : 0;
}
~SString() {
delete []s;
s = 0;
sSize = 0;
sLen = 0;
}
void clear(void) {
if (s) {
*s = '\0';
} }
sLen = 0; char *sNew = new char[lenNew + sizeGrowth + 1];
if (sNew) {
if (s) {
memcpy(sNew, s, sLen);
delete []s;
}
s = sNew;
s[sLen] = '\0';
sSize = lenNew + sizeGrowth;
}
return sNew != 0;
} }
/** Size of buffer. */
size_type size(void) const { ///< SString &assign(const char *sOther, lenpos_t sSize_=measure_length) {
if (s)
return sSize;
else
return 0;
}
/** Size of string in buffer. */
int length() const {
return sLen;
}
SString &assign(const char* sOther, int sSize_ = -1) {
if (!sOther) { if (!sOther) {
sSize_ = 0; sSize_ = 0;
} } else if (sSize_ == measure_length) {
if (sSize_ < 0) {
sSize_ = strlen(sOther); sSize_ = strlen(sOther);
} }
if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
@@ -114,7 +69,7 @@ public:
sLen = sSize_; sLen = sSize_;
} else { } else {
delete []s; delete []s;
s = StringDup(sOther, sSize_); s = StringAllocate(sOther, sSize_);
if (s) { if (s) {
sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
sLen = strlen(s); sLen = strlen(s);
@@ -124,8 +79,56 @@ public:
} }
return *this; 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) { SString &operator=(const char *source) {
return assign(source); return assign(source);
@@ -162,7 +165,7 @@ public:
else else
return false; return false;
} }
void setsizegrowth(int sizeGrowth_) { void setsizegrowth(lenpos_t sizeGrowth_) {
sizeGrowth = sizeGrowth_; sizeGrowth = sizeGrowth_;
} }
const char *c_str() const { const char *c_str() const {
@@ -179,77 +182,167 @@ public:
sLen = 0; sLen = 0;
return sRet; 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 if (s && i < sSize) // Or < sLen? Depends on the use, both are OK
return s[i]; return s[i];
else else
return '\0'; return '\0';
} }
SString &append(const char* sOther, int sLenOther=-1, char sep=0) { SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') {
if (sLenOther < 0) if (!sOther) {
return *this;
}
if (sLenOther == measure_length) {
sLenOther = strlen(sOther); sLenOther = strlen(sOther);
}
int lenSep = 0; 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; 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 // Conservative about growing the buffer: don't do it, unless really needed
if ((lenNew + 1 < sSize) || (grow(lenNew))) {
if (lenSep) { if (lenSep) {
s[sLen] = sep; s[sLen] = sep;
sLen++; sLen++;
} }
strncpy(&s[sLen], sOther, sLenOther); strncpy(&s[sLen], sOther, sLenOther);
s[sLen + sLenOther] = '\0';
sLen += sLenOther; sLen += sLenOther;
} else { s[sLen] = '\0';
// Grow the buffer bigger than really needed, to have room for other appends
char *sNew = new char[lenNew + sizeGrowth + 1];
if (sNew) {
if (s) {
memcpy(sNew, s, sLen);
delete []s;
}
s = sNew;
sSize = lenNew + sizeGrowth;
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
sNew[sLen + sLenOther] = '\0';
sLen += sLenOther;
}
} }
return *this; return *this;
} }
SString &operator +=(const char *sOther) { SString &operator+=(const char *sOther) {
return append(sOther, -1); 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); return append(sOther.s, sOther.sSize);
} }
SString &operator +=(char ch) { SString &operator+=(char ch) {
return append(&ch, 1); return append(&ch, 1);
} }
SString &appendwithseparator(const char* sOther, char sep) { SString &appendwithseparator(const char *sOther, char sep) {
return append(sOther, strlen(sOther), 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 { int value() const {
if (s) if (s)
return atoi(s); return atoi(s);
else else
return 0; return 0;
} }
void substitute(char find, char replace) { int search(const char *sFind, lenpos_t start=0) {
char *t = s; if (start < sLen) {
while (t) { const char *sFound = strstr(s + start, sFind);
t = strchr(t, find); if (sFound) {
if (t) { return sFound - s;
*t = replace;
t++;
} }
} }
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, chFind);
if (t) {
*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 #endif

View File

@@ -2,7 +2,7 @@
/** @file SciLexer.h /** @file SciLexer.h
** Interface to the added lexer functions in the SciLexer version of the edit control. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -41,6 +41,12 @@
#define SCLEX_EIFFELKW 24 #define SCLEX_EIFFELKW 24
#define SCLEX_TCL 25 #define SCLEX_TCL 25
#define SCLEX_NNCRONTAB 26 #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 SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0 #define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1 #define SCE_P_COMMENTLINE 1
@@ -75,6 +81,15 @@
#define SCE_C_WORD2 16 #define SCE_C_WORD2 16
#define SCE_C_COMMENTDOCKEYWORD 17 #define SCE_C_COMMENTDOCKEYWORD 17
#define SCE_C_COMMENTDOCKEYWORDERROR 18 #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_DEFAULT 0
#define SCE_H_TAG 1 #define SCE_H_TAG 1
#define SCE_H_TAGUNKNOWN 2 #define SCE_H_TAGUNKNOWN 2
@@ -233,6 +248,11 @@
#define SCE_LUA_OPERATOR 10 #define SCE_LUA_OPERATOR 10
#define SCE_LUA_IDENTIFIER 11 #define SCE_LUA_IDENTIFIER 11
#define SCE_LUA_STRINGEOL 12 #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_DEFAULT 0
#define SCE_ERR_PYTHON 1 #define SCE_ERR_PYTHON 1
#define SCE_ERR_GCC 2 #define SCE_ERR_GCC 2
@@ -291,6 +311,17 @@
#define SCE_ADA_OPERATOR 6 #define SCE_ADA_OPERATOR 6
#define SCE_ADA_IDENTIFIER 7 #define SCE_ADA_IDENTIFIER 7
#define SCE_ADA_STRINGEOL 8 #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_DEFAULT 0
#define SCE_LISP_COMMENT 1 #define SCE_LISP_COMMENT 1
#define SCE_LISP_NUMBER 2 #define SCE_LISP_NUMBER 2
@@ -319,6 +350,14 @@
#define SCE_NNCRONTAB_STRING 8 #define SCE_NNCRONTAB_STRING 8
#define SCE_NNCRONTAB_ENVIRONMENT 9 #define SCE_NNCRONTAB_ENVIRONMENT 9
#define SCE_NNCRONTAB_IDENTIFIER 10 #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 //--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif #endif

View File

@@ -2,7 +2,7 @@
/** @file Scintilla.h /** @file Scintilla.h
** Interface to the edit control. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition // Most of this file is automatically generated from the Scintilla.iface interface definition
@@ -12,10 +12,11 @@
#define SCINTILLA_H #define SCINTILLA_H
#if PLAT_WIN #if PLAT_WIN
#ifdef STATIC_BUILD // Return false on failure:
void Scintilla_RegisterClasses(HINSTANCE hInstance); bool Scintilla_RegisterClasses(void *hInstance);
#endif bool Scintilla_ReleaseResources();
#endif #endif
int Scintilla_LinkLexers();
// Here should be placed typedefs for uptr_t, an unsigned integer type large enough to // 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. // 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_CIRCLEPLUSCONNECTED 19
#define SC_MARK_CIRCLEMINUS 20 #define SC_MARK_CIRCLEMINUS 20
#define SC_MARK_CIRCLEMINUSCONNECTED 21 #define SC_MARK_CIRCLEMINUSCONNECTED 21
#define SC_MARK_BACKGROUND 22
#define SC_MARK_CHARACTER 10000 #define SC_MARK_CHARACTER 10000
#define SC_MARKNUM_FOLDEREND 25 #define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26 #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_FOLDERSUB 29
#define SC_MARKNUM_FOLDER 30 #define SC_MARKNUM_FOLDER 30
#define SC_MARKNUM_FOLDEROPEN 31 #define SC_MARKNUM_FOLDEROPEN 31
#define SC_MASK_FOLDERS 0xFE000000
#define SCI_MARKERDEFINE 2040 #define SCI_MARKERDEFINE 2040
#define SCI_MARKERSETFORE 2041 #define SCI_MARKERSETFORE 2041
#define SCI_MARKERSETBACK 2042 #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_TT 2
#define INDIC_DIAGONAL 3 #define INDIC_DIAGONAL 3
#define INDIC_STRIKE 4 #define INDIC_STRIKE 4
#define INDIC0_MASK 32 #define INDIC0_MASK 0x20
#define INDIC1_MASK 64 #define INDIC1_MASK 0x40
#define INDIC2_MASK 128 #define INDIC2_MASK 0x80
#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK #define INDICS_MASK 0xE0
#define SCI_INDICSETSTYLE 2080 #define SCI_INDICSETSTYLE 2080
#define SCI_INDICGETSTYLE 2081 #define SCI_INDICGETSTYLE 2081
#define SCI_INDICSETFORE 2082 #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_SETCARETLINEVISIBLE 2096
#define SCI_GETCARETLINEBACK 2097 #define SCI_GETCARETLINEBACK 2097
#define SCI_SETCARETLINEBACK 2098 #define SCI_SETCARETLINEBACK 2098
#define SCI_STYLESETCHANGEABLE 2099
#define SCI_AUTOCSHOW 2100 #define SCI_AUTOCSHOW 2100
#define SCI_AUTOCCANCEL 2101 #define SCI_AUTOCCANCEL 2101
#define SCI_AUTOCACTIVE 2102 #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_USERLISTSHOW 2117
#define SCI_AUTOCSETAUTOHIDE 2118 #define SCI_AUTOCSETAUTOHIDE 2118
#define SCI_AUTOCGETAUTOHIDE 2119 #define SCI_AUTOCGETAUTOHIDE 2119
#define SCI_AUTOCSETDROPRESTOFWORD 2270
#define SCI_AUTOCGETDROPRESTOFWORD 2271
#define SCI_SETINDENT 2122 #define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123 #define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124 #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 SC_TIME_FOREVER 10000000
#define SCI_SETMOUSEDWELLTIME 2264 #define SCI_SETMOUSEDWELLTIME 2264
#define SCI_GETMOUSEDWELLTIME 2265 #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_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301 #define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302 #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_UPPERCASE 2341
#define SCI_LINESCROLLDOWN 2342 #define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343 #define SCI_LINESCROLLUP 2343
#define SCI_DELETEBACKNOTLINE 2344
#define SCI_MOVECARETINSIDEVIEW 2401 #define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350 #define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351 #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 SC_CURSORWAIT 3
#define SCI_SETCURSOR 2386 #define SCI_SETCURSOR 2386
#define SCI_GETCURSOR 2387 #define SCI_GETCURSOR 2387
#define SCI_SETCONTROLCHARSYMBOL 2388
#define SCI_GETCONTROLCHARSYMBOL 2389
#define SCI_WORDPARTLEFT 2390 #define SCI_WORDPARTLEFT 2390
#define SCI_WORDPARTLEFTEXTEND 2391 #define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392 #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_SETVISIBLEPOLICY 2394
#define SCI_DELLINELEFT 2395 #define SCI_DELLINELEFT 2395
#define SCI_DELLINERIGHT 2396 #define SCI_DELLINERIGHT 2396
#define SCI_SETXOFFSET 2397
#define SCI_GETXOFFSET 2398
#define SCI_GRABFOCUS 2400 #define SCI_GRABFOCUS 2400
#define SCI_STARTRECORD 3001 #define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002 #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_KEY 2005
#define SCN_DOUBLECLICK 2006 #define SCN_DOUBLECLICK 2006
#define SCN_UPDATEUI 2007 #define SCN_UPDATEUI 2007
#define SCN_CHECKBRACE 2007
#define SCN_MODIFIED 2008 #define SCN_MODIFIED 2008
#define SCN_MACRORECORD 2009 #define SCN_MACRORECORD 2009
#define SCN_MARGINCLICK 2010 #define SCN_MARGINCLICK 2010
#define SCN_NEEDSHOWN 2011 #define SCN_NEEDSHOWN 2011
#define SCN_POSCHANGED 2012
#define SCN_PAINTED 2013 #define SCN_PAINTED 2013
#define SCN_USERLISTSELECTION 2014 #define SCN_USERLISTSELECTION 2014
#define SCN_URIDROPPED 2015 #define SCN_URIDROPPED 2015
@@ -528,7 +549,7 @@ struct TextToFind {
#ifdef PLATFORM_H #ifdef PLATFORM_H
// This structure is used in printing and requires some of the graphics types // This structure is used in printing and requires some of the graphics types
// from Platform.h. Not needed by most client code. // from Platform.h. Not needed by most client code.
struct RangeToFormat { struct RangeToFormat {
@@ -545,7 +566,7 @@ struct NotifyHeader {
// hwndFrom is really an environment specifc window handle or pointer // hwndFrom is really an environment specifc window handle or pointer
// but most clients of Scintilla.h do not have this type visible. // but most clients of Scintilla.h do not have this type visible.
//WindowID hwndFrom; //WindowID hwndFrom;
void *hwndFrom; void *hwndFrom;
unsigned int idFrom; unsigned int idFrom;
unsigned int code; unsigned int code;
}; };
@@ -571,20 +592,15 @@ struct SCNotification {
int y; // SCN_DWELLSTART, SCN_DWELLEND 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 // Deprecation section listing all API features that are deprecated and will
// will be removed completely in a future version. // will be removed completely in a future version.
// To enable these features define INCLUDE_DEPRECATED_FEATURES // To enable these features define INCLUDE_DEPRECATED_FEATURES
#ifdef INCLUDE_DEPRECATED_FEATURES #ifdef INCLUDE_DEPRECATED_FEATURES
#define SCN_POSCHANGED 2012
#define SCN_CHECKBRACE 2007
#endif #endif
#endif #endif

View File

@@ -2,6 +2,9 @@
## This file defines the interface to Scintilla ## 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 a pure comment and should be stripped by readers.
## A line starting with #! is for future shbang use ## A line starting with #! is for future shbang use
## A line starting with # followed by a space is a documentation comment and refers ## 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>]*]) ## 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 ## Feature names that contain an underscore are defined by Windows, so in these
## cases, using the Windows definition is preferred where available. ## 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: ## Types:
## void ## void
@@ -35,20 +41,27 @@
## string -> pointer to const character ## string -> pointer to const character
## stringresult -> pointer to character ## stringresult -> pointer to character
## cells -> pointer to array of cells, each cell containing a style byte and character byte ## 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 ## charrange -> range of a min and a max position
## charrangeresult -> like charrange, but output param ## 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 ## countedstring
## formatrange
## point -> x,y ## point -> x,y
## pointresult -> like point, but output param ## pointresult -> like point, but output param
## rectangle -> left,top,right,bottom ## rectangle -> left,top,right,bottom
## Client code should ignore definitions containing types it does not understand, except ## Client code should ignore definitions containing types it does not understand, except
## for possibly #defining the constants ## 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 cat Basics
################################################ ################################################
@@ -229,6 +242,9 @@ val SC_MARK_CIRCLEPLUSCONNECTED=19
val SC_MARK_CIRCLEMINUS=20 val SC_MARK_CIRCLEMINUS=20
val SC_MARK_CIRCLEMINUSCONNECTED=21 val SC_MARK_CIRCLEMINUSCONNECTED=21
# Invisible mark that only sets the line background color
val SC_MARK_BACKGROUND=22
val SC_MARK_CHARACTER=10000 val SC_MARK_CHARACTER=10000
# Markers used for outlining column # Markers used for outlining column
@@ -240,6 +256,8 @@ val SC_MARKNUM_FOLDERSUB=29
val SC_MARKNUM_FOLDER=30 val SC_MARKNUM_FOLDER=30
val SC_MARKNUM_FOLDEROPEN=31 val SC_MARKNUM_FOLDEROPEN=31
val SC_MASK_FOLDERS=0xFE000000
# Set the symbol used for a particular marker number. # Set the symbol used for a particular marker number.
fun void MarkerDefine=2040(int markerNumber, int markerSymbol) 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. # Set the background colour used for a particular marker number.
fun void MarkerSetBack=2042(int markerNumber, colour back) fun void MarkerSetBack=2042(int markerNumber, colour back)
# Add a marker to a line. # Add a marker to a line, returning an ID which can be used to find or delete the marker.
fun void MarkerAdd=2043(int line, int markerNumber) fun int MarkerAdd=2043(int line, int markerNumber)
# Delete a marker from a line # Delete a marker from a line
fun void MarkerDelete=2044(int line, int markerNumber) fun void MarkerDelete=2044(int line, int markerNumber)
@@ -413,11 +431,10 @@ val INDIC_SQUIGGLE=1
val INDIC_TT=2 val INDIC_TT=2
val INDIC_DIAGONAL=3 val INDIC_DIAGONAL=3
val INDIC_STRIKE=4 val INDIC_STRIKE=4
val INDIC0_MASK=32 val INDIC0_MASK=0x20
val INDIC1_MASK=64 val INDIC1_MASK=0x40
val INDIC2_MASK=128 val INDIC2_MASK=0x80
val INDICS_MASK=224 val INDICS_MASK=0xE0
##INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
# Set an indicator to plain, squiggle or TT. # Set an indicator to plain, squiggle or TT.
set void IndicSetStyle=2080(int indic, int style) 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? # Is the background of the line containing the caret in a different colour?
get bool GetCaretLineVisible=2095(,) 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,) set void SetCaretLineVisible=2096(bool show,)
# Get the colour of the background of the line containing the caret. # 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 the colour of the background of the line containing the caret.
set void SetCaretLineBack=2098(colour back,) 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. # Display a auto-completion list.
# The lenEntered parameter indicates how many characters before # The lenEntered parameter indicates how many characters before
# the caret should be used to provide context. # the caret should be used to provide context.
@@ -498,7 +519,8 @@ set void AutoCSetCancelAtStart=2110(bool cancel,)
# Retrieve whether auto-completion cancelled by backspacing before start. # Retrieve whether auto-completion cancelled by backspacing before start.
get bool AutoCGetCancelAtStart=2111(,) 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) set void AutoCSetFillUps=2112(, string characterSet)
# Should a single item auto-completion list automatically choose the item. # 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 # Retrieve whether or not autocompletion is hidden automatically when nothing matches
get bool AutoCGetAutoHide=2119(,) 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 the number of spaces used for one level of indentation.
set void SetIndent=2122(int indentSize,) 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 # Retrieve the time the mouse must sit still to generate a mouse dwell event
get int GetMouseDwellTime=2265(,) 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 ## Start of key messages
# Move caret down one line. # Move caret down one line.
fun void LineDown=2300(,) fun void LineDown=2300(,)
@@ -1014,6 +1068,10 @@ fun void LineScrollDown=2342(,)
# Scroll the document up, keeping the caret visible. # Scroll the document up, keeping the caret visible.
fun void LineScrollUp=2343(,) fun void LineScrollUp=2343(,)
# 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 # Move the caret inside current view if it's not there already
fun void MoveCaretInsideView=2401(,) fun void MoveCaretInsideView=2401(,)
@@ -1146,6 +1204,12 @@ set void SetCursor=2386(int cursorType,)
# Get cursor type # Get cursor type
get int GetCursor=2387(,) 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 # Move to the previous change in capitalistion
fun void WordPartLeft=2390(,) fun void WordPartLeft=2390(,)
# Move to the previous change in capitalistion extending selection to new caret position. # 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 # Delete forwards from the current position to the end of the line
fun void DelLineRight=2396(,) 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. # Set the focus to this Scintilla widget.
# GTK+ Specific # GTK+ Specific
fun void GrabFocus=2400(,) fun void GrabFocus=2400(,)
@@ -1273,6 +1341,13 @@ val SCLEX_EIFFEL=23
val SCLEX_EIFFELKW=24 val SCLEX_EIFFELKW=24
val SCLEX_TCL=25 val SCLEX_TCL=25
val SCLEX_NNCRONTAB=26 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 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1. # value assigned in sequence from SCLEX_AUTOMATIC+1.
val SCLEX_AUTOMATIC=1000 val SCLEX_AUTOMATIC=1000
@@ -1291,7 +1366,7 @@ val SCE_P_OPERATOR=10
val SCE_P_IDENTIFIER=11 val SCE_P_IDENTIFIER=11
val SCE_P_COMMENTBLOCK=12 val SCE_P_COMMENTBLOCK=12
val SCE_P_STRINGEOL=13 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_DEFAULT=0
val SCE_C_COMMENT=1 val SCE_C_COMMENT=1
val SCE_C_COMMENTLINE=2 val SCE_C_COMMENTLINE=2
@@ -1311,6 +1386,16 @@ val SCE_C_COMMENTLINEDOC=15
val SCE_C_WORD2=16 val SCE_C_WORD2=16
val SCE_C_COMMENTDOCKEYWORD=17 val SCE_C_COMMENTDOCKEYWORD=17
val SCE_C_COMMENTDOCKEYWORDERROR=18 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 # Lexical states for SCLEX_HTML, SCLEX_XML
val SCE_H_DEFAULT=0 val SCE_H_DEFAULT=0
val SCE_H_TAG=1 val SCE_H_TAG=1
@@ -1484,6 +1569,11 @@ val SCE_LUA_PREPROCESSOR=9
val SCE_LUA_OPERATOR=10 val SCE_LUA_OPERATOR=10
val SCE_LUA_IDENTIFIER=11 val SCE_LUA_IDENTIFIER=11
val SCE_LUA_STRINGEOL=12 val SCE_LUA_STRINGEOL=12
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 # Lexical states for SCLEX_ERRORLIST
val SCE_ERR_DEFAULT=0 val SCE_ERR_DEFAULT=0
val SCE_ERR_PYTHON=1 val SCE_ERR_PYTHON=1
@@ -1548,6 +1638,18 @@ val SCE_ADA_CHARACTER=5
val SCE_ADA_OPERATOR=6 val SCE_ADA_OPERATOR=6
val SCE_ADA_IDENTIFIER=7 val SCE_ADA_IDENTIFIER=7
val SCE_ADA_STRINGEOL=8 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 # Lexical states for SCLEX_LISP
val SCE_LISP_DEFAULT=0 val SCE_LISP_DEFAULT=0
val SCE_LISP_COMMENT=1 val SCE_LISP_COMMENT=1
@@ -1579,6 +1681,15 @@ val SCE_NNCRONTAB_NUMBER=7
val SCE_NNCRONTAB_STRING=8 val SCE_NNCRONTAB_STRING=8
val SCE_NNCRONTAB_ENVIRONMENT=9 val SCE_NNCRONTAB_ENVIRONMENT=9
val SCE_NNCRONTAB_IDENTIFIER=10 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 # Events
@@ -1591,14 +1702,10 @@ evt void ModifyAttemptRO=2004(void)
evt void Key=2005(int ch, int modifiers) evt void Key=2005(int ch, int modifiers)
evt void DoubleClick=2006(void) evt void DoubleClick=2006(void)
evt void UpdateUI=2007(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) 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 MacroRecord=2009(int message, int wParam, int lParam)
evt void MarginClick=2010(int modifiers, int position, int margin) evt void MarginClick=2010(int modifiers, int position, int margin)
evt void NeedShown=2011(int position, int length) evt void NeedShown=2011(int position, int length)
evt void PosChanged=2012(int position)
evt void Painted=2013(void) evt void Painted=2013(void)
evt void UserListSelection=2014(int listType, string text) evt void UserListSelection=2014(int listType, string text)
evt void URIDropped=2015(string text) evt void URIDropped=2015(string text)
@@ -1606,3 +1713,7 @@ evt void DwellStart=2016(int position)
evt void DwellEnd=2017(int position) evt void DwellEnd=2017(int position)
cat Deprecated cat Deprecated
# The old name for SCN_UPDATEUI
val SCN_CHECKBRACE=2007
evt void PosChanged=2012(int position)

View File

@@ -2,7 +2,7 @@
/** @file AutoComplete.cxx /** @file AutoComplete.cxx
** Defines the auto completion list box. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -22,7 +22,8 @@ AutoComplete::AutoComplete() :
posStart(0), posStart(0),
startLen(0), startLen(0),
cancelAtStartPos(true), cancelAtStartPos(true),
autoHide(true) { autoHide(true),
dropRestOfWord(false) {
stopChars[0] = '\0'; stopChars[0] = '\0';
fillUpChars[0] = '\0'; fillUpChars[0] = '\0';
} }

View File

@@ -2,7 +2,7 @@
/** @file AutoComplete.h /** @file AutoComplete.h
** Defines the auto completion list box. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef AUTOCOMPLETE_H #ifndef AUTOCOMPLETE_H
@@ -25,6 +25,7 @@ public:
/// Should autocompletion be canceled if editor's currentPos <= startPos? /// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos; bool cancelAtStartPos;
bool autoHide; bool autoHide;
bool dropRestOfWord;
AutoComplete(); AutoComplete();
~AutoComplete(); ~AutoComplete();

View File

@@ -21,11 +21,11 @@ CallTip::CallTip() {
startHighlight = 0; startHighlight = 0;
endHighlight = 0; endHighlight = 0;
colourBG.desired = Colour(0xff, 0xff, 0xff); colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
colourUnSel.desired = Colour(0x80, 0x80, 0x80); colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
colourSel.desired = Colour(0, 0, 0x80); colourSel.desired = ColourDesired(0, 0, 0x80);
colourShade.desired = Colour(0, 0, 0); colourShade.desired = ColourDesired(0, 0, 0);
colourLight.desired = Colour(0xc0, 0xc0, 0xc0); colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
} }
CallTip::~CallTip() { CallTip::~CallTip() {
@@ -81,7 +81,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
rcClient.left = x; rcClient.left = x;
rcClient.top = ytext - ascent - 1; rcClient.top = ytext - ascent - 1;
rcClient.right = xEnd; rcClient.right = xEnd;
surfaceWindow->DrawText(rcClient, font, ytext, surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal, thisStartHighlight, chunkVal, thisStartHighlight,
colourUnSel.allocated, colourBG.allocated); colourUnSel.allocated, colourBG.allocated);
x = xEnd; x = xEnd;
@@ -91,7 +91,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
rcClient.top = ytext; rcClient.top = ytext;
rcClient.left = x; rcClient.left = x;
rcClient.right = xEnd; rcClient.right = xEnd;
surfaceWindow->DrawText(rcClient, font, ytext, surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight, chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
colourSel.allocated, colourBG.allocated); colourSel.allocated, colourBG.allocated);
x = xEnd; x = xEnd;
@@ -100,7 +100,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
chunkLength - thisEndHighlight); chunkLength - thisEndHighlight);
rcClient.left = x; rcClient.left = x;
rcClient.right = xEnd; rcClient.right = xEnd;
surfaceWindow->DrawText(rcClient, font, ytext, surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight, chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
colourUnSel.allocated, colourBG.allocated); colourUnSel.allocated, colourBG.allocated);
chunkVal = chunkEnd + 1; chunkVal = chunkEnd + 1;
@@ -117,21 +117,25 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
} }
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size) { const char *faceName, int size, bool unicodeMode_) {
Surface surfaceMeasure;
surfaceMeasure.Init();
int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
if (val) if (val)
delete []val; delete []val;
val = new char[strlen(defn) + 1]; val = new char[strlen(defn) + 1];
if (!val) if (!val)
return PRectangle(); return PRectangle();
strcpy(val, defn); strcpy(val, defn);
unicodeMode = unicodeMode_;
Surface *surfaceMeasure = Surface::Allocate();
if (!surfaceMeasure)
return PRectangle();
surfaceMeasure->Init();
surfaceMeasure->SetUnicodeMode(unicodeMode);
startHighlight = 0; startHighlight = 0;
endHighlight = 0; endHighlight = 0;
inCallTipMode = true; inCallTipMode = true;
posStartCallTip = pos; posStartCallTip = pos;
int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
// Look for multiple lines in the text // Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r! // Only support \n here - simply means container must avoid \r!
int width = 0; int width = 0;
@@ -139,16 +143,17 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *newline; const char *newline;
const char *look = val; const char *look = val;
while ((newline = strchr(look, '\n')) != NULL) { 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); width = Platform::Maximum(width, thisWidth);
look = newline + 1; look = newline + 1;
numLines++; numLines++;
} }
int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look)); int lastWidth = surfaceMeasure->WidthText(font, look, strlen(look));
width = Platform::Maximum(width, lastWidth) + 10; 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 // 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); return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
} }

View File

@@ -29,6 +29,7 @@ public:
ColourPair colourSel; ColourPair colourSel;
ColourPair colourShade; ColourPair colourShade;
ColourPair colourLight; ColourPair colourLight;
bool unicodeMode;
CallTip(); CallTip();
~CallTip(); ~CallTip();
@@ -40,7 +41,7 @@ public:
/// Setup the calltip and return a rectangle of the area required. /// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(int pos, Point pt, const char *defn, PRectangle CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size); const char *faceName, int size, bool unicodeMode_);
void CallTipCancel(); void CallTipCancel();

View File

@@ -11,8 +11,9 @@
OneLine::OneLine() { OneLine::OneLine() {
displayLine = 0; displayLine = 0;
docLine = 0; //docLine = 0;
visible = true; visible = true;
height = 1;
expanded = true; expanded = true;
} }
@@ -22,6 +23,8 @@ ContractionState::ContractionState() {
linesInDoc = 1; linesInDoc = 1;
linesInDisplay = 1; linesInDisplay = 1;
valid = false; valid = false;
docLines = 0;
sizeDocLines = 0;
} }
ContractionState::~ContractionState() { ContractionState::~ContractionState() {
@@ -30,14 +33,34 @@ ContractionState::~ContractionState() {
void ContractionState::MakeValid() const { void ContractionState::MakeValid() const {
if (!valid) { if (!valid) {
// Could be cleverer by keeping the index of the last still valid entry // Could be cleverer by keeping the index of the last still valid entry
// rather than invalidating all. // 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++) { for (int line=0; line<linesInDoc; line++) {
lines[line].displayLine = lineDisplay;
if (lines[line].visible) { if (lines[line].visible) {
lines[lineDisplay].docLine = line; for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
lineDisplay++; docLines[lineInDisplay] = line;
lineInDisplay++;
}
} }
} }
valid = true; valid = true;
@@ -50,6 +73,9 @@ void ContractionState::Clear() {
size = 0; size = 0;
linesInDoc = 1; linesInDoc = 1;
linesInDisplay = 1; linesInDisplay = 1;
delete []docLines;
docLines = 0;
sizeDocLines = 0;
} }
int ContractionState::LinesInDoc() const { int ContractionState::LinesInDoc() const {
@@ -57,6 +83,9 @@ int ContractionState::LinesInDoc() const {
} }
int ContractionState::LinesDisplayed() const { int ContractionState::LinesDisplayed() const {
if (size != 0) {
MakeValid();
}
return linesInDisplay; return linesInDisplay;
} }
@@ -75,11 +104,15 @@ int ContractionState::DocFromDisplay(int lineDisplay) const {
if (lineDisplay <= 0) if (lineDisplay <= 0)
return 0; return 0;
if (lineDisplay >= linesInDisplay) if (lineDisplay >= linesInDisplay)
return linesInDoc-1; return linesInDoc;
if (size == 0) if (size == 0)
return lineDisplay; return lineDisplay;
MakeValid(); MakeValid();
return lines[lineDisplay].docLine; if (docLines) { // Valid allocation
return docLines[lineDisplay];
} else {
return 0;
}
} }
void ContractionState::Grow(int sizeNew) { void ContractionState::Grow(int sizeNew) {
@@ -113,13 +146,15 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
Grow(linesInDoc + lineCount + growSize); Grow(linesInDoc + lineCount + growSize);
} }
linesInDoc += lineCount; linesInDoc += lineCount;
linesInDisplay += lineCount;
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) { for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
lines[i].visible = lines[i - lineCount].visible; 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; lines[i].expanded = lines[i - lineCount].expanded;
} }
for (int d=0;d<lineCount;d++) { for (int d=0;d<lineCount;d++) {
lines[lineDoc+d].visible = true; // Should inherit visibility from context ? lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
lines[lineDoc+d].height = 1;
lines[lineDoc+d].expanded = true; lines[lineDoc+d].expanded = true;
} }
valid = false; valid = false;
@@ -134,7 +169,7 @@ void ContractionState::DeleteLines(int lineDoc, int lineCount) {
int deltaDisplayed = 0; int deltaDisplayed = 0;
for (int d=0;d<lineCount;d++) { for (int d=0;d<lineCount;d++) {
if (lines[lineDoc+d].visible) if (lines[lineDoc+d].visible)
deltaDisplayed--; deltaDisplayed -= lines[lineDoc+d].height;
} }
for (int i = lineDoc; i < linesInDoc-lineCount; i++) { for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
if (i != 0) // Line zero is always visible if (i != 0) // Line zero is always visible
@@ -157,10 +192,10 @@ bool ContractionState::GetVisible(int lineDoc) const {
} }
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) { bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
if (lineDocStart == 0) if (lineDocStart == 0)
lineDocStart++; lineDocStart++;
if (lineDocStart > lineDocEnd) if (lineDocStart > lineDocEnd)
return false; return false;
if (size == 0) { if (size == 0) {
Grow(linesInDoc + growSize); Grow(linesInDoc + growSize);
} }
@@ -170,7 +205,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) { if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
for (int line=lineDocStart; line <= lineDocEnd; line++) { for (int line=lineDocStart; line <= lineDocEnd; line++) {
if (lines[line].visible != visible) { if (lines[line].visible != visible) {
delta += visible ? 1 : -1; delta += visible ? lines[line].height : -lines[line].height;
lines[line].visible = visible; lines[line].visible = visible;
} }
} }
@@ -181,7 +216,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible
} }
bool ContractionState::GetExpanded(int lineDoc) const { bool ContractionState::GetExpanded(int lineDoc) const {
if (size == 0) if (size == 0)
return true; return true;
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
return lines[lineDoc].expanded; return lines[lineDoc].expanded;
@@ -192,6 +227,11 @@ bool ContractionState::GetExpanded(int lineDoc) const {
bool ContractionState::SetExpanded(int lineDoc, bool expanded) { bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
if (size == 0) { if (size == 0) {
if (expanded) {
// If in completely expanded state then setting
// one line to expanded has no effect.
return false;
}
Grow(linesInDoc + growSize); Grow(linesInDoc + growSize);
} }
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
@@ -203,6 +243,38 @@ bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
return false; 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() { void ContractionState::ShowAll() {
delete []lines; delete []lines;
lines = 0; lines = 0;

View File

@@ -13,10 +13,11 @@
class OneLine { class OneLine {
public: public:
int displayLine; ///< Position within set of visible lines int displayLine; ///< Position within set of visible lines
int docLine; ///< Inverse of @a displayLine //int docLine; ///< Inverse of @a displayLine
int height; ///< Number of display lines needed to show all of the line
bool visible; bool visible;
bool expanded; bool expanded;
OneLine(); OneLine();
virtual ~OneLine() {} virtual ~OneLine() {}
}; };
@@ -27,33 +28,38 @@ class ContractionState {
void Grow(int sizeNew); void Grow(int sizeNew);
enum { growSize = 4000 }; enum { growSize = 4000 };
int linesInDoc; int linesInDoc;
int linesInDisplay; mutable int linesInDisplay;
mutable OneLine *lines; mutable OneLine *lines;
int size; int size;
mutable int *docLines;
mutable int sizeDocLines;
mutable bool valid; mutable bool valid;
void MakeValid() const; void MakeValid() const;
public: public:
ContractionState(); ContractionState();
virtual ~ContractionState(); virtual ~ContractionState();
void Clear(); void Clear();
int LinesInDoc() const; int LinesInDoc() const;
int LinesDisplayed() const; int LinesDisplayed() const;
int DisplayFromDoc(int lineDoc) const; int DisplayFromDoc(int lineDoc) const;
int DocFromDisplay(int lineDisplay) const; int DocFromDisplay(int lineDisplay) const;
void InsertLines(int lineDoc, int lineCount); void InsertLines(int lineDoc, int lineCount);
void DeleteLines(int lineDoc, int lineCount); void DeleteLines(int lineDoc, int lineCount);
bool GetVisible(int lineDoc) const; bool GetVisible(int lineDoc) const;
bool SetVisible(int lineDocStart, int lineDocEnd, bool visible); bool SetVisible(int lineDocStart, int lineDocEnd, bool visible);
bool GetExpanded(int lineDoc) const; bool GetExpanded(int lineDoc) const;
bool SetExpanded(int lineDoc, bool expanded); bool SetExpanded(int lineDoc, bool expanded);
void ShowAll(); int GetHeight(int lineDoc) const;
bool SetHeight(int lineDoc, int height);
void ShowAll();
}; };
#endif #endif

View File

@@ -2,7 +2,7 @@
/** @file Document.cxx /** @file Document.cxx
** Text document that handles notifications, DBCS, styling, words and end of line. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> #include <stdlib.h>
@@ -19,7 +19,7 @@
#include "RESearch.h" #include "RESearch.h"
// This is ASCII specific but is safe with chars >= 0x80 // 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)); return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
} }
@@ -34,10 +34,9 @@ Document::Document() {
stylingBits = 5; stylingBits = 5;
stylingBitsMask = 0x1F; stylingBitsMask = 0x1F;
stylingMask = 0; stylingMask = 0;
for (int ch = 0; ch < 256; ch++) { SetWordChars(0);
wordchars[ch] = isalnum(ch) || ch == '_';
}
endStyled = 0; endStyled = 0;
styleClock = 0;
enteredCount = 0; enteredCount = 0;
enteredReadOnlyCount = 0; enteredReadOnlyCount = 0;
tabInChars = 8; tabInChars = 8;
@@ -219,7 +218,6 @@ bool Document::IsCrLf(int pos) {
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n'); return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
} }
#if PLAT_WIN
bool Document::IsDBCS(int pos) { bool Document::IsDBCS(int pos) {
if (dbcsCodePage) { if (dbcsCodePage) {
if (SC_CP_UTF8 == 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') while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
startLine--; startLine--;
while (startLine <= pos) { while (startLine <= pos) {
if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) { if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine))) {
startLine++; startLine++;
if (startLine >= pos) if (startLine >= pos)
return true; return true;
@@ -243,13 +241,6 @@ bool Document::IsDBCS(int pos) {
} }
return false; 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) { int Document::LenChar(int pos) {
if (IsCrLf(pos)) { if (IsCrLf(pos)) {
@@ -302,7 +293,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
// Not between CR and LF // Not between CR and LF
#if PLAT_WIN
if (dbcsCodePage) { if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) { if (SC_CP_UTF8 == dbcsCodePage) {
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos)); 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) { while (startLine < pos) {
if (atLeadByte) if (atLeadByte)
atLeadByte = false; atLeadByte = false;
else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) else if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine)))
atLeadByte = true; atLeadByte = true;
else else
atLeadByte = false; atLeadByte = false;
startLine++; startLine++;
//Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
} }
@@ -342,7 +331,6 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
} }
} }
} }
#endif
return pos; return pos;
} }
@@ -634,21 +622,46 @@ int Document::GetColumn(int pos) {
int column = 0; int column = 0;
int line = LineFromPosition(pos); int line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) { if ((line >= 0) && (line < LinesTotal())) {
for (int i = LineStart(line);i < pos;i++) { for (int i = LineStart(line);i < pos;) {
char ch = cb.CharAt(i); char ch = cb.CharAt(i);
if (ch == '\t') if (ch == '\t') {
column = NextTab(column, tabInChars); column = NextTab(column, tabInChars);
else if (ch == '\r') i++;
} else if (ch == '\r') {
return column; return column;
else if (ch == '\n') } else if (ch == '\n') {
return column; return column;
else } else {
column++; column++;
i = MovePositionOutsideChar(i + 1, 1);
}
} }
} }
return column; 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) { 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 // Dedent - suck white space off the front of the line to dedent by equivalent of a tab
for (int line = lineBottom; line >= lineTop; line--) { for (int line = lineBottom; line >= lineTop; line--) {
@@ -700,72 +713,88 @@ void Document::ConvertLineEnds(int eolModeSet) {
EndUndoAction(); EndUndoAction();
} }
bool Document::IsWordChar(unsigned char ch) { Document::charClassification Document::WordCharClass(unsigned char ch) {
if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80)) if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80))
return true; return ccWord;
return wordchars[ch]; 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) { 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--; pos--;
} else { } else {
while (pos < (Length()) && IsWordChar(cb.CharAt(pos))) if (!onlyWordCharacters)
pos++; ccStart = WordCharClass(cb.CharAt(pos));
} while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
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'))
pos++; pos++;
} }
return pos; return pos;
} }
/** /**
* Check that the character before the given position * Find the start of the next word in either a forward (delta >= 0) or backwards direction
* is not a word character. * (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) { bool Document::IsWordStartAt(int pos) {
if (pos > 0) { 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; return true;
} }
/** /**
* Check that the character after the given position * Check that the character at the given position is a word or punctuation character and that
* is not a word character. * the next character is of a different character class.
*/ */
bool Document::IsWordEndAt(int pos) { bool Document::IsWordEndAt(int pos) {
if (pos < Length() - 1) { 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; return true;
} }
/** /**
* Check that the given range is delimited by * Check that the given range is has transitions between character classes at both
* non word characters. * ends and where the characters on the inside are word or punctuation characters.
*/ */
bool Document::IsWordAt(int start, int end) { bool Document::IsWordAt(int start, int end) {
return IsWordStartAt(start) && IsWordEndAt(end); return IsWordStartAt(start) && IsWordEndAt(end);
@@ -1018,16 +1047,22 @@ void Document::ChangeCase(Range r, bool makeUpperCase) {
void Document::SetWordChars(unsigned char *chars) { void Document::SetWordChars(unsigned char *chars) {
int ch; int ch;
for (ch = 0; ch < 256; 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) { if (chars) {
while (*chars) { while (*chars) {
wordchars[*chars] = true; charClass[*chars] = ccWord;
chars++; chars++;
} }
} else { } else {
for (ch = 0; ch < 256; ch++) { 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; int prevEndStyled = endStyled;
bool didChange = false; bool didChange = false;
for (int iPos = 0; iPos < length; iPos++, endStyled++) { for (int iPos = 0; iPos < length; iPos++, endStyled++) {
PLATFORM_ASSERT(endStyled < Length());
if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) { if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
didChange = true; didChange = true;
} }
@@ -1080,6 +1116,12 @@ void Document::SetStyles(int length, char *styles) {
} }
bool Document::EnsureStyledTo(int pos) { 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. // Ask the watchers to style, and stop as soon as one responds.
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++) for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos); watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
@@ -1149,7 +1191,7 @@ void Document::NotifyModified(DocModification mh) {
} }
bool Document::IsWordPartSeparator(char ch) { bool Document::IsWordPartSeparator(char ch) {
return ispunct(ch) && IsWordChar(ch); return ispunct(ch) && (WordCharClass(ch) == ccWord);
} }
int Document::WordPartLeft(int pos) { int Document::WordPartLeft(int pos) {

View File

@@ -2,7 +2,7 @@
/** @file Document.h /** @file Document.h
** Text document that handles notifications, DBCS, styling, words and end of line. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef DOCUMENT_H #ifndef DOCUMENT_H
@@ -37,6 +37,7 @@ public:
return (start != invalidPosition) && (end != invalidPosition); return (start != invalidPosition) && (end != invalidPosition);
} }
// Is the position within the range?
bool Contains(Position pos) const { bool Contains(Position pos) const {
if (start < end) { if (start < end) {
return (pos >= start && pos <= end); return (pos >= start && pos <= end);
@@ -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 { bool Contains(Range other) const {
return Contains(other.start) && Contains(other.end); return Contains(other.start) && Contains(other.end);
} }
@@ -81,9 +91,11 @@ public:
private: private:
int refCount; int refCount;
CellBuffer cb; CellBuffer cb;
bool wordchars[256]; enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
charClassification charClass[256];
char stylingMask; char stylingMask;
int endStyled; int endStyled;
int styleClock;
int enteredCount; int enteredCount;
int enteredReadOnlyCount; int enteredReadOnlyCount;
@@ -140,6 +152,7 @@ public:
void SetLineIndentation(int line, int indent); void SetLineIndentation(int line, int indent);
int GetLineIndentPosition(int line); int GetLineIndentPosition(int line);
int GetColumn(int position); int GetColumn(int position);
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop); void Indent(bool forwards, int lineBottom, int lineTop);
void ConvertLineEnds(int eolModeSet); void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); } void SetReadOnly(bool set) { cb.SetReadOnly(set); }
@@ -175,7 +188,7 @@ public:
int GetFoldParent(int line); int GetFoldParent(int line);
void Indent(bool forwards); 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 NextWordStart(int pos, int delta);
int Length() { return cb.Length(); } int Length() { return cb.Length(); }
long FindText(int minPos, int maxPos, const char *s, long FindText(int minPos, int maxPos, const char *s,
@@ -193,6 +206,7 @@ public:
void SetStyles(int length, char *styles); void SetStyles(int length, char *styles);
int GetEndStyled() { return endStyled; } int GetEndStyled() { return endStyled; }
bool EnsureStyledTo(int pos); bool EnsureStyledTo(int pos);
int GetStyleClock() { return styleClock; }
int SetLineState(int line, int state) { return cb.SetLineState(line, state); } int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); } int GetLineState(int line) { return cb.GetLineState(line); }
@@ -209,7 +223,7 @@ public:
private: private:
bool IsDBCS(int pos); bool IsDBCS(int pos);
bool IsWordChar(unsigned char ch); charClassification WordCharClass(unsigned char ch);
bool IsWordStartAt(int pos); bool IsWordStartAt(int pos);
bool IsWordEndAt(int pos); bool IsWordEndAt(int pos);
bool IsWordAt(int start, int end); bool IsWordAt(int start, int end);

View File

@@ -23,22 +23,14 @@
DocumentAccessor::~DocumentAccessor() { DocumentAccessor::~DocumentAccessor() {
} }
#if PLAT_WIN
bool DocumentAccessor::InternalIsLeadByte(char ch) { bool DocumentAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage) if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the // For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte. // same so none is considered a lead byte.
return false; return false;
else else
return IsDBCSLeadByteEx(codePage, ch); return 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) { void DocumentAccessor::Fill(int position) {
if (lenDoc == -1) if (lenDoc == -1)
@@ -88,6 +80,7 @@ int DocumentAccessor::SetLineState(int line, int state) {
void DocumentAccessor::StartAt(unsigned int start, char chMask) { void DocumentAccessor::StartAt(unsigned int start, char chMask) {
pdoc->StartStyling(start, chMask); pdoc->StartStyling(start, chMask);
startPosStyling = start;
} }
void DocumentAccessor::StartSegment(unsigned int pos) { void DocumentAccessor::StartSegment(unsigned int pos) {
@@ -111,6 +104,7 @@ void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
chFlags = 0; chFlags = 0;
chAttr |= chFlags; chAttr |= chFlags;
for (unsigned int i = startSeg; i <= pos; i++) { for (unsigned int i = startSeg; i <= pos; i++) {
PLATFORM_ASSERT((startPosStyling + validLen) < Length());
styleBuf[validLen++] = static_cast<char>(chAttr); styleBuf[validLen++] = static_cast<char>(chAttr);
} }
} }
@@ -128,6 +122,7 @@ void DocumentAccessor::Flush() {
if (validLen > 0) { if (validLen > 0) {
pdoc->SetStyles(validLen, styleBuf); pdoc->SetStyles(validLen, styleBuf);
validLen = 0; validLen = 0;
startPosStyling += validLen;
} }
} }

View File

@@ -26,6 +26,7 @@ protected:
char chFlags; char chFlags;
char chWhile; char chWhile;
unsigned int startSeg; unsigned int startSeg;
int startPosStyling;
bool InternalIsLeadByte(char ch); bool InternalIsLeadByte(char ch);
void Fill(int position); void Fill(int position);
@@ -33,7 +34,8 @@ protected:
public: public:
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) : DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), id(id_), 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(); ~DocumentAccessor();
char StyleAt(int position); char StyleAt(int position);

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
/** @file Editor.h /** @file Editor.h
** Defines the main editor class. ** 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. // The License.txt file describes the conditions under which this software may be distributed.
#ifndef EDITOR_H #ifndef EDITOR_H
@@ -15,7 +15,7 @@ public:
bool active; bool active;
bool on; bool on;
int period; int period;
Caret(); Caret();
}; };
@@ -26,28 +26,89 @@ public:
bool ticking; bool ticking;
int ticksToWait; int ticksToWait;
enum {tickSize = 100}; enum {tickSize = 100};
int tickerID; TickerID tickerID;
Timer(); Timer();
}; };
/** /**
*/ */
class LineLayout { class LineLayout {
public: private:
friend class LineLayoutCache;
int *lineStarts;
int lenLineStarts;
/// Drawing is only performed for @a maxLineLength characters on each line. /// 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; int numCharsInLine;
enum validLevel { llInvalid, llPositions, llLines } validity;
int xHighlightGuide; int xHighlightGuide;
bool highlightColumn; bool highlightColumn;
int selStart; int selStart;
int selEnd; int selEnd;
bool containsCaret; bool containsCaret;
int edgeColumn; int edgeColumn;
char chars[maxLineLength+1]; char *chars;
char styles[maxLineLength+1]; char *styles;
char indicators[maxLineLength+1]; char *indicators;
int positions[maxLineLength+1]; 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 { 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 { class Editor : public DocWatcher {
@@ -85,20 +178,21 @@ protected: // ScintillaBase subclass needs access to much of Editor
/** Style resources may be expensive to allocate so are cached between uses. /** Style resources may be expensive to allocate so are cached between uses.
* When a style attribute is changed, this cache is flushed. */ * When a style attribute is changed, this cache is flushed. */
bool stylesValid; bool stylesValid;
ViewStyle vs; ViewStyle vs;
Palette palette; Palette palette;
int printMagnification; int printMagnification;
int printColourMode; int printColourMode;
int cursorMode; int cursorMode;
int controlCharSymbol;
bool hasFocus; bool hasFocus;
bool hideSelection; bool hideSelection;
bool inOverstrike; bool inOverstrike;
int errorStatus; int errorStatus;
bool mouseDownCaptures; bool mouseDownCaptures;
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
* the screen. This avoids flashing but is about 30% slower. */ * the screen. This avoids flashing but is about 30% slower. */
bool bufferedDraw; bool bufferedDraw;
@@ -106,12 +200,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
int xOffset; ///< Horizontal scrolled amount in pixels int xOffset; ///< Horizontal scrolled amount in pixels
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
bool horizontalScrollBarVisible; bool horizontalScrollBarVisible;
Surface pixmapLine; Surface *pixmapLine;
Surface pixmapSelMargin; Surface *pixmapSelMargin;
Surface pixmapSelPattern; Surface *pixmapSelPattern;
Surface pixmapIndentGuide; Surface *pixmapIndentGuide;
Surface pixmapIndentGuideHighlight; Surface *pixmapIndentGuideHighlight;
LineLayoutCache llc;
KeyMap kmap; KeyMap kmap;
@@ -141,32 +237,32 @@ protected: // ScintillaBase subclass needs access to much of Editor
int searchFlags; int searchFlags;
int topLine; int topLine;
int posTopLine; int posTopLine;
bool needUpdateUI; bool needUpdateUI;
Position braces[2]; Position braces[2];
int bracesMatchStyle; int bracesMatchStyle;
int highlightGuideColumn; int highlightGuideColumn;
int theEdge; int theEdge;
enum { notPainting, painting, paintAbandoned } paintState; enum { notPainting, painting, paintAbandoned } paintState;
PRectangle rcPaint; PRectangle rcPaint;
bool paintingAllText; bool paintingAllText;
int modEventMask; int modEventMask;
SelectionText drag; SelectionText drag;
enum { selStream, selRectangle, selRectangleFixed } selType; enum { selStream, selRectangle, selRectangleFixed } selType;
int xStartSelect; int xStartSelect;
int xEndSelect; int xEndSelect;
bool primarySelection; bool primarySelection;
int caretPolicy; int caretPolicy;
int caretSlop; int caretSlop;
int visiblePolicy; int visiblePolicy;
int visibleSlop; int visibleSlop;
int searchAnchor; int searchAnchor;
bool recordingMacro; bool recordingMacro;
@@ -174,6 +270,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
int foldFlags; int foldFlags;
ContractionState cs; ContractionState cs;
// Wrapping support
enum { eWrapNone, eWrapWord } wrapState;
int wrapWidth;
int docLineLastWrapped;
Document *pdoc; Document *pdoc;
Editor(); Editor();
@@ -189,7 +290,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual PRectangle GetClientRectangle(); virtual PRectangle GetClientRectangle();
PRectangle GetTextRectangle(); PRectangle GetTextRectangle();
int LinesOnScreen(); int LinesOnScreen();
int LinesToScroll(); int LinesToScroll();
int MaxScrollPos(); int MaxScrollPos();
@@ -200,13 +301,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
int PositionFromLineX(int line, int x); int PositionFromLineX(int line, int x);
int LineFromLocation(Point pt); int LineFromLocation(Point pt);
void SetTopLine(int topLineNew); void SetTopLine(int topLineNew);
void RedrawRect(PRectangle rc); void RedrawRect(PRectangle rc);
void Redraw(); void Redraw();
void RedrawSelMargin(); void RedrawSelMargin();
PRectangle RectangleFromRange(int start, int end); PRectangle RectangleFromRange(int start, int end);
void InvalidateRange(int start, int end); void InvalidateRange(int start, int end);
int CurrentPosition(); int CurrentPosition();
bool SelectionEmpty(); bool SelectionEmpty();
int SelectionStart(int line=-1); int SelectionStart(int line=-1);
@@ -223,16 +324,22 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void ScrollText(int linesToMove); virtual void ScrollText(int linesToMove);
void HorizontalScrollTo(int xPos); void HorizontalScrollTo(int xPos);
void MoveCaretInsideView(); void MoveCaretInsideView();
int DisplayFromPosition(int pos);
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true); void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
void ShowCaretAtCurrentPosition(); void ShowCaretAtCurrentPosition();
void DropCaret(); void DropCaret();
void InvalidateCaret(); void InvalidateCaret();
void NeedWrapping(int docLineStartWrapping=0);
bool WrapLines();
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault); int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
void PaintSelMargin(Surface *surface, PRectangle &rc); void PaintSelMargin(Surface *surface, PRectangle &rc);
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll); LineLayout *RetrieveLineLayout(int lineNumber);
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
PRectangle rcLine, LineLayout &ll); int width=LineLayout::wrapWidthInfinite);
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine=0);
void Paint(Surface *surfaceWindow, PRectangle rcArea); void Paint(Surface *surfaceWindow, PRectangle rcArea);
long FormatRange(bool draw, RangeToFormat *pfr); long FormatRange(bool draw, RangeToFormat *pfr);
@@ -240,11 +347,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void SetHorizontalScrollPos() = 0; virtual void SetHorizontalScrollPos() = 0;
virtual bool ModifyScrollBars(int nMax, int nPage) = 0; virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
virtual void ReconfigureScrollBars(); virtual void ReconfigureScrollBars();
void SetScrollBarsTo(PRectangle rsClient);
void SetScrollBars(); void SetScrollBars();
void ChangeSize();
void AddChar(char ch); 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 ClearSelection();
void ClearAll(); void ClearAll();
void ClearDocumentStyle(); void ClearDocumentStyle();
@@ -258,11 +365,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
void Undo(); void Undo();
void Redo(); void Redo();
void DelChar(); void DelChar();
void DelCharBack(); void DelCharBack(bool allowLineStartDeletion);
virtual void ClaimSelection() = 0; virtual void ClaimSelection() = 0;
virtual void NotifyChange() = 0; virtual void NotifyChange() = 0;
virtual void NotifyFocus(bool focus); virtual void NotifyFocus(bool focus);
virtual int GetCtrlID() { return ctrlID; }
virtual void NotifyParent(SCNotification scn) = 0; virtual void NotifyParent(SCNotification scn) = 0;
virtual void NotifyStyleToNeeded(int endStyleNeeded); virtual void NotifyStyleToNeeded(int endStyleNeeded);
void NotifyChar(int ch); void NotifyChar(int ch);
@@ -275,9 +383,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
void NotifyNeedShown(int pos, int len); void NotifyNeedShown(int pos, int len);
void NotifyDwelling(Point pt, bool state); void NotifyDwelling(Point pt, bool state);
void NotifyModifyAttempt(Document *document, void *userData); void NotifyModifyAttempt(Document *document, void *userData);
void NotifySavePoint(Document *document, void *userData, bool atSavePoint); void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
void CheckModificationForWrap(DocModification mh);
void NotifyModified(Document *document, DocModification mh, void *userData); void NotifyModified(Document *document, DocModification mh, void *userData);
void NotifyDeleted(Document *document, void *userData); void NotifyDeleted(Document *document, void *userData);
void NotifyStyleNeeded(Document *doc, void *userData, int endPos); void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
@@ -328,21 +437,23 @@ protected: // ScintillaBase subclass needs access to much of Editor
void CheckForChangeOutsidePaint(Range r); void CheckForChangeOutsidePaint(Range r);
int BraceMatch(int position, int maxReStyle); int BraceMatch(int position, int maxReStyle);
void SetBraceHighlight(Position pos0, Position pos1, int matchStyle); void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
void SetDocPointer(Document *document); void SetDocPointer(Document *document);
void Expand(int &line, bool doExpand); void Expand(int &line, bool doExpand);
void ToggleContraction(int line); void ToggleContraction(int line);
void EnsureLineVisible(int lineDoc, bool enforcePolicy); void EnsureLineVisible(int lineDoc, bool enforcePolicy);
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
public: public:
// Public so scintilla_send_message can use it // Public so 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); virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
// Public so scintilla_set_id can use it // Public so scintilla_set_id can use it.
int ctrlID; int ctrlID;
}; };
#endif #endif

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