#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
#define wxSTC_MARK_CIRCLEMINUS 20
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
+
+// Invisible mark that only sets the line background color
+#define wxSTC_MARK_BACKGROUND 22
#define wxSTC_MARK_CHARACTER 10000
// Markers used for outlining column
#define wxSTC_MARKNUM_FOLDERSUB 29
#define wxSTC_MARKNUM_FOLDER 30
#define wxSTC_MARKNUM_FOLDEROPEN 31
+#define wxSTC_MASK_FOLDERS 0xFE000000
#define wxSTC_MARGIN_SYMBOL 0
#define wxSTC_MARGIN_NUMBER 1
#define wxSTC_INDIC_TT 2
#define wxSTC_INDIC_DIAGONAL 3
#define wxSTC_INDIC_STRIKE 4
-#define wxSTC_INDIC0_MASK 32
-#define wxSTC_INDIC1_MASK 64
-#define wxSTC_INDIC2_MASK 128
-#define wxSTC_INDICS_MASK 224
+#define wxSTC_INDIC0_MASK 0x20
+#define wxSTC_INDIC1_MASK 0x40
+#define wxSTC_INDIC2_MASK 0x80
+#define wxSTC_INDICS_MASK 0xE0
// PrintColourMode - use same colours as screen.
#define wxSTC_PRINT_NORMAL 0
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
#define wxSTC_TIME_FOREVER 10000000
+#define wxSTC_WRAP_NONE 0
+#define wxSTC_WRAP_WORD 1
+#define wxSTC_CACHE_NONE 0
+#define wxSTC_CACHE_CARET 1
+#define wxSTC_CACHE_PAGE 2
+#define wxSTC_CACHE_DOCUMENT 3
#define wxSTC_CMD_LINEDOWN 2300
#define wxSTC_CMD_LINEDOWNEXTEND 2301
#define wxSTC_CMD_LINEUP 2302
#define wxSTC_CMD_UPPERCASE 2341
#define wxSTC_CMD_LINESCROLLDOWN 2342
#define wxSTC_CMD_LINESCROLLUP 2343
+#define wxSTC_CMD_DELETEBACKNOTLINE 2344
#define wxSTC_EDGE_NONE 0
#define wxSTC_EDGE_LINE 1
#define wxSTC_EDGE_BACKGROUND 2
#define wxSTC_LEX_EIFFELKW 24
#define wxSTC_LEX_TCL 25
#define wxSTC_LEX_NNCRONTAB 26
+#define wxSTC_LEX_BULLANT 27
+#define wxSTC_LEX_VBSCRIPT 28
+#define wxSTC_LEX_ASP 29
+#define wxSTC_LEX_PHP 30
+#define wxSTC_LEX_BAAN 31
+#define wxSTC_LEX_MATLAB 32
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1.
#define wxSTC_P_COMMENTBLOCK 12
#define wxSTC_P_STRINGEOL 13
-// Lexical states for SCLEX_CPP, SCLEX_VB
+// Lexical states for SCLEX_CPP
#define wxSTC_C_DEFAULT 0
#define wxSTC_C_COMMENT 1
#define wxSTC_C_COMMENTLINE 2
#define wxSTC_C_COMMENTDOCKEYWORD 17
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
+// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
+#define wxSTC_B_DEFAULT 0
+#define wxSTC_B_COMMENT 1
+#define wxSTC_B_NUMBER 2
+#define wxSTC_B_KEYWORD 3
+#define wxSTC_B_STRING 4
+#define wxSTC_B_PREPROCESSOR 5
+#define wxSTC_B_OPERATOR 6
+#define wxSTC_B_IDENTIFIER 7
+#define wxSTC_B_DATE 8
+
// Lexical states for SCLEX_HTML, SCLEX_XML
#define wxSTC_H_DEFAULT 0
#define wxSTC_H_TAG 1
#define wxSTC_LUA_OPERATOR 10
#define wxSTC_LUA_IDENTIFIER 11
#define wxSTC_LUA_STRINGEOL 12
+#define wxSTC_LUA_WORD2 13
+#define wxSTC_LUA_WORD3 14
+#define wxSTC_LUA_WORD4 15
+#define wxSTC_LUA_WORD5 16
+#define wxSTC_LUA_WORD6 17
// Lexical states for SCLEX_ERRORLIST
#define wxSTC_ERR_DEFAULT 0
#define wxSTC_ADA_IDENTIFIER 7
#define wxSTC_ADA_STRINGEOL 8
+// Lexical states for SCLEX_BAAN
+#define wxSTC_BAAN_DEFAULT 0
+#define wxSTC_BAAN_COMMENT 1
+#define wxSTC_BAAN_COMMENTDOC 2
+#define wxSTC_BAAN_NUMBER 3
+#define wxSTC_BAAN_WORD 4
+#define wxSTC_BAAN_STRING 5
+#define wxSTC_BAAN_PREPROCESSOR 6
+#define wxSTC_BAAN_OPERATOR 7
+#define wxSTC_BAAN_IDENTIFIER 8
+#define wxSTC_BAAN_STRINGEOL 9
+#define wxSTC_BAAN_WORD2 10
+
// Lexical states for SCLEX_LISP
#define wxSTC_LISP_DEFAULT 0
#define wxSTC_LISP_COMMENT 1
#define wxSTC_NNCRONTAB_ENVIRONMENT 9
#define wxSTC_NNCRONTAB_IDENTIFIER 10
-// 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))
-
-
-
+// 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
//----------------------------------------------------------------------
class ScintillaWX; // forward declare
void SetCodePage(int codePage);
// Set the symbol used for a particular marker number,
- // and optionally the for and background colours.
+ // and optionally the fore and background colours.
void MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground = wxNullColour,
const wxColour& background = wxNullColour);
// Set the background colour used for a particular marker number.
void MarkerSetBackground(int markerNumber, const wxColour& back);
- // Add a marker to a line.
- void MarkerAdd(int line, int markerNumber);
+ // Add a marker to a line, returning an ID which can be used to find or delete the marker.
+ int MarkerAdd(int line, int markerNumber);
// Delete a marker from a line
void MarkerDelete(int line, int markerNumber);
// Is the background of the line containing the caret in a different colour?
bool GetCaretLineVisible();
- // Display the background of the line containing the caret in a different colour.
+ // Dsplay the background of the line containing the caret in a different colour.
void SetCaretLineVisible(bool show);
// Get the colour of the background of the line containing the caret.
// Set the colour of the background of the line containing the caret.
void SetCaretLineBack(const wxColour& back);
+ // Set a style to be changeable or not (read only).
+ // Experimental feature, currently buggy.
+ void StyleSetChangeable(int style, bool changeable);
+
// Display a auto-completion list.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
// Retrieve whether auto-completion cancelled by backspacing before start.
bool AutoCompGetCancelAtStart();
- // Define a set of character that when typed fills up the selected word.
+ // Define a set of characters that when typed will cause the autocompletion to
+ // choose the selected item.
void AutoCompSetFillUps(const wxString& characterSet);
// Should a single item auto-completion list automatically choose the item.
// Retrieve whether or not autocompletion is hidden automatically when nothing matches
bool AutoCompGetAutoHide();
+ // Set whether or not autocompletion deletes any word characters after the inserted text upon completion
+ void AutoCompSetDropRestOfWord(bool dropRestOfWord);
+
+ // Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
+ bool AutoCompGetDropRestOfWord();
+
// Set the number of spaces used for one level of indentation.
void SetIndent(int indentSize);
// Retrieve the time the mouse must sit still to generate a mouse dwell event
int GetMouseDwellTime();
+ // Get position of start of word
+ int WordStartPosition(int pos, bool onlyWordCharacters);
+
+ // Get position of end of word
+ int WordEndPosition(int pos, bool onlyWordCharacters);
+
+ // Sets whether text is word wrapped
+ void SetWrapMode(int mode);
+
+ // Retrieve whether text is word wrapped
+ int GetWrapMode();
+
+ // Sets the degree of caching of layout information
+ void SetLayoutCache(int mode);
+
+ // Retrieve the degree of caching of layout information
+ int GetLayoutCache();
+
+ // Delete the selection or if no selection, the character before the caret.
+ // Will not delete the chraacter before at the start of a line.
+ void DeleteBackNotLine();
+
// Move the caret inside current view if it's not there already
void MoveCaretInsideView();
// Get cursor type
int GetCursor();
+ // Change the way control characters are displayed:
+ // If symbol is < 32, keep the drawn way, else, use the given character
+ void SetControlCharSymbol(int symbol);
+
+ // Get the way control characters are displayed
+ int GetControlCharSymbol();
+
// Move to the previous change in capitalistion
void WordPartLeft();
// Delete forwards from the current position to the end of the line
void DelLineRight();
+ // Get and Set the xOffset (ie, horizonal scroll position)
+ void SetXOffset(int newOffset);
+ int GetXOffset();
+
// Start notifying the container of all key presses and commands.
void StartRecord();
KeyMap.o \
KeyWords.o \
LexAVE.o \
+ LexBaan.o \
+ LexBullant.o \
+ LexMatlab.o \
LexAda.o \
LexCPP.o \
LexConf.o \
DEPFILES=$(OBJECTS:.o=.d)
-APPEXTRADEFS=-D__WX__ -DSCI_LEXER -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
+APPEXTRADEFS=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
include $(top_builddir)/src/makelib.env
#include <ctype.h>
+#include <wx/wx.h>
+
#include "Platform.h"
+#include "PlatWX.h"
#include "wx/stc/stc.h"
#include <gtk/gtk.h>
#endif
+
Point Point::FromLong(long lpoint) {
return Point(lpoint & 0xFFFF, lpoint >> 16);
}
rc.GetRight()+1, rc.GetBottom()+1);
}
-Colour::Colour(long lcol) {
- co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff);
-}
-
-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();
+wxColour wxColourFromCA(const ColourAllocated& ca) {
+ ColourDesired cd(ca.AsLong());
+ return wxColour(cd.GetRed(), cd.GetGreen(), cd.GetBlue());
}
-unsigned int Colour::GetBlue() {
- return co.Blue();
-}
+//----------------------------------------------------------------------
Palette::Palette() {
used = 0;
if (used < numEntries) {
entries[used].desired = cp.desired;
- entries[used].allocated = cp.desired;
+ entries[used].allocated.Set(cp.desired.AsLong());
used++;
}
} else {
return;
}
}
- cp.allocated = cp.desired;
+ cp.allocated.Set(cp.desired.AsLong());
}
}
}
+//----------------------------------------------------------------------
+
Font::Font() {
id = 0;
ascent = 0;
}
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
- // TODO: what to do about the characterSet?
+ wxFontEncoding encoding;
Release();
+
+ switch (characterSet) {
+ default:
+ case wxSTC_CHARSET_ANSI:
+ case wxSTC_CHARSET_DEFAULT:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_BALTIC:
+ encoding = wxFONTENCODING_ISO8859_13;
+ break;
+
+ case wxSTC_CHARSET_CHINESEBIG5:
+ encoding = wxFONTENCODING_CP950;
+ break;
+
+ case wxSTC_CHARSET_EASTEUROPE:
+ encoding = wxFONTENCODING_ISO8859_2;
+ break;
+
+ case wxSTC_CHARSET_GB2312:
+ encoding = wxFONTENCODING_CP936;
+ break;
+
+ case wxSTC_CHARSET_GREEK:
+ encoding = wxFONTENCODING_ISO8859_7;
+ break;
+
+ case wxSTC_CHARSET_HANGUL:
+ encoding = wxFONTENCODING_CP949;
+ break;
+
+ case wxSTC_CHARSET_MAC:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_OEM:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_RUSSIAN:
+ encoding = wxFONTENCODING_KOI8;
+ break;
+
+ case wxSTC_CHARSET_SHIFTJIS:
+ encoding = wxFONTENCODING_CP932;
+ break;
+
+ case wxSTC_CHARSET_SYMBOL:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_TURKISH:
+ encoding = wxFONTENCODING_ISO8859_9;
+ break;
+
+ case wxSTC_CHARSET_JOHAB:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_HEBREW:
+ encoding = wxFONTENCODING_ISO8859_8;
+ break;
+
+ case wxSTC_CHARSET_ARABIC:
+ encoding = wxFONTENCODING_ISO8859_6;
+ break;
+
+ case wxSTC_CHARSET_VIETNAMESE:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_THAI:
+ encoding = wxFONTENCODING_ISO8859_11;
+ break;
+ }
+
+ // TODO: Use wxFontMapper and wxEncodingConverter if encoding not available.
+
id = new wxFont(size,
wxDEFAULT,
italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL,
false,
faceName,
- wxFONTENCODING_DEFAULT);
+ encoding);
}
void Font::Release() {
if (id)
- delete id;
+ delete (wxFont*)id;
id = 0;
}
+//----------------------------------------------------------------------
+
+class SurfaceImpl : public Surface {
+private:
+ wxDC* hdc;
+ bool hdcOwned;
+ wxBitmap* bitmap;
+ int x;
+ int y;
+ bool unicodeMode;
-Surface::Surface() :
+public:
+ SurfaceImpl();
+ ~SurfaceImpl();
+
+ void Init();
+ void Init(SurfaceID sid);
+ void InitPixMap(int width, int height, Surface *surface_);
+
+ void Release();
+ bool Initialised();
+ void PenColour(ColourAllocated fore);
+ int LogPixelsY();
+ int DeviceHeightFont(int points);
+ void MoveTo(int x_, int y_);
+ void LineTo(int x_, int y_);
+ void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
+ void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void FillRectangle(PRectangle rc, ColourAllocated back);
+ void FillRectangle(PRectangle rc, Surface &surfacePattern);
+ void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void Copy(PRectangle rc, Point from, Surface &surfaceSource);
+
+ void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
+ void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
+ void MeasureWidths(Font &font_, const char *s, int len, int *positions);
+ int WidthText(Font &font_, const char *s, int len);
+ int WidthChar(Font &font_, char ch);
+ int Ascent(Font &font_);
+ int Descent(Font &font_);
+ int InternalLeading(Font &font_);
+ int ExternalLeading(Font &font_);
+ int Height(Font &font_);
+ int AverageCharWidth(Font &font_);
+
+ int SetPalette(Palette *pal, bool inBackGround);
+ void SetClip(PRectangle rc);
+ void FlushCachedState();
+
+ void SetUnicodeMode(bool unicodeMode_);
+
+ void BrushColour(ColourAllocated back);
+ void SetFont(Font &font_);
+};
+
+
+
+SurfaceImpl::SurfaceImpl() :
hdc(0), hdcOwned(0), bitmap(0),
- x(0), y(0) {
-}
+ x(0), y(0), unicodeMode(0)
+{}
-Surface::~Surface() {
+SurfaceImpl::~SurfaceImpl() {
Release();
}
-void Surface::Release() {
+void SurfaceImpl::Release() {
if (bitmap) {
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
delete bitmap;
}
-bool Surface::Initialised() {
+bool SurfaceImpl::Initialised() {
return hdc != 0;
}
-void Surface::Init() {
+void SurfaceImpl::Init() {
Release();
hdc = new wxMemoryDC();
hdcOwned = true;
}
-void Surface::Init(SurfaceID hdc_) {
+void SurfaceImpl::Init(SurfaceID hdc_) {
Release();
- hdc = hdc_;
+ hdc = (wxDC*)hdc_;
}
-void Surface::InitPixMap(int width, int height, Surface *surface_) {
+void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_) {
Release();
- hdc = new wxMemoryDC(surface_->hdc);
+ hdc = new wxMemoryDC();
hdcOwned = true;
if (width < 1) width = 1;
if (height < 1) height = 1;
((wxMemoryDC*)hdc)->SelectObject(*bitmap);
}
-void Surface::PenColour(Colour fore) {
- hdc->SetPen(wxPen(fore.co, 1, wxSOLID));
+void SurfaceImpl::PenColour(ColourAllocated fore) {
+ hdc->SetPen(wxPen(wxColourFromCA(fore), 1, wxSOLID));
}
-void Surface::BrushColor(Colour back) {
- hdc->SetBrush(wxBrush(back.co, wxSOLID));
+void SurfaceImpl::BrushColour(ColourAllocated back) {
+ hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID));
}
-void Surface::SetFont(Font &font_) {
+void SurfaceImpl::SetFont(Font &font_) {
if (font_.GetID()) {
- hdc->SetFont(*font_.GetID());
+ hdc->SetFont(*((wxFont*)font_.GetID()));
}
}
-int Surface::LogPixelsY() {
+int SurfaceImpl::LogPixelsY() {
return hdc->GetPPI().y;
}
-
-int Surface::DeviceHeightFont(int points) {
+int SurfaceImpl::DeviceHeightFont(int points) {
return points;
+// int logPix = LogPixelsY();
+// return (points * logPix + logPix / 2) / 72;
}
-
-void Surface::MoveTo(int x_, int y_) {
+void SurfaceImpl::MoveTo(int x_, int y_) {
x = x_;
y = y_;
}
-void Surface::LineTo(int x_, int y_) {
+void SurfaceImpl::LineTo(int x_, int y_) {
hdc->DrawLine(x,y, x_,y_);
x = x_;
y = y_;
}
-void Surface::Polygon(Point *pts, int npts, Colour fore,
- Colour back) {
+void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawPolygon(npts, (wxPoint*)pts);
}
-void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
+void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawRectangle(wxRectFromPRectangle(rc));
}
-void Surface::FillRectangle(PRectangle rc, Colour back) {
- BrushColor(back);
+void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
+ BrushColour(back);
hdc->SetPen(*wxTRANSPARENT_PEN);
hdc->DrawRectangle(wxRectFromPRectangle(rc));
}
-void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
+void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
wxBrush br;
- if (surfacePattern.bitmap)
- br = wxBrush(*surfacePattern.bitmap);
+ if (((SurfaceImpl&)surfacePattern).bitmap)
+ br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap);
else // Something is wrong so display in red
br = wxBrush(*wxRED, wxSOLID);
hdc->SetPen(*wxTRANSPARENT_PEN);
hdc->DrawRectangle(wxRectFromPRectangle(rc));
}
-void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
+void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4);
}
-void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
+void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawEllipse(wxRectFromPRectangle(rc));
}
-void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
+void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
wxRect r = wxRectFromPRectangle(rc);
hdc->Blit(r.x, r.y, r.width, r.height,
- surfaceSource.hdc, from.x, from.y, wxCOPY);
+ ((SurfaceImpl&)surfaceSource).hdc,
+ from.x, from.y, wxCOPY);
}
-void Surface::DrawText(PRectangle rc, Font &font, int ybase,
- const char *s, int len, Colour fore, Colour back) {
+void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
+ const char *s, int len,
+ ColourAllocated fore, ColourAllocated back) {
SetFont(font);
- hdc->SetTextForeground(fore.co);
- hdc->SetTextBackground(back.co);
+ hdc->SetTextForeground(wxColourFromCA(fore));
+ hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back);
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
// ybase is where the baseline should be, but wxWin uses the upper left
// corner, so I need to calculate the real position for the text...
- hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
+ hdc->DrawText(str, rc.left, ybase - font.ascent);
}
-void Surface::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, Colour fore, Colour back) {
+void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
+ const char *s, int len,
+ ColourAllocated fore, ColourAllocated back) {
SetFont(font);
- hdc->SetTextForeground(fore.co);
- hdc->SetTextBackground(back.co);
+ hdc->SetTextForeground(wxColourFromCA(fore));
+ hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
// see comments above
- hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
+ hdc->DrawText(str, rc.left, ybase - font.ascent);
hdc->DestroyClippingRegion();
}
-int Surface::WidthText(Font &font, const char *s, int len) {
+int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
SetFont(font);
int w;
int h;
- hdc->GetTextExtent(wxString(s, len), &w, &h);
+
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
+ hdc->GetTextExtent(str, &w, &h);
return w;
}
-void Surface::MeasureWidths(Font &font, const char *s, int len, int *positions) {
+void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
SetFont(font);
int totalWidth = 0;
- for (int i=0; i<len; i++) {
+ for (size_t i=0; i<(size_t)len; i++) {
int w;
int h;
- hdc->GetTextExtent(s[i], &w, &h);
+ hdc->GetTextExtent(str[i], &w, &h);
totalWidth += w;
positions[i] = totalWidth;
}
}
-int Surface::WidthChar(Font &font, char ch) {
+int SurfaceImpl::WidthChar(Font &font, char ch) {
SetFont(font);
int w;
int h;
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
hdc->GetTextExtent(ch, &w, &h);
+#endif
return w;
}
-#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+#define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
-int Surface::Ascent(Font &font) {
+int SurfaceImpl::Ascent(Font &font) {
SetFont(font);
int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return font.ascent;
}
-int Surface::Descent(Font &font) {
+int SurfaceImpl::Descent(Font &font) {
SetFont(font);
int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return d;
}
-int Surface::InternalLeading(Font &font) {
+int SurfaceImpl::InternalLeading(Font &font) {
return 0;
}
-int Surface::ExternalLeading(Font &font) {
+int SurfaceImpl::ExternalLeading(Font &font) {
SetFont(font);
int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return e;
}
-int Surface::Height(Font &font) {
+int SurfaceImpl::Height(Font &font) {
SetFont(font);
return hdc->GetCharHeight();
}
-int Surface::AverageCharWidth(Font &font) {
+int SurfaceImpl::AverageCharWidth(Font &font) {
SetFont(font);
return hdc->GetCharWidth();
}
-int Surface::SetPalette(Palette *pal, bool inBackGround) {
+int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
return 0;
}
-void Surface::SetClip(PRectangle rc) {
+void SurfaceImpl::SetClip(PRectangle rc) {
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
}
-void Surface::FlushCachedState() {
+void SurfaceImpl::FlushCachedState() {
}
+void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
+ // TODO: Make this jive with wxUSE_UNICODE
+ unicodeMode=unicodeMode_;
+}
+
+Surface *Surface::Allocate() {
+ return new SurfaceImpl;
+}
+
+
+//----------------------------------------------------------------------
+
+
+inline wxWindow* GETWIN(WindowID id) { return (wxWindow*)id; }
+
Window::~Window() {
}
void Window::Destroy() {
if (id)
- id->Destroy();
+ GETWIN(id)->Destroy();
id = 0;
}
bool Window::HasFocus() {
- return wxWindow::FindFocus() == id;
+ return wxWindow::FindFocus() == GETWIN(id);
}
PRectangle Window::GetPosition() {
- wxRect rc(id->GetPosition(), id->GetSize());
+ wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize());
return PRectangleFromwxRect(rc);
}
void Window::SetPosition(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc);
- id->SetSize(r);
+ GETWIN(id)->SetSize(r);
}
void Window::SetPositionRelative(PRectangle rc, Window) {
}
PRectangle Window::GetClientPosition() {
- wxSize sz = id->GetClientSize();
+ wxSize sz = GETWIN(id)->GetClientSize();
return PRectangle(0, 0, sz.x, sz.y);
}
void Window::Show(bool show) {
- id->Show(show);
+ GETWIN(id)->Show(show);
}
void Window::InvalidateAll() {
- id->Refresh(false);
+ GETWIN(id)->Refresh(false);
}
void Window::InvalidateRectangle(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc);
- id->Refresh(false, &r);
+ GETWIN(id)->Refresh(false, &r);
}
void Window::SetFont(Font &font) {
- id->SetFont(*font.GetID());
+ GETWIN(id)->SetFont(*((wxFont*)font.GetID()));
}
void Window::SetCursor(Cursor curs) {
break;
}
- id->SetCursor(wxCursor(cursorId));
+ GETWIN(id)->SetCursor(wxCursor(cursorId));
}
void Window::SetTitle(const char *s) {
- id->SetTitle(s);
+#if wxUSE_UNICODE
+#error Fix this...
+#else
+ GETWIN(id)->SetTitle(s);
+#endif
}
//----------------------------------------------------------------------
// Helper classes for ListBox
-// A wxListBox that gives focus to its parent if it gets it.
+// A wxListBox that gives focus back to its parent if it gets it.
class wxSTCListBox : public wxListBox {
public:
wxSTCListBox(wxWindow* parent, wxWindowID id)
END_EVENT_TABLE()
-#define GETLB(win) (((wxSTCListBoxWin*)win)->GetLB())
+inline wxListBox* GETLB(WindowID win) {
+ return (((wxSTCListBoxWin*)win)->GetLB());
+}
//----------------------------------------------------------------------
}
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::SetFont(Font &font) {
- GETLB(id)->SetFont(*font.GetID());
+ GETLB(id)->SetFont(*((wxFont*)font.GetID()));
}
void ListBox::Clear() {
}
void ListBox::GetValue(int n, char *value, int len) {
+#if wxUSE_UNICODE
+#error fix this...
wxString text = GETLB(id)->GetString(n);
strncpy(value, text.c_str(), len);
value[len-1] = '\0';
+#endif
}
void ListBox::Sort() {
}
+//----------------------------------------------------------------------
Menu::Menu() : id(0) {
}
void Menu::Destroy() {
if (id)
- delete id;
+ delete (wxMenu*)id;
id = 0;
}
void Menu::Show(Point pt, Window &w) {
- w.GetID()->PopupMenu(id, pt.x - 4, pt.y);
+ GETWIN(w.GetID())->PopupMenu((wxMenu*)id, pt.x - 4, pt.y);
Destroy();
}
+//----------------------------------------------------------------------
-Colour Platform::Chrome() {
+ColourDesired Platform::Chrome() {
wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
- return Colour(c.Red(), c.Green(), c.Blue());
+ return ColourDesired(c.Red(), c.Green(), c.Blue());
}
-Colour Platform::ChromeHighlight() {
+ColourDesired Platform::ChromeHighlight() {
wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
- return Colour(c.Red(), c.Green(), c.Blue());
+ return ColourDesired(c.Red(), c.Green(), c.Blue());
}
const char *Platform::DefaultFont() {
}
+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;
+}
+
+
+//----------------------------------------------------------------------
--- /dev/null
+
+
+
+
+wxRect wxRectFromPRectangle(PRectangle prc);
+PRectangle PRectangleFromwxRect(wxRect rc);
+wxColour wxColourFromCA(const ColourAllocated& ca);
+
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#include <ctype.h>
#include "ScintillaWX.h"
#include "wx/stc/stc.h"
+#include "PlatWX.h"
//----------------------------------------------------------------------
void OnPaint(wxPaintEvent& evt) {
wxPaintDC dc(this);
- Surface surfaceWindow;
- surfaceWindow.Init(&dc);
- m_ct->PaintCT(&surfaceWindow);
- surfaceWindow.Release();
+ Surface* surfaceWindow = Surface::Allocate();
+ surfaceWindow->Init(&dc);
+ m_ct->PaintCT(surfaceWindow);
+ delete surfaceWindow;
}
#if wxUSE_POPUPWIN
if (timer.ticking) {
steTimer = new wxSTCTimer(this);
steTimer->Start(timer.tickSize);
- timer.tickerID = (int)steTimer;
+ timer.tickerID = steTimer;
} else {
steTimer = (wxSTCTimer*)timer.tickerID;
steTimer->Stop();
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
if (!label[0])
- popup.GetID()->AppendSeparator();
+ ((wxMenu*)popup.GetID())->AppendSeparator();
else
- popup.GetID()->Append(cmd, label);
+ ((wxMenu*)popup.GetID())->Append(cmd, label);
if (!enabled)
- popup.GetID()->Enable(cmd, enabled);
+ ((wxMenu*)popup.GetID())->Enable(cmd, enabled);
}
void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
paintState = painting;
- Surface surfaceWindow;
- surfaceWindow.Init(dc);
+ Surface* surfaceWindow = Surface::Allocate();
+ surfaceWindow->Init(dc);
PRectangle rcPaint = PRectangleFromwxRect(rect);
dc->BeginDrawing();
- Paint(&surfaceWindow, rcPaint);
+ Paint(surfaceWindow, rcPaint);
dc->EndDrawing();
- surfaceWindow.Release();
+ delete surfaceWindow;
if (paintState == paintAbandoned) {
// Painting area was insufficient to cover new styling or brace highlight positions
FullPaint();
void ScintillaWX::DoSize(int width, int height) {
- PRectangle rcClient(0,0,width,height);
- SetScrollBarsTo(rcClient);
- DropGraphics();
+// PRectangle rcClient(0,0,width,height);
+// SetScrollBarsTo(rcClient);
+// DropGraphics();
+ ChangeSize();
}
void ScintillaWX::DoLoseFocus(){
rcPaint = GetTextRectangle();
paintingAllText = true;
wxClientDC dc(stc);
- Surface surfaceWindow;
- surfaceWindow.Init(&dc);
- Paint(&surfaceWindow, rcPaint);
- surfaceWindow.Release();
+ Surface* surfaceWindow = Surface::Allocate();
+ surfaceWindow->Init(&dc);
+ Paint(surfaceWindow, rcPaint);
+ delete surfaceWindow;
// stc->Refresh(FALSE);
//----------------------------------------------------------------------
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
#include "Platform.h"
#include "Scintilla.h"
CFG=StcVC - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "StcVC.mak".
-!MESSAGE
+!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug"
-!MESSAGE
+!MESSAGE
!MESSAGE Possible choices for configuration are:
-!MESSAGE
+!MESSAGE
!MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
+!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\lib\stcd.lib"
-!ENDIF
+!ENDIF
# Begin Target
# End Source File
# Begin Source File
+SOURCE=.\scintilla\src\LexBaan.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\scintilla\src\LexBullant.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\scintilla\src\LexMatlab.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\scintilla\src\LexConf.cxx
# End Source File
# Begin Source File
MarkerSetBackground(markerNumber, background);''',
('Set the symbol used for a particular marker number,',
- 'and optionally the for and background colours.')),
+ 'and optionally the fore and background colours.')),
'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
+ 'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
+ 'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
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
KeyWords.obj \
LexAVE.obj \
LexAda.obj \
+ LexBaan.obj \
+ LexBullant.obj \
+ LexMatlab.obj \
LexCPP.obj \
LexConf.obj \
LexCrontab.obj \
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
S=$(SCINTILLA)/src
-EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
+EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
OBJECTS = \
$(S)/AutoComplete.$(OBJSUFF) \
$(S)/KeyWords.$(OBJSUFF) \
$(S)/LexAVE.$(OBJSUFF) \
$(S)/LexAda.$(OBJSUFF) \
+ $(S)/LexBaan.$(OBJSUFF) \
+ $(S)/LexBullant.$(OBJSUFF) \
+ $(S)/LexMatlab.$(OBJSUFF) \
$(S)/LexCPP.$(OBJSUFF) \
$(S)/LexConf.$(OBJSUFF) \
$(S)/LexCrontab.$(OBJSUFF) \
WXDIR = $(WXWIN)
SCINTILLA=.\scintilla
S=$(SCINTILLA)\src
-EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
+EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
NOPCH=1
!include $(WXDIR)\src\makevc.env
$(D)\KeyWords.obj \
$(D)\LexAVE.obj \
$(D)\LexAda.obj \
+ $(D)\LexBaan.obj \
+ $(D)\LexBullant.obj \
+ $(D)\LexMatlab.obj \
$(D)\LexCPP.obj \
$(D)\LexConf.obj \
$(D)\LexCrontab.obj \
distribution. All other code needed to implement Scintilla on top of
wxWindows is located in the directory above this one.
-The current version of the Scintilla code is 1.40
+The current version of the Scintilla code is 1.45
*/
class LexerModule {
protected:
- LexerModule *next;
+ const LexerModule *next;
int language;
- const char *languageName;
LexerFunction fnLexer;
LexerFunction fnFolder;
- static LexerModule *base;
+ static const LexerModule *base;
static int nextLanguage;
public:
+ const char *languageName;
LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_=0, LexerFunction fnFolder_=0);
- int GetLanguage() { return language; }
+ int GetLanguage() const { return language; }
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler);
+ WordList *keywordlists[], Accessor &styler) const;
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler);
- static LexerModule *Find(int language);
- static LexerModule *Find(const char *languageName);
+ WordList *keywordlists[], Accessor &styler) const;
+ static const LexerModule *Find(int language);
+ static const LexerModule *Find(const char *languageName);
};
/**
** Interface to platform facilities. Also includes some basic utilities.
** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef PLATFORM_H
#define PLAT_GTK_WIN32 0
#define PLAT_WIN 0
#define PLAT_WX 0
+#define PLAT_FOX 0
-#if defined(__WX__)
+#if defined(FOX)
+#undef PLAT_FOX
+#define PLAT_FOX 1
+
+#elif defined(__WX__)
#undef PLAT_WX
#define PLAT_WX 1
#endif
-// Include the main header for each platform
-
-#if PLAT_GTK
-#ifdef _MSC_VER
-#pragma warning(disable: 4505 4514 4710 4800)
-#endif
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#endif
-
-#if PLAT_WIN
-#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out
-// Vassili Bourdo: shut up annoying Visual C++ warnings:
-#ifdef _MSC_VER
-#pragma warning(disable: 4244 4309 4710 4800)
-#endif
-#include <windows.h>
-#include <commctrl.h>
-#include <richedit.h>
-#endif
-
-#if PLAT_WX
-#include <wx/wx.h>
-#endif
-
-#define ColourID scColourID
-#define FontID scFontID
-#define SurfaceID scSurfaceID
-#define WindowID scWindowID
-#define MenuID scMenuID
-#define Point scPoint
-#define PRectangle scPRectangle
-#define Colour scColour
-#define ColourPair scColourPair
-#define Window scWindow
-#define Palette scPalette
-#define Font scFont
-#define Surface scSurface
-#define Window scWindow
-#define ListBox scListBox
-#define Menu scMenu
-#define Platform scPlatform
-#define TextRange scTextRange
-#define KeyMap scKeyMap
-#define Style scStyle
-
-
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
-#if PLAT_GTK
-typedef GdkColor ColourID;
-typedef GdkFont* FontID;
-typedef GdkDrawable* SurfaceID;
-typedef GtkWidget* WindowID;
-typedef GtkItemFactory* MenuID;
-#endif
-
-#if PLAT_WIN
-typedef COLORREF ColourID;
-typedef HFONT FontID;
-typedef HDC SurfaceID;
-typedef HWND WindowID;
-typedef HMENU MenuID;
-#endif
-
-#if PLAT_WX
-typedef wxColour ColourID;
-typedef wxFont* FontID;
-typedef wxDC* SurfaceID;
-typedef wxWindow* WindowID;
-typedef wxMenu* MenuID;
-#endif
+typedef void *FontID;
+typedef void *SurfaceID;
+typedef void *WindowID;
+typedef void *MenuID;
+typedef void *TickerID;
/**
* A geometric point class.
int Height() { return bottom - top; }
};
-#if PLAT_WX
-wxRect wxRectFromPRectangle(PRectangle prc);
-PRectangle PRectangleFromwxRect(wxRect rc);
-#endif
+/**
+ * In some circumstances, including Win32 in paletted mode and GTK+, each colour
+ * must be allocated before use. The desired colours are held in the ColourDesired class,
+ * and after allocation the allocation entry is stored in the ColourAllocated class. In other
+ * circumstances, such as Win32 in true colour mode, the allocation process just copies
+ * the RGB values from the desired to the allocated class.
+ * As each desired colour requires allocation before it can be used, the ColourPair class
+ * holds both a ColourDesired and a ColourAllocated
+ * The Palette class is responsible for managing the palette of colours which contains a
+ * list of ColourPair objects and performs the allocation.
+ */
/**
- * A colour class.
+ * Holds a desired RGB colour.
*/
-class Colour {
- ColourID co;
+class ColourDesired {
+ long co;
public:
- Colour(long lcol=0);
- Colour(unsigned int red, unsigned int green, unsigned int blue);
- bool operator==(const Colour &other) const;
- long AsLong() const;
- unsigned int GetRed();
- unsigned int GetGreen();
- unsigned int GetBlue();
+ ColourDesired(long lcol=0) {
+ co = lcol;
+ }
- friend class Surface;
- friend class Palette;
+ ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
+ co = red | (green << 8) | (blue << 16);
+ }
+
+ bool operator==(const ColourDesired &other) const {
+ return co == other.co;
+ }
+
+ void Set(long lcol) {
+ co = lcol;
+ }
+
+ long AsLong() const {
+ return co;
+ }
+
+ unsigned int GetRed() {
+ return co & 0xff;
+ }
+
+ unsigned int GetGreen() {
+ return (co >> 8) & 0xff;
+ }
+
+ unsigned int GetBlue() {
+ return (co >> 16) & 0xff;
+ }
};
/**
- * Colour pairs hold a desired colour and the colour that the graphics engine
- * allocates to approximate the desired colour.
- * To make palette management more automatic, ColourPairs could register at
- * construction time with a palette management object.
+ * Holds an allocated RGB colour which may be an approximation to the desired colour.
+ */
+class ColourAllocated {
+ long coAllocated;
+
+public:
+
+ ColourAllocated(long lcol=0) {
+ coAllocated = lcol;
+ }
+
+ void Set(long lcol) {
+ coAllocated = lcol;
+ }
+
+ long AsLong() const {
+ return coAllocated;
+ }
+};
+
+/**
+ * Colour pairs hold a desired colour and an allocated colour.
*/
struct ColourPair {
- Colour desired;
- Colour allocated;
+ ColourDesired desired;
+ ColourAllocated allocated;
- ColourPair(Colour desired_=Colour(0,0,0)) {
+ ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
desired = desired_;
- allocated = desired;
+ allocated.Set(desired.AsLong());
}
};
enum {numEntries = 100};
ColourPair entries[numEntries];
#if PLAT_GTK
- GdkColor *allocatedPalette;
+ void *allocatedPalette; // GdkColor *
int allocatedLen;
-#elif PLAT_WIN
- HPALETTE hpal;
-#elif PLAT_WX
- // wxPalette* pal; // **** Is this needed?
#endif
public:
+#if PLAT_WIN
+ void *hpal;
+#endif
bool allowRealization;
Palette();
void WantFind(ColourPair &cp, bool want);
void Allocate(Window &w);
-
- friend class Surface;
};
/**
// Alias another font - caller guarantees not to Release
void SetID(FontID id_) { id = id_; }
friend class Surface;
+ friend class SurfaceImpl;
};
/**
*/
class Surface {
private:
- bool unicodeMode;
-#if PLAT_GTK
- GdkDrawable *drawable;
- GdkGC *gc;
- GdkPixmap *ppixmap;
- int x;
- int y;
- bool inited;
- bool createdGC;
-#elif PLAT_WIN
- HDC hdc;
- bool hdcOwned;
- HPEN pen;
- HPEN penOld;
- HBRUSH brush;
- HBRUSH brushOld;
- HFONT font;
- HFONT fontOld;
- HBITMAP bitmap;
- HBITMAP bitmapOld;
- HPALETTE paletteOld;
-#elif PLAT_WX
- wxDC* hdc;
- bool hdcOwned;
- wxBitmap* bitmap;
- int x;
- int y;
-#endif
-
// Private so Surface objects can not be copied
Surface(const Surface &) {}
Surface &operator=(const Surface &) { return *this; }
-#if PLAT_WIN || PLAT_WX
- void BrushColor(Colour back);
- void SetFont(Font &font_);
-#endif
public:
- Surface();
- ~Surface();
-
- void Init();
- void Init(SurfaceID hdc_);
- void InitPixMap(int width, int height, Surface *surface_);
-
- void Release();
- bool Initialised();
- void PenColour(Colour fore);
- int LogPixelsY();
- int DeviceHeightFont(int points);
- void MoveTo(int x_, int y_);
- void LineTo(int x_, int y_);
- void Polygon(Point *pts, int npts, Colour fore, Colour back);
- void RectangleDraw(PRectangle rc, Colour fore, Colour back);
- void FillRectangle(PRectangle rc, Colour back);
- void FillRectangle(PRectangle rc, Surface &surfacePattern);
- void RoundedRectangle(PRectangle rc, Colour fore, Colour back);
- void Ellipse(PRectangle rc, Colour fore, Colour back);
- void Copy(PRectangle rc, Point from, Surface &surfaceSource);
-
- void DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
- void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
- void MeasureWidths(Font &font_, const char *s, int len, int *positions);
- int WidthText(Font &font_, const char *s, int len);
- int WidthChar(Font &font_, char ch);
- int Ascent(Font &font_);
- int Descent(Font &font_);
- int InternalLeading(Font &font_);
- int ExternalLeading(Font &font_);
- int Height(Font &font_);
- int AverageCharWidth(Font &font_);
-
- int SetPalette(Palette *pal, bool inBackGround);
- void SetClip(PRectangle rc);
- void FlushCachedState();
-
- void SetUnicodeMode(bool unicodeMode_) {
- unicodeMode=unicodeMode_;
- }
+ Surface() {};
+ virtual ~Surface() {};
+ static Surface *Allocate();
+
+ virtual void Init()=0;
+ virtual void Init(SurfaceID sid)=0;
+ virtual void InitPixMap(int width, int height, Surface *surface_)=0;
+
+ virtual void Release()=0;
+ virtual bool Initialised()=0;
+ virtual void PenColour(ColourAllocated fore)=0;
+ virtual int LogPixelsY()=0;
+ virtual int DeviceHeightFont(int points)=0;
+ virtual void MoveTo(int x_, int y_)=0;
+ virtual void LineTo(int x_, int y_)=0;
+ virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
+ virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
+ virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
+
+ virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
+ virtual int WidthText(Font &font_, const char *s, int len)=0;
+ virtual int WidthChar(Font &font_, char ch)=0;
+ virtual int Ascent(Font &font_)=0;
+ virtual int Descent(Font &font_)=0;
+ virtual int InternalLeading(Font &font_)=0;
+ virtual int ExternalLeading(Font &font_)=0;
+ virtual int Height(Font &font_)=0;
+ virtual int AverageCharWidth(Font &font_)=0;
+
+ virtual int SetPalette(Palette *pal, bool inBackGround)=0;
+ virtual void SetClip(PRectangle rc)=0;
+ virtual void FlushCachedState()=0;
+
+ virtual void SetUnicodeMode(bool unicodeMode_)=0;
};
+/**
+ * A simple callback action passing one piece of untyped user data.
+ */
+typedef void (*CallBackAction)(void*);
+
/**
* Class to hide the details of window manipulation.
* Does not own the window which will normally have a longer life than this object.
*/
class Window {
- friend class ListBox;
protected:
WindowID id;
public:
- Window() : id(0) {}
- Window(const Window &source) : id(source.id) {}
+ Window() : id(0), cursorLast(cursorInvalid) {}
+ Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
virtual ~Window();
Window &operator=(WindowID id_) {
id = id_;
void InvalidateAll();
void InvalidateRectangle(PRectangle rc);
virtual void SetFont(Font &font);
- enum Cursor { cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
+ enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
void SetCursor(Cursor curs);
void SetTitle(const char *s);
-#if PLAT_WIN
- LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0);
- int GetDlgCtrlID();
- HINSTANCE GetInstance();
-#endif
+private:
+ Cursor cursorLast;
};
/**
* Listbox management.
*/
+
class ListBox : public Window {
+private:
#if PLAT_GTK
WindowID list;
WindowID scroller;
int desiredVisibleRows;
unsigned int maxItemCharacters;
unsigned int aveCharWidth;
+public:
+ CallBackAction doubleClickAction;
+ void *doubleClickActionData;
public:
ListBox();
virtual ~ListBox();
int Find(const char *prefix);
void GetValue(int n, char *value, int len);
void Sort();
+ void SetDoubleClickAction(CallBackAction action, void *data) {
+ doubleClickAction = action;
+ doubleClickActionData = data;
+ }
};
/**
void Show(Point pt, Window &w);
};
+class ElapsedTime {
+ long bigBit;
+ long littleBit;
+public:
+ ElapsedTime();
+ double Duration(bool reset=false);
+};
+
/**
* Platform class used to retrieve system wide parameters such as double click speed
* and chrome colour. Not a creatable object, more of a module with several functions.
// but gcc warns about this
Platform() {}
~Platform() {}
- static Colour Chrome();
- static Colour ChromeHighlight();
+ static ColourDesired Chrome();
+ static ColourDesired ChromeHighlight();
static const char *DefaultFont();
static int DefaultFontSize();
static unsigned int DoubleClickTime();
static bool IsKeyDown(int key);
static long SendScintilla(
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
+ static bool IsDBCSLeadByte(int codePage, char ch);
// These are utility functions not really tied to a platform
static int Minimum(int a, int b);
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif
+// Shut up annoying Visual C++ warnings:
+#ifdef _MSC_VER
+#pragma warning(disable: 4244 4309 4514 4710)
+#endif
+
#endif
/** @file PropSet.h
** A Java style properties file module.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef PROPSET_H
SString Expand(const char *withVars);
int GetInt(const char *key, int defaultValue=0);
SString GetWild(const char *keybase, const char *filename);
- SString GetNewExpand(const char *keybase, const char *filename);
+ SString GetNewExpand(const char *keybase, const char *filename="");
void Clear();
char *ToString(); // Caller must delete[] the return value
bool GetFirst(char **key, char **val);
char *Allocate(int size);
void SetFromAllocated();
bool InList(const char *s);
- const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
+ const char *GetNearestWord(const char *wordStart, int searchLen = -1,
+ bool ignoreCase = false, SString wordCharacters="");
char *GetNearestWords(const char *wordStart, int searchLen=-1,
bool ignoreCase=false, char otherSeparator='\0');
};
#ifndef SSTRING_H
#define SSTRING_H
-// These functions are implemented because each platform calls them something different
+// These functions are implemented because each platform calls them something different.
int CompareCaseInsensitive(const char *a, const char *b);
int CompareNCaseInsensitive(const char *a, const char *b, int len);
bool EqualCaseInsensitive(const char *a, const char *b);
// While it would be 'better' to use std::string, that doubles the executable size.
// An SString may contain embedded nul characters.
-/**
- * Duplicate a C string.
- * Allocate memory of the given size, or big enough to fit the string if length isn't given;
- * then copy the given string in the allocated memory.
- * @return the pointer to the new string
- */
-inline char *StringDup(
- const char *s, ///< The string to duplicate
- int len=-1) ///< The length of memory to allocate. Optional.
-{
- if (!s)
- return 0;
- if (len == -1)
- len = strlen(s);
- char *sNew = new char[len + 1];
- if (sNew) {
- strncpy(sNew, s, len);
- sNew[len] = '\0';
- }
- return sNew;
-}
-
/**
* @brief A simple string class.
+ *
* Hold the length of the string for quick operations,
* can have a buffer bigger than the string to avoid too many memory allocations and copies.
* May have embedded zeroes as a result of @a substitute, but rely too heavily on C string
* functions to allow reliable manipulations of these strings.
**/
class SString {
- char *s; ///< The C string
- int sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
- int sLen; ///< The size of the string in s
- int sizeGrowth; ///< Minimum growth size when appending strings
+public:
+ /** 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};
+
+private:
+ char *s; ///< The C string
+ lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
+ lenpos_t sLen; ///< The size of the string in s
+ lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
enum { sizeGrowthDefault = 64 };
+ bool grow(lenpos_t lenNew) {
+ while (sizeGrowth * 6 < lenNew) {
+ sizeGrowth *= 2;
+ }
+ 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;
+ }
-public:
- typedef int size_type;
+ SString &assign(const char *sOther, lenpos_t sSize_=measure_length) {
+ if (!sOther) {
+ sSize_ = 0;
+ } else if (sSize_ == measure_length) {
+ sSize_ = strlen(sOther);
+ }
+ if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
+ if (s && sSize_) {
+ strncpy(s, sOther, sSize_);
+ }
+ s[sSize_] = '\0';
+ sLen = sSize_;
+ } else {
+ delete []s;
+ s = StringAllocate(sOther, sSize_);
+ if (s) {
+ sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
+ sLen = strlen(s);
+ } else {
+ sSize = sLen = 0;
+ }
+ }
+ return *this;
+ }
+public:
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
}
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) {
- s = StringDup(source.s);
+ s = StringAllocate(source.s);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) {
- s = StringDup(s_);
+ s = StringAllocate(s_);
sSize = sLen = (s) ? strlen(s) : 0;
}
- SString(const char *s_, int first, int last) : sizeGrowth(sizeGrowthDefault) {
- s = StringDup(s_ + first, last - first);
+ 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 = StringDup(number);
+ 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() {
sSize = 0;
sLen = 0;
}
- void clear(void) {
+ void clear() {
if (s) {
*s = '\0';
}
sLen = 0;
}
/** Size of buffer. */
- size_type size(void) const { ///<
+ lenpos_t size() const {
if (s)
return sSize;
else
return 0;
}
/** Size of string in buffer. */
- int length() const {
+ lenpos_t length() const {
return sLen;
}
- SString &assign(const char* sOther, int sSize_ = -1) {
- if (!sOther) {
- sSize_ = 0;
- }
- if (sSize_ < 0) {
- sSize_ = strlen(sOther);
- }
- if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
- if (s && sSize_) {
- strncpy(s, sOther, sSize_);
- }
- s[sSize_] = '\0';
- sLen = sSize_;
- } else {
- delete []s;
- s = StringDup(sOther, sSize_);
- if (s) {
- sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
- sLen = strlen(s);
- } else {
- sSize = sLen = 0;
- }
- }
- return *this;
- }
- SString &assign(const SString& sOther, int sSize_ = -1) {
- return assign(sOther.s, sSize_);
- }
SString &operator=(const char *source) {
return assign(source);
}
else
return false;
}
- void setsizegrowth(int sizeGrowth_) {
+ void setsizegrowth(lenpos_t sizeGrowth_) {
sizeGrowth = sizeGrowth_;
}
const char *c_str() const {
sLen = 0;
return sRet;
}
- char operator[](int i) const {
+ char operator[](lenpos_t i) const {
if (s && i < sSize) // Or < sLen? Depends on the use, both are OK
return s[i];
else
return '\0';
}
- SString &append(const char* sOther, int sLenOther=-1, char sep=0) {
- if (sLenOther < 0)
+ SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') {
+ if (!sOther) {
+ return *this;
+ }
+ if (sLenOther == measure_length) {
sLenOther = strlen(sOther);
+ }
int lenSep = 0;
- if (sLen && sep) // Only add a separator if not empty
+ if (sLen && sep) { // Only add a separator if not empty
lenSep = 1;
- int lenNew = sLen + sLenOther + lenSep;
- if (lenNew + 1 < sSize) {
- // Conservative about growing the buffer: don't do it, unless really needed
+ }
+ lenpos_t lenNew = sLen + sLenOther + lenSep;
+ // Conservative about growing the buffer: don't do it, unless really needed
+ if ((lenNew + 1 < sSize) || (grow(lenNew))) {
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
- s[sLen + sLenOther] = '\0';
sLen += sLenOther;
- } else {
- // Grow the buffer bigger than really needed, to have room for other appends
- char *sNew = new char[lenNew + sizeGrowth + 1];
- if (sNew) {
- if (s) {
- memcpy(sNew, s, sLen);
- delete []s;
- }
- s = sNew;
- sSize = lenNew + sizeGrowth;
- if (lenSep) {
- s[sLen] = sep;
- sLen++;
- }
- strncpy(&s[sLen], sOther, sLenOther);
- sNew[sLen + sLenOther] = '\0';
- sLen += sLenOther;
- }
+ s[sLen] = '\0';
}
return *this;
}
- SString &operator +=(const char *sOther) {
- return append(sOther, -1);
+ SString &operator+=(const char *sOther) {
+ return append(sOther, static_cast<lenpos_t>(measure_length));
}
- SString &operator +=(const SString &sOther) {
+ SString &operator+=(const SString &sOther) {
return append(sOther.s, sOther.sSize);
}
- SString &operator +=(char ch) {
+ SString &operator+=(char ch) {
return append(&ch, 1);
}
- SString &appendwithseparator(const char* sOther, char sep) {
+ SString &appendwithseparator(const char *sOther, char sep) {
return append(sOther, strlen(sOther), sep);
}
+ SString &insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther=measure_length) {
+ if (!sOther) {
+ return *this;
+ }
+ if (sLenOther == measure_length) {
+ sLenOther = strlen(sOther);
+ }
+ lenpos_t lenNew = sLen + sLenOther;
+ // Conservative about growing the buffer: don't do it, unless really needed
+ if ((lenNew + 1 < sSize) || grow(lenNew)) {
+ lenpos_t moveChars = sLen - pos + 1;
+ for (lenpos_t i = moveChars; i > 0; i--) {
+ s[pos + sLenOther + i - 1] = s[pos + i - 1];
+ }
+ memcpy(s + pos, sOther, sLenOther);
+ sLen = lenNew;
+ }
+ return *this;
+ }
+ /** Remove @a len characters from the @a pos position, included.
+ * Characters at pos + len and beyond replace characters at pos.
+ * If @a len is 0, or greater than the length of the string
+ * starting at @a pos, the string is just truncated at @a pos.
+ */
+ void remove(lenpos_t pos, lenpos_t len) {
+ if (len < 1 || pos + len >= sLen) {
+ s[pos] = '\0';
+ sLen = pos;
+ } else {
+ for (lenpos_t i = pos; i < sLen - len + 1; i++) {
+ s[i] = s[i+len];
+ }
+ sLen -= len;
+ }
+ }
+ /** Read an integral numeric value from the string. */
int value() const {
if (s)
return atoi(s);
else
return 0;
}
- void substitute(char find, char replace) {
+ int search(const char *sFind, lenpos_t start=0) {
+ if (start < sLen) {
+ const char *sFound = strstr(s + start, sFind);
+ if (sFound) {
+ return sFound - s;
+ }
+ }
+ return -1;
+ }
+ bool contains(const char *sFind) {
+ return search(sFind) >= 0;
+ }
+ int substitute(char chFind, char chReplace) {
+ int c = 0;
char *t = s;
while (t) {
- t = strchr(t, find);
+ t = strchr(t, chFind);
if (t) {
- *t = replace;
+ *t = chReplace;
t++;
+ c++;
}
}
+ return c;
+ }
+ int substitute(const char *sFind, const char *sReplace) {
+ int c = 0;
+ lenpos_t lenFind = strlen(sFind);
+ lenpos_t lenReplace = strlen(sReplace);
+ int posFound = search(sFind);
+ while (posFound >= 0) {
+ remove(posFound, lenFind);
+ insert(posFound, sReplace, lenReplace);
+ posFound = search(sFind, posFound + lenReplace);
+ c++;
+ }
+ return c;
+ }
+ int remove(const char *sFind) {
+ return substitute(sFind, "");
+ }
+ /**
+ * Duplicate a C string.
+ * Allocate memory of the given size, or big enough to fit the string if length isn't given;
+ * then copy the given string in the allocated memory.
+ * @return the pointer to the new string
+ */
+ static char *StringAllocate(
+ const char *s, ///< The string to duplicate
+ lenpos_t len=measure_length) ///< The length of memory to allocate. Optional.
+ {
+ if (s == 0) {
+ return 0;
+ }
+ if (len == measure_length) {
+ len = strlen(s);
+ }
+ char *sNew = new char[len + 1];
+ if (sNew) {
+ strncpy(sNew, s, len);
+ sNew[len] = '\0';
+ }
+ return sNew;
}
};
+/**
+ * Duplicate a C string.
+ * Allocate memory of the given size, or big enough to fit the string if length isn't given;
+ * then copy the given string in the allocated memory.
+ * @return the pointer to the new string
+ */
+inline char *StringDup(
+ const char *s, ///< The string to duplicate
+ SString::lenpos_t len=SString::measure_length) ///< The length of memory to allocate. Optional.
+{
+ return SString::StringAllocate(s, len);
+}
+
#endif
/** @file SciLexer.h
** Interface to the added lexer functions in the SciLexer version of the edit control.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition
#define SCLEX_EIFFELKW 24
#define SCLEX_TCL 25
#define SCLEX_NNCRONTAB 26
+#define SCLEX_BULLANT 27
+#define SCLEX_VBSCRIPT 28
+#define SCLEX_ASP 29
+#define SCLEX_PHP 30
+#define SCLEX_BAAN 31
+#define SCLEX_MATLAB 32
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
#define SCE_C_WORD2 16
#define SCE_C_COMMENTDOCKEYWORD 17
#define SCE_C_COMMENTDOCKEYWORDERROR 18
+#define SCE_B_DEFAULT 0
+#define SCE_B_COMMENT 1
+#define SCE_B_NUMBER 2
+#define SCE_B_KEYWORD 3
+#define SCE_B_STRING 4
+#define SCE_B_PREPROCESSOR 5
+#define SCE_B_OPERATOR 6
+#define SCE_B_IDENTIFIER 7
+#define SCE_B_DATE 8
#define SCE_H_DEFAULT 0
#define SCE_H_TAG 1
#define SCE_H_TAGUNKNOWN 2
#define SCE_LUA_OPERATOR 10
#define SCE_LUA_IDENTIFIER 11
#define SCE_LUA_STRINGEOL 12
+#define SCE_LUA_WORD2 13
+#define SCE_LUA_WORD3 14
+#define SCE_LUA_WORD4 15
+#define SCE_LUA_WORD5 16
+#define SCE_LUA_WORD6 17
#define SCE_ERR_DEFAULT 0
#define SCE_ERR_PYTHON 1
#define SCE_ERR_GCC 2
#define SCE_ADA_OPERATOR 6
#define SCE_ADA_IDENTIFIER 7
#define SCE_ADA_STRINGEOL 8
+#define SCE_BAAN_DEFAULT 0
+#define SCE_BAAN_COMMENT 1
+#define SCE_BAAN_COMMENTDOC 2
+#define SCE_BAAN_NUMBER 3
+#define SCE_BAAN_WORD 4
+#define SCE_BAAN_STRING 5
+#define SCE_BAAN_PREPROCESSOR 6
+#define SCE_BAAN_OPERATOR 7
+#define SCE_BAAN_IDENTIFIER 8
+#define SCE_BAAN_STRINGEOL 9
+#define SCE_BAAN_WORD2 10
#define SCE_LISP_DEFAULT 0
#define SCE_LISP_COMMENT 1
#define SCE_LISP_NUMBER 2
#define SCE_NNCRONTAB_STRING 8
#define SCE_NNCRONTAB_ENVIRONMENT 9
#define SCE_NNCRONTAB_IDENTIFIER 10
+#define SCE_MATLAB_DEFAULT 0
+#define SCE_MATLAB_COMMENT 1
+#define SCE_MATLAB_COMMAND 2
+#define SCE_MATLAB_NUMBER 3
+#define SCE_MATLAB_KEYWORD 4
+#define SCE_MATLAB_STRING 5
+#define SCE_MATLAB_OPERATOR 6
+#define SCE_MATLAB_IDENTIFIER 7
//--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif
/** @file Scintilla.h
** Interface to the edit control.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition
#define SCINTILLA_H
#if PLAT_WIN
-#ifdef STATIC_BUILD
-void Scintilla_RegisterClasses(HINSTANCE hInstance);
-#endif
+// Return false on failure:
+bool Scintilla_RegisterClasses(void *hInstance);
+bool Scintilla_ReleaseResources();
#endif
+int Scintilla_LinkLexers();
// Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
// hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
#define SC_MARK_CIRCLEPLUSCONNECTED 19
#define SC_MARK_CIRCLEMINUS 20
#define SC_MARK_CIRCLEMINUSCONNECTED 21
+#define SC_MARK_BACKGROUND 22
#define SC_MARK_CHARACTER 10000
#define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26
#define SC_MARKNUM_FOLDERSUB 29
#define SC_MARKNUM_FOLDER 30
#define SC_MARKNUM_FOLDEROPEN 31
+#define SC_MASK_FOLDERS 0xFE000000
#define SCI_MARKERDEFINE 2040
#define SCI_MARKERSETFORE 2041
#define SCI_MARKERSETBACK 2042
#define INDIC_TT 2
#define INDIC_DIAGONAL 3
#define INDIC_STRIKE 4
-#define INDIC0_MASK 32
-#define INDIC1_MASK 64
-#define INDIC2_MASK 128
-#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
+#define INDIC0_MASK 0x20
+#define INDIC1_MASK 0x40
+#define INDIC2_MASK 0x80
+#define INDICS_MASK 0xE0
#define SCI_INDICSETSTYLE 2080
#define SCI_INDICGETSTYLE 2081
#define SCI_INDICSETFORE 2082
#define SCI_SETCARETLINEVISIBLE 2096
#define SCI_GETCARETLINEBACK 2097
#define SCI_SETCARETLINEBACK 2098
+#define SCI_STYLESETCHANGEABLE 2099
#define SCI_AUTOCSHOW 2100
#define SCI_AUTOCCANCEL 2101
#define SCI_AUTOCACTIVE 2102
#define SCI_USERLISTSHOW 2117
#define SCI_AUTOCSETAUTOHIDE 2118
#define SCI_AUTOCGETAUTOHIDE 2119
+#define SCI_AUTOCSETDROPRESTOFWORD 2270
+#define SCI_AUTOCGETDROPRESTOFWORD 2271
#define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124
#define SC_TIME_FOREVER 10000000
#define SCI_SETMOUSEDWELLTIME 2264
#define SCI_GETMOUSEDWELLTIME 2265
+#define SCI_WORDSTARTPOSITION 2266
+#define SCI_WORDENDPOSITION 2267
+#define SC_WRAP_NONE 0
+#define SC_WRAP_WORD 1
+#define SCI_SETWRAPMODE 2268
+#define SCI_GETWRAPMODE 2269
+#define SC_CACHE_NONE 0
+#define SC_CACHE_CARET 1
+#define SC_CACHE_PAGE 2
+#define SC_CACHE_DOCUMENT 3
+#define SCI_SETLAYOUTCACHE 2272
+#define SCI_GETLAYOUTCACHE 2273
#define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302
#define SCI_UPPERCASE 2341
#define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343
+#define SCI_DELETEBACKNOTLINE 2344
#define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351
#define SC_CURSORWAIT 3
#define SCI_SETCURSOR 2386
#define SCI_GETCURSOR 2387
+#define SCI_SETCONTROLCHARSYMBOL 2388
+#define SCI_GETCONTROLCHARSYMBOL 2389
#define SCI_WORDPARTLEFT 2390
#define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392
#define SCI_SETVISIBLEPOLICY 2394
#define SCI_DELLINELEFT 2395
#define SCI_DELLINERIGHT 2396
+#define SCI_SETXOFFSET 2397
+#define SCI_GETXOFFSET 2398
#define SCI_GRABFOCUS 2400
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCN_KEY 2005
#define SCN_DOUBLECLICK 2006
#define SCN_UPDATEUI 2007
-#define SCN_CHECKBRACE 2007
#define SCN_MODIFIED 2008
#define SCN_MACRORECORD 2009
#define SCN_MARGINCLICK 2010
#define SCN_NEEDSHOWN 2011
-#define SCN_POSCHANGED 2012
#define SCN_PAINTED 2013
#define SCN_USERLISTSELECTION 2014
#define SCN_URIDROPPED 2015
#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.
struct RangeToFormat {
// hwndFrom is really an environment specifc window handle or pointer
// but most clients of Scintilla.h do not have this type visible.
//WindowID hwndFrom;
- void *hwndFrom;
+ void *hwndFrom;
unsigned int idFrom;
unsigned int code;
};
int y; // SCN_DWELLSTART, SCN_DWELLEND
};
-#define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | \
- (1<<SC_MARKNUM_FOLDEROPEN) | \
- (1<<SC_MARKNUM_FOLDERSUB) | \
- (1<<SC_MARKNUM_FOLDERTAIL) | \
- (1<<SC_MARKNUM_FOLDERMIDTAIL) | \
- (1<<SC_MARKNUM_FOLDEROPENMID) | \
- (1<<SC_MARKNUM_FOLDEREND))
-
// Deprecation section listing all API features that are deprecated and will
// will be removed completely in a future version.
// To enable these features define INCLUDE_DEPRECATED_FEATURES
#ifdef INCLUDE_DEPRECATED_FEATURES
+#define SCN_POSCHANGED 2012
+#define SCN_CHECKBRACE 2007
+
#endif
#endif
## This file defines the interface to Scintilla
+## Copyright 2000-2002 by Neil Hodgson <neilh@scintilla.org>
+## The License.txt file describes the conditions under which this software may be distributed.
+
## A line starting with ## is a pure comment and should be stripped by readers.
## A line starting with #! is for future shbang use
## A line starting with # followed by a space is a documentation comment and refers
## The syntax for evt is <featureType><ws><returnType><ws><name>[=<number]([<param>[,<param>]*])
## Feature names that contain an underscore are defined by Windows, so in these
## cases, using the Windows definition is preferred where available.
+## The feature numbers are stable so features will not be renumbered.
+## Features may be removed but they will go through a period of deprecation
+## before removal which is signalled by moving them into the Deprecated category.
## Types:
## void
## string -> pointer to const character
## stringresult -> pointer to character
## cells -> pointer to array of cells, each cell containing a style byte and character byte
-## charrange -> range of a min and a max position
-## charrangeresult -> like charrange, but output param
-## textrange -> charrange + output string
+## textrange -> range of a min and a max position with an output string
## findtext -> searchrange, text -> foundposition
-## findtextex -> searchrange
## keymod -> integer containing key in low half and modifiers in high half
-## countedstring
## formatrange
+## Types no longer used:
+## findtextex -> searchrange
+## charrange -> range of a min and a max position
+## charrangeresult -> like charrange, but output param
+## countedstring
## point -> x,y
## pointresult -> like point, but output param
## rectangle -> left,top,right,bottom
## Client code should ignore definitions containing types it does not understand, except
## for possibly #defining the constants
+## String arguments may contain NUL ('\0') characters where the calls provide a length
+## argument and retrieve NUL characters. All retrieved strings except for those retrieved
+## by GetLine also have a NUL appended but client code should calculate the size that
+## will be returned rather than relying upon the NUL whenever possible. Allow for the
+## extra NUL character when allocating buffers.
+
cat Basics
################################################
val SC_MARK_CIRCLEMINUS=20
val SC_MARK_CIRCLEMINUSCONNECTED=21
+# Invisible mark that only sets the line background color
+val SC_MARK_BACKGROUND=22
+
val SC_MARK_CHARACTER=10000
# Markers used for outlining column
val SC_MARKNUM_FOLDER=30
val SC_MARKNUM_FOLDEROPEN=31
+val SC_MASK_FOLDERS=0xFE000000
+
# Set the symbol used for a particular marker number.
fun void MarkerDefine=2040(int markerNumber, int markerSymbol)
# Set the background colour used for a particular marker number.
fun void MarkerSetBack=2042(int markerNumber, colour back)
-# Add a marker to a line.
-fun void MarkerAdd=2043(int line, int markerNumber)
+# Add a marker to a line, returning an ID which can be used to find or delete the marker.
+fun int MarkerAdd=2043(int line, int markerNumber)
# Delete a marker from a line
fun void MarkerDelete=2044(int line, int markerNumber)
val INDIC_TT=2
val INDIC_DIAGONAL=3
val INDIC_STRIKE=4
-val INDIC0_MASK=32
-val INDIC1_MASK=64
-val INDIC2_MASK=128
-val INDICS_MASK=224
-##INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
+val INDIC0_MASK=0x20
+val INDIC1_MASK=0x40
+val INDIC2_MASK=0x80
+val INDICS_MASK=0xE0
# Set an indicator to plain, squiggle or TT.
set void IndicSetStyle=2080(int indic, int style)
# Is the background of the line containing the caret in a different colour?
get bool GetCaretLineVisible=2095(,)
-# Display the background of the line containing the caret in a different colour.
+# Dsplay the background of the line containing the caret in a different colour.
set void SetCaretLineVisible=2096(bool show,)
# Get the colour of the background of the line containing the caret.
# Set the colour of the background of the line containing the caret.
set void SetCaretLineBack=2098(colour back,)
+# Set a style to be changeable or not (read only).
+# Experimental feature, currently buggy.
+set void StyleSetChangeable=2099(int style, bool changeable)
+
# Display a auto-completion list.
# The lenEntered parameter indicates how many characters before
# the caret should be used to provide context.
# Retrieve whether auto-completion cancelled by backspacing before start.
get bool AutoCGetCancelAtStart=2111(,)
-# Define a set of character that when typed fills up the selected word.
+# Define a set of characters that when typed will cause the autocompletion to
+# choose the selected item.
set void AutoCSetFillUps=2112(, string characterSet)
# Should a single item auto-completion list automatically choose the item.
# Retrieve whether or not autocompletion is hidden automatically when nothing matches
get bool AutoCGetAutoHide=2119(,)
+# Set whether or not autocompletion deletes any word characters after the inserted text upon completion
+set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,)
+
+# Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
+get bool AutoCGetDropRestOfWord=2271(,)
+
# Set the number of spaces used for one level of indentation.
set void SetIndent=2122(int indentSize,)
# Retrieve the time the mouse must sit still to generate a mouse dwell event
get int GetMouseDwellTime=2265(,)
+# Get position of start of word
+fun int WordStartPosition=2266(position pos, bool onlyWordCharacters)
+
+# Get position of end of word
+fun int WordEndPosition=2267(position pos, bool onlyWordCharacters)
+
+val SC_WRAP_NONE=0
+val SC_WRAP_WORD=1
+
+# Sets whether text is word wrapped
+set void SetWrapMode=2268(int mode,)
+
+# Retrieve whether text is word wrapped
+get int GetWrapMode=2269(,)
+
+val SC_CACHE_NONE=0
+val SC_CACHE_CARET=1
+val SC_CACHE_PAGE=2
+val SC_CACHE_DOCUMENT=3
+
+# Sets the degree of caching of layout information
+set void SetLayoutCache=2272(int mode,)
+
+# Retrieve the degree of caching of layout information
+get int GetLayoutCache=2273(,)
+
## Start of key messages
# Move caret down one line.
fun void LineDown=2300(,)
# Scroll the document up, keeping the caret visible.
fun void LineScrollUp=2343(,)
+# Delete the selection or if no selection, the character before the caret.
+# Will not delete the chraacter before at the start of a line.
+fun void DeleteBackNotLine=2344(,)
+
# Move the caret inside current view if it's not there already
fun void MoveCaretInsideView=2401(,)
# Get cursor type
get int GetCursor=2387(,)
+# Change the way control characters are displayed:
+# If symbol is < 32, keep the drawn way, else, use the given character
+set void SetControlCharSymbol=2388(int symbol,)
+# Get the way control characters are displayed
+get int GetControlCharSymbol=2389(,)
+
# Move to the previous change in capitalistion
fun void WordPartLeft=2390(,)
# Move to the previous change in capitalistion extending selection to new caret position.
# Delete forwards from the current position to the end of the line
fun void DelLineRight=2396(,)
+# Get and Set the xOffset (ie, horizonal scroll position)
+set void SetXOffset=2397(int newOffset,)
+get int GetXOffset=2398(,)
+
# Set the focus to this Scintilla widget.
# GTK+ Specific
fun void GrabFocus=2400(,)
val SCLEX_EIFFELKW=24
val SCLEX_TCL=25
val SCLEX_NNCRONTAB=26
+val SCLEX_BULLANT=27
+val SCLEX_VBSCRIPT=28
+val SCLEX_ASP=29
+val SCLEX_PHP=30
+val SCLEX_BAAN=31
+val SCLEX_MATLAB=32
+
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
val SCLEX_AUTOMATIC=1000
val SCE_P_IDENTIFIER=11
val SCE_P_COMMENTBLOCK=12
val SCE_P_STRINGEOL=13
-# Lexical states for SCLEX_CPP, SCLEX_VB
+# Lexical states for SCLEX_CPP
val SCE_C_DEFAULT=0
val SCE_C_COMMENT=1
val SCE_C_COMMENTLINE=2
val SCE_C_WORD2=16
val SCE_C_COMMENTDOCKEYWORD=17
val SCE_C_COMMENTDOCKEYWORDERROR=18
+# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
+val SCE_B_DEFAULT=0
+val SCE_B_COMMENT=1
+val SCE_B_NUMBER=2
+val SCE_B_KEYWORD=3
+val SCE_B_STRING=4
+val SCE_B_PREPROCESSOR=5
+val SCE_B_OPERATOR=6
+val SCE_B_IDENTIFIER=7
+val SCE_B_DATE=8
# Lexical states for SCLEX_HTML, SCLEX_XML
val SCE_H_DEFAULT=0
val SCE_H_TAG=1
val SCE_LUA_OPERATOR=10
val SCE_LUA_IDENTIFIER=11
val SCE_LUA_STRINGEOL=12
+val SCE_LUA_WORD2=13
+val SCE_LUA_WORD3=14
+val SCE_LUA_WORD4=15
+val SCE_LUA_WORD5=16
+val SCE_LUA_WORD6=17
# Lexical states for SCLEX_ERRORLIST
val SCE_ERR_DEFAULT=0
val SCE_ERR_PYTHON=1
val SCE_ADA_OPERATOR=6
val SCE_ADA_IDENTIFIER=7
val SCE_ADA_STRINGEOL=8
+# Lexical states for SCLEX_BAAN
+val SCE_BAAN_DEFAULT=0
+val SCE_BAAN_COMMENT=1
+val SCE_BAAN_COMMENTDOC=2
+val SCE_BAAN_NUMBER=3
+val SCE_BAAN_WORD=4
+val SCE_BAAN_STRING=5
+val SCE_BAAN_PREPROCESSOR=6
+val SCE_BAAN_OPERATOR=7
+val SCE_BAAN_IDENTIFIER=8
+val SCE_BAAN_STRINGEOL=9
+val SCE_BAAN_WORD2=10
# Lexical states for SCLEX_LISP
val SCE_LISP_DEFAULT=0
val SCE_LISP_COMMENT=1
val SCE_NNCRONTAB_STRING=8
val SCE_NNCRONTAB_ENVIRONMENT=9
val SCE_NNCRONTAB_IDENTIFIER=10
+# Lexical states for SCLEX_MATLAB
+val SCE_MATLAB_DEFAULT=0
+val SCE_MATLAB_COMMENT=1
+val SCE_MATLAB_COMMAND=2
+val SCE_MATLAB_NUMBER=3
+val SCE_MATLAB_KEYWORD=4
+val SCE_MATLAB_STRING=5
+val SCE_MATLAB_OPERATOR=6
+val SCE_MATLAB_IDENTIFIER=7
# Events
evt void Key=2005(int ch, int modifiers)
evt void DoubleClick=2006(void)
evt void UpdateUI=2007(void)
-# The old name for SCN_UPDATEUI
-val SCN_CHECKBRACE=2007
evt void Modified=2008(int position, int modificationType, string text, int length, int linesAdded, int line, int foldLevelNow, int foldLevelPrev)
-# Optional module for macro recording
evt void MacroRecord=2009(int message, int wParam, int lParam)
evt void MarginClick=2010(int modifiers, int position, int margin)
evt void NeedShown=2011(int position, int length)
-evt void PosChanged=2012(int position)
evt void Painted=2013(void)
evt void UserListSelection=2014(int listType, string text)
evt void URIDropped=2015(string text)
evt void DwellEnd=2017(int position)
cat Deprecated
+
+# The old name for SCN_UPDATEUI
+val SCN_CHECKBRACE=2007
+evt void PosChanged=2012(int position)
/** @file AutoComplete.cxx
** Defines the auto completion list box.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
posStart(0),
startLen(0),
cancelAtStartPos(true),
- autoHide(true) {
+ autoHide(true),
+ dropRestOfWord(false) {
stopChars[0] = '\0';
fillUpChars[0] = '\0';
}
/** @file AutoComplete.h
** Defines the auto completion list box.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef AUTOCOMPLETE_H
/// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos;
bool autoHide;
+ bool dropRestOfWord;
AutoComplete();
~AutoComplete();
startHighlight = 0;
endHighlight = 0;
- colourBG.desired = Colour(0xff, 0xff, 0xff);
- colourUnSel.desired = Colour(0x80, 0x80, 0x80);
- colourSel.desired = Colour(0, 0, 0x80);
- colourShade.desired = Colour(0, 0, 0);
- colourLight.desired = Colour(0xc0, 0xc0, 0xc0);
+ colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
+ colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
+ colourSel.desired = ColourDesired(0, 0, 0x80);
+ colourShade.desired = ColourDesired(0, 0, 0);
+ colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
}
CallTip::~CallTip() {
rcClient.left = x;
rcClient.top = ytext - ascent - 1;
rcClient.right = xEnd;
- surfaceWindow->DrawText(rcClient, font, ytext,
+ surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal, thisStartHighlight,
colourUnSel.allocated, colourBG.allocated);
x = xEnd;
rcClient.top = ytext;
rcClient.left = x;
rcClient.right = xEnd;
- surfaceWindow->DrawText(rcClient, font, ytext,
+ surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
colourSel.allocated, colourBG.allocated);
x = xEnd;
chunkLength - thisEndHighlight);
rcClient.left = x;
rcClient.right = xEnd;
- surfaceWindow->DrawText(rcClient, font, ytext,
+ surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
colourUnSel.allocated, colourBG.allocated);
chunkVal = chunkEnd + 1;
}
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
- const char *faceName, int size) {
- Surface surfaceMeasure;
- surfaceMeasure.Init();
- int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
- font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
+ const char *faceName, int size, bool unicodeMode_) {
if (val)
delete []val;
val = new char[strlen(defn) + 1];
if (!val)
return PRectangle();
strcpy(val, defn);
+ unicodeMode = unicodeMode_;
+ Surface *surfaceMeasure = Surface::Allocate();
+ if (!surfaceMeasure)
+ return PRectangle();
+ surfaceMeasure->Init();
+ surfaceMeasure->SetUnicodeMode(unicodeMode);
startHighlight = 0;
endHighlight = 0;
inCallTipMode = true;
posStartCallTip = pos;
+ int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
+ font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
// Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r!
int width = 0;
const char *newline;
const char *look = val;
while ((newline = strchr(look, '\n')) != NULL) {
- int thisWidth = surfaceMeasure.WidthText(font, look, newline - look);
+ int thisWidth = surfaceMeasure->WidthText(font, look, newline - look);
width = Platform::Maximum(width, thisWidth);
look = newline + 1;
numLines++;
}
- int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look));
+ int lastWidth = surfaceMeasure->WidthText(font, look, strlen(look));
width = Platform::Maximum(width, lastWidth) + 10;
- int lineHeight = surfaceMeasure.Height(font);
+ int lineHeight = surfaceMeasure->Height(font);
// Extra line for border and an empty line at top and bottom
- int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2;
+ int height = lineHeight * numLines - surfaceMeasure->InternalLeading(font) + 2 + 2;
+ delete surfaceMeasure;
return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
}
ColourPair colourSel;
ColourPair colourShade;
ColourPair colourLight;
+ bool unicodeMode;
CallTip();
~CallTip();
/// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(int pos, Point pt, const char *defn,
- const char *faceName, int size);
+ const char *faceName, int size, bool unicodeMode_);
void CallTipCancel();
OneLine::OneLine() {
displayLine = 0;
- docLine = 0;
+ //docLine = 0;
visible = true;
+ height = 1;
expanded = true;
}
linesInDoc = 1;
linesInDisplay = 1;
valid = false;
+ docLines = 0;
+ sizeDocLines = 0;
}
ContractionState::~ContractionState() {
void ContractionState::MakeValid() const {
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.
- int lineDisplay = 0;
+ linesInDisplay = 0;
+ for (int lineInDoc=0; lineInDoc<linesInDoc; lineInDoc++) {
+ lines[lineInDoc].displayLine = linesInDisplay;
+ if (lines[lineInDoc].visible) {
+ linesInDisplay += lines[lineInDoc].height;
+ }
+ }
+ if (sizeDocLines < linesInDisplay) {
+ delete []docLines;
+ int *docLinesNew = new int[linesInDisplay + growSize];
+ if (!docLinesNew) {
+ docLines = 0;
+ sizeDocLines = 0;
+ return;
+ }
+ docLines = docLinesNew;
+ sizeDocLines = linesInDisplay + growSize;
+ }
+
+ int lineInDisplay=0;
for (int line=0; line<linesInDoc; line++) {
- lines[line].displayLine = lineDisplay;
if (lines[line].visible) {
- lines[lineDisplay].docLine = line;
- lineDisplay++;
+ for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
+ docLines[lineInDisplay] = line;
+ lineInDisplay++;
+ }
}
}
valid = true;
size = 0;
linesInDoc = 1;
linesInDisplay = 1;
+ delete []docLines;
+ docLines = 0;
+ sizeDocLines = 0;
}
int ContractionState::LinesInDoc() const {
}
int ContractionState::LinesDisplayed() const {
+ if (size != 0) {
+ MakeValid();
+ }
return linesInDisplay;
}
if (lineDisplay <= 0)
return 0;
if (lineDisplay >= linesInDisplay)
- return linesInDoc-1;
+ return linesInDoc;
if (size == 0)
return lineDisplay;
MakeValid();
- return lines[lineDisplay].docLine;
+ if (docLines) { // Valid allocation
+ return docLines[lineDisplay];
+ } else {
+ return 0;
+ }
}
void ContractionState::Grow(int sizeNew) {
Grow(linesInDoc + lineCount + growSize);
}
linesInDoc += lineCount;
- linesInDisplay += lineCount;
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
lines[i].visible = lines[i - lineCount].visible;
+ lines[i].height = lines[i - lineCount].height;
+ linesInDisplay += lines[i].height;
lines[i].expanded = lines[i - lineCount].expanded;
}
for (int d=0;d<lineCount;d++) {
lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
+ lines[lineDoc+d].height = 1;
lines[lineDoc+d].expanded = true;
}
valid = false;
int deltaDisplayed = 0;
for (int d=0;d<lineCount;d++) {
if (lines[lineDoc+d].visible)
- deltaDisplayed--;
+ deltaDisplayed -= lines[lineDoc+d].height;
}
for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
if (i != 0) // Line zero is always visible
}
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
- if (lineDocStart == 0)
- lineDocStart++;
- if (lineDocStart > lineDocEnd)
- return false;
+ if (lineDocStart == 0)
+ lineDocStart++;
+ if (lineDocStart > lineDocEnd)
+ return false;
if (size == 0) {
Grow(linesInDoc + growSize);
}
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
for (int line=lineDocStart; line <= lineDocEnd; line++) {
if (lines[line].visible != visible) {
- delta += visible ? 1 : -1;
+ delta += visible ? lines[line].height : -lines[line].height;
lines[line].visible = visible;
}
}
}
bool ContractionState::GetExpanded(int lineDoc) const {
- if (size == 0)
+ if (size == 0)
return true;
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
return lines[lineDoc].expanded;
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
if (size == 0) {
+ if (expanded) {
+ // If in completely expanded state then setting
+ // one line to expanded has no effect.
+ return false;
+ }
Grow(linesInDoc + growSize);
}
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
return false;
}
+int ContractionState::GetHeight(int lineDoc) const {
+ if (size == 0)
+ return 1;
+ if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
+ return lines[lineDoc].height;
+ } else {
+ return 1;
+ }
+}
+
+// Set the number of display lines needed for this line.
+// Return true if this is a change.
+bool ContractionState::SetHeight(int lineDoc, int height) {
+ if (lineDoc > linesInDoc)
+ return false;
+ if (size == 0) {
+ if (height == 1) {
+ // If in completely expanded state then all lines
+ // assumed to have height of one so no effect here.
+ return false;
+ }
+ Grow(linesInDoc + growSize);
+ }
+ if (lines[lineDoc].height != height) {
+ lines[lineDoc].height = height;
+ valid = false;
+ return true;
+ } else {
+ return false;
+ }
+}
+
void ContractionState::ShowAll() {
delete []lines;
lines = 0;
class OneLine {
public:
int displayLine; ///< Position within set of visible lines
- int docLine; ///< Inverse of @a displayLine
+ //int docLine; ///< Inverse of @a displayLine
+ int height; ///< Number of display lines needed to show all of the line
bool visible;
bool expanded;
-
+
OneLine();
virtual ~OneLine() {}
};
void Grow(int sizeNew);
enum { growSize = 4000 };
int linesInDoc;
- int linesInDisplay;
+ mutable int linesInDisplay;
mutable OneLine *lines;
int size;
+ mutable int *docLines;
+ mutable int sizeDocLines;
mutable bool valid;
void MakeValid() const;
public:
ContractionState();
virtual ~ContractionState();
-
+
void Clear();
-
- int LinesInDoc() const;
- int LinesDisplayed() const;
+
+ int LinesInDoc() const;
+ int LinesDisplayed() const;
int DisplayFromDoc(int lineDoc) const;
int DocFromDisplay(int lineDisplay) const;
-
+
void InsertLines(int lineDoc, int lineCount);
void DeleteLines(int lineDoc, int lineCount);
-
+
bool GetVisible(int lineDoc) const;
bool SetVisible(int lineDocStart, int lineDocEnd, bool visible);
-
+
bool GetExpanded(int lineDoc) const;
bool SetExpanded(int lineDoc, bool expanded);
- void ShowAll();
+ int GetHeight(int lineDoc) const;
+ bool SetHeight(int lineDoc, int height);
+
+ void ShowAll();
};
#endif
/** @file Document.cxx
** Text document that handles notifications, DBCS, styling, words and end of line.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include "RESearch.h"
// This is ASCII specific but is safe with chars >= 0x80
-inline bool isspacechar(unsigned char ch) {
+static inline bool isspacechar(unsigned char ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
stylingBits = 5;
stylingBitsMask = 0x1F;
stylingMask = 0;
- for (int ch = 0; ch < 256; ch++) {
- wordchars[ch] = isalnum(ch) || ch == '_';
- }
+ SetWordChars(0);
endStyled = 0;
+ styleClock = 0;
enteredCount = 0;
enteredReadOnlyCount = 0;
tabInChars = 8;
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
}
-#if PLAT_WIN
bool Document::IsDBCS(int pos) {
if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) {
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
startLine--;
while (startLine <= pos) {
- if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) {
+ if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine))) {
startLine++;
if (startLine >= pos)
return true;
}
return false;
}
-#else
-// PLAT_GTK or PLAT_WX
-// TODO: support DBCS under GTK+ and WX
-bool Document::IsDBCS(int) {
- return false;
-}
-#endif
int Document::LenChar(int pos) {
if (IsCrLf(pos)) {
// Not between CR and LF
-#if PLAT_WIN
if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) {
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
while (startLine < pos) {
if (atLeadByte)
atLeadByte = false;
- else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine)))
+ else if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine)))
atLeadByte = true;
else
atLeadByte = false;
startLine++;
- //Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
}
}
}
}
-#endif
return pos;
}
int column = 0;
int line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) {
- for (int i = LineStart(line);i < pos;i++) {
+ for (int i = LineStart(line);i < pos;) {
char ch = cb.CharAt(i);
- if (ch == '\t')
+ if (ch == '\t') {
column = NextTab(column, tabInChars);
- else if (ch == '\r')
+ i++;
+ } else if (ch == '\r') {
return column;
- else if (ch == '\n')
+ } else if (ch == '\n') {
return column;
- else
+ } else {
column++;
+ i = MovePositionOutsideChar(i + 1, 1);
+ }
}
}
return column;
}
+int Document::FindColumn(int line, int column) {
+ int position = LineStart(line);
+ int columnCurrent = 0;
+ if ((line >= 0) && (line < LinesTotal())) {
+ while (columnCurrent < column) {
+ char ch = cb.CharAt(position);
+ if (ch == '\t') {
+ columnCurrent = NextTab(columnCurrent, tabInChars);
+ position++;
+ } else if (ch == '\r') {
+ return position;
+ } else if (ch == '\n') {
+ return position;
+ } else {
+ columnCurrent++;
+ position = MovePositionOutsideChar(position + 1, 1);
+ }
+ }
+ }
+ return position;
+}
+
void Document::Indent(bool forwards, int lineBottom, int lineTop) {
// Dedent - suck white space off the front of the line to dedent by equivalent of a tab
for (int line = lineBottom; line >= lineTop; line--) {
EndUndoAction();
}
-bool Document::IsWordChar(unsigned char ch) {
- if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80))
- return true;
- return wordchars[ch];
+Document::charClassification Document::WordCharClass(unsigned char ch) {
+ if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80))
+ return ccWord;
+ return charClass[ch];
}
-int Document::ExtendWordSelect(int pos, int delta) {
+/**
+ * Used by commmands that want to select whole words.
+ * Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0.
+ */
+int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) {
+ charClassification ccStart = ccWord;
if (delta < 0) {
- while (pos > 0 && IsWordChar(cb.CharAt(pos - 1)))
+ if (!onlyWordCharacters)
+ ccStart = WordCharClass(cb.CharAt(pos-1));
+ while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
pos--;
} else {
- while (pos < (Length()) && IsWordChar(cb.CharAt(pos)))
+ if (!onlyWordCharacters)
+ ccStart = WordCharClass(cb.CharAt(pos));
+ while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
pos++;
}
return pos;
}
+/**
+ * Find the start of the next word in either a forward (delta >= 0) or backwards direction
+ * (delta < 0).
+ * This is looking for a transition between character classes although there is also some
+ * additional movement to transit white space.
+ * Used by cursor movement by word commands.
+ */
int Document::NextWordStart(int pos, int delta) {
if (delta < 0) {
- while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))
+ while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccSpace))
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))))
+ if (pos > 0) {
+ charClassification ccStart = WordCharClass(cb.CharAt(pos-1));
+ while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) {
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))))
+ charClassification ccStart = WordCharClass(cb.CharAt(pos));
+ while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
pos++;
- while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))
+ while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccSpace))
pos++;
}
return pos;
}
/**
- * Check that the character before the given position
- * is not a word character.
+ * Check that the character at the given position is a word or punctuation character and that
+ * the previous character is of a different character class.
*/
bool Document::IsWordStartAt(int pos) {
if (pos > 0) {
- return !IsWordChar(CharAt(pos - 1));
+ charClassification ccPos = WordCharClass(CharAt(pos));
+ return (ccPos == ccWord || ccPos == ccPunctuation) &&
+ (ccPos != WordCharClass(CharAt(pos - 1)));
}
return true;
}
/**
- * Check that the character after the given position
- * is not a word character.
+ * Check that the character at the given position is a word or punctuation character and that
+ * the next character is of a different character class.
*/
bool Document::IsWordEndAt(int pos) {
if (pos < Length() - 1) {
- return !IsWordChar(CharAt(pos));
+ charClassification ccPrev = WordCharClass(CharAt(pos-1));
+ return (ccPrev == ccWord || ccPrev == ccPunctuation) &&
+ (ccPrev != WordCharClass(CharAt(pos)));
}
return true;
}
/**
- * Check that the given range is delimited by
- * non word characters.
+ * Check that the given range is has transitions between character classes at both
+ * ends and where the characters on the inside are word or punctuation characters.
*/
bool Document::IsWordAt(int start, int end) {
return IsWordStartAt(start) && IsWordEndAt(end);
void Document::SetWordChars(unsigned char *chars) {
int ch;
for (ch = 0; ch < 256; ch++) {
- wordchars[ch] = false;
+ if (ch == '\r' || ch == '\n')
+ charClass[ch] = ccNewLine;
+ else if (ch < 0x20 || ch == ' ')
+ charClass[ch] = ccSpace;
+ else
+ charClass[ch] = ccPunctuation;
}
if (chars) {
while (*chars) {
- wordchars[*chars] = true;
+ charClass[*chars] = ccWord;
chars++;
}
} else {
for (ch = 0; ch < 256; ch++) {
- wordchars[ch] = isalnum(ch) || ch == '_';
+ if (ch >= 0x80 || isalnum(ch) || ch == '_')
+ charClass[ch] = ccWord;
}
}
}
int prevEndStyled = endStyled;
bool didChange = false;
for (int iPos = 0; iPos < length; iPos++, endStyled++) {
+ PLATFORM_ASSERT(endStyled < Length());
if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
didChange = true;
}
}
bool Document::EnsureStyledTo(int pos) {
+ if (pos > GetEndStyled()) {
+ styleClock++;
+ if (styleClock > 0x100000) {
+ styleClock = 0;
+ }
+ }
// Ask the watchers to style, and stop as soon as one responds.
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
}
bool Document::IsWordPartSeparator(char ch) {
- return ispunct(ch) && IsWordChar(ch);
+ return ispunct(ch) && (WordCharClass(ch) == ccWord);
}
int Document::WordPartLeft(int pos) {
/** @file Document.h
** Text document that handles notifications, DBCS, styling, words and end of line.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef DOCUMENT_H
return (start != invalidPosition) && (end != invalidPosition);
}
+ // Is the position within the range?
bool Contains(Position pos) const {
if (start < end) {
return (pos >= start && pos <= end);
}
}
+ // Is the character after pos within the range?
+ bool ContainsCharacter(Position pos) const {
+ if (start < end) {
+ return (pos >= start && pos < end);
+ } else {
+ return (pos < start && pos >= end);
+ }
+ }
+
bool Contains(Range other) const {
return Contains(other.start) && Contains(other.end);
}
private:
int refCount;
CellBuffer cb;
- bool wordchars[256];
+ enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
+ charClassification charClass[256];
char stylingMask;
int endStyled;
+ int styleClock;
int enteredCount;
int enteredReadOnlyCount;
void SetLineIndentation(int line, int indent);
int GetLineIndentPosition(int line);
int GetColumn(int position);
+ int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
int GetFoldParent(int line);
void Indent(bool forwards);
- int ExtendWordSelect(int pos, int delta);
+ int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
int NextWordStart(int pos, int delta);
int Length() { return cb.Length(); }
long FindText(int minPos, int maxPos, const char *s,
void SetStyles(int length, char *styles);
int GetEndStyled() { return endStyled; }
bool EnsureStyledTo(int pos);
+ int GetStyleClock() { return styleClock; }
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); }
private:
bool IsDBCS(int pos);
- bool IsWordChar(unsigned char ch);
+ charClassification WordCharClass(unsigned char ch);
bool IsWordStartAt(int pos);
bool IsWordEndAt(int pos);
bool IsWordAt(int start, int end);
DocumentAccessor::~DocumentAccessor() {
}
-#if PLAT_WIN
bool DocumentAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte.
return false;
else
- return IsDBCSLeadByteEx(codePage, ch);
+ return Platform::IsDBCSLeadByte(codePage, ch);
}
-#else
-// PLAT_GTK or PLAT_WX
-// TODO: support DBCS under GTK+ and WX
-bool DocumentAccessor::InternalIsLeadByte(char) {
- return false;
-}
-#endif
void DocumentAccessor::Fill(int position) {
if (lenDoc == -1)
void DocumentAccessor::StartAt(unsigned int start, char chMask) {
pdoc->StartStyling(start, chMask);
+ startPosStyling = start;
}
void DocumentAccessor::StartSegment(unsigned int pos) {
chFlags = 0;
chAttr |= chFlags;
for (unsigned int i = startSeg; i <= pos; i++) {
+ PLATFORM_ASSERT((startPosStyling + validLen) < Length());
styleBuf[validLen++] = static_cast<char>(chAttr);
}
}
if (validLen > 0) {
pdoc->SetStyles(validLen, styleBuf);
validLen = 0;
+ startPosStyling += validLen;
}
}
char chFlags;
char chWhile;
unsigned int startSeg;
+ int startPosStyling;
bool InternalIsLeadByte(char ch);
void Fill(int position);
public:
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), id(id_),
- lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
+ lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
+ startSeg(0), startPosStyling(0) {
}
~DocumentAccessor();
char StyleAt(int position);
/** @file Editor.cxx
** Main code for 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.
#include <stdlib.h>
#include "Platform.h"
+#define INCLUDE_DEPRECATED_FEATURES
#include "Scintilla.h"
#include "ContractionState.h"
Timer::Timer() :
ticking(false), ticksToWait(0), tickerID(0) {}
+LineLayout::LineLayout(int maxLineLength_) :
+ lineStarts(0),
+ lenLineStarts(0),
+ lineNumber(-1),
+ inCache(false),
+ maxLineLength(-1),
+ numCharsInLine(0),
+ validity(llInvalid),
+ xHighlightGuide(0),
+ highlightColumn(0),
+ selStart(0),
+ selEnd(0),
+ containsCaret(false),
+ edgeColumn(0),
+ chars(0),
+ styles(0),
+ indicators(0),
+ positions(0),
+ widthLine(wrapWidthInfinite),
+ lines(1) {
+ Resize(maxLineLength_);
+}
+
+LineLayout::~LineLayout() {
+ Free();
+}
+
+void LineLayout::Resize(int maxLineLength_) {
+ if (maxLineLength_ > maxLineLength) {
+ Free();
+ chars = new char[maxLineLength_ + 1];
+ styles = new char[maxLineLength_ + 1];
+ indicators = new char[maxLineLength_ + 1];
+ positions = new int[maxLineLength_ + 1];
+ maxLineLength = maxLineLength_;
+ }
+}
+
+void LineLayout::Free() {
+ delete []chars;
+ chars = 0;
+ delete []styles;
+ styles = 0;
+ delete []indicators;
+ indicators = 0;
+ delete []positions;
+ positions = 0;
+ delete []lineStarts;
+ lineStarts = 0;
+}
+
+void LineLayout::Invalidate(validLevel validity_) {
+ validity = validity_;
+}
+
+void LineLayout::SetLineStart(int line, int start) {
+ if ((line >= lenLineStarts) && (line != 0)) {
+ int newMaxLines = line + 20;
+ int *newLineStarts = new int[newMaxLines];
+ if (!newLineStarts)
+ return;
+ for (int i=0; i<newMaxLines; i++) {
+ if (i < lenLineStarts)
+ newLineStarts[i] = lineStarts[i];
+ else
+ newLineStarts[i] = 0;
+ }
+ delete []lineStarts;
+ lineStarts = newLineStarts;
+ lenLineStarts = newMaxLines;
+ }
+ lineStarts[line] = start;
+}
+
+void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],
+ char bracesMatchStyle, int xHighlight) {
+ if (rangeLine.ContainsCharacter(braces[0])) {
+ int braceOffset = braces[0] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ bracePreviousStyles[0] = styles[braceOffset];
+ styles[braceOffset] = bracesMatchStyle;
+ }
+ }
+ if (rangeLine.ContainsCharacter(braces[1])) {
+ int braceOffset = braces[1] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ bracePreviousStyles[1] = styles[braceOffset];
+ styles[braceOffset] = bracesMatchStyle;
+ }
+ }
+ if ((braces[0] >= rangeLine.start && braces[1] <= rangeLine.end) ||
+ (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) {
+ xHighlightGuide = xHighlight;
+ }
+}
+
+void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) {
+ if (rangeLine.ContainsCharacter(braces[0])) {
+ int braceOffset = braces[0] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ styles[braceOffset] = bracePreviousStyles[0];
+ }
+ }
+ if (rangeLine.ContainsCharacter(braces[1])) {
+ int braceOffset = braces[1] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ styles[braceOffset] = bracePreviousStyles[1];
+ }
+ }
+ xHighlightGuide = 0;
+}
+
+LineLayoutCache::LineLayoutCache() :
+ level(0), length(0), size(0), cache(0),
+ allInvalidated(false), styleClock(-1) {
+ Allocate(0);
+}
+
+LineLayoutCache::~LineLayoutCache() {
+ Deallocate();
+}
+
+void LineLayoutCache::Allocate(int length_) {
+ allInvalidated = false;
+ length = length_;
+ size = length;
+ if (size > 1) {
+ size = (size / 16 + 1) * 16;
+ }
+ if (size > 0) {
+ cache = new LineLayout *[size];
+ }
+ for (int i=0; i<size; i++)
+ cache[i] = 0;
+}
+
+void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
+ int lengthForLevel = 0;
+ if (level == llcCaret) {
+ lengthForLevel = 1;
+ } else if (level == llcPage) {
+ lengthForLevel = linesOnScreen + 1;
+ } else if (level == llcDocument) {
+ lengthForLevel = linesInDoc;
+ }
+ if (lengthForLevel > size) {
+ Deallocate();
+ } else {
+ if (lengthForLevel < length) {
+ for (int i=lengthForLevel; i<length; i++) {
+ delete cache[i];
+ cache[i] = 0;
+ }
+ }
+ Invalidate(LineLayout::llInvalid);
+ }
+ if (!cache) {
+ Allocate(lengthForLevel);
+ }
+}
+
+void LineLayoutCache::Deallocate() {
+ for (int i=0; i<length; i++)
+ delete cache[i];
+ delete []cache;
+ cache = 0;
+ length = 0;
+}
+
+void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
+ if (cache && !allInvalidated) {
+ for (int i=0; i<length; i++) {
+ if (cache[i]) {
+ cache[i]->Invalidate(validity_);
+ }
+ }
+ if (validity_ == LineLayout::llInvalid) {
+ allInvalidated = true;
+ }
+ }
+}
+
+void LineLayoutCache::SetLevel(int level_) {
+ allInvalidated = false;
+ if ((level_ != -1) && (level != level_)) {
+ level = level_;
+ Deallocate();
+ }
+}
+
+LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+ int linesOnScreen, int linesInDoc) {
+ AllocateForLevel(linesOnScreen, linesInDoc);
+ if (styleClock != styleClock_) {
+ Invalidate(LineLayout::llInvalid);
+ styleClock = styleClock_;
+ }
+ allInvalidated = false;
+ int pos = -1;
+ LineLayout *ret = 0;
+ if (((level == llcCaret) || (level == llcPage)) && (lineNumber == lineCaret)) {
+ pos = 0;
+ } else if (level == llcPage) {
+ pos = lineNumber % length;
+ } else if (level == llcDocument) {
+ pos = lineNumber;
+ }
+ if (pos >= 0) {
+ if (cache && (pos < length)) {
+ if (cache[pos]) {
+ if ((cache[pos]->lineNumber != lineNumber) ||
+ (cache[pos]->maxLineLength < maxChars)) {
+ delete cache[pos];
+ cache[pos] = 0;
+ }
+ }
+ if (!cache[pos]) {
+ cache[pos] = new LineLayout(maxChars);
+ }
+ if (cache[pos]) {
+ cache[pos]->lineNumber = lineNumber;
+ cache[pos]->inCache = true;
+ ret = cache[pos];
+ }
+ }
+ }
+
+ if (!ret) {
+ ret = new LineLayout(maxChars);
+ ret->lineNumber = lineNumber;
+ }
+
+ return ret;
+}
+
+void LineLayoutCache::Dispose(LineLayout *ll) {
+ allInvalidated = false;
+ if (ll) {
+ if (!ll->inCache) {
+ delete ll;
+ }
+ }
+}
+
Editor::Editor() {
ctrlID = 0;
printMagnification = 0;
printColourMode = SC_PRINT_NORMAL;
cursorMode = SC_CURSORNORMAL;
+ controlCharSymbol = 0; /* Draw the control characters */
hasFocus = false;
hideSelection = false;
xCaretMargin = 50;
horizontalScrollBarVisible = true;
+ pixmapLine = Surface::Allocate();
+ pixmapSelMargin = Surface::Allocate();
+ pixmapSelPattern = Surface::Allocate();
+ pixmapIndentGuide = Surface::Allocate();
+ pixmapIndentGuideHighlight = Surface::Allocate();
+
currentPos = 0;
anchor = 0;
recordingMacro = false;
foldFlags = 0;
+
+ wrapState = eWrapNone;
+ wrapWidth = LineLayout::wrapWidthInfinite;
+ docLineLastWrapped = -1;
+
+ llc.SetLevel(LineLayoutCache::llcDocument);
}
Editor::~Editor() {
pdoc->Release();
pdoc = 0;
DropGraphics();
+ delete pixmapLine;
+ delete pixmapSelMargin;
+ delete pixmapSelPattern;
+ delete pixmapIndentGuide;
+ delete pixmapIndentGuideHighlight;
}
void Editor::Finalise() {
}
void Editor::DropGraphics() {
- pixmapLine.Release();
- pixmapSelMargin.Release();
- pixmapSelPattern.Release();
- pixmapIndentGuide.Release();
+ pixmapLine->Release();
+ pixmapSelMargin->Release();
+ pixmapSelPattern->Release();
+ pixmapIndentGuide->Release();
}
void Editor::InvalidateStyleData() {
stylesValid = false;
palette.Release();
DropGraphics();
+ llc.Invalidate(LineLayout::llInvalid);
}
void Editor::InvalidateStyleRedraw() {
void Editor::RefreshStyleData() {
if (!stylesValid) {
stylesValid = true;
- Surface surface;
- surface.Init();
- vs.Refresh(surface);
- RefreshColourPalette(palette, true);
- palette.Allocate(wMain);
- RefreshColourPalette(palette, false);
+ AutoSurface surface(IsUnicodeMode());
+ if (surface) {
+ vs.Refresh(*surface);
+ RefreshColourPalette(palette, true);
+ palette.Allocate(wMain);
+ RefreshColourPalette(palette, false);
+ }
SetScrollBars();
}
}
int line = pdoc->LineFromPosition(pos);
int lineVisible = cs.DisplayFromDoc(line);
//Platform::DebugPrintf("line=%d\n", line);
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- pt.y = (lineVisible - topLine) * vs.lineHeight; // + half a lineheight?
- unsigned int posLineStart = pdoc->LineStart(line);
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- if ((pos - posLineStart) > LineLayout::maxLineLength) {
- // very long line so put x at arbitrary large position
- pt.x = ll.positions[LineLayout::maxLineLength] + vs.fixedColumnWidth - xOffset;
- } else {
- pt.x = ll.positions[pos - posLineStart] + vs.fixedColumnWidth - xOffset;
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(line);
+ if (surface && ll) {
+ // -1 because of adding in for visible lines in following loop.
+ pt.y = (lineVisible - topLine - 1) * vs.lineHeight;
+ pt.x = 0;
+ unsigned int posLineStart = pdoc->LineStart(line);
+ LayoutLine(line, surface, vs, ll, wrapWidth);
+ int posInLine = pos - posLineStart;
+ // In case of very long line put x at arbitrary large position
+ if (posInLine > ll->maxLineLength) {
+ pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)];
+ }
+ for (int subLine=0; subLine<ll->lines; subLine++) {
+ if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine+1))) {
+ pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)];
+ }
+ if (posInLine >= ll->LineStart(subLine)) {
+ pt.y += vs.lineHeight;
+ }
+ }
+ pt.x += vs.fixedColumnWidth - xOffset;
}
+ llc.Dispose(ll);
return pt;
}
int Editor::PositionFromLocation(Point pt) {
RefreshStyleData();
pt.x = pt.x - vs.fixedColumnWidth + xOffset;
- int line = cs.DocFromDisplay(pt.y / vs.lineHeight + topLine);
+ int visibleLine = pt.y / vs.lineHeight + topLine;
if (pt.y < 0) { // Division rounds towards 0
- line = cs.DocFromDisplay((pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine);
+ visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine;
}
- if (line < 0)
- return 0;
- if (line >= pdoc->LinesTotal())
+ if (visibleLine < 0)
+ visibleLine = 0;
+ int lineDoc = cs.DocFromDisplay(visibleLine);
+ if (lineDoc >= pdoc->LinesTotal())
return pdoc->Length();
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- unsigned int posLineStart = pdoc->LineStart(line);
-
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- for (int i = 0; i < ll.numCharsInLine; i++) {
- if (pt.x < ((ll.positions[i] + ll.positions[i + 1]) / 2) ||
- ll.chars[i] == '\r' || ll.chars[i] == '\n') {
- return i + posLineStart;
+ AutoSurface surface(IsUnicodeMode());
+ int retVal = 0;
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ int lineStartSet = cs.DisplayFromDoc(lineDoc);
+ int subLine = visibleLine - lineStartSet;
+ if (subLine < ll->lines) {
+ int lineStart = ll->LineStart(subLine);
+ int lineEnd = ll->LineStart(subLine+1);
+ int subLineStart = ll->positions[lineStart];
+ for (int i = lineStart; i < lineEnd; i++) {
+ if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
+ ll->chars[i] == '\r' || ll->chars[i] == '\n') {
+ llc.Dispose(ll);
+ return pdoc->MovePositionOutsideChar(i + posLineStart, 1);
+ }
+ }
+ llc.Dispose(ll);
+ return lineEnd + posLineStart;
}
+ retVal = ll->numCharsInLine + posLineStart;
}
-
- return ll.numCharsInLine + posLineStart;
+ llc.Dispose(ll);
+ return retVal;
}
// Like PositionFromLocation but INVALID_POSITION returned when not near any text.
if (pt.y < 0)
return INVALID_POSITION;
pt.x = pt.x - vs.fixedColumnWidth + xOffset;
- int line = cs.DocFromDisplay(pt.y / vs.lineHeight + topLine);
+ int visibleLine = pt.y / vs.lineHeight + topLine;
if (pt.y < 0) { // Division rounds towards 0
- line = cs.DocFromDisplay((pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine);
+ visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine;
}
- if (line < 0)
+ int lineDoc = cs.DocFromDisplay(visibleLine);
+ if (lineDoc < 0)
return INVALID_POSITION;
- if (line >= pdoc->LinesTotal())
+ if (lineDoc >= pdoc->LinesTotal())
return INVALID_POSITION;
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- unsigned int posLineStart = pdoc->LineStart(line);
-
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- for (int i = 0; i < ll.numCharsInLine; i++) {
- if (pt.x < ((ll.positions[i] + ll.positions[i + 1]) / 2) ||
- ll.chars[i] == '\r' || ll.chars[i] == '\n') {
- return i + posLineStart;
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ int lineStartSet = cs.DisplayFromDoc(lineDoc);
+ int subLine = visibleLine - lineStartSet;
+ if (subLine < ll->lines) {
+ int lineStart = ll->LineStart(subLine);
+ int lineEnd = ll->LineStart(subLine+1);
+ int subLineStart = ll->positions[lineStart];
+ for (int i = lineStart; i < lineEnd; i++) {
+ if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
+ ll->chars[i] == '\r' || ll->chars[i] == '\n') {
+ llc.Dispose(ll);
+ return pdoc->MovePositionOutsideChar(i + posLineStart, 1);
+ }
+ }
}
}
+ llc.Dispose(ll);
return INVALID_POSITION;
}
-int Editor::PositionFromLineX(int line, int x) {
+// Find the document position corresponding to an x coordinate on a particular document line.
+// Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
+int Editor::PositionFromLineX(int lineDoc, int x) {
RefreshStyleData();
- if (line >= pdoc->LinesTotal())
+ if (lineDoc >= pdoc->LinesTotal())
return pdoc->Length();
//Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine);
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- unsigned int posLineStart = pdoc->LineStart(line);
-
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- for (int i = 0; i < ll.numCharsInLine; i++) {
- if (x < ((ll.positions[i] + ll.positions[i + 1]) / 2) ||
- ll.chars[i] == '\r' || ll.chars[i] == '\n') {
- return i + posLineStart;
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ int retVal = 0;
+ if (surface && ll) {
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ retVal = ll->numCharsInLine + posLineStart;
+ int subLine = 0;
+ int lineStart = ll->LineStart(subLine);
+ int lineEnd = ll->LineStart(subLine+1);
+ int subLineStart = ll->positions[lineStart];
+ for (int i = lineStart; i < lineEnd; i++) {
+ if (x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
+ ll->chars[i] == '\r' || ll->chars[i] == '\n') {
+ retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1);
+ break;
+ }
}
}
-
- return ll.numCharsInLine + posLineStart;
+ llc.Dispose(ll);
+ return retVal;
}
void Editor::RedrawRect(PRectangle rc) {
if (maxPos < end)
maxPos = end;
int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(minPos));
- int maxLine = cs.DisplayFromDoc(pdoc->LineFromPosition(maxPos));
+ int lineDocMax = pdoc->LineFromPosition(maxPos);
+ int maxLine = cs.DisplayFromDoc(lineDocMax) + cs.GetHeight(lineDocMax) - 1;
PRectangle rcClient = GetTextRectangle();
PRectangle rc;
rc.left = vs.fixedColumnWidth;
int mask = pdoc->stylingBitsMask;
if (moveDir > 0) {
while ((pos < pdoc->Length()) &&
- (!vs.styles[pdoc->StyleAt(pos - 1) & mask].visible))
+ (vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected()))
pos++;
} else {
while ((pos > 0) &&
- (!vs.styles[pdoc->StyleAt(pos - 1) & mask].visible))
+ (vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected()))
pos--;
}
return pos;
} else {
int lineDisplay = cs.DisplayFromDoc(lineDoc);
if (moveDir > 0) {
- lineDisplay = Platform::Clamp(lineDisplay + 1, 0, cs.LinesDisplayed());
+ // lineDisplay is already line before fold as lines in fold use display line of line after fold
+ lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
return pdoc->LineStart(cs.DocFromDisplay(lineDisplay));
} else {
- // lineDisplay is already line before fold as lines in fold use display line of line before fold
- lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
- return pdoc->LineEndPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay)));
+ lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed());
+ return pdoc->LineEnd(cs.DocFromDisplay(lineDisplay));
}
}
}
void Editor::HorizontalScrollTo(int xPos) {
//Platform::DebugPrintf("HorizontalScroll %d\n", xPos);
- xOffset = xPos;
- if (xOffset < 0)
- xOffset = 0;
- SetHorizontalScrollPos();
- RedrawRect(GetClientRectangle());
+ if (xPos < 0)
+ xPos = 0;
+ if ((wrapState == eWrapNone) && (xOffset != xPos)) {
+ xOffset = xPos;
+ SetHorizontalScrollPos();
+ RedrawRect(GetClientRectangle());
+ }
}
void Editor::MoveCaretInsideView() {
}
}
+int Editor::DisplayFromPosition(int pos) {
+ int lineDoc = pdoc->LineFromPosition(pos);
+ int lineDisplay = cs.DisplayFromDoc(lineDoc);
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ int posInLine = pos - posLineStart;
+ lineDisplay--; // To make up for first increment ahead.
+ for (int subLine=0; subLine<ll->lines; subLine++) {
+ if (posInLine >= ll->LineStart(subLine)) {
+ lineDisplay++;
+ }
+ }
+ }
+ llc.Dispose(ll);
+ return lineDisplay;
+}
+
void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
//Platform::DebugPrintf("EnsureCaretVisible %d %s\n", xOffset, useMargin ? " margin" : " ");
PRectangle rcClient = GetTextRectangle();
Point pt = LocationFromPosition(posCaret);
Point ptEOL = LocationFromPosition(pdoc->LineEndPosition(posCaret));
Point ptBottomCaret = pt;
- int lineCaret = cs.DisplayFromDoc(pdoc->LineFromPosition(posCaret));
+ int lineCaret = DisplayFromPosition(posCaret);
ptBottomCaret.y += vs.lineHeight - 1;
// Ensure the caret is reasonably visible in context:
// If we scroll the display, we use a minimum amount of xMargin.
int offsetLeft = rcClient.left + xMargin;
int offsetRight = rcClient.right - xMargin;
- // If we are in XJUMPS mode, then when the margin is reached, the
+ // If we are in XJUMPS mode, then when the margin is reached, the
// offset jumps so that it won't need to move agin for a while.
if (!(caretPolicy & CARET_XJUMPS)) {
rcClient.left = offsetLeft;
}
// Horizontal positioning
- if (horiz) {
+ if (horiz && (wrapState == eWrapNone)) {
int xOffsetNew = xOffset;
if (pt.x < rcClient.left) {
xOffsetNew = xOffset - (offsetLeft - pt.x);
}
void Editor::ShowCaretAtCurrentPosition() {
- if (!hasFocus) {
+ if (hasFocus) {
+ caret.active = true;
+ caret.on = true;
+ SetTicking(true);
+ } else {
caret.active = false;
caret.on = false;
- return;
}
- caret.active = true;
- caret.on = true;
- SetTicking(true);
+ InvalidateCaret();
}
void Editor::DropCaret() {
InvalidateRange(currentPos, currentPos + 1);
}
+void Editor::NeedWrapping(int docLineStartWrapping) {
+ docLineLastWrapped = docLineStartWrapping - 1;
+ if (docLineLastWrapped < -1)
+ docLineLastWrapped = -1;
+ llc.Invalidate(LineLayout::llPositions);
+}
+
+// Check if wrapping needed and perform any needed wrapping.
+// Return true if wrapping occurred.
+bool Editor::WrapLines() {
+ int goodTopLine = topLine;
+ bool wrapOccurred = false;
+ if (docLineLastWrapped < pdoc->LinesTotal()) {
+ if (wrapState == eWrapNone) {
+ if (wrapWidth != LineLayout::wrapWidthInfinite) {
+ wrapWidth = LineLayout::wrapWidthInfinite;
+ for (int lineDoc=0; lineDoc<pdoc->LinesTotal(); lineDoc++) {
+ cs.SetHeight(lineDoc, 1);
+ }
+ wrapOccurred = true;
+ }
+ docLineLastWrapped = 0x7ffffff;
+ } else {
+ ElapsedTime et;
+ int lineDocTop = cs.DocFromDisplay(topLine);
+ int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);
+ PRectangle rcTextArea = GetClientRectangle();
+ rcTextArea.left = vs.fixedColumnWidth;
+ rcTextArea.right -= vs.rightMarginWidth;
+ wrapWidth = rcTextArea.Width();
+ // Ensure all of the document is styled.
+ pdoc->EnsureStyledTo(pdoc->Length());
+ AutoSurface surface(IsUnicodeMode());
+ if (surface) {
+ int lastLineToWrap = pdoc->LinesTotal();
+ while (docLineLastWrapped <= lastLineToWrap) {
+ docLineLastWrapped++;
+ LineLayout *ll = RetrieveLineLayout(docLineLastWrapped);
+ int linesWrapped = 1;
+ if (ll) {
+ LayoutLine(docLineLastWrapped, surface, vs, ll, wrapWidth);
+ linesWrapped = ll->lines;
+ }
+ llc.Dispose(ll);
+ if (cs.SetHeight(docLineLastWrapped, linesWrapped)) {
+ wrapOccurred = true;
+ }
+ }
+ }
+ goodTopLine = cs.DisplayFromDoc(lineDocTop);
+ if (subLineTop < cs.GetHeight(lineDocTop))
+ goodTopLine += subLineTop;
+ else
+ goodTopLine += cs.GetHeight(lineDocTop);
+ double durWrap = et.Duration(true);
+ Platform::DebugPrintf("Wrap:%9.6g \n", durWrap);
+ }
+ }
+ if (wrapOccurred) {
+ SetScrollBars();
+ SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos()));
+ SetVerticalScrollPos();
+ }
+ return wrapOccurred;
+}
+
int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) {
if (vs.markers[markerCheck].markType == SC_MARK_EMPTY)
return markerDefault;
Surface *surface;
if (bufferedDraw) {
- surface = &pixmapSelMargin;
+ surface = pixmapSelMargin;
} else {
surface = surfWindow;
}
*/
if (vs.ms[margin].mask & SC_MASK_FOLDERS)
// Required because of special way brush is created for selection margin
- surface->FillRectangle(rcSelMargin, pixmapSelPattern);
+ surface->FillRectangle(rcSelMargin, *pixmapSelPattern);
else
surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated);
} else {
}
int visibleLine = topLine;
- int line = cs.DocFromDisplay(visibleLine);
int yposScreen = 0;
- // Work out whether the top line is whitespace located after a
+ // Work out whether the top line is whitespace located after a
// lessening of fold level which implies a 'fold tail' but which should not
// be displayed until the last of a sequence of whitespace.
- bool needWhiteClosure = false;
- int level = pdoc->GetLevel(line);
+ bool needWhiteClosure = false;
+ int level = pdoc->GetLevel(cs.DocFromDisplay(topLine));
if (level & SC_FOLDLEVELWHITEFLAG) {
- int lineBack = line;
+ int lineBack = cs.DocFromDisplay(topLine);
int levelPrev = level;
while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) {
lineBack--;
needWhiteClosure = true;
}
}
-
+
// Old code does not know about new markers needed to distinguish all cases
- int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
+ int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
SC_MARKNUM_FOLDEROPEN);
- int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
+ int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
SC_MARKNUM_FOLDER);
-
+
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
+ PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed());
+
+ int lineDoc = cs.DocFromDisplay(visibleLine);
+ PLATFORM_ASSERT(cs.GetVisible(lineDoc));
+ bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc);
+
// Decide which fold indicator should be displayed
- level = pdoc->GetLevel(line);
- int levelNext = pdoc->GetLevel(line+1);
- int marks = pdoc->GetMark(line);
+ level = pdoc->GetLevel(lineDoc);
+ int levelNext = pdoc->GetLevel(lineDoc+1);
+ int marks = pdoc->GetMark(lineDoc);
+ if (!firstSubLine)
+ marks = 0;
int levelNum = level & SC_FOLDLEVELNUMBERMASK;
int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
if (level & SC_FOLDLEVELHEADERFLAG) {
- if (cs.GetExpanded(line)) {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDEROPEN;
- else
- marks |= 1 << folderOpenMid;
+ if (firstSubLine) {
+ if (cs.GetExpanded(lineDoc)) {
+ if (levelNum == SC_FOLDLEVELBASE)
+ marks |= 1 << SC_MARKNUM_FOLDEROPEN;
+ else
+ marks |= 1 << folderOpenMid;
+ } else {
+ if (levelNum == SC_FOLDLEVELBASE)
+ marks |= 1 << SC_MARKNUM_FOLDER;
+ else
+ marks |= 1 << folderEnd;
+ }
} else {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDER;
- else
- marks |= 1 << folderEnd;
+ marks |= 1 << SC_MARKNUM_FOLDERSUB;
}
needWhiteClosure = false;
} else if (level & SC_FOLDLEVELWHITEFLAG) {
if (!vs.ms[margin].symbol) {
char number[100];
number[0] = '\0';
- sprintf(number, "%d", line + 1);
+ if (firstSubLine)
+ sprintf(number, "%d", lineDoc + 1);
if (foldFlags & 64)
- sprintf(number, "%X", pdoc->GetLevel(line));
+ sprintf(number, "%X", pdoc->GetLevel(lineDoc));
PRectangle rcNumber = rcMarker;
// Right justify
int width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, strlen(number));
int xpos = rcNumber.right - width - 3;
rcNumber.left = xpos;
- if ((visibleLine < cs.LinesDisplayed()) && cs.GetVisible(line)) {
- surface->DrawText(rcNumber, vs.styles[STYLE_LINENUMBER].font,
- rcNumber.top + vs.maxAscent, number, strlen(number),
- vs.styles[STYLE_LINENUMBER].fore.allocated,
- vs.styles[STYLE_LINENUMBER].back.allocated);
- }
+ surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
+ rcNumber.top + vs.maxAscent, number, strlen(number),
+ vs.styles[STYLE_LINENUMBER].fore.allocated,
+ vs.styles[STYLE_LINENUMBER].back.allocated);
}
if (marks) {
}
visibleLine++;
- line = cs.DocFromDisplay(visibleLine);
yposScreen += vs.lineHeight;
}
}
surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back.allocated);
if (bufferedDraw) {
- surfWindow->Copy(rcMargin, Point(), pixmapSelMargin);
+ surfWindow->Copy(rcMargin, Point(), *pixmapSelMargin);
}
}
void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {
int ydiff = (rcTab.bottom - rcTab.top) / 2;
int xhead = rcTab.right - 1 - ydiff;
+ if (xhead <= rcTab.left) {
+ ydiff -= rcTab.left - xhead - 1;
+ xhead = rcTab.left - 1;
+ }
if ((rcTab.left + 2) < (rcTab.right - 1))
surface->MoveTo(rcTab.left + 2, ymid);
else
surface->LineTo(xhead, ymid + ydiff);
}
+static bool IsSpaceOrTab(char ch) {
+ return ch == ' ' || ch == '\t';
+}
+
+LineLayout *Editor::RetrieveLineLayout(int lineNumber) {
+ int posLineStart = pdoc->LineStart(lineNumber);
+ int posLineEnd = pdoc->LineStart(lineNumber + 1);
+ int lineCaret = pdoc->LineFromPosition(currentPos);
+ return llc.Retrieve(lineNumber, lineCaret,
+ posLineEnd - posLineStart, pdoc->GetStyleClock(),
+ LinesOnScreen() + 1, pdoc->LinesTotal());
+}
+
/**
* Fill in the LineLayout data for the given line.
* Copy the given @a line and its styles from the document into local arrays.
* Also determine the x position at which each character starts.
*/
-void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll) {
- int numCharsInLine = 0;
+void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) {
+ if (!ll)
+ return;
int posLineStart = pdoc->LineStart(line);
- int posLineEnd = pdoc->LineStart(line + 1);
- Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;
- char styleByte = 0;
- int styleMask = pdoc->stylingBitsMask;
- ll.xHighlightGuide = 0;
- // If the line is very long, limit the treatment to a length that should fit in the viewport
- if (posLineEnd > (posLineStart + LineLayout::maxLineLength)) {
- posLineEnd = posLineStart + LineLayout::maxLineLength;
- }
- // Fill base line layout
- for (int charInDoc = posLineStart; charInDoc < posLineEnd; charInDoc++) {
- char chDoc = pdoc->CharAt(charInDoc);
- styleByte = pdoc->StyleAt(charInDoc);
- if (vstyle.viewEOL || ((chDoc != '\r') && (chDoc != '\n'))) {
- ll.chars[numCharsInLine] = chDoc;
- ll.styles[numCharsInLine] = static_cast<char>(styleByte & styleMask);
- ll.indicators[numCharsInLine] = static_cast<char>(styleByte & ~styleMask);
- if (vstyle.styles[ll.styles[numCharsInLine]].caseForce == Style::caseUpper)
- ll.chars[numCharsInLine] = static_cast<char>(toupper(chDoc));
- else if (vstyle.styles[ll.styles[numCharsInLine]].caseForce == Style::caseLower)
- ll.chars[numCharsInLine] = static_cast<char>(tolower(chDoc));
- numCharsInLine++;
- }
- }
- // Extra element at the end of the line to hold end x position and act as
- ll.chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character
- ll.styles[numCharsInLine] = styleByte; // For eolFilled
- ll.indicators[numCharsInLine] = 0;
-
- // Layout the line, determining the position of each character,
- // with an extra element at the end for the end of the line.
- int startseg = 0; // Start of the current segment, in char. number
- int startsegx = 0; // Start of the current segment, in pixels
- ll.positions[0] = 0;
- unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
- bool lastSegItalics = false;
-
- for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
- if ((ll.styles[charInLine] != ll.styles[charInLine + 1]) ||
- IsControlCharacter(ll.chars[charInLine]) || IsControlCharacter(ll.chars[charInLine + 1])) {
- ll.positions[startseg] = 0;
- if (vstyle.styles[ll.styles[charInLine]].visible) {
- if (IsControlCharacter(ll.chars[charInLine])) {
- if (ll.chars[charInLine] == '\t') {
- ll.positions[charInLine + 1] = ((((startsegx + 2) /
- tabWidth) + 1) * tabWidth) - startsegx;
- } else {
- const char *ctrlChar = ControlCharacterString(ll.chars[charInLine]);
- // +3 For a blank on front and rounded edge each side:
- ll.positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, ctrlChar, strlen(ctrlChar)) + 3;
+ if (ll->validity == LineLayout::llInvalid) {
+ ll->widthLine = LineLayout::wrapWidthInfinite;
+ ll->lines = 1;
+ int numCharsInLine = 0;
+ if (vstyle.edgeState == EDGE_BACKGROUND) {
+ ll->edgeColumn = pdoc->FindColumn(line, theEdge);
+ if (ll->edgeColumn >= posLineStart) {
+ ll->edgeColumn -= posLineStart;
+ }
+ } else {
+ ll->edgeColumn = -1;
+ }
+
+ int posLineEnd = pdoc->LineStart(line + 1);
+ Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;
+ char styleByte = 0;
+ int styleMask = pdoc->stylingBitsMask;
+ ll->xHighlightGuide = 0;
+ // If the line is very long, limit the treatment to a length that should fit in the viewport
+ if (posLineEnd > (posLineStart + ll->maxLineLength)) {
+ posLineEnd = posLineStart + ll->maxLineLength;
+ }
+ // Fill base line layout
+ for (int charInDoc = posLineStart; charInDoc < posLineEnd; charInDoc++) {
+ char chDoc = pdoc->CharAt(charInDoc);
+ styleByte = pdoc->StyleAt(charInDoc);
+ if (vstyle.viewEOL || ((chDoc != '\r') && (chDoc != '\n'))) {
+ ll->chars[numCharsInLine] = chDoc;
+ ll->styles[numCharsInLine] = static_cast<char>(styleByte & styleMask);
+ ll->indicators[numCharsInLine] = static_cast<char>(styleByte & ~styleMask);
+ if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper)
+ ll->chars[numCharsInLine] = static_cast<char>(toupper(chDoc));
+ else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower)
+ ll->chars[numCharsInLine] = static_cast<char>(tolower(chDoc));
+ numCharsInLine++;
+ }
+ }
+ // Extra element at the end of the line to hold end x position and act as
+ ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character
+ ll->styles[numCharsInLine] = styleByte; // For eolFilled
+ ll->indicators[numCharsInLine] = 0;
+
+ // Layout the line, determining the position of each character,
+ // with an extra element at the end for the end of the line.
+ int startseg = 0; // Start of the current segment, in char. number
+ int startsegx = 0; // Start of the current segment, in pixels
+ ll->positions[0] = 0;
+ unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
+ bool lastSegItalics = false;
+
+ for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
+ if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) ||
+ IsControlCharacter(ll->chars[charInLine]) || IsControlCharacter(ll->chars[charInLine + 1])) {
+ ll->positions[startseg] = 0;
+ if (vstyle.styles[ll->styles[charInLine]].visible) {
+ if (IsControlCharacter(ll->chars[charInLine])) {
+ if (ll->chars[charInLine] == '\t') {
+ ll->positions[charInLine + 1] = ((((startsegx + 2) /
+ tabWidth) + 1) * tabWidth) - startsegx;
+ } else if (controlCharSymbol < 32) {
+ const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
+ // +3 For a blank on front and rounded edge each side:
+ ll->positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, ctrlChar, strlen(ctrlChar)) + 3;
+ } else {
+ char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
+ surface->MeasureWidths(ctrlCharsFont, cc, 1,
+ ll->positions + startseg + 1);
+ }
+ lastSegItalics = false;
+ } else { // Regular character
+ lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic;
+ int lenSeg = charInLine - startseg + 1;
+ if ((lenSeg == 1) && (' ' == ll->chars[startseg])) {
+ // Over half the segments are single characters and of these about half are space characters.
+ ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth;
+ } else {
+ surface->MeasureWidths(vstyle.styles[ll->styles[charInLine]].font, ll->chars + startseg,
+ lenSeg, ll->positions + startseg + 1);
+ }
}
- lastSegItalics = false;
- } else { // Regular character
- lastSegItalics = vstyle.styles[ll.styles[charInLine]].italic;
- int lenSeg = charInLine - startseg + 1;
- if ((lenSeg == 1) && (' ' == ll.chars[startseg])) {
- // Over half the segments are single characters and of these about half are space characters.
- ll.positions[charInLine + 1] = vstyle.styles[ll.styles[charInLine]].spaceWidth;
- } else {
- surface->MeasureWidths(vstyle.styles[ll.styles[charInLine]].font, ll.chars + startseg,
- lenSeg, ll.positions + startseg + 1);
+ } else { // invisible
+ for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) {
+ ll->positions[posToZero] = 0;
}
}
- } else { // invisible
- for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) {
- ll.positions[posToZero] = 0;
+ for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) {
+ ll->positions[posToIncrease] += startsegx;
}
+ startsegx = ll->positions[charInLine + 1];
+ startseg = charInLine + 1;
}
- for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) {
- ll.positions[posToIncrease] += startsegx;
- }
- startsegx = ll.positions[charInLine + 1];
- startseg = charInLine + 1;
}
+ // Small hack to make lines that end with italics not cut off the edge of the last character
+ if ((startseg > 0) && lastSegItalics) {
+ ll->positions[startseg] += 2;
+ }
+ ll->numCharsInLine = numCharsInLine;
+ ll->validity = LineLayout::llPositions;
+ }
+ // Hard to cope when too narrow, so just assume there is space
+ if (width < 20) {
+ width = 20;
}
- // Small hack to make lines that end with italics not cut off the edge of the last character
- if ((startseg > 0) && lastSegItalics) {
- ll.positions[startseg] += 2;
+ if ((ll->validity == LineLayout::llPositions) || (ll->widthLine != width)) {
+ ll->widthLine = width;
+ if (width == LineLayout::wrapWidthInfinite) {
+ ll->lines = 1;
+ } else {
+ ll->lines = 0;
+ // Calculate line start positions based upon width.
+ // For now this is simplistic - wraps on byte rather than character and
+ // in the middle of words. Should search for spaces or style changes.
+ int lastGoodBreak = 0;
+ int lastLineStart = 0;
+ int startOffset = 0;
+ int p=0;
+ while (p < ll->numCharsInLine) {
+ if ((ll->positions[p+1] - startOffset) >= width) {
+ if (lastGoodBreak == lastLineStart) {
+ // Try moving to start of last character
+ if (p > 0) {
+ lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
+ - posLineStart;
+ }
+ if (lastGoodBreak == lastLineStart) {
+ // Ensure at least one character on line.
+ lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart +1, 1)
+ - posLineStart;
+ }
+ }
+ lastLineStart = lastGoodBreak;
+ ll->lines++;
+ ll->SetLineStart(ll->lines, lastGoodBreak);
+ startOffset = ll->positions[lastGoodBreak];
+ p = lastGoodBreak + 1;
+ continue;
+ }
+ if (p > 0) {
+ if (ll->styles[p] != ll->styles[p-1]) {
+ lastGoodBreak = p;
+ } else if (IsSpaceOrTab(ll->chars[p-1]) && !IsSpaceOrTab(ll->chars[p])) {
+ lastGoodBreak = p;
+ }
+ }
+ p++;
+ }
+ ll->lines++;
+ }
+ ll->validity = LineLayout::llLines;
}
- ll.numCharsInLine = numCharsInLine;
}
void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
- PRectangle rcLine, LineLayout &ll) {
+ PRectangle rcLine, LineLayout *ll, int subLine) {
PRectangle rcSegment = rcLine;
// is taken by an individual character - internal leading gives varying results.
Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font;
+ // See if something overrides the line background color: Either if caret is on the line
+ // and background color is set for that, or if a marker is defined that forces its background
+ // color onto the line, or if a marker is defined but has no selection margin in which to
+ // display itself. These are checked in order with the earlier taking precedence. When
+ // multiple markers cause background override, the color for the highest numbered one is used.
bool overrideBackground = false;
- Colour background = Colour(0, 0, 0);
- if (caret.active && vsDraw.showCaretLineBackground && ll.containsCaret) {
+ ColourAllocated background;
+ if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) {
overrideBackground = true;
background = vsDraw.caretLineBackground.allocated;
}
- if (vsDraw.maskInLine) {
- int marks = pdoc->GetMark(line) & vsDraw.maskInLine;
- if (marks) {
- overrideBackground = true;
- for (int markBit = 0; (markBit < 32) && marks; markBit++) {
- if (marks & 1) {
- background = vsDraw.markers[markBit].back.allocated;
+ if (!overrideBackground) {
+ int marks = pdoc->GetMark(line);
+ for (int markBit = 0; (markBit < 32) && marks; markBit++) {
+ if ((marks & 1) && vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) {
+ background = vsDraw.markers[markBit].back.allocated;
+ overrideBackground = true;
+ }
+ marks >>= 1;
+ }
+ }
+ if (!overrideBackground) {
+ if (vsDraw.maskInLine) {
+ int marks = pdoc->GetMark(line) & vsDraw.maskInLine;
+ if (marks) {
+ overrideBackground = true;
+ for (int markBit = 0; (markBit < 32) && marks; markBit++) {
+ if (marks & 1) {
+ background = vsDraw.markers[markBit].back.allocated;
+ }
+ marks >>= 1;
}
- marks >>= 1;
}
}
}
- bool inIndentation = true;
+ bool inIndentation = subLine == 0; // Do not handle indentation except on first subline.
int indentWidth = pdoc->indentInChars * vsDraw.spaceWidth;
if (indentWidth == 0)
indentWidth = pdoc->tabInChars * vsDraw.spaceWidth;
int posLineEnd = pdoc->LineStart(line + 1);
int styleMask = pdoc->stylingBitsMask;
- int startseg = 0;
- for (int i = 0; i < ll.numCharsInLine; i++) {
+ int startseg = ll->LineStart(subLine);
+ int subLineStart = ll->positions[startseg];
+ int lineStart = 0;
+ int lineEnd = 0;
+ if (subLine < ll->lines) {
+ lineStart = ll->LineStart(subLine);
+ lineEnd = ll->LineStart(subLine+1);
+ }
+ for (int i = lineStart; i < lineEnd; i++) {
int iDoc = i + posLineStart;
// If there is the end of a style run for any reason
- if ((ll.styles[i] != ll.styles[i + 1]) ||
- IsControlCharacter(ll.chars[i]) || IsControlCharacter(ll.chars[i + 1]) ||
- ((ll.selStart != ll.selEnd) && ((iDoc + 1 == ll.selStart) || (iDoc + 1 == ll.selEnd))) ||
- (i == (ll.edgeColumn - 1))) {
- int styleMain = ll.styles[i];
- Colour textBack = vsDraw.styles[styleMain].back.allocated;
- Colour textFore = vsDraw.styles[styleMain].fore.allocated;
- Font &textFont = vsDraw.styles[styleMain].font;
- bool inSelection = (iDoc >= ll.selStart) && (iDoc < ll.selEnd) && (ll.selStart != ll.selEnd);
- if (inSelection) {
- if (vsDraw.selbackset) {
- if (primarySelection)
- textBack = vsDraw.selbackground.allocated;
- else
- textBack = vsDraw.selbackground2.allocated;
- }
- if (vsDraw.selforeset)
- textFore = vsDraw.selforeground.allocated;
- } else {
- if (overrideBackground)
- textBack = background;
- if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll.edgeColumn) && (ll.chars[i] != '\n') && (ll.chars[i] != '\r'))
- textBack = vsDraw.edgecolour.allocated;
- }
- // Manage tab display
- if (ll.chars[i] == '\t') {
- rcSegment.left = ll.positions[i] + xStart;
- rcSegment.right = ll.positions[i + 1] + xStart;
- surface->FillRectangle(rcSegment, textBack);
- if ((vsDraw.viewWhitespace != wsInvisible) || ((inIndentation && vsDraw.viewIndentationGuides))) {
- surface->PenColour(textFore);
+ if ((ll->styles[i] != ll->styles[i + 1]) ||
+ i == (lineEnd-1) ||
+ IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) ||
+ ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) ||
+ (i == (ll->edgeColumn - 1))) {
+ rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
+ rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+ // Only try to draw if really visible - enhances performance by not calling environment to
+ // draw strings that are completely past the right side of the window.
+ //if (rcSegment.left <= rcLine.right) {
+ if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+ int styleMain = ll->styles[i];
+ ColourAllocated textBack = vsDraw.styles[styleMain].back.allocated;
+ ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+ Font &textFont = vsDraw.styles[styleMain].font;
+ bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
+ if (inSelection) {
+ if (vsDraw.selbackset) {
+ if (primarySelection)
+ textBack = vsDraw.selbackground.allocated;
+ else
+ textBack = vsDraw.selbackground2.allocated;
+ }
+ if (vsDraw.selforeset)
+ textFore = vsDraw.selforeground.allocated;
+ } else {
+ if (overrideBackground)
+ textBack = background;
+ if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll->edgeColumn) && (ll->chars[i] != '\n') && (ll->chars[i] != '\r'))
+ textBack = vsDraw.edgecolour.allocated;
}
- if (inIndentation && vsDraw.viewIndentationGuides) {
- for (int xIG = ll.positions[i] / indentWidth * indentWidth; xIG < ll.positions[i + 1]; xIG += indentWidth) {
- if (xIG >= ll.positions[i] && xIG > 0) {
- Point from(0, ((lineVisible & 1) && (vsDraw.lineHeight & 1)) ? 1 : 0);
- PRectangle rcCopyArea(xIG + xStart + 1, rcSegment.top, xIG + xStart + 2, rcSegment.bottom);
- surface->Copy(rcCopyArea, from, (ll.xHighlightGuide == xIG) ?
- pixmapIndentGuideHighlight : pixmapIndentGuide);
+ if (ll->chars[i] == '\t') {
+ // Manage tab display
+ surface->FillRectangle(rcSegment, textBack);
+ if ((vsDraw.viewWhitespace != wsInvisible) || ((inIndentation && vsDraw.viewIndentationGuides))) {
+ surface->PenColour(textFore);
+ }
+ if (inIndentation && vsDraw.viewIndentationGuides) {
+ for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) {
+ if (xIG >= ll->positions[i] && xIG > 0) {
+ Point from(0, ((lineVisible & 1) && (vsDraw.lineHeight & 1)) ? 1 : 0);
+ PRectangle rcCopyArea(xIG + xStart + 1, rcSegment.top, xIG + xStart + 2, rcSegment.bottom);
+ surface->Copy(rcCopyArea, from, (ll->xHighlightGuide == xIG) ?
+ *pixmapIndentGuideHighlight : *pixmapIndentGuide);
+ }
}
}
- }
- if (vsDraw.viewWhitespace != wsInvisible) {
- if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
- rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
- DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ if (vsDraw.viewWhitespace != wsInvisible) {
+ if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+ PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
+ rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
+ DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ }
}
- }
- // Manage control character display
- }
- else if (IsControlCharacter(ll.chars[i])) {
- inIndentation = false;
- const char *ctrlChar = ControlCharacterString(ll.chars[i]);
- rcSegment.left = ll.positions[i] + xStart;
- rcSegment.right = ll.positions[i + 1] + xStart;
- surface->FillRectangle(rcSegment, textBack);
- int normalCharHeight = surface->Ascent(ctrlCharsFont) -
- surface->InternalLeading(ctrlCharsFont);
- PRectangle rcCChar = rcSegment;
- rcCChar.left = rcCChar.left + 1;
- rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
- rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1;
- PRectangle rcCentral = rcCChar;
- rcCentral.top++;
- rcCentral.bottom--;
- surface->FillRectangle(rcCentral, textFore);
- PRectangle rcChar = rcCChar;
- rcChar.left++;
- rcChar.right--;
- surface->DrawTextClipped(rcChar, ctrlCharsFont,
- rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar),
- textBack, textFore);
- // Manage normal display
- }
- else {
- rcSegment.left = ll.positions[startseg] + xStart;
- rcSegment.right = ll.positions[i + 1] + xStart;
- // Only try to draw if really visible - enhances performance by not calling environment to
- // draw strings that are completely past the right side of the window.
- if (rcSegment.left <= rcLine.right) {
- surface->DrawText(rcSegment, textFont,
- rcSegment.top + vsDraw.maxAscent, ll.chars + startseg,
+ } else if (IsControlCharacter(ll->chars[i])) {
+ // Manage control character display
+ inIndentation = false;
+ if (controlCharSymbol < 32) {
+ // Draw the character
+ const char *ctrlChar = ControlCharacterString(ll->chars[i]);
+ surface->FillRectangle(rcSegment, textBack);
+ int normalCharHeight = surface->Ascent(ctrlCharsFont) -
+ surface->InternalLeading(ctrlCharsFont);
+ PRectangle rcCChar = rcSegment;
+ rcCChar.left = rcCChar.left + 1;
+ rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
+ rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1;
+ PRectangle rcCentral = rcCChar;
+ rcCentral.top++;
+ rcCentral.bottom--;
+ surface->FillRectangle(rcCentral, textFore);
+ PRectangle rcChar = rcCChar;
+ rcChar.left++;
+ rcChar.right--;
+ surface->DrawTextClipped(rcChar, ctrlCharsFont,
+ rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar),
+ textBack, textFore);
+ } else {
+ char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
+ surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
+ rcSegment.top + vsDraw.maxAscent,
+ cc, 1, textBack, textFore);
+ }
+ } else {
+ // Manage normal display
+ surface->DrawTextNoClip(rcSegment, textFont,
+ rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
i - startseg + 1, textFore, textBack);
if (vsDraw.viewWhitespace != wsInvisible ||
(inIndentation && vsDraw.viewIndentationGuides)) {
for (int cpos = 0; cpos <= i - startseg; cpos++) {
- if (ll.chars[cpos + startseg] == ' ') {
+ if (ll->chars[cpos + startseg] == ' ') {
if (vsDraw.viewWhitespace != wsInvisible) {
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- int xmid = (ll.positions[cpos + startseg] + ll.positions[cpos + startseg + 1]) / 2;
- PRectangle rcDot(xmid + xStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
+ int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
+ PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
rcDot.right = rcDot.left + 1;
rcDot.bottom = rcDot.top + 1;
surface->FillRectangle(rcDot, textFore);
}
}
if (inIndentation && vsDraw.viewIndentationGuides) {
- int startSpace = ll.positions[cpos + startseg];
+ int startSpace = ll->positions[cpos + startseg];
if (startSpace > 0 && (startSpace % indentWidth == 0)) {
Point from(0, ((lineVisible & 1) && (vsDraw.lineHeight & 1)) ? 1 : 0);
PRectangle rcCopyArea(startSpace + xStart + 1, rcSegment.top, startSpace + xStart + 2, rcSegment.bottom);
- surface->Copy(rcCopyArea, from, (ll.xHighlightGuide == ll.positions[cpos + startseg]) ?
- pixmapIndentGuideHighlight : pixmapIndentGuide);
+ surface->Copy(rcCopyArea, from, (ll->xHighlightGuide == ll->positions[cpos + startseg]) ?
+ *pixmapIndentGuideHighlight : *pixmapIndentGuide);
}
}
} else {
for (int indica = 0; indica <= INDIC_MAX; indica++)
indStart[indica] = 0;
- for (int indicPos = 0; indicPos < ll.numCharsInLine; indicPos++) {
- if (ll.indicators[indicPos] != ll.indicators[indicPos + 1]) {
+ for (int indicPos = 0; indicPos < ll->numCharsInLine; indicPos++) {
+ if (ll->indicators[indicPos] != ll->indicators[indicPos + 1]) {
int mask = 1 << pdoc->stylingBits;
for (int indicnum = 0; mask < 0x100; indicnum++) {
- if ((ll.indicators[indicPos + 1] & mask) && !(ll.indicators[indicPos] & mask)) {
- indStart[indicnum] = ll.positions[indicPos + 1];
+ if ((ll->indicators[indicPos + 1] & mask) && !(ll->indicators[indicPos] & mask)) {
+ indStart[indicnum] = ll->positions[indicPos + 1];
}
- if (!(ll.indicators[indicPos + 1] & mask) && (ll.indicators[indicPos] & mask)) {
+ if (!(ll->indicators[indicPos + 1] & mask) && (ll->indicators[indicPos] & mask)) {
PRectangle rcIndic(
indStart[indicnum] + xStart,
rcLine.top + vsDraw.maxAscent,
- ll.positions[indicPos + 1] + xStart,
+ ll->positions[indicPos + 1] + xStart,
rcLine.top + vsDraw.maxAscent + 3);
vsDraw.indicators[indicnum].Draw(surface, rcIndic);
}
// End of the drawing of the current line
// Fill in a PRectangle representing the end of line characters
- int xEol = ll.positions[ll.numCharsInLine];
+ int xEol = ll->positions[lineEnd] - subLineStart;
rcSegment.left = xEol + xStart;
rcSegment.right = xEol + vsDraw.aveCharWidth + xStart;
- bool eolInSelection = (posLineEnd > ll.selStart) && (posLineEnd <= ll.selEnd) && (ll.selStart != ll.selEnd);
+ bool eolInSelection = (subLine == (ll->lines-1)) &&
+ (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd);
if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
if (primarySelection)
surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated);
} else if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
} else {
- surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
}
rcSegment.left = xEol + vsDraw.aveCharWidth + xStart;
rcSegment.right = rcLine.right;
if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
- } else if (vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].eolFilled) {
- surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated);
+ } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
+ surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
} else {
surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
}
if (vsDraw.edgeState == EDGE_LINE) {
- int edgeX = ll.edgeColumn * vsDraw.spaceWidth;
+ int edgeX = theEdge * vsDraw.spaceWidth;
rcSegment.left = edgeX + xStart;
rcSegment.right = rcSegment.left + 1;
surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n",
// rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
- if (!pixmapSelPattern.Initialised()) {
- pixmapSelPattern.InitPixMap(8, 8, surfaceWindow);
+ if (WrapLines()) {
+ // The wrapping process has changed the height of some lines so abandon this
+ // paint for a complete repaint.
+ paintState = paintAbandoned;
+ return;
+ }
+
+ if (!pixmapSelPattern->Initialised()) {
+ pixmapSelPattern->InitPixMap(8, 8, surfaceWindow);
// This complex procedure is to reproduce the checker board dithered pattern used by windows
// for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half
// way between the chrome colour and the chrome highlight colour making a nice transition
// between the window chrome and the content area. And it works in low colour depths.
PRectangle rcPattern(0, 0, 8, 8);
- if (vs.selbarlight.desired == Colour(0xff, 0xff, 0xff)) {
- pixmapSelPattern.FillRectangle(rcPattern, vs.selbar.allocated);
- pixmapSelPattern.PenColour(vs.selbarlight.allocated);
+ if (vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff)) {
+ pixmapSelPattern->FillRectangle(rcPattern, vs.selbar.allocated);
+ pixmapSelPattern->PenColour(vs.selbarlight.allocated);
for (int stripe = 0; stripe < 8; stripe++) {
- pixmapSelPattern.MoveTo(0, stripe * 2);
- pixmapSelPattern.LineTo(8, stripe * 2 - 8);
+ pixmapSelPattern->MoveTo(0, stripe * 2);
+ pixmapSelPattern->LineTo(8, stripe * 2 - 8);
}
} else {
// User has chosen an unusual chrome colour scheme so just use the highlight edge colour.
- pixmapSelPattern.FillRectangle(rcPattern, vs.selbarlight.allocated);
+ pixmapSelPattern->FillRectangle(rcPattern, vs.selbarlight.allocated);
}
}
- if (!pixmapIndentGuide.Initialised()) {
+ if (!pixmapIndentGuide->Initialised()) {
// 1 extra pixel in height so can handle odd/even positions and so produce a continuous line
- pixmapIndentGuide.InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
- pixmapIndentGuideHighlight.InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
+ pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
+ pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
PRectangle rcIG(0, 0, 1, vs.lineHeight);
- pixmapIndentGuide.FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back.allocated);
- pixmapIndentGuide.PenColour(vs.styles[STYLE_INDENTGUIDE].fore.allocated);
- pixmapIndentGuideHighlight.FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated);
- pixmapIndentGuideHighlight.PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated);
+ pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back.allocated);
+ pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore.allocated);
+ pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated);
+ pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated);
for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) {
- pixmapIndentGuide.MoveTo(0, stripe);
- pixmapIndentGuide.LineTo(2, stripe);
- pixmapIndentGuideHighlight.MoveTo(0, stripe);
- pixmapIndentGuideHighlight.LineTo(2, stripe);
+ pixmapIndentGuide->MoveTo(0, stripe);
+ pixmapIndentGuide->LineTo(2, stripe);
+ pixmapIndentGuideHighlight->MoveTo(0, stripe);
+ pixmapIndentGuideHighlight->LineTo(2, stripe);
}
}
if (bufferedDraw) {
- if (!pixmapLine.Initialised()) {
- pixmapLine.InitPixMap(rcClient.Width(), rcClient.Height(),
+ if (!pixmapLine->Initialised()) {
+ pixmapLine->InitPixMap(rcClient.Width(), rcClient.Height(),
surfaceWindow);
- pixmapSelMargin.InitPixMap(vs.fixedColumnWidth,
+ pixmapSelMargin->InitPixMap(vs.fixedColumnWidth,
rcClient.Height(), surfaceWindow);
}
}
surfaceWindow->SetPalette(&palette, true);
- pixmapLine.SetPalette(&palette, !hasFocus);
+ pixmapLine->SetPalette(&palette, !hasFocus);
//Platform::DebugPrintf("Paint: (%3d,%3d) ... (%3d,%3d)\n",
// rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
// Ensure we are styled as far as we are painting.
pdoc->EnsureStyledTo(endPosPaint);
-
+ bool paintAbandonedByStyling = paintState == paintAbandoned;
if (needUpdateUI) {
NotifyUpdateUI();
needUpdateUI = false;
// Either styling or NotifyUpdateUI noticed that painting is needed
// outside the current painting rectangle
//Platform::DebugPrintf("Abandoning paint\n");
+ if (wrapState != eWrapNone) {
+ if (paintAbandonedByStyling) {
+ // Styling has spilled over a line end, such as occurs by starting a multiline
+ // comment. The width of subsequent text may have changed, so rewrap.
+ NeedWrapping(cs.DocFromDisplay(topLine));
+ }
+ }
return;
}
//Platform::DebugPrintf("start display %d, offset = %d\n", pdoc->Length(), xOffset);
Surface *surface = surfaceWindow;
if (bufferedDraw) {
- surface = &pixmapLine;
+ surface = pixmapLine;
}
- surface->SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
+ surface->SetUnicodeMode(IsUnicodeMode());
int visibleLine = topLine + screenLinePaintFirst;
- int line = cs.DocFromDisplay(visibleLine);
int posCaret = currentPos;
if (posDrag >= 0)
surfaceWindow->SetClip(rcTextArea);
// Loop on visible lines
- //GTimer *tim=g_timer_new();
+ //double durLayout = 0.0;
+ //double durPaint = 0.0;
+ //double durCopy = 0.0;
+ //ElapsedTime etWhole;
+ int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times
+ LineLayout *ll = 0;
while (visibleLine < cs.LinesDisplayed() && yposScreen < rcArea.bottom) {
- //g_timer_start(tim);
+
+ int lineDoc = cs.DocFromDisplay(visibleLine);
//Platform::DebugPrintf("Painting line %d\n", line);
+ // Only visible lines should be handled by the code within the loop
+ PLATFORM_ASSERT(cs.GetVisible(lineDoc));
+ int lineStartSet = cs.DisplayFromDoc(lineDoc);
+ int subLine = visibleLine - lineStartSet;
// Copy this line and its styles from the document into local arrays
// and determine the x position at which each character starts.
- LineLayout ll;
- LayoutLine(line, surface, vs, ll);
-
- ll.selStart = SelectionStart(line);
- ll.selEnd = SelectionEnd(line);
- ll.containsCaret = line == lineCaret;
- if (hideSelection) {
- ll.selStart = -1;
- ll.selEnd = -1;
- ll.containsCaret = false;
+ //ElapsedTime et;
+ if (lineDoc != lineDocPrevious) {
+ llc.Dispose(ll);
+ ll = RetrieveLineLayout(lineDoc);
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ lineDocPrevious = lineDoc;
}
- // Need to fix this up so takes account of Unicode and DBCS
- ll.edgeColumn = theEdge;
-
- int posLineStart = pdoc->LineStart(line);
- int posLineEnd = pdoc->LineStart(line + 1);
- //Platform::DebugPrintf("line %d %d - %d\n", line, posLineStart, posLineEnd);
-
- PRectangle rcLine = rcClient;
- rcLine.top = ypos;
- rcLine.bottom = ypos + vs.lineHeight;
-
- // Highlight the current braces if any
- if ((braces[0] >= posLineStart) && (braces[0] < posLineEnd)) {
- int braceOffset = braces[0] - posLineStart;
- if (braceOffset < ll.numCharsInLine)
- ll.styles[braceOffset] = static_cast<char>(bracesMatchStyle);
- }
- if ((braces[1] >= posLineStart) && (braces[1] < posLineEnd)) {
- int braceOffset = braces[1] - posLineStart;
- if (braceOffset < ll.numCharsInLine)
- ll.styles[braceOffset] = static_cast<char>(bracesMatchStyle);
- }
- if ((braces[0] >= posLineStart && braces[1] <= posLineEnd) ||
- (braces[1] >= posLineStart && braces[0] <= posLineEnd)) {
- ll.xHighlightGuide = highlightGuideColumn * vs.spaceWidth;
- }
-
- // Draw the line
- if (cs.GetVisible(line))
- DrawLine(surface, vs, line, visibleLine, xStart, rcLine, ll);
-
- bool expanded = cs.GetExpanded(line);
- if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
- if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
- PRectangle rcFoldLine = rcLine;
- rcFoldLine.bottom = rcFoldLine.top + 1;
- surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ //durLayout += et.Duration(true);
+
+ if (ll) {
+ ll->selStart = SelectionStart(lineDoc);
+ ll->selEnd = SelectionEnd(lineDoc);
+ ll->containsCaret = lineDoc == lineCaret;
+ if (hideSelection) {
+ ll->selStart = -1;
+ ll->selEnd = -1;
+ ll->containsCaret = false;
}
- }
- if ( (expanded && (foldFlags & 8)) || (!expanded && (foldFlags & 16)) ) {
- if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
- PRectangle rcFoldLine = rcLine;
- rcFoldLine.top = rcFoldLine.bottom - 1;
- surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+
+ PRectangle rcLine = rcClient;
+ rcLine.top = ypos;
+ rcLine.bottom = ypos + vs.lineHeight;
+
+ Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1));
+ // Highlight the current braces if any
+ ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle),
+ highlightGuideColumn * vs.spaceWidth);
+
+ // Draw the line
+ DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine);
+ //durPaint += et.Duration(true);
+
+ // Restore the precvious styles for the brace highlights in case layout is in cache.
+ ll->RestoreBracesHighlight(rangeLine, braces);
+
+ bool expanded = cs.GetExpanded(lineDoc);
+ if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
+ if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) {
+ PRectangle rcFoldLine = rcLine;
+ rcFoldLine.bottom = rcFoldLine.top + 1;
+ surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ }
}
- }
-
- // Draw the Caret
- if (line == lineCaret) {
- int offset = Platform::Minimum(posCaret - posLineStart, LineLayout::maxLineLength);
- int xposCaret = ll.positions[offset] + xStart;
- int widthOverstrikeCaret;
- if (posCaret == pdoc->Length()) { // At end of document
- widthOverstrikeCaret = vs.aveCharWidth;
- } else if ((posCaret - posLineStart) >= ll.numCharsInLine) { // At end of line
- widthOverstrikeCaret = vs.aveCharWidth;
- } else {
- widthOverstrikeCaret = ll.positions[offset + 1] - ll.positions[offset];
+ if ( (expanded && (foldFlags & 8)) || (!expanded && (foldFlags & 16)) ) {
+ if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) {
+ PRectangle rcFoldLine = rcLine;
+ rcFoldLine.top = rcFoldLine.bottom - 1;
+ surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ }
}
- if (widthOverstrikeCaret < 3) // Make sure its visible
- widthOverstrikeCaret = 3;
- if (((caret.active && caret.on) || (posDrag >= 0)) && xposCaret >= 0) {
- PRectangle rcCaret = rcLine;
- int caretWidthOffset = 0;
- if ((offset > 0) && (vs.caretWidth > 1))
- caretWidthOffset = 1; // Move back so overlaps both character cells.
- if (posDrag >= 0) {
- rcCaret.left = xposCaret - caretWidthOffset;
- rcCaret.right = rcCaret.left + vs.caretWidth;
- } else {
- if (inOverstrike) {
- rcCaret.top = rcCaret.bottom - 2;
- rcCaret.left = xposCaret + 1;
- rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+
+ // Draw the Caret
+ if (lineDoc == lineCaret) {
+ int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength);
+ if ((offset >= ll->LineStart(subLine)) &&
+ ((offset < ll->LineStart(subLine+1)) || offset == ll->numCharsInLine)) {
+ int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
+ int widthOverstrikeCaret;
+ if (posCaret == pdoc->Length()) { // At end of document
+ widthOverstrikeCaret = vs.aveCharWidth;
+ } else if ((posCaret - rangeLine.start) >= ll->numCharsInLine) { // At end of line
+ widthOverstrikeCaret = vs.aveCharWidth;
} else {
- rcCaret.left = xposCaret - caretWidthOffset;
- rcCaret.right = rcCaret.left + vs.caretWidth;
+ widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset];
+ }
+ if (widthOverstrikeCaret < 3) // Make sure its visible
+ widthOverstrikeCaret = 3;
+ if (((caret.active && caret.on) || (posDrag >= 0)) && xposCaret >= 0) {
+ PRectangle rcCaret = rcLine;
+ int caretWidthOffset = 0;
+ if ((offset > 0) && (vs.caretWidth > 1))
+ caretWidthOffset = 1; // Move back so overlaps both character cells.
+ if (posDrag >= 0) {
+ rcCaret.left = xposCaret - caretWidthOffset;
+ rcCaret.right = rcCaret.left + vs.caretWidth;
+ } else {
+ if (inOverstrike) {
+ rcCaret.top = rcCaret.bottom - 2;
+ rcCaret.left = xposCaret + 1;
+ rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+ } else {
+ rcCaret.left = xposCaret - caretWidthOffset;
+ rcCaret.right = rcCaret.left + vs.caretWidth;
+ }
+ }
+ surface->FillRectangle(rcCaret, vs.caretcolour.allocated);
}
}
- surface->FillRectangle(rcCaret, vs.caretcolour.allocated);
}
- }
-
- if (cs.GetVisible(line)) {
+
if (bufferedDraw) {
Point from(vs.fixedColumnWidth, 0);
PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen,
- rcClient.right, yposScreen + vs.lineHeight);
- surfaceWindow->Copy(rcCopyArea, from, pixmapLine);
+ rcClient.right, yposScreen + vs.lineHeight);
+ surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
}
+ //durCopy += et.Duration(true);
}
-
+
if (!bufferedDraw) {
ypos += vs.lineHeight;
}
yposScreen += vs.lineHeight;
visibleLine++;
- line = cs.DocFromDisplay(visibleLine);
//gdk_flush();
- //g_timer_stop(tim);
- //Platform::DebugPrintf("Paint [%0d] took %g\n", line, g_timer_elapsed(tim, 0));
}
- //g_timer_destroy(tim);
+ llc.Dispose(ll);
+ //if (durPaint < 0.00000001)
+ // durPaint = 0.00000001;
// Right column limit indicator
-
-
-
PRectangle rcBeyondEOF = rcClient;
rcBeyondEOF.left = vs.fixedColumnWidth;
rcBeyondEOF.right = rcBeyondEOF.right;
surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour.allocated);
}
}
+ //Platform::DebugPrintf(
+ //"Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n",
+ //durLayout, durPaint, durLayout / durPaint, durCopy, etWhole.Duration());
NotifyPainted();
}
}
// Space (3 space characters) between line numbers and text when printing.
#define lineNumberPrintSpace " "
-Colour InvertedLight(Colour orig) {
+ColourDesired InvertedLight(ColourDesired orig) {
unsigned int r = orig.GetRed();
unsigned int g = orig.GetGreen();
unsigned int b = orig.GetBlue();
unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye
unsigned int il = 0xff - l;
if (l == 0)
- return Colour(0xff, 0xff, 0xff);
+ return ColourDesired(0xff, 0xff, 0xff);
r = r * il / l;
g = g * il / l;
b = b * il / l;
- return Colour(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff));
+ return ColourDesired(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff));
}
// This is mostly copied from the Paint method but with some things omitted
if (!pfr)
return 0;
- Surface *surface = new Surface();
- surface->Init(pfr->hdc);
- surface->SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- Surface *surfaceMeasure = new Surface();
- surfaceMeasure->Init(pfr->hdcTarget);
- surfaceMeasure->SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
+ AutoSurface surface(pfr->hdc, IsUnicodeMode());
+ if (!surface)
+ return 0;
+ AutoSurface surfaceMeasure(pfr->hdcTarget, IsUnicodeMode());
+ if (!surfaceMeasure) {
+ return 0;
+ }
ViewStyle vsPrint(vs);
vsPrint.styles[sty].fore.desired = InvertedLight(vsPrint.styles[sty].fore.desired);
vsPrint.styles[sty].back.desired = InvertedLight(vsPrint.styles[sty].back.desired);
} else if (printColourMode == SC_PRINT_BLACKONWHITE) {
- vsPrint.styles[sty].fore.desired = Colour(0, 0, 0);
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].fore.desired = ColourDesired(0, 0, 0);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITE) {
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
if (sty <= STYLE_DEFAULT) {
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
}
}
}
// White background for the line numbers
- vsPrint.styles[STYLE_LINENUMBER].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff);
vsPrint.Refresh(*surfaceMeasure);
// Ensure colours are set up
// Copy this line and its styles from the document into local arrays
// and determine the x position at which each character starts.
- LineLayout ll;
- LayoutLine(line, surfaceMeasure, vsPrint, ll);
+ LineLayout ll(8000);
+ LayoutLine(line, surfaceMeasure, vsPrint, &ll);
ll.selStart = -1;
ll.selEnd = -1;
ll.containsCaret = false;
- // Need to fix this up so takes account of Unicode and DBCS
- ll.edgeColumn = theEdge;
PRectangle rcLine;
rcLine.left = pfr->rc.left + lineNumberWidth;
// Right justify
rcNumber.left -=
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
- surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
+ surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
ypos + vsPrint.maxAscent, number, strlen(number),
vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
// Draw the line
surface->FlushCachedState();
- DrawLine(surface, vsPrint, line, line, xStart, rcLine, ll);
+ DrawLine(surface, vsPrint, line, line, xStart, rcLine, &ll);
ypos += vsPrint.lineHeight;
line++;
}
}
- delete surface;
- delete surfaceMeasure;
-
return endPosPrint;
}
// Empty method is overridden on GTK+ to show / hide scrollbars
void Editor::ReconfigureScrollBars() {}
-void Editor::SetScrollBarsTo(PRectangle) {
+void Editor::SetScrollBars() {
RefreshStyleData();
int nMax = cs.LinesDisplayed();
- int nPage = cs.LinesDisplayed() - MaxScrollPos() + 1;
+ int nPage = nMax - MaxScrollPos() + 1;
bool modified = ModifyScrollBars(nMax, nPage);
// TODO: ensure always showing as many lines as possible
//Platform::DebugPrintf("end max = %d page = %d\n", nMax, nPage);
}
-void Editor::SetScrollBars() {
- PRectangle rsClient = GetClientRectangle();
- SetScrollBarsTo(rsClient);
+void Editor::ChangeSize() {
+ DropGraphics();
+ SetScrollBars();
+ if (wrapState != eWrapNone) {
+ PRectangle rcTextArea = GetClientRectangle();
+ rcTextArea.left = vs.fixedColumnWidth;
+ rcTextArea.right -= vs.rightMarginWidth;
+ if (wrapWidth != rcTextArea.Width()) {
+ NeedWrapping();
+ Redraw();
+ }
+ }
}
void Editor::AddChar(char ch) {
AddCharUTF(s, 1);
}
-void Editor::AddCharUTF(char *s, unsigned int len) {
+void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool wasSelection = currentPos != anchor;
ClearSelection();
if (inOverstrike && !wasSelection) {
ShowCaretAtCurrentPosition();
SetLastXChosen();
- int byte = static_cast<unsigned char>(s[0]);
- if ((byte < 0xC0) || (1 == len)) {
- // Handles UTF-8 characters between 0x01 and 0x7F and single byte
- // characters when not in UTF-8 mode.
- // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
- // characters representing themselves.
+ if (treatAsDBCS) {
+ NotifyChar((static_cast<unsigned char>(s[0]) << 8) |
+ static_cast<unsigned char>(s[1]));
} else {
- // Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
- // http://www.cl.cam.ac.uk/~mgk25/unicode.html
- // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
- if (byte < 0xE0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- if ((byte2 & 0xC0) == 0x80) {
- // Two-byte-character lead-byte followed by a trail-byte.
- byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
- }
- // A two-byte-character lead-byte not followed by trail-byte
- // represents itself.
- } else if (byte < 0xF0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- int byte3 = static_cast<unsigned char>(s[2]);
- if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
- // Three-byte-character lead byte followed by two trail bytes.
- byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
- (byte3 & 0x3F));
+ int byte = static_cast<unsigned char>(s[0]);
+ if ((byte < 0xC0) || (1 == len)) {
+ // Handles UTF-8 characters between 0x01 and 0x7F and single byte
+ // characters when not in UTF-8 mode.
+ // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
+ // characters representing themselves.
+ } else {
+ // Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
+ // http://www.cl.cam.ac.uk/~mgk25/unicode.html
+ // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
+ if (byte < 0xE0) {
+ int byte2 = static_cast<unsigned char>(s[1]);
+ if ((byte2 & 0xC0) == 0x80) {
+ // Two-byte-character lead-byte followed by a trail-byte.
+ byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
+ }
+ // A two-byte-character lead-byte not followed by trail-byte
+ // represents itself.
+ } else if (byte < 0xF0) {
+ int byte2 = static_cast<unsigned char>(s[1]);
+ int byte3 = static_cast<unsigned char>(s[2]);
+ if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
+ // Three-byte-character lead byte followed by two trail bytes.
+ byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
+ (byte3 & 0x3F));
+ }
+ // A three-byte-character lead-byte not followed by two trail-bytes
+ // represents itself.
}
- // A three-byte-character lead-byte not followed by two trail-bytes
- // represents itself.
}
+ NotifyChar(byte);
}
- NotifyChar(byte);
}
void Editor::ClearSelection() {
return;
}
currentPos = pos;
- int insertPos = currentPos;
int xInsert = XFromPosition(currentPos);
int line = pdoc->LineFromPosition(currentPos);
bool prevCr = false;
pdoc->InsertChar(currentPos, ' ');
currentPos++;
}
- insertPos = currentPos;
}
prevCr = ptr[i] == '\r';
} else {
pdoc->InsertString(currentPos, ptr + i, 1);
currentPos++;
- insertPos = currentPos;
prevCr = false;
}
}
pdoc->EndUndoAction();
- SetEmptySelection(insertPos);
+ SetEmptySelection(pos);
}
bool Editor::CanPaste() {
ShowCaretAtCurrentPosition();
}
-void Editor::DelCharBack() {
+void Editor::DelCharBack(bool allowLineStartDeletion) {
if (currentPos == anchor) {
int lineCurrentPos = pdoc->LineFromPosition(currentPos);
- if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) &&
- pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) {
- pdoc->BeginUndoAction();
- int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
- if (indentation % indentationStep == 0) {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != currentPos)) {
+ if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) &&
+ pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) {
+ pdoc->BeginUndoAction();
+ int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
+ if (indentation % indentationStep == 0) {
+ pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ } else {
+ pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep));
+ }
+ SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
+ pdoc->EndUndoAction();
} else {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep));
+ int newPos = pdoc->DelCharBack(currentPos);
+ SetEmptySelection(newPos);
}
- SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
- pdoc->EndUndoAction();
- } else {
- int newPos = pdoc->DelCharBack(currentPos);
- SetEmptySelection(newPos);
}
} else {
ClearSelection();
NotifySavePoint(atSavePoint);
}
+void Editor::CheckModificationForWrap(DocModification mh) {
+ if ((mh.modificationType & SC_MOD_INSERTTEXT) ||
+ (mh.modificationType & SC_MOD_DELETETEXT)) {
+ llc.Invalidate(LineLayout::llInvalid);
+ if (wrapState != eWrapNone) {
+ int lineDoc = pdoc->LineFromPosition(mh.position);
+ if (mh.linesAdded == 0) {
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ if (cs.GetHeight(lineDoc) != ll->lines) {
+ NeedWrapping(lineDoc-1);
+ Redraw();
+ }
+ } else {
+ NeedWrapping(lineDoc);
+ }
+ llc.Dispose(ll);
+ } else {
+ NeedWrapping(lineDoc);
+ }
+ }
+ }
+}
+
+// Move a position so it is still after the same character as before the insertion.
+static inline int MovePositionForInsertion(int position, int startInsertion, int length) {
+ if (position > startInsertion) {
+ return position + length;
+ }
+ return position;
+}
+
+// Move a position so it is still after the same character as before the deletion if that
+// character is still present else after the previous surviving character.
+static inline int MovePositionForDeletion(int position, int startDeletion, int length) {
+ if (position > startDeletion) {
+ int endDeletion = startDeletion + length;
+ if (position > endDeletion) {
+ return position - length;
+ } else {
+ return startDeletion;
+ }
+ } else {
+ return position;
+ }
+}
+
void Editor::NotifyModified(Document*, DocModification mh, void *) {
needUpdateUI = true;
if (paintState == painting) {
CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
} else if (paintState == notPainting) {
+ CheckModificationForWrap(mh);
if (mh.modificationType & SC_MOD_CHANGESTYLE) {
if (mh.position < pdoc->LineStart(topLine)) {
// Styling performed before this view
} else {
// Move selection and brace highlights
if (mh.modificationType & SC_MOD_INSERTTEXT) {
- if (currentPos > mh.position) {
- currentPos += mh.length;
- }
- if (anchor > mh.position) {
- anchor += mh.length;
- }
- if (braces[0] > mh.position) {
- braces[0] += mh.length;
- }
- if (braces[1] > mh.position) {
- braces[1] += mh.length;
- }
- } else { // SC_MOD_DELETETEXT
- int endPos = mh.position + mh.length;
- if (currentPos > mh.position) {
- if (currentPos > endPos) {
- currentPos -= mh.length;
- } else {
- currentPos = endPos;
- }
- }
- if (anchor > mh.position) {
- if (anchor > endPos) {
- anchor -= mh.length;
- } else {
- anchor = endPos;
- }
- }
- if (braces[0] > mh.position) {
- if (braces[0] > endPos) {
- braces[0] -= mh.length;
- } else {
- braces[0] = endPos;
- }
- }
- if (braces[1] > mh.position) {
- if (braces[1] > endPos) {
- braces[1] -= mh.length;
- } else {
- braces[1] = endPos;
- }
- }
+ currentPos = MovePositionForInsertion(currentPos, mh.position, mh.length);
+ anchor = MovePositionForInsertion(anchor, mh.position, mh.length);
+ braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length);
+ braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length);
+ } else if (mh.modificationType & SC_MOD_DELETETEXT) {
+ currentPos = MovePositionForDeletion(currentPos, mh.position, mh.length);
+ anchor = MovePositionForDeletion(anchor, mh.position, mh.length);
+ braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length);
+ braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length);
}
if (cs.LinesDisplayed() < cs.LinesInDoc()) {
// Some lines are hidden so may need shown.
NotifyChange(); // Send EN_CHANGE
}
-
-
SCNotification scn;
scn.nmhdr.code = SCN_MODIFIED;
scn.position = mh.position;
case SCI_LINETRANSPOSE:
case SCI_LOWERCASE:
case SCI_UPPERCASE:
+ case SCI_LINESCROLLDOWN:
+ case SCI_LINESCROLLUP:
+ case SCI_DELETEBACKNOTLINE:
break;
// Filter out all others like display changes. Also, newlines are redundant
CancelModes();
break;
case SCI_DELETEBACK:
- DelCharBack();
+ DelCharBack(true);
+ SetLastXChosen();
+ EnsureCaretVisible();
+ break;
+ case SCI_DELETEBACKNOTLINE:
+ DelCharBack(false);
SetLastXChosen();
EnsureCaretVisible();
break;
case SCI_ZOOMIN:
if (vs.zoomLevel < 20)
vs.zoomLevel++;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
case SCI_ZOOMOUT:
if (vs.zoomLevel > -10)
vs.zoomLevel--;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
case SCI_DELWORDLEFT: {
TextToFind *ft = reinterpret_cast<TextToFind *>(lParam);
int lengthFound = strlen(ft->lpstrText);
int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText,
- wParam & SCFIND_MATCHCASE,
- wParam & SCFIND_WHOLEWORD,
- wParam & SCFIND_WORDSTART,
- wParam & SCFIND_REGEXP,
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
&lengthFound);
if (pos != -1) {
ft->chrgText.cpMin = pos;
int lengthFound = strlen(txt);
if (iMessage == SCI_SEARCHNEXT) {
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
- wParam & SCFIND_MATCHCASE,
- wParam & SCFIND_WHOLEWORD,
- wParam & SCFIND_WORDSTART,
- wParam & SCFIND_REGEXP,
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
&lengthFound);
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
- wParam & SCFIND_MATCHCASE,
- wParam & SCFIND_WHOLEWORD,
- wParam & SCFIND_WORDSTART,
- wParam & SCFIND_REGEXP,
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
&lengthFound);
}
long Editor::SearchInTarget(const char *text, int length) {
int lengthFound = length;
int pos = pdoc->FindText(targetStart, targetEnd, text,
- searchFlags & SCFIND_MATCHCASE,
- searchFlags & SCFIND_WHOLEWORD,
- searchFlags & SCFIND_WORDSTART,
- searchFlags & SCFIND_REGEXP,
+ (searchFlags & SCFIND_MATCHCASE) != 0,
+ (searchFlags & SCFIND_WHOLEWORD) != 0,
+ (searchFlags & SCFIND_WORDSTART) != 0,
+ (searchFlags & SCFIND_REGEXP) != 0,
&lengthFound);
if (pos != -1) {
targetStart = pos;
SetSelection(movePos);
} else if (selectionType == selWord) {
// Continue selecting by word
- if (currentPos > originalAnchorPos) { // Moved forward
+ if (movePos >= originalAnchorPos) { // Moved forward
SetSelection(pdoc->ExtendWordSelect(movePos, 1),
pdoc->ExtendWordSelect(originalAnchorPos, -1));
} else { // Moved backward
lastClickTime = curTime;
lastClick = pt;
lastXChosen = pt.x;
+ if (selType == selStream) {
+ SetLastXChosen();
+ }
inDragDrop = false;
EnsureCaretVisible(false);
}
InvalidateCaret();
}
}
- if ((dwellDelay < SC_TIME_FOREVER) &&
+ if ((dwellDelay < SC_TIME_FOREVER) &&
(ticksToDwell > 0) &&
(!HaveMouseCapture())) {
ticksToDwell -= timer.tickSize;
NotifyFocus(hasFocus);
if (hasFocus) {
ShowCaretAtCurrentPosition();
- InvalidateCaret();
} else {
DropCaret();
}
// Reset the contraction state to fully shown.
cs.Clear();
cs.InsertLines(0, pdoc->LinesTotal() - 1);
+ llc.Deallocate();
+ NeedWrapping();
pdoc->AddWatcher(this, 0);
Redraw();
}
// Recurse up from this line to find any folds that prevent this line from being visible
-// and unfold them all.
+// and unfold them all->
void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
+
+ // In case in need of wrapping to ensure DisplayFromDoc works.
+ WrapLines();
+
if (!cs.GetVisible(lineDoc)) {
int lineParent = pdoc->GetFoldParent(lineDoc);
if (lineParent >= 0) {
return length;
}
+bool Editor::IsUnicodeMode() const {
+ return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage);
+}
+
static bool ValidMargin(unsigned long wParam) {
return wParam < ViewStyle::margins;
}
case SCI_SETTEXT:
{
if (lParam == 0)
- return FALSE;
+ return 0;
pdoc->DeleteChars(0, pdoc->Length());
SetEmptySelection(0);
pdoc->InsertString(0, reinterpret_cast<char *>(lParam));
- return TRUE;
+ return 1;
}
case SCI_GETTEXTLENGTH:
break;
case SCI_CANUNDO:
- return pdoc->CanUndo() ? TRUE : FALSE;
+ return pdoc->CanUndo() ? 1 : 0;
case SCI_EMPTYUNDOBUFFER:
pdoc->DeleteUndoHistory();
case SCI_LINESCROLL:
ScrollTo(topLine + lParam);
HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
- return TRUE;
+ return 1;
+
+ case SCI_SETXOFFSET:
+ xOffset = wParam;
+ Redraw();
+ break;
+
+ case SCI_GETXOFFSET:
+ return xOffset;
case SCI_SCROLLCARET:
EnsureCaretVisible();
break;
case SCI_SETREADONLY:
- pdoc->SetReadOnly(wParam);
- return TRUE;
+ pdoc->SetReadOnly(wParam != 0);
+ return 1;
case SCI_GETREADONLY:
return pdoc->IsReadOnly();
}
case SCI_HIDESELECTION:
- hideSelection = wParam;
+ hideSelection = wParam != 0;
Redraw();
break;
case SCI_FORMATRANGE:
- return FormatRange(wParam, reinterpret_cast<RangeToFormat *>(lParam));
+ return FormatRange(wParam != 0, reinterpret_cast<RangeToFormat *>(lParam));
case SCI_GETMARGINLEFT:
return vs.leftMarginWidth;
case SCI_SETMARGINLEFT:
vs.leftMarginWidth = lParam;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
case SCI_SETMARGINRIGHT:
vs.rightMarginWidth = lParam;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
return 0;
case SCI_SETUNDOCOLLECTION:
- pdoc->SetUndoCollection(wParam);
+ pdoc->SetUndoCollection(wParam != 0);
return 0;
case SCI_GETUNDOCOLLECTION:
}
case SCI_CANREDO:
- return pdoc->CanRedo() ? TRUE : FALSE;
+ return pdoc->CanRedo() ? 1 : 0;
case SCI_MARKERLINEFROMHANDLE:
return pdoc->LineFromHandle(wParam);
break;
case SCI_SETBUFFEREDDRAW:
- bufferedDraw = wParam;
+ bufferedDraw = wParam != 0;
break;
case SCI_GETBUFFEREDDRAW:
return pdoc->indentInChars;
case SCI_SETUSETABS:
- pdoc->useTabs = wParam;
+ pdoc->useTabs = wParam != 0;
InvalidateStyleRedraw();
break;
return pdoc->GetLineIndentPosition(wParam);
case SCI_SETTABINDENTS:
- pdoc->tabIndents = wParam;
+ pdoc->tabIndents = wParam != 0;
break;
case SCI_GETTABINDENTS:
return pdoc->tabIndents;
case SCI_SETBACKSPACEUNINDENTS:
- pdoc->backspaceUnindents = wParam;
+ pdoc->backspaceUnindents = wParam != 0;
break;
case SCI_GETBACKSPACEUNINDENTS:
dwellDelay = wParam;
ticksToDwell = dwellDelay;
break;
-
+
case SCI_GETMOUSEDWELLTIME:
return dwellDelay;
-
+
+ case SCI_WORDSTARTPOSITION:
+ return pdoc->ExtendWordSelect(wParam, -1, lParam != 0);
+
+ case SCI_WORDENDPOSITION:
+ return pdoc->ExtendWordSelect(wParam, 1, lParam != 0);
+
+ case SCI_SETWRAPMODE:
+ wrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone;
+ NeedWrapping();
+ xOffset = 0;
+ InvalidateStyleRedraw();
+ ReconfigureScrollBars();
+ break;
+
+ case SCI_GETWRAPMODE:
+ return wrapState;
+
+ case SCI_SETLAYOUTCACHE:
+ llc.SetLevel(wParam);
+ break;
+
+ case SCI_GETLAYOUTCACHE:
+ return llc.GetLevel();
+
case SCI_GETCOLUMN:
return pdoc->GetColumn(wParam);
case SCI_SETHSCROLLBAR :
- horizontalScrollBarVisible = wParam;
- SetScrollBars();
- ReconfigureScrollBars();
+ if (horizontalScrollBarVisible != (wParam != 0)) {
+ horizontalScrollBarVisible = wParam != 0;
+ SetScrollBars();
+ ReconfigureScrollBars();
+ }
break;
case SCI_GETHSCROLLBAR:
return horizontalScrollBarVisible;
case SCI_SETINDENTATIONGUIDES:
- vs.viewIndentationGuides = wParam;
+ vs.viewIndentationGuides = wParam != 0;
Redraw();
break;
return pdoc->dbcsCodePage;
case SCI_SETUSEPALETTE:
- palette.allowRealization = wParam;
+ palette.allowRealization = wParam != 0;
InvalidateStyleRedraw();
break;
break;
case SCI_MARKERSETFORE:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].fore.desired = Colour(lParam);
+ vs.markers[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_MARKERSETBACK:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].back.desired = Colour(lParam);
+ vs.markers[wParam].back.desired = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_SETMARGINWIDTHN:
if (ValidMargin(wParam)) {
vs.ms[wParam].width = lParam;
+ NeedWrapping();
InvalidateStyleRedraw();
}
break;
case SCI_SETMARGINSENSITIVEN:
if (ValidMargin(wParam)) {
- vs.ms[wParam].sensitive = lParam;
+ vs.ms[wParam].sensitive = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETFORE:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].fore.desired = Colour(lParam);
+ vs.styles[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETBACK:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].back.desired = Colour(lParam);
+ vs.styles[wParam].back.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETBOLD:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].bold = lParam;
+ vs.styles[wParam].bold = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETITALIC:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].italic = lParam;
+ vs.styles[wParam].italic = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETEOLFILLED:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].eolFilled = lParam;
+ vs.styles[wParam].eolFilled = lParam != 0;
InvalidateStyleRedraw();
}
break;
break;
case SCI_STYLESETUNDERLINE:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].underline = lParam;
+ vs.styles[wParam].underline = lParam != 0;
InvalidateStyleRedraw();
}
break;
break;
case SCI_STYLESETVISIBLE:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].visible = lParam;
+ vs.styles[wParam].visible = lParam != 0;
+ InvalidateStyleRedraw();
+ }
+ break;
+ case SCI_STYLESETCHANGEABLE:
+ if (wParam <= STYLE_MAX) {
+ vs.styles[wParam].changeable = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_GETCARETLINEVISIBLE:
return vs.showCaretLineBackground;
case SCI_SETCARETLINEVISIBLE:
- vs.showCaretLineBackground = wParam;
+ vs.showCaretLineBackground = wParam != 0;
InvalidateStyleRedraw();
break;
case SCI_GETCARETLINEBACK:
return cs.GetVisible(wParam);
case SCI_SETFOLDEXPANDED:
- if (cs.SetExpanded(wParam, lParam)) {
+ if (cs.SetExpanded(wParam, lParam != 0)) {
RedrawSelMargin();
}
break;
return LinesOnScreen();
case SCI_SETSELFORE:
- vs.selforeset = wParam;
- vs.selforeground.desired = Colour(lParam);
+ vs.selforeset = wParam != 0;
+ vs.selforeground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
- vs.selbackset = wParam;
- vs.selbackground.desired = Colour(lParam);
+ vs.selbackset = wParam != 0;
+ vs.selbackground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETCARETFORE:
- vs.caretcolour.desired = Colour(wParam);
+ vs.caretcolour.desired = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].fore.desired = Colour(lParam);
+ vs.indicators[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_WORDPARTLEFTEXTEND:
case SCI_WORDPARTRIGHT:
case SCI_WORDPARTRIGHTEXTEND:
+ case SCI_DELETEBACKNOTLINE:
return KeyCommand(iMessage);
case SCI_BRACEHIGHLIGHT:
return vs.viewEOL;
case SCI_SETVIEWEOL:
- vs.viewEOL = wParam;
+ vs.viewEOL = wParam != 0;
Redraw();
break;
case SCI_SETZOOM:
vs.zoomLevel = wParam;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
return vs.edgecolour.desired.AsLong();
case SCI_SETEDGECOLOUR:
- vs.edgecolour.desired = Colour(wParam);
+ vs.edgecolour.desired = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_GETDOCPOINTER:
- return reinterpret_cast<long>(pdoc);
+ return reinterpret_cast<sptr_t>(pdoc);
case SCI_SETDOCPOINTER:
SetDocPointer(reinterpret_cast<Document *>(lParam));
case SCI_CREATEDOCUMENT: {
Document *doc = new Document();
doc->AddRef();
- return reinterpret_cast<long>(doc);
+ return reinterpret_cast<sptr_t>(doc);
}
case SCI_ADDREFDOCUMENT:
return (selType == selRectangle) ? 1 : 0;
case SCI_SETOVERTYPE:
- inOverstrike = wParam;
+ inOverstrike = wParam != 0;
break;
case SCI_GETOVERTYPE:
- return inOverstrike ? TRUE : FALSE;
+ return inOverstrike ? 1 : 0;
case SCI_SETFOCUS:
- SetFocusState(wParam);
+ SetFocusState(wParam != 0);
break;
case SCI_GETFOCUS:
return errorStatus;
case SCI_SETMOUSEDOWNCAPTURES:
- mouseDownCaptures = wParam;
+ mouseDownCaptures = wParam != 0;
break;
case SCI_GETMOUSEDOWNCAPTURES:
case SCI_GETCURSOR:
return cursorMode;
+ case SCI_SETCONTROLCHARSYMBOL:
+ controlCharSymbol = wParam;
+ break;
+
+ case SCI_GETCONTROLCHARSYMBOL:
+ return controlCharSymbol;
+
case SCI_STARTRECORD:
recordingMacro = true;
return 0;
/** @file Editor.h
** Defines the main editor class.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef EDITOR_H
bool active;
bool on;
int period;
-
+
Caret();
};
bool ticking;
int ticksToWait;
enum {tickSize = 100};
- int tickerID;
-
+ TickerID tickerID;
+
Timer();
};
/**
*/
class LineLayout {
-public:
+private:
+ friend class LineLayoutCache;
+ int *lineStarts;
+ int lenLineStarts;
/// Drawing is only performed for @a maxLineLength characters on each line.
- enum {maxLineLength = 4000};
+ int lineNumber;
+ bool inCache;
+public:
+ enum { wrapWidthInfinite = 0x7ffffff };
+ int maxLineLength;
int numCharsInLine;
+ enum validLevel { llInvalid, llPositions, llLines } validity;
int xHighlightGuide;
bool highlightColumn;
int selStart;
int selEnd;
bool containsCaret;
int edgeColumn;
- char chars[maxLineLength+1];
- char styles[maxLineLength+1];
- char indicators[maxLineLength+1];
- int positions[maxLineLength+1];
+ char *chars;
+ char *styles;
+ char *indicators;
+ int *positions;
+ char bracePreviousStyles[2];
+
+ // Wrapped line support
+ int widthLine;
+ int lines;
+
+ LineLayout(int maxLineLength_);
+ virtual ~LineLayout();
+ void Resize(int maxLineLength_);
+ void Free();
+ void Invalidate(validLevel validity_);
+ int LineStart(int line) {
+ if (line <= 0) {
+ return 0;
+ } else if ((line >= lines) || !lineStarts) {
+ return numCharsInLine;
+ } else {
+ return lineStarts[line];
+ }
+ }
+ void SetLineStart(int line, int start);
+ void SetBracesHighlight(Range rangeLine, Position braces[],
+ char bracesMatchStyle, int xHighlight);
+ void RestoreBracesHighlight(Range rangeLine, Position braces[]);
+};
+
+/**
+ */
+class LineLayoutCache {
+ int level;
+ int length;
+ int size;
+ LineLayout **cache;
+ bool allInvalidated;
+ int styleClock;
+ void Allocate(int length_);
+ void AllocateForLevel(int linesOnScreen, int linesInDoc);
+public:
+ LineLayoutCache();
+ virtual ~LineLayoutCache();
+ void Deallocate();
+ enum {
+ llcNone=SC_CACHE_NONE,
+ llcCaret=SC_CACHE_CARET,
+ llcPage=SC_CACHE_PAGE,
+ llcDocument=SC_CACHE_DOCUMENT
+ };
+ void Invalidate(LineLayout::validLevel validity_);
+ void SetLevel(int level_);
+ int GetLevel() { return level; }
+ LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+ int linesOnScreen, int linesInDoc);
+ void Dispose(LineLayout *ll);
};
class SelectionText {
}
};
+/**
+ * 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 {
/** Style resources may be expensive to allocate so are cached between uses.
* When a style attribute is changed, this cache is flushed. */
- bool stylesValid;
+ bool stylesValid;
ViewStyle vs;
Palette palette;
int printMagnification;
int printColourMode;
int cursorMode;
+ int controlCharSymbol;
bool hasFocus;
bool hideSelection;
bool inOverstrike;
int errorStatus;
bool mouseDownCaptures;
-
+
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
* the screen. This avoids flashing but is about 30% slower. */
bool bufferedDraw;
int xOffset; ///< Horizontal scrolled amount in pixels
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
bool horizontalScrollBarVisible;
-
- Surface pixmapLine;
- Surface pixmapSelMargin;
- Surface pixmapSelPattern;
- Surface pixmapIndentGuide;
- Surface pixmapIndentGuideHighlight;
+
+ Surface *pixmapLine;
+ Surface *pixmapSelMargin;
+ Surface *pixmapSelPattern;
+ Surface *pixmapIndentGuide;
+ Surface *pixmapIndentGuideHighlight;
+
+ LineLayoutCache llc;
KeyMap kmap;
int searchFlags;
int topLine;
int posTopLine;
-
+
bool needUpdateUI;
Position braces[2];
int bracesMatchStyle;
int highlightGuideColumn;
-
+
int theEdge;
enum { notPainting, painting, paintAbandoned } paintState;
PRectangle rcPaint;
bool paintingAllText;
-
+
int modEventMask;
-
+
SelectionText drag;
enum { selStream, selRectangle, selRectangleFixed } selType;
int xStartSelect;
int xEndSelect;
bool primarySelection;
-
+
int caretPolicy;
int caretSlop;
int visiblePolicy;
int visibleSlop;
-
+
int searchAnchor;
bool recordingMacro;
int foldFlags;
ContractionState cs;
+ // Wrapping support
+ enum { eWrapNone, eWrapWord } wrapState;
+ int wrapWidth;
+ int docLineLastWrapped;
+
Document *pdoc;
Editor();
virtual PRectangle GetClientRectangle();
PRectangle GetTextRectangle();
-
+
int LinesOnScreen();
int LinesToScroll();
int MaxScrollPos();
int PositionFromLineX(int line, int x);
int LineFromLocation(Point pt);
void SetTopLine(int topLineNew);
-
+
void RedrawRect(PRectangle rc);
void Redraw();
void RedrawSelMargin();
PRectangle RectangleFromRange(int start, int end);
void InvalidateRange(int start, int end);
-
+
int CurrentPosition();
bool SelectionEmpty();
int SelectionStart(int line=-1);
virtual void ScrollText(int linesToMove);
void HorizontalScrollTo(int xPos);
void MoveCaretInsideView();
+ int DisplayFromPosition(int pos);
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
void ShowCaretAtCurrentPosition();
void DropCaret();
void InvalidateCaret();
+ void NeedWrapping(int docLineStartWrapping=0);
+ bool WrapLines();
+
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
void PaintSelMargin(Surface *surface, PRectangle &rc);
- void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll);
- void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
- PRectangle rcLine, LineLayout &ll);
+ LineLayout *RetrieveLineLayout(int lineNumber);
+ void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
+ int width=LineLayout::wrapWidthInfinite);
+ void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
+ PRectangle rcLine, LineLayout *ll, int subLine=0);
void Paint(Surface *surfaceWindow, PRectangle rcArea);
long FormatRange(bool draw, RangeToFormat *pfr);
virtual void SetHorizontalScrollPos() = 0;
virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
virtual void ReconfigureScrollBars();
- void SetScrollBarsTo(PRectangle rsClient);
void SetScrollBars();
+ void ChangeSize();
void AddChar(char ch);
- virtual void AddCharUTF(char *s, unsigned int len);
+ virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void ClearSelection();
void ClearAll();
void ClearDocumentStyle();
void Undo();
void Redo();
void DelChar();
- void DelCharBack();
+ void DelCharBack(bool allowLineStartDeletion);
virtual void ClaimSelection() = 0;
virtual void NotifyChange() = 0;
virtual void NotifyFocus(bool focus);
+ virtual int GetCtrlID() { return ctrlID; }
virtual void NotifyParent(SCNotification scn) = 0;
virtual void NotifyStyleToNeeded(int endStyleNeeded);
void NotifyChar(int ch);
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
void NotifyNeedShown(int pos, int len);
void NotifyDwelling(Point pt, bool state);
-
+
void NotifyModifyAttempt(Document *document, void *userData);
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
+ void CheckModificationForWrap(DocModification mh);
void NotifyModified(Document *document, DocModification mh, void *userData);
void NotifyDeleted(Document *document, void *userData);
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
void CheckForChangeOutsidePaint(Range r);
int BraceMatch(int position, int maxReStyle);
void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
-
+
void SetDocPointer(Document *document);
-
+
void Expand(int &line, bool doExpand);
void ToggleContraction(int line);
void EnsureLineVisible(int lineDoc, bool enforcePolicy);
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
-
+
public:
- // Public so scintilla_send_message can use it
+ // Public so the COM thunks can access it.
+ bool IsUnicodeMode() const;
+ // Public so scintilla_send_message can use it.
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
- // Public so scintilla_set_id can use it
- int ctrlID;
+ // Public so scintilla_set_id can use it.
+ int ctrlID;
};
#endif
public:
int style;
ColourPair fore;
- Indicator() : style(INDIC_PLAIN), fore(Colour(0,0,0)) {
+ Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) {
}
void Draw(Surface *surface, PRectangle &rc);
};
return 0;
}
-KeyToCommand KeyMap::MapDefault[] = {
+const KeyToCommand KeyMap::MapDefault[] = {
{SCK_DOWN, SCI_NORM, SCI_LINEDOWN},
{SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND},
{SCK_DOWN, SCI_CTRL, SCI_LINESCROLLDOWN},
KeyToCommand *kmap;
int len;
int alloc;
- static KeyToCommand MapDefault[];
+ static const KeyToCommand MapDefault[];
public:
KeyMap();
/** @file KeyWords.cxx
** Colourise for particular languages.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include "Scintilla.h"
#include "SciLexer.h"
-LexerModule *LexerModule::base = 0;
+const LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_, LexerFunction fnFolder_) :
language(language_),
- languageName(languageName_),
fnLexer(fnLexer_),
- fnFolder(fnFolder_) {
+ fnFolder(fnFolder_),
+ languageName(languageName_) {
next = base;
base = this;
if (language == SCLEX_AUTOMATIC) {
}
}
-LexerModule *LexerModule::Find(int language) {
- LexerModule *lm = base;
+const LexerModule *LexerModule::Find(int language) {
+ const LexerModule *lm = base;
while (lm) {
if (lm->language == language) {
return lm;
return 0;
}
-LexerModule *LexerModule::Find(const char *languageName) {
+const LexerModule *LexerModule::Find(const char *languageName) {
if (languageName) {
- LexerModule *lm = base;
+ const LexerModule *lm = base;
while (lm) {
if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
return lm;
}
void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) const {
if (fnLexer)
fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
}
void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) const {
if (fnFolder) {
int lineCurrent = styler.GetLine(startPos);
// Move back one line in case deletion wrecked current line fold state
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
#ifdef __vms
+#define LINK_LEXERS
+#endif
+
+#ifdef LINK_LEXERS
// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// Taken from wxWindow's stc.cpp. Walter.
int wxForceScintillaLexers(void) {
+ return Scintilla_LinkLexers();
+}
+
+int Scintilla_LinkLexers() {
extern LexerModule lmAda;
extern LexerModule lmAVE;
+ extern LexerModule lmBaan;
extern LexerModule lmBatch;
extern LexerModule lmConf;
extern LexerModule lmCPP;
extern LexerModule lmLISP;
extern LexerModule lmLua;
extern LexerModule lmMake;
+ extern LexerModule lmMatlab;
extern LexerModule lmPascal;
extern LexerModule lmPerl;
extern LexerModule lmProps;
extern LexerModule lmSQL;
extern LexerModule lmVB;
extern LexerModule lmXML;
+ extern LexerModule lmBullant;
if (
&lmAda
&& &lmAVE
+ && &lmBaan
&& &lmConf
&& &lmDiff
&& &lmLatex
&& &lmProps
&& &lmErrorList
&& &lmMake
+ && &lmMatlab
&& &lmBatch
&& &lmPerl
&& &lmPython
&& &lmLISP
&& &lmLua
&& &lmNull
+ && &lmBullant
)
{
return 1;
styler.StartAt(startPos);
- bool fold = styler.GetPropertyInt("fold");
+ bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
}
-inline bool isAdaOperator(char ch) {
+static inline bool isAdaOperator(char ch) {
if (ch == '&' || ch == '\'' || ch == '(' || ch == ')' ||
ch == '*' || ch == '+' || ch == ',' || ch == '-' ||
--- /dev/null
+// 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);
--- /dev/null
+// 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");
/** @file LexCPP.cxx
** Lexer for C++, C, Java, and Javascript.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
return (ch == '(') || (ch == '=') || (ch == ',');
}
-inline bool IsAWordChar(const int ch) {
+static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
-inline bool IsAWordStart(const int ch) {
+static inline bool IsAWordStart(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
-inline bool IsADoxygenChar(const int ch) {
+static inline bool IsADoxygenChar(const int ch) {
return (islower(ch) || ch == '$' || ch == '@' ||
ch == '\\' || ch == '&' || ch == '<' ||
ch == '>' || ch == '#' || ch == '{' ||
ch == '}' || ch == '[' || ch == ']');
}
-inline bool IsStateComment(const int state) {
+static inline bool IsStateComment(const int state) {
return ((state == SCE_C_COMMENT) ||
(state == SCE_C_COMMENTLINE) ||
(state == SCE_C_COMMENTDOC) ||
(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));
}
WordList &keywords2 = *keywordlists[1];
WordList &keywords3 = *keywordlists[2];
- bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
+ bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
// Do not leak onto next line
if (initStyle == SCE_C_STRINGEOL)
int chPrevNonWhite = ' ';
int visibleChars = 0;
- int noDocChars = 0;
bool lastWordWasUUID = false;
StyleContext sc(startPos, length, initStyle, styler);
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
- } else if ((sc.ch == '@' || sc.ch == '\\') && (noDocChars == 0)) {
+ } else if (sc.ch == '@' || sc.ch == '\\') {
sc.SetState(SCE_C_COMMENTDOCKEYWORD);
- } else if (sc.atLineEnd) {
- noDocChars = 0;
- } else if (!isspace(sc.ch) && (sc.ch != '*')) {
- noDocChars++;
}
} else if (sc.state == SCE_C_COMMENTLINE || sc.state == SCE_C_COMMENTLINEDOC) {
if (sc.atLineEnd) {
}
} else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
- noDocChars = 0;
sc.SetState(SCE_C_COMMENTDOC);
} else {
sc.SetState(SCE_C_COMMENT);
static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
Accessor &styler) {
- bool foldComment = styler.GetPropertyInt("fold.comment");
- bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
}
}
+ delete []buffer;
}
LexerModule lmConf(SCLEX_CONF, ColouriseConfDoc, "conf");
break;
}
}
+ delete []buffer;
}
LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab");
#include "Scintilla.h"
#include "SciLexer.h"
-inline bool isEiffelOperator(unsigned int ch) {
+static inline bool isEiffelOperator(unsigned int ch) {
// '.' left out as it is used to make up numbers
return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' ||
ch == '(' || ch == ')' || ch == '=' ||
ch == '!' || ch == '@' || ch == '?';
}
-inline bool IsAWordChar(unsigned int ch) {
+static inline bool IsAWordChar(unsigned int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
-inline bool IsAWordStart(unsigned int ch) {
+static inline bool IsAWordStart(unsigned int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
// Scintilla source code edit control
/** @file LexHTML.cxx
** Lexer for HTML.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+ **/
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include "PropSet.h"
#include "Accessor.h"
+#include "StyleContext.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
#define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
#define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
-enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
-enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
+enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
+enum script_mode { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
-static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, script_type prevValue) {
char s[30 + 1];
unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) {
return iResult;
}
-static int ScriptOfState(int state) {
+static script_type ScriptOfState(int state) {
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
return eScriptPython;
} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
return eScriptJS;
} else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
return eScriptPHP;
- } else if ((state >= SCE_H_SGML_DEFAULT) && (state <= SCE_H_SGML_BLOCK_DEFAULT)) {
+ } else if ((state >= SCE_H_SGML_DEFAULT) && (state < SCE_H_SGML_BLOCK_DEFAULT)) {
return eScriptSGML;
} else if (state == SCE_H_SGML_BLOCK_DEFAULT) {
return eScriptSGMLblock;
}
}
-static int statePrintForState(int state, int inScriptType) {
+static int statePrintForState(int state, script_mode inScriptType) {
int StateToPrint;
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
}
static void classifyWordHTJS(unsigned int start, unsigned int end,
- WordList &keywords, Accessor &styler, int inScriptType) {
+ WordList &keywords, Accessor &styler, script_mode inScriptType) {
char chAttr = SCE_HJ_WORD;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
styler.ColourTo(end, statePrintForState(chAttr, inScriptType));
}
-static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, int inScriptType) {
+static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) {
char chAttr = SCE_HB_IDENTIFIER;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
return SCE_HB_DEFAULT;
}
-static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) {
- bool wordIsNumber = isdigit(styler[start]);
+static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) {
+ bool wordIsNumber = isdigit(styler[start]) != 0;
char s[30 + 1];
unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) {
// Called when in a PHP word
static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char chAttr = SCE_HPHP_DEFAULT;
- bool wordIsNumber = isdigit(styler[start]);
+ bool wordIsNumber = isdigit(styler[start]) != 0;
if (wordIsNumber)
chAttr = SCE_HPHP_NUMBER;
else {
- char s[30 + 1];
+ char s[100 + 1];
unsigned int i = 0;
- for (; i < end - start + 1 && i < 30; i++) {
- s[i] = styler[start + i];
+ for (; i < end - start + 1 && i < 100; i++) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
}
s[i] = '\0';
if (keywords.InList(s))
}
// Return the first state to reach when entering a scripting language
-static int StateForScript(int scriptLanguage) {
+static int StateForScript(script_type scriptLanguage) {
int Result;
switch (scriptLanguage) {
case eScriptVBS:
return Result;
}
-inline bool ishtmlwordchar(char ch) {
+static inline bool ishtmlwordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
}
-inline bool issgmlwordchar(char ch) {
+static inline bool issgmlwordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[';
}
lineState = eScriptJS << 8;
lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4;
}
- int inScriptType = (lineState >> 0) & 0x03; // 2 bits of scripting type
+ script_mode inScriptType = script_mode((lineState >> 0) & 0x03); // 2 bits of scripting mode
bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
bool tagClosing = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
- int aspScript = (lineState >> 4) & 0x0F; // 4 bits of script name
- int clientScript = (lineState >> 8) & 0x0F; // 4 bits of script name
+ script_type aspScript = script_type((lineState >> 4) & 0x0F); // 4 bits of script name
+ script_type clientScript = script_type((lineState >> 8) & 0x0F); // 4 bits of script name
int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state
- int scriptLanguage = ScriptOfState(state);
+ script_type scriptLanguage = ScriptOfState(state);
- const bool foldHTML = styler.GetPropertyInt("fold.html", 0);
+ const bool foldHTML = styler.GetPropertyInt("fold.html", 0) != 0;
const bool fold = foldHTML && styler.GetPropertyInt("fold");
- const bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
+ const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
}
}
break;
+ default:
+ break;
}
}
}
break;
case SCE_H_SGML_DEFAULT:
- if (scriptLanguage == eScriptSGMLblock)
- StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
+ case SCE_H_SGML_BLOCK_DEFAULT:
+// if (scriptLanguage == eScriptSGMLblock)
+// StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
if (ch == '\"') {
styler.ColourTo(i - 1, StateToPrint);
} else if (ch == '[') {
styler.ColourTo(i - 1, StateToPrint);
scriptLanguage = eScriptSGMLblock;
+ state = SCE_H_SGML_BLOCK_DEFAULT;
} else if (ch == ']') {
if (scriptLanguage == eScriptSGMLblock) {
styler.ColourTo(i, StateToPrint);
styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i, SCE_H_SGML_ERROR);
}
+ state = SCE_H_SGML_DEFAULT;
} else if (scriptLanguage == eScriptSGMLblock) {
if ((ch == '!') && (chPrev == '<')) {
styler.ColourTo(i - 2, StateToPrint);
i += size - 1;
visibleChars += size - 1;
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;
}
break;
}
}
+static bool isASPScript(int state) {
+ return
+ (state >= SCE_HJA_START && state <= SCE_HJA_REGEX) ||
+ (state >= SCE_HBA_START && state <= SCE_HBA_STRINGEOL) ||
+ (state >= SCE_HPA_DEFAULT && state <= SCE_HPA_IDENTIFIER);
+}
+
+static void ColouriseHBAPiece(StyleContext &sc, WordList *keywordlists[]) {
+ WordList &keywordsVBS = *keywordlists[2];
+ if (sc.state == SCE_HBA_WORD) {
+ if (!IsAWordChar(sc.ch)) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywordsVBS.InList(s)) {
+ if (strcmp(s, "rem") == 0) {
+ sc.ChangeState(SCE_HBA_COMMENTLINE);
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else {
+ sc.ChangeState(SCE_HBA_IDENTIFIER);
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+ } else if (sc.state == SCE_HBA_NUMBER) {
+ if (!IsAWordChar(sc.ch)) {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else if (sc.state == SCE_HBA_STRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_HBA_DEFAULT);
+ } else if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.ChangeState(SCE_HBA_STRINGEOL);
+ sc.ForwardSetState(SCE_HBA_DEFAULT);
+ }
+ } else if (sc.state == SCE_HBA_COMMENTLINE) {
+ if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+
+ if (sc.state == SCE_HBA_DEFAULT) {
+ if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ sc.SetState(SCE_HBA_NUMBER);
+ } else if (IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HBA_WORD);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_HBA_COMMENTLINE);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_HBA_STRING);
+ }
+ }
+}
+
+static void ColouriseHTMLPiece(StyleContext &sc, WordList *keywordlists[]) {
+ WordList &keywordsTags = *keywordlists[0];
+ if (sc.state == SCE_H_COMMENT) {
+ if (sc.Match("-->")) {
+ sc.Forward();
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+ } else if (sc.state == SCE_H_ENTITY) {
+ if (sc.ch == ';') {
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch)) { // Should check that '#' follows '&', but it is unlikely anyway...
+ sc.ChangeState(SCE_H_TAGUNKNOWN);
+ sc.SetState(SCE_H_DEFAULT);
+ }
+ } else if (sc.state == SCE_H_TAGUNKNOWN) {
+ if (!ishtmlwordchar(static_cast<char>(sc.ch)) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (s[1] == '/') {
+ if (keywordsTags.InList(s + 2)) {
+ sc.ChangeState(SCE_H_TAG);
+ }
+ } else {
+ if (keywordsTags.InList(s + 1)) {
+ sc.ChangeState(SCE_H_TAG);
+ }
+ }
+ if (sc.ch == '>') {
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.Match('/', '>')) {
+ sc.SetState(SCE_H_TAGEND);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else {
+ sc.SetState(SCE_H_OTHER);
+ }
+ }
+ } else if (sc.state == SCE_H_ATTRIBUTE) {
+ if (!ishtmlwordchar(static_cast<char>(sc.ch))) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (!keywordsTags.InList(s)) {
+ sc.ChangeState(SCE_H_ATTRIBUTEUNKNOWN);
+ }
+ sc.SetState(SCE_H_OTHER);
+ }
+ } else if (sc.state == SCE_H_OTHER) {
+ if (sc.ch == '>') {
+ sc.SetState(SCE_H_TAG);
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.Match('/', '>')) {
+ sc.SetState(SCE_H_TAG);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.chPrev == '=') {
+ sc.SetState(SCE_H_VALUE);
+ }
+ } else if (sc.state == SCE_H_DOUBLESTRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_H_OTHER);
+ }
+ } else if (sc.state == SCE_H_SINGLESTRING) {
+ if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_H_OTHER);
+ }
+ } else if (sc.state == SCE_H_NUMBER) {
+ if (!IsADigit(sc.ch)) {
+ sc.SetState(SCE_H_OTHER);
+ }
+ }
+
+ if (sc.state == SCE_H_DEFAULT) {
+ if (sc.ch == '<') {
+ if (sc.Match("<!--"))
+ sc.SetState(SCE_H_COMMENT);
+ else
+ sc.SetState(SCE_H_TAGUNKNOWN);
+ } else if (sc.ch == '&') {
+ sc.SetState(SCE_H_ENTITY);
+ }
+ } else if ((sc.state == SCE_H_OTHER) || (sc.state == SCE_H_VALUE)) {
+ if (sc.ch == '\"') {
+ sc.SetState(SCE_H_DOUBLESTRING);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_H_SINGLESTRING);
+ } else if (IsADigit(sc.ch)) {
+ sc.SetState(SCE_H_NUMBER);
+ } else if (sc.ch == '>') {
+ sc.SetState(SCE_H_TAG);
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (ishtmlwordchar(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_H_ATTRIBUTE);
+ }
+ }
+}
+
+static void ColouriseASPPiece(StyleContext &sc, WordList *keywordlists[]) {
+ // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
+ if ((sc.state == SCE_H_ASPAT || isASPScript(sc.state)) && sc.Match('%', '>')) {
+ sc.SetState(SCE_H_ASP);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+
+ // Handle some ASP script
+ if (sc.state >= SCE_HBA_START && sc.state <= SCE_HBA_STRINGEOL) {
+ ColouriseHBAPiece(sc, keywordlists);
+ } else if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) {
+ ColouriseHTMLPiece(sc, keywordlists);
+ }
+
+ // Enter new sc.state
+ if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) {
+ if (sc.Match('<', '%')) {
+ if (sc.state == SCE_H_TAGUNKNOWN)
+ sc.ChangeState(SCE_H_ASP);
+ else
+ sc.SetState(SCE_H_ASP);
+ sc.Forward();
+ sc.Forward();
+ if (sc.ch == '@') {
+ sc.ForwardSetState(SCE_H_ASPAT);
+ } else {
+ if (sc.ch == '=') {
+ sc.Forward();
+ }
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+ }
+}
+
+static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ for (; sc.More(); sc.Forward()) {
+ ColouriseASPPiece(sc, keywordlists);
+ }
+ sc.Complete();
+}
+
+static void ColourisePHPPiece(StyleContext &sc, WordList *keywordlists[]) {
+ // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
+ if (sc.state >= SCE_HPHP_DEFAULT && sc.state <= SCE_HPHP_OPERATOR) {
+ if (!isPHPStringState(sc.state) &&
+ (sc.state != SCE_HPHP_COMMENT) &&
+ (sc.Match('?', '>'))) {
+ sc.SetState(SCE_H_QUESTION);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+ }
+
+ if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) {
+ ColouriseHTMLPiece(sc, keywordlists);
+ }
+
+ // Handle some PHP script
+ if (sc.state == SCE_HPHP_WORD) {
+ if (!IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_COMMENTLINE) {
+ if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_COMMENT) {
+ if (sc.Match('*', '/')) {
+ sc.Forward();
+ sc.Forward();
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_HSTRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_SIMPLESTRING) {
+ if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_VARIABLE) {
+ if (!IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_OPERATOR) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+
+ // Enter new sc.state
+ if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) {
+ if (sc.Match("<?php")) {
+ sc.SetState(SCE_H_QUESTION);
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ }
+ if (sc.state == SCE_HPHP_DEFAULT) {
+ if (IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_WORD);
+ } else if (sc.ch == '#') {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match("<!--")) {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match('/', '/')) {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match('/', '*')) {
+ sc.SetState(SCE_HPHP_COMMENT);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_HPHP_HSTRING);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_HPHP_SIMPLESTRING);
+ } else if (sc.ch == '$') {
+ sc.SetState(SCE_HPHP_VARIABLE);
+ } else if (isoperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_HPHP_OPERATOR);
+ }
+ }
+}
+
+static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ for (; sc.More(); sc.Forward()) {
+ ColourisePHPPiece(sc, keywordlists);
+ }
+ sc.Complete();
+}
+
LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
+LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp");
+LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php");
#include "SciLexer.h"
-inline bool isLispoperator(char ch) {
+static inline bool isLispoperator(char ch) {
if (isascii(ch) && isalnum(ch))
return false;
if (ch == '\'' || ch == '(' || ch == ')' )
return false;
}
-inline bool isLispwordstart(char ch) {
+static inline bool isLispwordstart(char ch) {
return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) &&
ch != '\n' && ch != '\r' && ch != '\"';
}
**
** Written by Paul Winwood.
** Folder by Alexey Yutkin.
+ ** Modified by Marcos E. Wurzius
**/
#include <stdlib.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 == '_');
+}
+
+inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+
inline bool isLuaOperator(char ch) {
if (isalnum(ch))
return false;
// '.' left out as it is used to make up numbers
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 false;
}
-static void classifyWordLua(unsigned int start,
- unsigned int end,
- WordList &keywords,
- Accessor &styler) {
- char s[100];
- bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
-
- for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
- s[i] = styler[start + i];
- s[i + 1] = '\0';
- }
-
- char chAttr = SCE_LUA_IDENTIFIER;
-
- if (wordIsNumber)
- chAttr = SCE_LUA_NUMBER;
- else {
- if (keywords.InList(s)) {
- chAttr = SCE_LUA_WORD;
- }
- }
- styler.ColourTo(end, chAttr);
-}
-static void ColouriseLuaDoc(unsigned int startPos,
- int length,
- int initStyle,
- WordList *keywordlists[],
+static void ColouriseLuaDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
-
- styler.StartAt(startPos);
- styler.GetLine(startPos);
-
- int state = initStyle;
- char chPrev = ' ';
- char chNext = styler[startPos];
- unsigned int lengthDoc = startPos + length;
- bool firstChar = true;
-
- /* Must initialize the literalString level, if we are inside such a string.
- * Note: this isn't enough, because literal strings can be nested,
- * we should go back to see at what level we are...
- */
- int literalString = (initStyle == SCE_LUA_LITERALSTRING) ? 1 : 0;
-
- styler.StartSegment(startPos);
- for (unsigned int i = startPos; i <= lengthDoc; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
-
- if (styler.IsLeadByte(ch)) {
- chNext = styler.SafeGetCharAt(i + 2);
- chPrev = ' ';
- i += 1;
- continue;
- }
-
- if (state == SCE_LUA_STRINGEOL) {
- if (ch != '\r' && ch != '\n') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_DEFAULT;
+ 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;
+
+ // Do not leak onto next line
+ if (initStyle == SCE_LUA_STRINGEOL)
+ initStyle = SCE_LUA_DEFAULT;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+ if(startPos == 0 && sc.ch == '#') sc.SetState(SCE_LUA_COMMENTLINE);
+ for (; sc.More(); sc.Forward()) {
+
+ // Handle line continuation generically.
+ if (sc.ch == '\\') {
+ if (sc.Match("\\\n")) {
+ sc.Forward();
+ sc.Forward();
+ continue;
+ }
+ if (sc.Match("\\\r\n")) {
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ continue;
}
}
- if (state == SCE_LUA_LITERALSTRING && ch == '[' && chNext == '[') {
- literalString++;
- } else if (state == SCE_LUA_DEFAULT) {
- if (ch == '-' && chNext == '-') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_COMMENTLINE;
- } else if (ch == '[' && chNext == '[') {
- state = SCE_LUA_LITERALSTRING;
- literalString = 1;
- } else if (ch == '\"') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_STRING;
- } else if (ch == '\'') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_CHARACTER;
- } else if (ch == '$' && firstChar) {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_PREPROCESSOR;
- } else if (ch == '#' && firstChar) // Should be only on the first line of the file! Cannot be tested here
- {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_COMMENTLINE;
- } else if (isLuaOperator(ch)) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_LUA_OPERATOR);
- } else if (iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_WORD;
+ // Determine if the current state should terminate.
+ if (sc.state == SCE_LUA_OPERATOR) {
+ sc.SetState(SCE_LUA_DEFAULT);
+ } else if (sc.state == SCE_LUA_NUMBER) {
+ if (!IsAWordChar(sc.ch)) {
+ sc.SetState(SCE_LUA_DEFAULT);
}
- } else if (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 (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);
}
- } else if (ch == '.' && chNext == '.') {
- classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
- styler.ColourTo(i, SCE_LUA_OPERATOR);
- state = SCE_LUA_DEFAULT;
+ sc.SetState(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);
+
+
+ } 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);
}
-
- if (state == SCE_LUA_DEFAULT) {
- if (ch == '-' && chNext == '-') {
- state = SCE_LUA_COMMENTLINE;
- } else if (ch == '\"') {
- state = SCE_LUA_STRING;
- } else if (ch == '\'') {
- state = SCE_LUA_CHARACTER;
- } else if (ch == '$' && firstChar) {
- state = SCE_LUA_PREPROCESSOR;
- } else if (iswordstart(ch)) {
- state = SCE_LUA_WORD;
- } else if (isLuaOperator(ch)) {
- styler.ColourTo(i, SCE_LUA_OPERATOR);
+
+ } else if (sc.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;
+ } else if (sc.ch == '-' && sc.chNext == '-') {
+ sc.SetState(SCE_LUA_COMMENTLINE);
+ } else if (isLuaOperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_LUA_OPERATOR);
}
}
- chPrev = ch;
- firstChar = (ch == '\r' || ch == '\n');
}
- styler.ColourTo(lengthDoc - 1, state);
+ sc.Complete();
}
+
static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[],
Accessor &styler) {
unsigned int lengthDoc = startPos + length;
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
int styleNext = styler.StyleAt(startPos);
char s[10];
for (unsigned int i = startPos; i < lengthDoc; i++) {
int style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
- if (style == SCE_LUA_WORD)
- if ( ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') {
+ if (style == SCE_LUA_WORD) {
+ if ( ch == 'i' || ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') {
for (unsigned int j = 0; j < 8; j++) {
- if (!iswordchar(styler[i + j])) break;
+ if (!iswordchar(styler[i + j]))
+ break;
s[j] = styler[i + j];
s[j + 1] = '\0';
}
-
- if ((strcmp(s, "then") == 0) || (strcmp(s, "do") == 0)
- || (strcmp(s, "function") == 0))
+
+ if ((strcmp(s, "if") == 0) || (strcmp(s, "do") == 0)
+ || (strcmp(s, "function") == 0))
levelCurrent++;
- if (strcmp(s, "end") == 0) levelCurrent--;
+ if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0))
+ levelCurrent--;
+
}
-
+ }
+ else if (style == SCE_LUA_OPERATOR)
+ {
+ if(ch == '{' || ch == '(')
+ levelCurrent++;
+ else if(ch == '}' || ch == ')')
+ levelCurrent--;
+ }
+
if (atEOL) {
int lev = levelPrev;
- if (visibleChars == 0)
+ if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
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);
}
--- /dev/null
+// Scintilla source code edit control
+/** @file LexMatlab.cxx
+ ** Lexer for Matlab.
+ ** Written by José 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);
#include "Scintilla.h"
#include "SciLexer.h"
+static inline bool AtEOL(Accessor &styler, unsigned int i) {
+ return (styler[i] == '\n') ||
+ ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
+}
+
static void ColouriseBatchLine(
char *lineBuffer,
unsigned int lengthLine,
unsigned int i = 0;
unsigned int state = SCE_BAT_DEFAULT;
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip initial spaces
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip initial spaces
i++;
}
if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
styler.ColourTo(startLine + i, SCE_BAT_HIDE);
i++;
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip next spaces
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip next spaces
i++;
}
}
styler.StartAt(startPos);
styler.StartSegment(startPos);
- unsigned int linePos = 0, startLine = startPos;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ unsigned int linePos = 0;
+ unsigned int startLine = startPos;
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >=
- sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
- if (styler[i + 1] == '\n') {
- lineBuffer[linePos++] = styler[++i];
- }
lineBuffer[linePos] = '\0';
ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
linePos = 0;
startLine = i + 1;
}
}
- if (linePos > 0) {
- ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length,
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
keywords, styler);
}
}
unsigned int linePos = 0;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
+ lineBuffer[linePos] = '\0';
ColouriseDiffLine(lineBuffer, i, styler);
linePos = 0;
}
}
- if (linePos > 0)
- ColouriseDiffLine(lineBuffer, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
+ }
}
static void ColourisePropsLine(
Accessor &styler) {
unsigned int i = 0;
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
i++;
- if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
- styler.ColourTo(endPos, 1);
- } else if (lineBuffer[i] == '[') {
- styler.ColourTo(endPos, 2);
- } else if (lineBuffer[i] == '@') {
- styler.ColourTo(startLine + i, 4);
- if (lineBuffer[++i] == '=')
- styler.ColourTo(startLine + i, 3);
- styler.ColourTo(endPos, 0);
- } 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);
+ if (i < lengthLine) {
+ if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
+ styler.ColourTo(endPos, 1);
+ } else if (lineBuffer[i] == '[') {
+ styler.ColourTo(endPos, 2);
+ } else if (lineBuffer[i] == '@') {
+ styler.ColourTo(startLine + i, 4);
+ if (lineBuffer[++i] == '=')
+ styler.ColourTo(startLine + i, 3);
styler.ColourTo(endPos, 0);
} 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);
}
}
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
- unsigned int linePos = 0, startLine = startPos;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ unsigned int linePos = 0;
+ unsigned int startLine = startPos;
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if ((styler[i] == '\r' && styler.SafeGetCharAt(i + 1) != '\n') ||
- styler[i] == '\n' ||
- (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0;
startLine = i + 1;
}
}
- if (linePos > 0)
- ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
+ }
}
static void ColouriseMakeLine(
unsigned int state = SCE_MAKE_DEFAULT;
bool bSpecial = false;
// Skip initial spaces
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) {
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
i++;
}
if (lineBuffer[i] == '#') { // Comment
}
if (!bSpecial) {
if (lineBuffer[i] == ':') {
+ // We should check that no colouring was made since the beginning of the line,
+ // to avoid colouring stuff like /OUT:file
styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
- unsigned int linePos = 0, startLine = startPos;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ unsigned int linePos = 0;
+ unsigned int startLine = startPos;
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0;
startLine = i + 1;
}
}
- if (linePos > 0) {
- ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
}
}
// Borland warning message
styler.ColourTo(endPos, SCE_ERR_BORLAND);
} else if (strstr(lineBuffer, "at line " ) &&
- strstr(lineBuffer, "at line " ) < lineBuffer + lengthLine &&
+ (strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
strstr(lineBuffer, "file ") &&
- strstr(lineBuffer, "file ") < lineBuffer + lengthLine) {
+ (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
// Lua error message
styler.ColourTo(endPos, SCE_ERR_LUA);
} else if (strstr(lineBuffer, " at " ) &&
- strstr(lineBuffer, " at " ) < lineBuffer + lengthLine &&
+ (strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
strstr(lineBuffer, " line ") &&
- strstr(lineBuffer, " line ") < lineBuffer + lengthLine) {
+ (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine))) {
// perl error message
styler.ColourTo(endPos, SCE_ERR_PERL);
} else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
// Look for <filename>(line,pos)message
int state = 0;
for (unsigned int i = 0; i < lengthLine; i++) {
- if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
+ if ((state == 0) && (lineBuffer[i] == ':') && isdigit(lineBuffer[i + 1])) {
state = 1;
- } else if (state == 0 && lineBuffer[i] == '(') {
+ } else if ((state == 0) && (lineBuffer[i] == '(')) {
state = 10;
- } else if (state == 1 && isdigit(lineBuffer[i])) {
+ } else if ((state == 1) && isdigit(lineBuffer[i])) {
state = 2;
- } else if (state == 2 && lineBuffer[i] == ':') {
+ } else if ((state == 2) && (lineBuffer[i] == ':')) {
state = 3;
break;
- } else if (state == 2 && !isdigit(lineBuffer[i])) {
+ } else if ((state == 2) && !isdigit(lineBuffer[i])) {
state = 99;
- } else if (state == 10 && isdigit(lineBuffer[i])) {
+ } else if ((state == 10) && isdigit(lineBuffer[i])) {
state = 11;
- } else if (state == 11 && lineBuffer[i] == ',') {
+ } else if ((state == 11) && (lineBuffer[i] == ',')) {
state = 14;
- } else if (state == 11 && lineBuffer[i] == ')') {
+ } else if ((state == 11) && (lineBuffer[i] == ')')) {
state = 12;
- } else if (state == 12 && lineBuffer[i] == ':') {
+ } else if ((state == 12) && (lineBuffer[i] == ':')) {
state = 13;
- } else if (state == 14 && lineBuffer[i] == ')') {
+ } else if ((state == 14) && (lineBuffer[i] == ')')) {
state = 15;
break;
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
+ lineBuffer[linePos] = '\0';
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
linePos = 0;
}
}
- if (linePos > 0)
- ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
+ }
}
static int isSpecial(char s) {
#include "Scintilla.h"
#include "SciLexer.h"
-
static int classifyWordPascal(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char s[100];
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
styler.StartAt(startPos);
- bool fold = styler.GetPropertyInt("fold");
+ bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
}
chPrev = ch;
}
- styler.ColourTo(lengthDoc, state);
+ styler.ColourTo(lengthDoc - 1, state);
}
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl");
// Scintilla source code edit control
/** @file LexPython.cxx
** Lexer for Python.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+ **/
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
enum kwType { kwOther, kwClass, kwDef, kwImport };
static bool IsPyComment(Accessor &styler, int pos, int len) {
- return len>0 && styler[pos]=='#';
+ return len > 0 && styler[pos] == '#';
}
static bool IsPyStringStart(int ch, int chNext, int chNext2) {
i++;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
- }
- else if (ch == 'u' || ch == 'U') {
+ } else if (ch == 'u' || ch == 'U') {
if (chNext == 'r' || chNext == 'R')
i += 2;
else
}
}
-inline bool IsAWordChar(int ch) {
+static inline bool IsAWordChar(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
-inline bool IsAWordStart(int ch) {
+static inline bool IsAWordStart(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) {
int endPos = startPos + length;
int lineCurrent = styler.GetLine(startPos);
if (startPos > 0) {
if (lineCurrent > 0) {
- startPos = styler.LineStart(lineCurrent-1);
+ startPos = styler.LineStart(lineCurrent - 1);
if (startPos == 0)
initStyle = SCE_P_DEFAULT;
else
- initStyle = styler.StyleAt(startPos-1);
+ initStyle = styler.StyleAt(startPos - 1);
}
}
kwType kwLast = kwOther;
int spaceFlags = 0;
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
-
+ bool hexadecimal = false;
+
// Python uses a different mask because bad indentation is marked by oring with 32
- StyleContext sc(startPos, endPos-startPos, initStyle, styler, 0x7f);
-
+ StyleContext sc(startPos, endPos - startPos, initStyle, styler, 0x7f);
+
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
}
if (sc.atLineEnd) {
- if ((sc.state == SCE_P_DEFAULT) ||
- (sc.state == SCE_P_TRIPLE) ||
- (sc.state == SCE_P_TRIPLEDOUBLE)) {
+ if ((sc.state == SCE_P_DEFAULT) ||
+ (sc.state == SCE_P_TRIPLE) ||
+ (sc.state == SCE_P_TRIPLEDOUBLE)) {
// Perform colourisation of white space and triple quoted strings at end of each line to allow
// tab marking to work inside white space and triple quoted strings
sc.ForwardSetState(sc.state);
sc.ChangeState(SCE_P_STRINGEOL);
sc.ForwardSetState(SCE_P_DEFAULT);
}
+ if (!sc.More())
+ break;
}
// Check for a state end
kwLast = kwOther;
sc.SetState(SCE_C_DEFAULT);
} else if (sc.state == SCE_P_NUMBER) {
- if (!IsAWordChar(sc.ch)) {
+ if (!IsAWordChar(sc.ch) &&
+ !(!hexadecimal && ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
sc.SetState(SCE_P_DEFAULT);
}
- } else if (sc.state == SCE_P_WORD) {
+ } else if (sc.state == SCE_P_IDENTIFIER) {
if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) {
char s[100];
sc.GetCurrent(s, sizeof(s));
else
kwLast = kwOther;
} else if (style == SCE_P_CLASSNAME) {
- kwLast = kwOther;
+ kwLast = kwOther;
} else if (style == SCE_P_DEFNAME) {
- kwLast = kwOther;
+ kwLast = kwOther;
}
}
} else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) {
// Check for a new state starting character
if (sc.state == SCE_P_DEFAULT) {
- if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
+ if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ if (sc.ch == '0' && (sc.chNext == 'x' || sc.chNext == 'X')) {
+ hexadecimal = true;
+ } else {
+ hexadecimal = false;
+ }
+ sc.SetState(SCE_P_NUMBER);
+ } else if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
sc.SetState(SCE_P_OPERATOR);
} else if (sc.ch == '#') {
sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);
- } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
- sc.SetState(SCE_P_NUMBER);
} else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2))) {
int nextIndex = 0;
sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex));
- while (nextIndex > (sc.currentPos+1)) {
+ while (nextIndex > (sc.currentPos + 1)) {
sc.Forward();
}
} else if (IsAWordStart(sc.ch)) {
- sc.SetState(SCE_P_WORD);
+ sc.SetState(SCE_P_IDENTIFIER);
}
}
}
static bool IsCommentLine(int line, Accessor &styler) {
int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line+1) - 1;
+ int eol_pos = styler.LineStart(line + 1) - 1;
for (int i = pos; i < eol_pos; i++) {
char ch = styler[i];
if (ch == '#')
static bool IsQuoteLine(int line, Accessor &styler) {
int style = styler.StyleAt(styler.LineStart(line)) & 31;
- return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
+ return ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
}
static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
- WordList *[], Accessor &styler) {
+ WordList *[], Accessor &styler) {
const int maxPos = startPos + length;
- const int maxLines = styler.GetLine(maxPos-1); // Requested last line
+ const int maxLines = styler.GetLine(maxPos - 1); // Requested last line
const int docLines = styler.GetLine(styler.Length() - 1); // Available last line
- const bool foldComment = styler.GetPropertyInt("fold.comment.python");
- const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
-
+ const bool foldComment = styler.GetPropertyInt("fold.comment.python") != 0;
+ const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0;
+
// Backtrack to previous non-blank line so we can determine indent level
// for any white space lines (needed esp. within triple quoted strings)
// and so we can fix any preceding fold level (which is why we go back
lineCurrent--;
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) &&
- (!IsCommentLine(lineCurrent, styler)) &&
- (!IsQuoteLine(lineCurrent, styler)))
+ (!IsCommentLine(lineCurrent, styler)) &&
+ (!IsQuoteLine(lineCurrent, styler)))
break;
}
int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
-
+
// Set up initial loop state
startPos = styler.LineStart(lineCurrent);
int prev_state = SCE_P_DEFAULT & 31;
if (lineCurrent >= 1)
- prev_state = styler.StyleAt(startPos-1) & 31;
+ prev_state = styler.StyleAt(startPos - 1) & 31;
int prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
int prevComment = 0;
if (lineCurrent >= 1)
// Information about next line is only available if not at end of document
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
- quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
+ quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
}
const int quote_start = (quote && !prevQuote);
const int quote_continue = (quote && prevQuote);
const int comment = foldComment && IsCommentLine(lineCurrent, styler);
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);
if ((!quote || !prevQuote) && !comment)
indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
// than screwing up folding.
const int saveIndentNext = indentNext;
while (!quote &&
- (lineNext < docLines) &&
- ((indentNext & SC_FOLDLEVELWHITEFLAG) ||
- (lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) {
+ (lineNext < docLines) &&
+ ((indentNext & SC_FOLDLEVELWHITEFLAG) ||
+ (lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) {
lineNext++;
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
// 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.
const int skip_level = Platform::Maximum(indentCurrentLevel,
- indentNext & SC_FOLDLEVELNUMBERMASK);
-
+ indentNext & SC_FOLDLEVELNUMBERMASK);
+
// Now set all the indent levels on the lines we skipped
int skipLine = lineCurrent + 1;
int skipIndentNext = saveIndentNext;
skipLine++;
skipIndentNext = styler.IndentAmount(skipLine, &spaceFlags, NULL);
}
-
+
// Set fold header on non-quote/non-comment line
if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
static void ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
char s[100];
- bool wordIsNumber = isdigit(styler[start]);
+ bool wordIsNumber = isdigit(styler[start]) != 0;
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
chPrev = ch;
}
if (state == SCE_P_WORD) {
- ClassifyWordRb(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
+ ClassifyWordRb(styler.GetStartSegment(), lengthDoc-1, keywords, styler, prevWord);
} else {
- styler.ColourTo(lengthDoc, state);
+ styler.ColourTo(lengthDoc-1, state);
}
}
/** @file LexSQL.cxx
** Lexer for SQL.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
styler.StartAt(startPos);
- bool fold = styler.GetPropertyInt("fold");
+ bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos);
int spaceFlags = 0;
#include "PropSet.h"
#include "Accessor.h"
+#include "StyleContext.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
-static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
+static bool IsVBComment(Accessor &styler, int pos, int len) {
+ return len>0 && styler[pos]=='\'';
+}
- 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 inline bool IsTypeCharacter(const int ch) {
+ return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$';
}
-static bool IsVBComment(Accessor &styler, int pos, int len) {
- return len>0 && styler[pos]=='\'';
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsADateCharacter(const int ch) {
+ return (ch < 0x80) &&
+ (isalnum(ch) || ch == '|' || ch == '-' || ch == '/' || ch == ':' || ch == ' ' || ch == '\t');
}
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
int visibleChars = 0;
- int state = initStyle;
- char chNext = styler[startPos];
- styler.StartSegment(startPos);
- int lengthDoc = startPos + length;
- for (int i = startPos; i < lengthDoc; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
-
- if (styler.IsLeadByte(ch)) {
- chNext = styler.SafeGetCharAt(i + 2);
- i += 1;
- continue;
- }
-
- if (ch == '\r' || ch == '\n') {
- // End of line
- if (state == SCE_C_COMMENTLINE || state == SCE_C_PREPROCESSOR) {
- styler.ColourTo(i - 1, state);
- state = SCE_C_DEFAULT;
- }
- visibleChars = 0;
- }
- if (!isspacechar(ch))
- visibleChars++;
-
- if (state == SCE_C_DEFAULT) {
- if (iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_C_WORD;
- } else if (ch == '\'') {
- styler.ColourTo(i - 1, state);
- state = SCE_C_COMMENTLINE;
- } else if (ch == '\"') {
- styler.ColourTo(i - 1, state);
- state = SCE_C_STRING;
- } else if (ch == '#' && visibleChars == 1) {
- // Preprocessor commands are alone on their line
- styler.ColourTo(i - 1, state);
- state = SCE_C_PREPROCESSOR;
- } else if (ch == '&' && tolower(chNext) == 'h') {
- styler.ColourTo(i - 1, state);
- state = SCE_C_WORD;
- } else if (isoperator(ch)) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_C_OPERATOR);
- }
- } else if (state == SCE_C_WORD) {
- if (!iswordchar(ch)) {
- state = classifyWordVB(styler.GetStartSegment(), i - 1, keywords, styler);
- if (state == SCE_C_DEFAULT) {
- if (ch == '\'') {
- state = SCE_C_COMMENTLINE;
- } else if (ch == '\"') {
- state = SCE_C_STRING;
- } else if (isoperator(ch)) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_C_OPERATOR);
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+
+ if (sc.state == SCE_B_OPERATOR) {
+ sc.SetState(SCE_B_DEFAULT);
+ } else if (sc.state == SCE_B_KEYWORD) {
+ if (!IsAWordChar(sc.ch)) {
+ if (vbScriptSyntax || !IsTypeCharacter(sc.ch)) {
+ if (sc.ch == ']')
+ sc.Forward();
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywords.InList(s)) {
+ if (strcmp(s, "rem") == 0) {
+ sc.ChangeState(SCE_B_COMMENT);
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else {
+ sc.ChangeState(SCE_B_IDENTIFIER);
+ sc.SetState(SCE_B_DEFAULT);
}
}
}
- } else {
- if (state == SCE_C_STRING) {
- // VB doubles quotes to preserve them
- if (ch == '\"') {
- styler.ColourTo(i, state);
- state = SCE_C_DEFAULT;
- i++;
- ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
+ } else if (sc.state == SCE_B_NUMBER) {
+ if (!IsAWordChar(sc.ch)) {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else if (sc.state == SCE_B_STRING) {
+ // VB doubles quotes to preserve them, so just end this string
+ // state now as a following quote will start again
+ if (sc.ch == '\"') {
+ if (tolower(sc.chNext) == 'c') {
+ sc.Forward();
}
+ sc.ForwardSetState(SCE_B_DEFAULT);
+ }
+ } else if (sc.state == SCE_B_COMMENT) {
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else if (sc.state == SCE_B_PREPROCESSOR) {
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_B_DEFAULT);
}
- if (state == SCE_C_DEFAULT) { // One of the above succeeded
- if (ch == '\'') {
- state = SCE_C_COMMENTLINE;
- } else if (ch == '\"') {
- state = SCE_C_STRING;
- } else if (iswordstart(ch)) {
- state = SCE_C_WORD;
+ } else 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) {
- int lengthDoc = startPos + length;
+ int endPos = startPos + length;
// Backtrack to previous line in case need to fix its fold status
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) {
lineCurrent--;
startPos = styler.LineStart(lineCurrent);
- if (startPos == 0)
- initStyle = SCE_P_DEFAULT;
- else
- initStyle = styler.StyleAt(startPos-1);
}
}
- int state = initStyle & 31;
int spaceFlags = 0;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsVBComment);
- if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
- indentCurrent |= SC_FOLDLEVELWHITEFLAG;
char chNext = styler[startPos];
- for (int i = startPos; i < lengthDoc; i++) {
+ for (int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
- int style = styler.StyleAt(i) & 31;
- if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
+ if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsVBComment);
- if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE))
- indentNext |= SC_FOLDLEVELWHITEFLAG;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
}
}
-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);
+
#include "Scintilla.h"
#include "LineMarker.h"
-static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
+static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
PRectangle rc;
rc.left = centreX - armSize;
rc.top = centreY - armSize;
surface->RectangleDraw(rc, back, fore);
}
-static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
+static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
PRectangle rcCircle;
rcCircle.left = centreX - armSize;
rcCircle.top = centreY - armSize;
surface->Ellipse(rcCircle, back, fore);
}
-static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
+static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore);
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
-static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
+static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
rcSmall.bottom = rc.bottom - 2;
surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
- } else if (markType == SC_MARK_EMPTY) {
+ } else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND) {
// An invisible marker so don't draw anything
} else if (markType == SC_MARK_VLINE) {
ColourPair back;
LineMarker() {
markType = SC_MARK_CIRCLE;
- fore = Colour(0,0,0);
- back = Colour(0xff,0xff,0xff);
+ fore = ColourDesired(0,0,0);
+ back = ColourDesired(0xff,0xff,0xff);
}
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
};
/** @file PropSet.cxx
** A Java style properties file module.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// Maintain a dictionary of properties
}
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) {
- while (*a && *b) {
- if (*a != *b) {
- char upperA = MakeUpperCase(*a);
- char upperB = MakeUpperCase(*b);
- if (upperA != upperB)
- return upperA - upperB;
- }
- a++;
- b++;
- }
- // Either *a or *b is nul
- return *a - *b;
+ while (*a && *b) {
+ if (*a != *b) {
+ char upperA = MakeUpperCase(*a);
+ char upperB = MakeUpperCase(*b);
+ if (upperA != upperB)
+ return upperA - upperB;
+ }
+ a++;
+ b++;
+ }
+ // Either *a or *b is nul
+ return *a - *b;
}
int CompareNCaseInsensitive(const char *a, const char *b, int len) {
- while (*a && *b && len) {
- if (*a != *b) {
- char upperA = MakeUpperCase(*a);
- char upperB = MakeUpperCase(*b);
- if (upperA != upperB)
- return upperA - upperB;
- }
- a++;
- b++;
- len--;
- }
- if (len == 0)
- return 0;
- else
- // Either *a or *b is nul
- return *a - *b;
+ while (*a && *b && len) {
+ if (*a != *b) {
+ char upperA = MakeUpperCase(*a);
+ char upperB = MakeUpperCase(*b);
+ if (upperA != upperB)
+ return upperA - upperB;
+ }
+ a++;
+ b++;
+ len--;
+ }
+ if (len == 0)
+ return 0;
+ else
+ // Either *a or *b is nul
+ return *a - *b;
}
-
bool EqualCaseInsensitive(const char *a, const char *b) {
return 0 == CompareCaseInsensitive(a, b);
}
lenVal = strlen(val);
unsigned int hash = HashString(key, lenKey);
for (Property *p = props[hash % hashRoots]; p; p = p->next) {
- if ((hash == p->hash) &&
- ((strlen(p->key) == static_cast<unsigned int>(lenKey)) &&
+ if ((hash == p->hash) &&
+ ((strlen(p->key) == static_cast<unsigned int>(lenKey)) &&
(0 == strncmp(p->key, key, lenKey)))) {
// Replace current value
delete [](p->val);
* The length of the word to compare is passed too.
* Letter case can be ignored or preserved (default).
*/
-const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/) {
+const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */) {
int start = 0; // lower bound of the api array block to search
int end = len - 1; // upper bound of the api array block to search
int pivot; // index of api array element just being compared
pivot = (start + end) >> 1;
word = wordsNoCase[pivot];
cond = CompareNCaseInsensitive(wordStart, word, searchLen);
- if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
- return word; // result must not be freed with free()
+ if (!cond && (!wordCharacters.contains(word[searchLen])))
+ return word; // result must not be freed with free()
else if (cond > 0)
start = pivot + 1;
else if (cond <= 0)
pivot = (start + end) >> 1;
word = words[pivot];
cond = strncmp(wordStart, word, searchLen);
- if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
+ if (!cond && (!wordCharacters.contains(word[searchLen])))
return word; // result must not be freed with free()
else if (cond > 0)
start = pivot + 1;
if (!cond) {
// Find first match
while ((pivot > start) &&
- (0 == CompareNCaseInsensitive(wordStart,
+ (0 == CompareNCaseInsensitive(wordStart,
wordsNoCase[pivot-1], searchLen))) {
--pivot;
}
// Grab each match
while ((pivot <= end) &&
- (0 == CompareNCaseInsensitive(wordStart,
+ (0 == CompareNCaseInsensitive(wordStart,
wordsNoCase[pivot], searchLen))) {
wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1;
wordsNear.append(wordsNoCase[pivot], wordlen, ' ');
if (!cond) {
// Find first match
while ((pivot > start) &&
- (0 == strncmp(wordStart,
- words[pivot-1], searchLen))) {
+ (0 == strncmp(wordStart,
+ words[pivot-1], searchLen))) {
--pivot;
}
// Grab each match
while ((pivot <= end) &&
- (0 == strncmp(wordStart,
- words[pivot], searchLen))) {
+ (0 == strncmp(wordStart,
+ words[pivot], searchLen))) {
wordlen = LengthWord(words[pivot], otherSeparator) + 1;
wordsNear.append(words[pivot], wordlen, ' ');
++pivot;
* Modification history:
*
* $Log$
- * Revision 1.2 2001/10/18 01:24:58 RD
- * Updated to version 1.40 of Scintilla
+ * Revision 1.3 2002/03/18 22:31:00 RD
+ * Updated wxSTC from Scintilla 1.40 to Scintilla 1.45
*
* Revision 1.6 2001/04/29 13:32:10 nyamatongwe
* Addition of new target methods - versions of ReplaceTarget that take counted
/** @file ScintillaBase.cxx
** An enhanced subclass of Editor with calltips, autocomplete and context menu.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
ct.RefreshColourPalette(pal, want);
}
-void ScintillaBase::AddCharUTF(char *s, unsigned int len) {
+void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool acActiveBeforeCharAdded = ac.Active();
if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s))
- Editor::AddCharUTF(s, len);
+ Editor::AddCharUTF(s, len, treatAsDBCS);
if (acActiveBeforeCharAdded)
AutoCompleteChanged(s[0]);
}
AutoCompleteMove(5000);
return 0;
case SCI_DELETEBACK:
- DelCharBack();
+ DelCharBack(true);
+ AutoCompleteChanged();
+ EnsureCaretVisible();
+ return 0;
+ case SCI_DELETEBACKNOTLINE:
+ DelCharBack(false);
AutoCompleteChanged();
EnsureCaretVisible();
return 0;
(iMessage != SCI_CHARRIGHT) &&
(iMessage != SCI_CHARLEFTEXTEND) &&
(iMessage != SCI_EDITTOGGLEOVERTYPE) &&
- (iMessage != SCI_DELETEBACK)
+ (iMessage != SCI_DELETEBACK) &&
+ (iMessage != SCI_DELETEBACKNOTLINE)
) {
ct.CallTipCancel();
}
- if (iMessage == SCI_DELETEBACK) {
+ if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
if (currentPos <= ct.posStartCallTip) {
ct.CallTipCancel();
}
return Editor::KeyCommand(iMessage);
}
+void ScintillaBase::AutoCompleteDoubleClick(void* p) {
+ ScintillaBase* sci = reinterpret_cast<ScintillaBase*>(p);
+ sci->AutoCompleteCompleted();
+}
+
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
//Platform::DebugPrintf("AutoComplete %s\n", list);
ct.CallTipCancel();
pdoc->InsertString(currentPos, list + lenEntered);
SetEmptySelection(currentPos + strlen(list + lenEntered));
}
- return ;
+ return;
}
}
ac.Start(wMain, idAutoComplete, currentPos, lenEntered);
ac.lb.SetPositionRelative(rcac, wMain);
ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font);
ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth);
+ ac.lb.SetDoubleClickAction(AutoCompleteDoubleClick, this);
ac.SetList(list);
scn.lParam = 0;
scn.text = userListSelected.c_str();
NotifyParent(scn);
- return ;
+ return;
}
Position firstPos = ac.posStart - ac.startLen;
- if (currentPos < firstPos)
- return ;
- if (currentPos != firstPos) {
- pdoc->DeleteChars(firstPos, currentPos - firstPos);
+ Position endPos = currentPos;
+ if (ac.dropRestOfWord)
+ endPos = pdoc->ExtendWordSelect(endPos, 1, true);
+ if (endPos < firstPos)
+ return;
+ pdoc->BeginUndoAction();
+ if (endPos != firstPos) {
+ pdoc->DeleteChars(firstPos, endPos - firstPos);
}
SetEmptySelection(ac.posStart);
if (item != -1) {
pdoc->InsertString(firstPos, piece.c_str());
SetEmptySelection(firstPos + piece.length());
}
+ pdoc->EndUndoAction();
}
void ScintillaBase::ContextMenu(Point pt) {
styleStart = styler.StyleAt(start - 1);
styler.SetCodePage(pdoc->dbcsCodePage);
- if (lexCurrent) { // Should always succeed as null lexer should always be available
+ if (lexCurrent && (len > 0)) { // Should always succeed as null lexer should always be available
lexCurrent->Lex(start, len, styleStart, keyWordLists, styler);
styler.Flush();
if (styler.GetPropertyInt("fold")) {
int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);
endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);
Colourise(endStyled, endStyleNeeded);
- return ;
+ return;
}
#endif
Editor::NotifyStyleToNeeded(endStyleNeeded);
break;
case SCI_AUTOCSETCANCELATSTART:
- ac.cancelAtStartPos = wParam;
+ ac.cancelAtStartPos = wParam != 0;
break;
case SCI_AUTOCGETCANCELATSTART:
break;
case SCI_AUTOCSETCHOOSESINGLE:
- ac.chooseSingle = wParam;
+ ac.chooseSingle = wParam != 0;
break;
case SCI_AUTOCGETCHOOSESINGLE:
return ac.chooseSingle;
case SCI_AUTOCSETIGNORECASE:
- ac.ignoreCase = wParam;
+ ac.ignoreCase = wParam != 0;
break;
case SCI_AUTOCGETIGNORECASE:
break;
case SCI_AUTOCSETAUTOHIDE:
- ac.autoHide = wParam;
+ ac.autoHide = wParam != 0;
break;
case SCI_AUTOCGETAUTOHIDE:
return ac.autoHide;
+ case SCI_AUTOCSETDROPRESTOFWORD:
+ ac.dropRestOfWord = wParam != 0;
+ break;
+
+ case SCI_AUTOCGETDROPRESTOFWORD:
+ return ac.dropRestOfWord;
+
case SCI_CALLTIPSHOW: {
AutoCompleteCancel();
if (!ct.wCallTip.Created()) {
PRectangle rc = ct.CallTipStart(currentPos, pt,
reinterpret_cast<char *>(lParam),
vs.styles[STYLE_DEFAULT].fontName,
- vs.styles[STYLE_DEFAULT].sizeZoomed);
+ vs.styles[STYLE_DEFAULT].sizeZoomed,
+ IsUnicodeMode());
// If the call-tip window would be out of the client
// space, adjust so it displays above the text.
PRectangle rcClient = GetClientRectangle();
break;
case SCI_CALLTIPSETBACK:
- ct.colourBG = Colour(wParam);
+ ct.colourBG = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_USEPOPUP:
- displayPopupMenu = wParam;
+ displayPopupMenu = wParam != 0;
break;
#ifdef SCI_LEXER
/** @file ScintillaBase.h
** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef SCINTILLABASE_H
enum {
idCallTip=1,
idAutoComplete=2,
-
+
idcmdUndo=10,
idcmdRedo=11,
idcmdCut=12,
int listType; ///< 0 is an autocomplete list
SString userListSelected; ///< Receives listbox selected string
-
+
#ifdef SCI_LEXER
int lexLanguage;
- LexerModule *lexCurrent;
+ const LexerModule *lexCurrent;
PropSet props;
enum {numWordLists=6};
WordList *keyWordLists[numWordLists+1];
virtual void Finalise() = 0;
virtual void RefreshColourPalette(Palette &pal, bool want);
-
- virtual void AddCharUTF(char *s, unsigned int len);
+
+ virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void Command(int cmdId);
virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage);
-
+
void AutoCompleteStart(int lenEntered, const char *list);
void AutoCompleteCancel();
void AutoCompleteMove(int delta);
void AutoCompleteChanged(char ch=0);
void AutoCompleteCompleted(char fillUp='\0');
void AutoCompleteMoveToCurrentWord();
+ static void AutoCompleteDoubleClick(void* p);
virtual void CreateCallTipWindow(PRectangle rc) = 0;
-
+
virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0;
void ContextMenu(Point pt);
-
+
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
virtual void NotifyStyleToNeeded(int endStyleNeeded);
Style::Style() {
aliasOfDefaultFont = true;
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
- false, false, false, false, caseMixed, true);
+ false, false, false, false, caseMixed, true, true);
}
Style::Style(const Style &source) {
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, 0,
- false, false, false, false, caseMixed, true);
+ false, false, false, false, caseMixed, true, true);
fore.desired = source.fore.desired;
back.desired = source.back.desired;
characterSet = source.characterSet;
underline = source.underline;
caseForce = source.caseForce;
visible = source.visible;
+ changeable = source.changeable;
}
Style::~Style() {
Style &Style::operator=(const Style &source) {
if (this == &source)
return * this;
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, SC_CHARSET_DEFAULT,
- false, false, false, false, caseMixed, true);
+ false, false, false, false, caseMixed, true, true);
fore.desired = source.fore.desired;
back.desired = source.back.desired;
characterSet = source.characterSet;
underline = source.underline;
caseForce = source.caseForce;
visible = source.visible;
+ changeable = source.changeable;
return *this;
}
-void Style::Clear(Colour fore_, Colour back_, int size_,
+void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_,
- bool underline_, ecaseForced caseForce_, bool visible_) {
+ bool underline_, ecaseForced caseForce_,
+ bool visible_, bool changeable_) {
fore.desired = fore_;
back.desired = back_;
characterSet = characterSet_;
underline = underline_;
caseForce = caseForce_;
visible = visible_;
+ changeable = changeable_;
if (aliasOfDefaultFont)
font.SetID(0);
else
source.eolFilled,
source.underline,
source.caseForce,
- source.visible);
+ source.visible,
+ source.changeable);
}
bool Style::EquivalentFontTo(const Style *other) const {
enum ecaseForced {caseMixed, caseUpper, caseLower};
ecaseForced caseForce;
bool visible;
+ bool changeable;
Font font;
int sizeZoomed;
Style(const Style &source);
~Style();
Style &operator=(const Style &source);
- void Clear(Colour fore_, Colour back_,
+ void Clear(ColourDesired fore_, ColourDesired back_,
int size_,
const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_,
- bool underline_, ecaseForced caseForce_, bool visible_);
+ bool underline_, ecaseForced caseForce_,
+ bool visible_, bool changeable_);
void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0);
+ bool IsProtected() { return !(changeable && visible);} ;
};
#endif
styler.ColourTo(currentPos - 1, state);
}
bool More() {
- return currentPos <= endPos;
+ return currentPos < endPos;
}
void Forward() {
- atLineStart = atLineEnd;
- // A lot of this is repeated from the constructor - TODO: merge code
- chPrev = ch;
- currentPos++;
- if (ch >= 0x100)
+ if (currentPos < endPos) {
+ atLineStart = atLineEnd;
+ // A lot of this is repeated from the constructor - TODO: merge code
+ chPrev = ch;
currentPos++;
- ch = chNext;
- chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
- if (styler.IsLeadByte(static_cast<char>(chNext))) {
- chNext = chNext << 8;
- chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
+ if (ch >= 0x100)
+ currentPos++;
+ ch = chNext;
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
+ if (styler.IsLeadByte(static_cast<char>(chNext))) {
+ chNext = chNext << 8;
+ chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
+ }
+ // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
+ // Avoid triggering two times on Dos/Win
+ // End of line
+ 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_) {
state = state_;
}
return true;
}
+ bool MatchIgnoreCase(const char *s) {
+ if (tolower(ch) != *s)
+ return false;
+ s++;
+ if (tolower(chNext) != *s)
+ return false;
+ s++;
+ for (int n=2; *s; n++) {
+ if (*s != tolower((styler.SafeGetCharAt(currentPos+n))))
+ return false;
+ s++;
+ }
+ return true;
+ }
// Non-inline
void GetCurrent(char *s, int len);
void GetCurrentLowered(char *s, int len);
}
unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
-#ifdef USE_API
- return ::MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, tlen);
-#else
unsigned int ui=0;
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
unsigned int i=0;
ui++;
}
return ui;
-#endif
}
ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE;
- indicators[0].fore = Colour(0, 0x7f, 0);
+ indicators[0].fore = ColourDesired(0, 0x7f, 0);
indicators[1].style = INDIC_TT;
- indicators[1].fore = Colour(0, 0, 0xff);
+ indicators[1].fore = ColourDesired(0, 0, 0xff);
indicators[2].style = INDIC_PLAIN;
- indicators[2].fore = Colour(0xff, 0, 0);
+ indicators[2].fore = ColourDesired(0xff, 0, 0);
lineHeight = 1;
maxAscent = 1;
spaceWidth = 8;
selforeset = false;
- selforeground.desired = Colour(0xff, 0, 0);
+ selforeground.desired = ColourDesired(0xff, 0, 0);
selbackset = true;
- selbackground.desired = Colour(0xc0, 0xc0, 0xc0);
- selbackground2.desired = Colour(0xb0, 0xb0, 0xb0);
+ selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+ selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
selbar.desired = Platform::Chrome();
selbarlight.desired = Platform::ChromeHighlight();
- styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0);
+ styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
- caretcolour.desired = Colour(0, 0, 0);
+ caretcolour.desired = ColourDesired(0, 0, 0);
showCaretLineBackground = false;
- caretLineBackground.desired = Colour(0xff, 0xff, 0);
- edgecolour.desired = Colour(0xc0, 0xc0, 0xc0);
+ caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
+ edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
edgeState = EDGE_NONE;
caretWidth = 1;
}
void ViewStyle::ResetDefaultStyle() {
- styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
+ styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
+ ColourDesired(0xff,0xff,0xff),
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT,
- false, false, false, false, Style::caseMixed, true);
+ false, false, false, false, Style::caseMixed, true, true);
}
void ViewStyle::ClearStyles() {
WindowAccessor::~WindowAccessor() {
}
-#if PLAT_WIN
bool WindowAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte.
return false;
else
- return IsDBCSLeadByteEx(codePage, ch);
+ return Platform::IsDBCSLeadByte(codePage, ch);
}
-#else
-// PLAT_GTK or PLAT_WX
-// TODO: support DBCS under GTK+ and WX
-bool WindowAccessor::InternalIsLeadByte(char) {
- return false;
-}
-#endif
void WindowAccessor::Fill(int position) {
if (lenDoc == -1)
#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;
- }
-}
//----------------------------------------------------------------------
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
+// forces the linking of the lexer modules
+int Scintilla_LinkLexers();
+
//----------------------------------------------------------------------
// Constructor and Destructor
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
wxDefaultValidator, name)
{
- wxForceScintillaLexers();
+ Scintilla_LinkLexers();
m_swx = new ScintillaWX(this);
m_stopWatch.Start();
m_lastKeyDownConsumed = FALSE;
}
// Set the symbol used for a particular marker number,
-// and optionally the for and background colours.
+// and optionally the fore and background colours.
void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground,
const wxColour& background) {
SendMsg(2042, markerNumber, wxColourAsLong(back));
}
-// Add a marker to a line.
-void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
- SendMsg(2043, line, markerNumber);
+// Add a marker to a line, returning an ID which can be used to find or delete the marker.
+int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
+ return SendMsg(2043, line, markerNumber);
}
// Delete a marker from a line
return SendMsg(2095, 0, 0) != 0;
}
-// Display the background of the line containing the caret in a different colour.
+// Dsplay the background of the line containing the caret in a different colour.
void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
SendMsg(2096, show, 0);
}
SendMsg(2098, wxColourAsLong(back), 0);
}
+// Set a style to be changeable or not (read only).
+// Experimental feature, currently buggy.
+void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
+ SendMsg(2099, style, changeable);
+}
+
// Display a auto-completion list.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
return SendMsg(2111, 0, 0) != 0;
}
-// Define a set of character that when typed fills up the selected word.
+// Define a set of characters that when typed will cause the autocompletion to
+// choose the selected item.
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
SendMsg(2112, 0, (long)characterSet.c_str());
}
return SendMsg(2119, 0, 0) != 0;
}
+// Set whether or not autocompletion deletes any word characters after the inserted text upon completion
+void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
+ SendMsg(2270, dropRestOfWord, 0);
+}
+
+// Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
+bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
+ return SendMsg(2271, 0, 0) != 0;
+}
+
// Set the number of spaces used for one level of indentation.
void wxStyledTextCtrl::SetIndent(int indentSize) {
SendMsg(2122, indentSize, 0);
return SendMsg(2265, 0, 0);
}
+// Get position of start of word
+int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
+ return SendMsg(2266, pos, onlyWordCharacters);
+}
+
+// Get position of end of word
+int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
+ return SendMsg(2267, pos, onlyWordCharacters);
+}
+
+// Sets whether text is word wrapped
+void wxStyledTextCtrl::SetWrapMode(int mode) {
+ SendMsg(2268, mode, 0);
+}
+
+// Retrieve whether text is word wrapped
+int wxStyledTextCtrl::GetWrapMode() {
+ return SendMsg(2269, 0, 0);
+}
+
+// Sets the degree of caching of layout information
+void wxStyledTextCtrl::SetLayoutCache(int mode) {
+ SendMsg(2272, mode, 0);
+}
+
+// Retrieve the degree of caching of layout information
+int wxStyledTextCtrl::GetLayoutCache() {
+ return SendMsg(2273, 0, 0);
+}
+
+// Delete the selection or if no selection, the character before the caret.
+// Will not delete the chraacter before at the start of a line.
+void wxStyledTextCtrl::DeleteBackNotLine() {
+ SendMsg(2344, 0, 0);
+}
+
// Move the caret inside current view if it's not there already
void wxStyledTextCtrl::MoveCaretInsideView() {
SendMsg(2401, 0, 0);
return SendMsg(2387, 0, 0);
}
+// Change the way control characters are displayed:
+// If symbol is < 32, keep the drawn way, else, use the given character
+void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
+ SendMsg(2388, symbol, 0);
+}
+
+// Get the way control characters are displayed
+int wxStyledTextCtrl::GetControlCharSymbol() {
+ return SendMsg(2389, 0, 0);
+}
+
// Move to the previous change in capitalistion
void wxStyledTextCtrl::WordPartLeft() {
SendMsg(2390, 0, 0);
SendMsg(2396, 0, 0);
}
+// Get and Set the xOffset (ie, horizonal scroll position)
+void wxStyledTextCtrl::SetXOffset(int newOffset) {
+ SendMsg(2397, newOffset, 0);
+}
+int wxStyledTextCtrl::GetXOffset() {
+ return SendMsg(2398, 0, 0);
+}
+
// Start notifying the container of all key presses and commands.
void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0);
evt.SetLength(scn.length);
break;
- case SCN_POSCHANGED:
- evt.SetEventType(wxEVT_STC_POSCHANGED);
- break;
-
case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED);
break;
#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;
- }
-}
//----------------------------------------------------------------------
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
+// forces the linking of the lexer modules
+int Scintilla_LinkLexers();
+
//----------------------------------------------------------------------
// Constructor and Destructor
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
wxDefaultValidator, name)
{
- wxForceScintillaLexers();
+ Scintilla_LinkLexers();
m_swx = new ScintillaWX(this);
m_stopWatch.Start();
m_lastKeyDownConsumed = FALSE;
evt.SetLength(scn.length);
break;
- case SCN_POSCHANGED:
- evt.SetEventType(wxEVT_STC_POSCHANGED);
- break;
-
case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED);
break;
%(VALUES)s
// END of generated section
-//----------------------------------------------------------------------
-// Others
-
-#define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | \
- (1 << wxSTC_MARKNUM_FOLDEROPEN) | \
- (1 << wxSTC_MARKNUM_FOLDERSUB) | \
- (1 << wxSTC_MARKNUM_FOLDERTAIL) | \
- (1 << wxSTC_MARKNUM_FOLDERMIDTAIL) | \
- (1 << wxSTC_MARKNUM_FOLDEROPENMID) | \
- (1 << wxSTC_MARKNUM_FOLDEREND))
-
-
-
-
//----------------------------------------------------------------------
class ScintillaWX; // forward declare
#define wxSTC_MARK_CIRCLEPLUSCONNECTED 19
#define wxSTC_MARK_CIRCLEMINUS 20
#define wxSTC_MARK_CIRCLEMINUSCONNECTED 21
+
+// Invisible mark that only sets the line background color
+#define wxSTC_MARK_BACKGROUND 22
#define wxSTC_MARK_CHARACTER 10000
// Markers used for outlining column
#define wxSTC_MARKNUM_FOLDERSUB 29
#define wxSTC_MARKNUM_FOLDER 30
#define wxSTC_MARKNUM_FOLDEROPEN 31
+#define wxSTC_MASK_FOLDERS 0xFE000000
#define wxSTC_MARGIN_SYMBOL 0
#define wxSTC_MARGIN_NUMBER 1
#define wxSTC_INDIC_TT 2
#define wxSTC_INDIC_DIAGONAL 3
#define wxSTC_INDIC_STRIKE 4
-#define wxSTC_INDIC0_MASK 32
-#define wxSTC_INDIC1_MASK 64
-#define wxSTC_INDIC2_MASK 128
-#define wxSTC_INDICS_MASK 224
+#define wxSTC_INDIC0_MASK 0x20
+#define wxSTC_INDIC1_MASK 0x40
+#define wxSTC_INDIC2_MASK 0x80
+#define wxSTC_INDICS_MASK 0xE0
// PrintColourMode - use same colours as screen.
#define wxSTC_PRINT_NORMAL 0
#define wxSTC_FOLDLEVELHEADERFLAG 0x2000
#define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF
#define wxSTC_TIME_FOREVER 10000000
+#define wxSTC_WRAP_NONE 0
+#define wxSTC_WRAP_WORD 1
+#define wxSTC_CACHE_NONE 0
+#define wxSTC_CACHE_CARET 1
+#define wxSTC_CACHE_PAGE 2
+#define wxSTC_CACHE_DOCUMENT 3
#define wxSTC_CMD_LINEDOWN 2300
#define wxSTC_CMD_LINEDOWNEXTEND 2301
#define wxSTC_CMD_LINEUP 2302
#define wxSTC_CMD_UPPERCASE 2341
#define wxSTC_CMD_LINESCROLLDOWN 2342
#define wxSTC_CMD_LINESCROLLUP 2343
+#define wxSTC_CMD_DELETEBACKNOTLINE 2344
#define wxSTC_EDGE_NONE 0
#define wxSTC_EDGE_LINE 1
#define wxSTC_EDGE_BACKGROUND 2
#define wxSTC_LEX_EIFFELKW 24
#define wxSTC_LEX_TCL 25
#define wxSTC_LEX_NNCRONTAB 26
+#define wxSTC_LEX_BULLANT 27
+#define wxSTC_LEX_VBSCRIPT 28
+#define wxSTC_LEX_ASP 29
+#define wxSTC_LEX_PHP 30
+#define wxSTC_LEX_BAAN 31
+#define wxSTC_LEX_MATLAB 32
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1.
#define wxSTC_P_COMMENTBLOCK 12
#define wxSTC_P_STRINGEOL 13
-// Lexical states for SCLEX_CPP, SCLEX_VB
+// Lexical states for SCLEX_CPP
#define wxSTC_C_DEFAULT 0
#define wxSTC_C_COMMENT 1
#define wxSTC_C_COMMENTLINE 2
#define wxSTC_C_COMMENTDOCKEYWORD 17
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
+// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
+#define wxSTC_B_DEFAULT 0
+#define wxSTC_B_COMMENT 1
+#define wxSTC_B_NUMBER 2
+#define wxSTC_B_KEYWORD 3
+#define wxSTC_B_STRING 4
+#define wxSTC_B_PREPROCESSOR 5
+#define wxSTC_B_OPERATOR 6
+#define wxSTC_B_IDENTIFIER 7
+#define wxSTC_B_DATE 8
+
// Lexical states for SCLEX_HTML, SCLEX_XML
#define wxSTC_H_DEFAULT 0
#define wxSTC_H_TAG 1
#define wxSTC_LUA_OPERATOR 10
#define wxSTC_LUA_IDENTIFIER 11
#define wxSTC_LUA_STRINGEOL 12
+#define wxSTC_LUA_WORD2 13
+#define wxSTC_LUA_WORD3 14
+#define wxSTC_LUA_WORD4 15
+#define wxSTC_LUA_WORD5 16
+#define wxSTC_LUA_WORD6 17
// Lexical states for SCLEX_ERRORLIST
#define wxSTC_ERR_DEFAULT 0
#define wxSTC_ADA_IDENTIFIER 7
#define wxSTC_ADA_STRINGEOL 8
+// Lexical states for SCLEX_BAAN
+#define wxSTC_BAAN_DEFAULT 0
+#define wxSTC_BAAN_COMMENT 1
+#define wxSTC_BAAN_COMMENTDOC 2
+#define wxSTC_BAAN_NUMBER 3
+#define wxSTC_BAAN_WORD 4
+#define wxSTC_BAAN_STRING 5
+#define wxSTC_BAAN_PREPROCESSOR 6
+#define wxSTC_BAAN_OPERATOR 7
+#define wxSTC_BAAN_IDENTIFIER 8
+#define wxSTC_BAAN_STRINGEOL 9
+#define wxSTC_BAAN_WORD2 10
+
// Lexical states for SCLEX_LISP
#define wxSTC_LISP_DEFAULT 0
#define wxSTC_LISP_COMMENT 1
#define wxSTC_NNCRONTAB_ENVIRONMENT 9
#define wxSTC_NNCRONTAB_IDENTIFIER 10
-// 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))
-
-
-
+// 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
//----------------------------------------------------------------------
class ScintillaWX; // forward declare
void SetCodePage(int codePage);
// Set the symbol used for a particular marker number,
- // and optionally the for and background colours.
+ // and optionally the fore and background colours.
void MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground = wxNullColour,
const wxColour& background = wxNullColour);
// Set the background colour used for a particular marker number.
void MarkerSetBackground(int markerNumber, const wxColour& back);
- // Add a marker to a line.
- void MarkerAdd(int line, int markerNumber);
+ // Add a marker to a line, returning an ID which can be used to find or delete the marker.
+ int MarkerAdd(int line, int markerNumber);
// Delete a marker from a line
void MarkerDelete(int line, int markerNumber);
// Is the background of the line containing the caret in a different colour?
bool GetCaretLineVisible();
- // Display the background of the line containing the caret in a different colour.
+ // Dsplay the background of the line containing the caret in a different colour.
void SetCaretLineVisible(bool show);
// Get the colour of the background of the line containing the caret.
// Set the colour of the background of the line containing the caret.
void SetCaretLineBack(const wxColour& back);
+ // Set a style to be changeable or not (read only).
+ // Experimental feature, currently buggy.
+ void StyleSetChangeable(int style, bool changeable);
+
// Display a auto-completion list.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
// Retrieve whether auto-completion cancelled by backspacing before start.
bool AutoCompGetCancelAtStart();
- // Define a set of character that when typed fills up the selected word.
+ // Define a set of characters that when typed will cause the autocompletion to
+ // choose the selected item.
void AutoCompSetFillUps(const wxString& characterSet);
// Should a single item auto-completion list automatically choose the item.
// Retrieve whether or not autocompletion is hidden automatically when nothing matches
bool AutoCompGetAutoHide();
+ // Set whether or not autocompletion deletes any word characters after the inserted text upon completion
+ void AutoCompSetDropRestOfWord(bool dropRestOfWord);
+
+ // Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
+ bool AutoCompGetDropRestOfWord();
+
// Set the number of spaces used for one level of indentation.
void SetIndent(int indentSize);
// Retrieve the time the mouse must sit still to generate a mouse dwell event
int GetMouseDwellTime();
+ // Get position of start of word
+ int WordStartPosition(int pos, bool onlyWordCharacters);
+
+ // Get position of end of word
+ int WordEndPosition(int pos, bool onlyWordCharacters);
+
+ // Sets whether text is word wrapped
+ void SetWrapMode(int mode);
+
+ // Retrieve whether text is word wrapped
+ int GetWrapMode();
+
+ // Sets the degree of caching of layout information
+ void SetLayoutCache(int mode);
+
+ // Retrieve the degree of caching of layout information
+ int GetLayoutCache();
+
+ // Delete the selection or if no selection, the character before the caret.
+ // Will not delete the chraacter before at the start of a line.
+ void DeleteBackNotLine();
+
// Move the caret inside current view if it's not there already
void MoveCaretInsideView();
// Get cursor type
int GetCursor();
+ // Change the way control characters are displayed:
+ // If symbol is < 32, keep the drawn way, else, use the given character
+ void SetControlCharSymbol(int symbol);
+
+ // Get the way control characters are displayed
+ int GetControlCharSymbol();
+
// Move to the previous change in capitalistion
void WordPartLeft();
// Delete forwards from the current position to the end of the line
void DelLineRight();
+ // Get and Set the xOffset (ie, horizonal scroll position)
+ void SetXOffset(int newOffset);
+ int GetXOffset();
+
// Start notifying the container of all key presses and commands.
void StartRecord();
KeyMap.o \
KeyWords.o \
LexAVE.o \
+ LexBaan.o \
+ LexBullant.o \
+ LexMatlab.o \
LexAda.o \
LexCPP.o \
LexConf.o \
DEPFILES=$(OBJECTS:.o=.d)
-APPEXTRADEFS=-D__WX__ -DSCI_LEXER -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
+APPEXTRADEFS=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(scintilla_dir)/src -I$(scintilla_dir)/include -I$(top_srcdir)/contrib/include
include $(top_builddir)/src/makelib.env
#include <ctype.h>
+#include <wx/wx.h>
+
#include "Platform.h"
+#include "PlatWX.h"
#include "wx/stc/stc.h"
#include <gtk/gtk.h>
#endif
+
Point Point::FromLong(long lpoint) {
return Point(lpoint & 0xFFFF, lpoint >> 16);
}
rc.GetRight()+1, rc.GetBottom()+1);
}
-Colour::Colour(long lcol) {
- co.Set(lcol & 0xff, (lcol >> 8) & 0xff, (lcol >> 16) & 0xff);
-}
-
-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();
+wxColour wxColourFromCA(const ColourAllocated& ca) {
+ ColourDesired cd(ca.AsLong());
+ return wxColour(cd.GetRed(), cd.GetGreen(), cd.GetBlue());
}
-unsigned int Colour::GetBlue() {
- return co.Blue();
-}
+//----------------------------------------------------------------------
Palette::Palette() {
used = 0;
if (used < numEntries) {
entries[used].desired = cp.desired;
- entries[used].allocated = cp.desired;
+ entries[used].allocated.Set(cp.desired.AsLong());
used++;
}
} else {
return;
}
}
- cp.allocated = cp.desired;
+ cp.allocated.Set(cp.desired.AsLong());
}
}
}
+//----------------------------------------------------------------------
+
Font::Font() {
id = 0;
ascent = 0;
}
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic) {
- // TODO: what to do about the characterSet?
+ wxFontEncoding encoding;
Release();
+
+ switch (characterSet) {
+ default:
+ case wxSTC_CHARSET_ANSI:
+ case wxSTC_CHARSET_DEFAULT:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_BALTIC:
+ encoding = wxFONTENCODING_ISO8859_13;
+ break;
+
+ case wxSTC_CHARSET_CHINESEBIG5:
+ encoding = wxFONTENCODING_CP950;
+ break;
+
+ case wxSTC_CHARSET_EASTEUROPE:
+ encoding = wxFONTENCODING_ISO8859_2;
+ break;
+
+ case wxSTC_CHARSET_GB2312:
+ encoding = wxFONTENCODING_CP936;
+ break;
+
+ case wxSTC_CHARSET_GREEK:
+ encoding = wxFONTENCODING_ISO8859_7;
+ break;
+
+ case wxSTC_CHARSET_HANGUL:
+ encoding = wxFONTENCODING_CP949;
+ break;
+
+ case wxSTC_CHARSET_MAC:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_OEM:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_RUSSIAN:
+ encoding = wxFONTENCODING_KOI8;
+ break;
+
+ case wxSTC_CHARSET_SHIFTJIS:
+ encoding = wxFONTENCODING_CP932;
+ break;
+
+ case wxSTC_CHARSET_SYMBOL:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_TURKISH:
+ encoding = wxFONTENCODING_ISO8859_9;
+ break;
+
+ case wxSTC_CHARSET_JOHAB:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_HEBREW:
+ encoding = wxFONTENCODING_ISO8859_8;
+ break;
+
+ case wxSTC_CHARSET_ARABIC:
+ encoding = wxFONTENCODING_ISO8859_6;
+ break;
+
+ case wxSTC_CHARSET_VIETNAMESE:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_THAI:
+ encoding = wxFONTENCODING_ISO8859_11;
+ break;
+ }
+
+ // TODO: Use wxFontMapper and wxEncodingConverter if encoding not available.
+
id = new wxFont(size,
wxDEFAULT,
italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL,
false,
faceName,
- wxFONTENCODING_DEFAULT);
+ encoding);
}
void Font::Release() {
if (id)
- delete id;
+ delete (wxFont*)id;
id = 0;
}
+//----------------------------------------------------------------------
+
+class SurfaceImpl : public Surface {
+private:
+ wxDC* hdc;
+ bool hdcOwned;
+ wxBitmap* bitmap;
+ int x;
+ int y;
+ bool unicodeMode;
-Surface::Surface() :
+public:
+ SurfaceImpl();
+ ~SurfaceImpl();
+
+ void Init();
+ void Init(SurfaceID sid);
+ void InitPixMap(int width, int height, Surface *surface_);
+
+ void Release();
+ bool Initialised();
+ void PenColour(ColourAllocated fore);
+ int LogPixelsY();
+ int DeviceHeightFont(int points);
+ void MoveTo(int x_, int y_);
+ void LineTo(int x_, int y_);
+ void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
+ void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void FillRectangle(PRectangle rc, ColourAllocated back);
+ void FillRectangle(PRectangle rc, Surface &surfacePattern);
+ void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void Copy(PRectangle rc, Point from, Surface &surfaceSource);
+
+ void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
+ void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
+ void MeasureWidths(Font &font_, const char *s, int len, int *positions);
+ int WidthText(Font &font_, const char *s, int len);
+ int WidthChar(Font &font_, char ch);
+ int Ascent(Font &font_);
+ int Descent(Font &font_);
+ int InternalLeading(Font &font_);
+ int ExternalLeading(Font &font_);
+ int Height(Font &font_);
+ int AverageCharWidth(Font &font_);
+
+ int SetPalette(Palette *pal, bool inBackGround);
+ void SetClip(PRectangle rc);
+ void FlushCachedState();
+
+ void SetUnicodeMode(bool unicodeMode_);
+
+ void BrushColour(ColourAllocated back);
+ void SetFont(Font &font_);
+};
+
+
+
+SurfaceImpl::SurfaceImpl() :
hdc(0), hdcOwned(0), bitmap(0),
- x(0), y(0) {
-}
+ x(0), y(0), unicodeMode(0)
+{}
-Surface::~Surface() {
+SurfaceImpl::~SurfaceImpl() {
Release();
}
-void Surface::Release() {
+void SurfaceImpl::Release() {
if (bitmap) {
((wxMemoryDC*)hdc)->SelectObject(wxNullBitmap);
delete bitmap;
}
-bool Surface::Initialised() {
+bool SurfaceImpl::Initialised() {
return hdc != 0;
}
-void Surface::Init() {
+void SurfaceImpl::Init() {
Release();
hdc = new wxMemoryDC();
hdcOwned = true;
}
-void Surface::Init(SurfaceID hdc_) {
+void SurfaceImpl::Init(SurfaceID hdc_) {
Release();
- hdc = hdc_;
+ hdc = (wxDC*)hdc_;
}
-void Surface::InitPixMap(int width, int height, Surface *surface_) {
+void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_) {
Release();
- hdc = new wxMemoryDC(surface_->hdc);
+ hdc = new wxMemoryDC();
hdcOwned = true;
if (width < 1) width = 1;
if (height < 1) height = 1;
((wxMemoryDC*)hdc)->SelectObject(*bitmap);
}
-void Surface::PenColour(Colour fore) {
- hdc->SetPen(wxPen(fore.co, 1, wxSOLID));
+void SurfaceImpl::PenColour(ColourAllocated fore) {
+ hdc->SetPen(wxPen(wxColourFromCA(fore), 1, wxSOLID));
}
-void Surface::BrushColor(Colour back) {
- hdc->SetBrush(wxBrush(back.co, wxSOLID));
+void SurfaceImpl::BrushColour(ColourAllocated back) {
+ hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID));
}
-void Surface::SetFont(Font &font_) {
+void SurfaceImpl::SetFont(Font &font_) {
if (font_.GetID()) {
- hdc->SetFont(*font_.GetID());
+ hdc->SetFont(*((wxFont*)font_.GetID()));
}
}
-int Surface::LogPixelsY() {
+int SurfaceImpl::LogPixelsY() {
return hdc->GetPPI().y;
}
-
-int Surface::DeviceHeightFont(int points) {
+int SurfaceImpl::DeviceHeightFont(int points) {
return points;
+// int logPix = LogPixelsY();
+// return (points * logPix + logPix / 2) / 72;
}
-
-void Surface::MoveTo(int x_, int y_) {
+void SurfaceImpl::MoveTo(int x_, int y_) {
x = x_;
y = y_;
}
-void Surface::LineTo(int x_, int y_) {
+void SurfaceImpl::LineTo(int x_, int y_) {
hdc->DrawLine(x,y, x_,y_);
x = x_;
y = y_;
}
-void Surface::Polygon(Point *pts, int npts, Colour fore,
- Colour back) {
+void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawPolygon(npts, (wxPoint*)pts);
}
-void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
+void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawRectangle(wxRectFromPRectangle(rc));
}
-void Surface::FillRectangle(PRectangle rc, Colour back) {
- BrushColor(back);
+void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
+ BrushColour(back);
hdc->SetPen(*wxTRANSPARENT_PEN);
hdc->DrawRectangle(wxRectFromPRectangle(rc));
}
-void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
+void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
wxBrush br;
- if (surfacePattern.bitmap)
- br = wxBrush(*surfacePattern.bitmap);
+ if (((SurfaceImpl&)surfacePattern).bitmap)
+ br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap);
else // Something is wrong so display in red
br = wxBrush(*wxRED, wxSOLID);
hdc->SetPen(*wxTRANSPARENT_PEN);
hdc->DrawRectangle(wxRectFromPRectangle(rc));
}
-void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
+void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4);
}
-void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
+void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
- BrushColor(back);
+ BrushColour(back);
hdc->DrawEllipse(wxRectFromPRectangle(rc));
}
-void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
+void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
wxRect r = wxRectFromPRectangle(rc);
hdc->Blit(r.x, r.y, r.width, r.height,
- surfaceSource.hdc, from.x, from.y, wxCOPY);
+ ((SurfaceImpl&)surfaceSource).hdc,
+ from.x, from.y, wxCOPY);
}
-void Surface::DrawText(PRectangle rc, Font &font, int ybase,
- const char *s, int len, Colour fore, Colour back) {
+void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
+ const char *s, int len,
+ ColourAllocated fore, ColourAllocated back) {
SetFont(font);
- hdc->SetTextForeground(fore.co);
- hdc->SetTextBackground(back.co);
+ hdc->SetTextForeground(wxColourFromCA(fore));
+ hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back);
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
// ybase is where the baseline should be, but wxWin uses the upper left
// corner, so I need to calculate the real position for the text...
- hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
+ hdc->DrawText(str, rc.left, ybase - font.ascent);
}
-void Surface::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, Colour fore, Colour back) {
+void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
+ const char *s, int len,
+ ColourAllocated fore, ColourAllocated back) {
SetFont(font);
- hdc->SetTextForeground(fore.co);
- hdc->SetTextBackground(back.co);
+ hdc->SetTextForeground(wxColourFromCA(fore));
+ hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
// see comments above
- hdc->DrawText(wxString(s, len), rc.left, ybase - font.ascent);
+ hdc->DrawText(str, rc.left, ybase - font.ascent);
hdc->DestroyClippingRegion();
}
-int Surface::WidthText(Font &font, const char *s, int len) {
+int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
SetFont(font);
int w;
int h;
- hdc->GetTextExtent(wxString(s, len), &w, &h);
+
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
+ hdc->GetTextExtent(str, &w, &h);
return w;
}
-void Surface::MeasureWidths(Font &font, const char *s, int len, int *positions) {
+void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
+ wxString str = wxString(s, len);
+#endif
+
SetFont(font);
int totalWidth = 0;
- for (int i=0; i<len; i++) {
+ for (size_t i=0; i<(size_t)len; i++) {
int w;
int h;
- hdc->GetTextExtent(s[i], &w, &h);
+ hdc->GetTextExtent(str[i], &w, &h);
totalWidth += w;
positions[i] = totalWidth;
}
}
-int Surface::WidthChar(Font &font, char ch) {
+int SurfaceImpl::WidthChar(Font &font, char ch) {
SetFont(font);
int w;
int h;
+#if wxUSE_UNICODE
+#error fix this... Convert s from UTF-8.
+#else
hdc->GetTextExtent(ch, &w, &h);
+#endif
return w;
}
-#define EXTENT_TEST " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+#define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
-int Surface::Ascent(Font &font) {
+int SurfaceImpl::Ascent(Font &font) {
SetFont(font);
int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return font.ascent;
}
-int Surface::Descent(Font &font) {
+int SurfaceImpl::Descent(Font &font) {
SetFont(font);
int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return d;
}
-int Surface::InternalLeading(Font &font) {
+int SurfaceImpl::InternalLeading(Font &font) {
return 0;
}
-int Surface::ExternalLeading(Font &font) {
+int SurfaceImpl::ExternalLeading(Font &font) {
SetFont(font);
int w, h, d, e;
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
return e;
}
-int Surface::Height(Font &font) {
+int SurfaceImpl::Height(Font &font) {
SetFont(font);
return hdc->GetCharHeight();
}
-int Surface::AverageCharWidth(Font &font) {
+int SurfaceImpl::AverageCharWidth(Font &font) {
SetFont(font);
return hdc->GetCharWidth();
}
-int Surface::SetPalette(Palette *pal, bool inBackGround) {
+int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
return 0;
}
-void Surface::SetClip(PRectangle rc) {
+void SurfaceImpl::SetClip(PRectangle rc) {
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
}
-void Surface::FlushCachedState() {
+void SurfaceImpl::FlushCachedState() {
}
+void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
+ // TODO: Make this jive with wxUSE_UNICODE
+ unicodeMode=unicodeMode_;
+}
+
+Surface *Surface::Allocate() {
+ return new SurfaceImpl;
+}
+
+
+//----------------------------------------------------------------------
+
+
+inline wxWindow* GETWIN(WindowID id) { return (wxWindow*)id; }
+
Window::~Window() {
}
void Window::Destroy() {
if (id)
- id->Destroy();
+ GETWIN(id)->Destroy();
id = 0;
}
bool Window::HasFocus() {
- return wxWindow::FindFocus() == id;
+ return wxWindow::FindFocus() == GETWIN(id);
}
PRectangle Window::GetPosition() {
- wxRect rc(id->GetPosition(), id->GetSize());
+ wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize());
return PRectangleFromwxRect(rc);
}
void Window::SetPosition(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc);
- id->SetSize(r);
+ GETWIN(id)->SetSize(r);
}
void Window::SetPositionRelative(PRectangle rc, Window) {
}
PRectangle Window::GetClientPosition() {
- wxSize sz = id->GetClientSize();
+ wxSize sz = GETWIN(id)->GetClientSize();
return PRectangle(0, 0, sz.x, sz.y);
}
void Window::Show(bool show) {
- id->Show(show);
+ GETWIN(id)->Show(show);
}
void Window::InvalidateAll() {
- id->Refresh(false);
+ GETWIN(id)->Refresh(false);
}
void Window::InvalidateRectangle(PRectangle rc) {
wxRect r = wxRectFromPRectangle(rc);
- id->Refresh(false, &r);
+ GETWIN(id)->Refresh(false, &r);
}
void Window::SetFont(Font &font) {
- id->SetFont(*font.GetID());
+ GETWIN(id)->SetFont(*((wxFont*)font.GetID()));
}
void Window::SetCursor(Cursor curs) {
break;
}
- id->SetCursor(wxCursor(cursorId));
+ GETWIN(id)->SetCursor(wxCursor(cursorId));
}
void Window::SetTitle(const char *s) {
- id->SetTitle(s);
+#if wxUSE_UNICODE
+#error Fix this...
+#else
+ GETWIN(id)->SetTitle(s);
+#endif
}
//----------------------------------------------------------------------
// Helper classes for ListBox
-// A wxListBox that gives focus to its parent if it gets it.
+// A wxListBox that gives focus back to its parent if it gets it.
class wxSTCListBox : public wxListBox {
public:
wxSTCListBox(wxWindow* parent, wxWindowID id)
END_EVENT_TABLE()
-#define GETLB(win) (((wxSTCListBoxWin*)win)->GetLB())
+inline wxListBox* GETLB(WindowID win) {
+ return (((wxSTCListBoxWin*)win)->GetLB());
+}
//----------------------------------------------------------------------
}
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::SetFont(Font &font) {
- GETLB(id)->SetFont(*font.GetID());
+ GETLB(id)->SetFont(*((wxFont*)font.GetID()));
}
void ListBox::Clear() {
}
void ListBox::GetValue(int n, char *value, int len) {
+#if wxUSE_UNICODE
+#error fix this...
wxString text = GETLB(id)->GetString(n);
strncpy(value, text.c_str(), len);
value[len-1] = '\0';
+#endif
}
void ListBox::Sort() {
}
+//----------------------------------------------------------------------
Menu::Menu() : id(0) {
}
void Menu::Destroy() {
if (id)
- delete id;
+ delete (wxMenu*)id;
id = 0;
}
void Menu::Show(Point pt, Window &w) {
- w.GetID()->PopupMenu(id, pt.x - 4, pt.y);
+ GETWIN(w.GetID())->PopupMenu((wxMenu*)id, pt.x - 4, pt.y);
Destroy();
}
+//----------------------------------------------------------------------
-Colour Platform::Chrome() {
+ColourDesired Platform::Chrome() {
wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
- return Colour(c.Red(), c.Green(), c.Blue());
+ return ColourDesired(c.Red(), c.Green(), c.Blue());
}
-Colour Platform::ChromeHighlight() {
+ColourDesired Platform::ChromeHighlight() {
wxColour c;
c = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
- return Colour(c.Red(), c.Green(), c.Blue());
+ return ColourDesired(c.Red(), c.Green(), c.Blue());
}
const char *Platform::DefaultFont() {
}
+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;
+}
+
+
+//----------------------------------------------------------------------
--- /dev/null
+
+
+
+
+wxRect wxRectFromPRectangle(PRectangle prc);
+PRectangle PRectangleFromwxRect(wxRect rc);
+wxColour wxColourFromCA(const ColourAllocated& ca);
+
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#include <ctype.h>
#include "ScintillaWX.h"
#include "wx/stc/stc.h"
+#include "PlatWX.h"
//----------------------------------------------------------------------
void OnPaint(wxPaintEvent& evt) {
wxPaintDC dc(this);
- Surface surfaceWindow;
- surfaceWindow.Init(&dc);
- m_ct->PaintCT(&surfaceWindow);
- surfaceWindow.Release();
+ Surface* surfaceWindow = Surface::Allocate();
+ surfaceWindow->Init(&dc);
+ m_ct->PaintCT(surfaceWindow);
+ delete surfaceWindow;
}
#if wxUSE_POPUPWIN
if (timer.ticking) {
steTimer = new wxSTCTimer(this);
steTimer->Start(timer.tickSize);
- timer.tickerID = (int)steTimer;
+ timer.tickerID = steTimer;
} else {
steTimer = (wxSTCTimer*)timer.tickerID;
steTimer->Stop();
void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
if (!label[0])
- popup.GetID()->AppendSeparator();
+ ((wxMenu*)popup.GetID())->AppendSeparator();
else
- popup.GetID()->Append(cmd, label);
+ ((wxMenu*)popup.GetID())->Append(cmd, label);
if (!enabled)
- popup.GetID()->Enable(cmd, enabled);
+ ((wxMenu*)popup.GetID())->Enable(cmd, enabled);
}
void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
paintState = painting;
- Surface surfaceWindow;
- surfaceWindow.Init(dc);
+ Surface* surfaceWindow = Surface::Allocate();
+ surfaceWindow->Init(dc);
PRectangle rcPaint = PRectangleFromwxRect(rect);
dc->BeginDrawing();
- Paint(&surfaceWindow, rcPaint);
+ Paint(surfaceWindow, rcPaint);
dc->EndDrawing();
- surfaceWindow.Release();
+ delete surfaceWindow;
if (paintState == paintAbandoned) {
// Painting area was insufficient to cover new styling or brace highlight positions
FullPaint();
void ScintillaWX::DoSize(int width, int height) {
- PRectangle rcClient(0,0,width,height);
- SetScrollBarsTo(rcClient);
- DropGraphics();
+// PRectangle rcClient(0,0,width,height);
+// SetScrollBarsTo(rcClient);
+// DropGraphics();
+ ChangeSize();
}
void ScintillaWX::DoLoseFocus(){
rcPaint = GetTextRectangle();
paintingAllText = true;
wxClientDC dc(stc);
- Surface surfaceWindow;
- surfaceWindow.Init(&dc);
- Paint(&surfaceWindow, rcPaint);
- surfaceWindow.Release();
+ Surface* surfaceWindow = Surface::Allocate();
+ surfaceWindow->Init(&dc);
+ Paint(surfaceWindow, rcPaint);
+ delete surfaceWindow;
// stc->Refresh(FALSE);
//----------------------------------------------------------------------
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
#include "Platform.h"
#include "Scintilla.h"
CFG=StcVC - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "StcVC.mak".
-!MESSAGE
+!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "StcVC.mak" CFG="StcVC - Win32 Debug"
-!MESSAGE
+!MESSAGE
!MESSAGE Possible choices for configuration are:
-!MESSAGE
+!MESSAGE
!MESSAGE "StcVC - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "StcVC - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
+!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\lib\stcd.lib"
-!ENDIF
+!ENDIF
# Begin Target
# End Source File
# Begin Source File
+SOURCE=.\scintilla\src\LexBaan.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\scintilla\src\LexBullant.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\scintilla\src\LexMatlab.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\scintilla\src\LexConf.cxx
# End Source File
# Begin Source File
MarkerSetBackground(markerNumber, background);''',
('Set the symbol used for a particular marker number,',
- 'and optionally the for and background colours.')),
+ 'and optionally the fore and background colours.')),
'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
+ 'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
+ 'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
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
KeyWords.obj \
LexAVE.obj \
LexAda.obj \
+ LexBaan.obj \
+ LexBullant.obj \
+ LexMatlab.obj \
LexCPP.obj \
LexConf.obj \
LexCrontab.obj \
SCINTILLA=$(WXDIR)/contrib/src/stc/scintilla
S=$(SCINTILLA)/src
-EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
+EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)/contrib/include
OBJECTS = \
$(S)/AutoComplete.$(OBJSUFF) \
$(S)/KeyWords.$(OBJSUFF) \
$(S)/LexAVE.$(OBJSUFF) \
$(S)/LexAda.$(OBJSUFF) \
+ $(S)/LexBaan.$(OBJSUFF) \
+ $(S)/LexBullant.$(OBJSUFF) \
+ $(S)/LexMatlab.$(OBJSUFF) \
$(S)/LexCPP.$(OBJSUFF) \
$(S)/LexConf.$(OBJSUFF) \
$(S)/LexCrontab.$(OBJSUFF) \
WXDIR = $(WXWIN)
SCINTILLA=.\scintilla
S=$(SCINTILLA)\src
-EXTRAINC=-D__WX__ -DSCI_LEXER -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
+EXTRAINC=-D__WX__ -DSCI_LEXER -DLINK_LEXERS -I$(SCINTILLA)/include -I$(S) -I. -I$(WXDIR)\contrib\include
NOPCH=1
!include $(WXDIR)\src\makevc.env
$(D)\KeyWords.obj \
$(D)\LexAVE.obj \
$(D)\LexAda.obj \
+ $(D)\LexBaan.obj \
+ $(D)\LexBullant.obj \
+ $(D)\LexMatlab.obj \
$(D)\LexCPP.obj \
$(D)\LexConf.obj \
$(D)\LexCrontab.obj \
distribution. All other code needed to implement Scintilla on top of
wxWindows is located in the directory above this one.
-The current version of the Scintilla code is 1.40
+The current version of the Scintilla code is 1.45
*/
class LexerModule {
protected:
- LexerModule *next;
+ const LexerModule *next;
int language;
- const char *languageName;
LexerFunction fnLexer;
LexerFunction fnFolder;
- static LexerModule *base;
+ static const LexerModule *base;
static int nextLanguage;
public:
+ const char *languageName;
LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_=0, LexerFunction fnFolder_=0);
- int GetLanguage() { return language; }
+ int GetLanguage() const { return language; }
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler);
+ WordList *keywordlists[], Accessor &styler) const;
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler);
- static LexerModule *Find(int language);
- static LexerModule *Find(const char *languageName);
+ WordList *keywordlists[], Accessor &styler) const;
+ static const LexerModule *Find(int language);
+ static const LexerModule *Find(const char *languageName);
};
/**
** Interface to platform facilities. Also includes some basic utilities.
** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef PLATFORM_H
#define PLAT_GTK_WIN32 0
#define PLAT_WIN 0
#define PLAT_WX 0
+#define PLAT_FOX 0
-#if defined(__WX__)
+#if defined(FOX)
+#undef PLAT_FOX
+#define PLAT_FOX 1
+
+#elif defined(__WX__)
#undef PLAT_WX
#define PLAT_WX 1
#endif
-// Include the main header for each platform
-
-#if PLAT_GTK
-#ifdef _MSC_VER
-#pragma warning(disable: 4505 4514 4710 4800)
-#endif
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#endif
-
-#if PLAT_WIN
-#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out
-// Vassili Bourdo: shut up annoying Visual C++ warnings:
-#ifdef _MSC_VER
-#pragma warning(disable: 4244 4309 4710 4800)
-#endif
-#include <windows.h>
-#include <commctrl.h>
-#include <richedit.h>
-#endif
-
-#if PLAT_WX
-#include <wx/wx.h>
-#endif
-
-#define ColourID scColourID
-#define FontID scFontID
-#define SurfaceID scSurfaceID
-#define WindowID scWindowID
-#define MenuID scMenuID
-#define Point scPoint
-#define PRectangle scPRectangle
-#define Colour scColour
-#define ColourPair scColourPair
-#define Window scWindow
-#define Palette scPalette
-#define Font scFont
-#define Surface scSurface
-#define Window scWindow
-#define ListBox scListBox
-#define Menu scMenu
-#define Platform scPlatform
-#define TextRange scTextRange
-#define KeyMap scKeyMap
-#define Style scStyle
-
-
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
-#if PLAT_GTK
-typedef GdkColor ColourID;
-typedef GdkFont* FontID;
-typedef GdkDrawable* SurfaceID;
-typedef GtkWidget* WindowID;
-typedef GtkItemFactory* MenuID;
-#endif
-
-#if PLAT_WIN
-typedef COLORREF ColourID;
-typedef HFONT FontID;
-typedef HDC SurfaceID;
-typedef HWND WindowID;
-typedef HMENU MenuID;
-#endif
-
-#if PLAT_WX
-typedef wxColour ColourID;
-typedef wxFont* FontID;
-typedef wxDC* SurfaceID;
-typedef wxWindow* WindowID;
-typedef wxMenu* MenuID;
-#endif
+typedef void *FontID;
+typedef void *SurfaceID;
+typedef void *WindowID;
+typedef void *MenuID;
+typedef void *TickerID;
/**
* A geometric point class.
int Height() { return bottom - top; }
};
-#if PLAT_WX
-wxRect wxRectFromPRectangle(PRectangle prc);
-PRectangle PRectangleFromwxRect(wxRect rc);
-#endif
+/**
+ * In some circumstances, including Win32 in paletted mode and GTK+, each colour
+ * must be allocated before use. The desired colours are held in the ColourDesired class,
+ * and after allocation the allocation entry is stored in the ColourAllocated class. In other
+ * circumstances, such as Win32 in true colour mode, the allocation process just copies
+ * the RGB values from the desired to the allocated class.
+ * As each desired colour requires allocation before it can be used, the ColourPair class
+ * holds both a ColourDesired and a ColourAllocated
+ * The Palette class is responsible for managing the palette of colours which contains a
+ * list of ColourPair objects and performs the allocation.
+ */
/**
- * A colour class.
+ * Holds a desired RGB colour.
*/
-class Colour {
- ColourID co;
+class ColourDesired {
+ long co;
public:
- Colour(long lcol=0);
- Colour(unsigned int red, unsigned int green, unsigned int blue);
- bool operator==(const Colour &other) const;
- long AsLong() const;
- unsigned int GetRed();
- unsigned int GetGreen();
- unsigned int GetBlue();
+ ColourDesired(long lcol=0) {
+ co = lcol;
+ }
- friend class Surface;
- friend class Palette;
+ ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
+ co = red | (green << 8) | (blue << 16);
+ }
+
+ bool operator==(const ColourDesired &other) const {
+ return co == other.co;
+ }
+
+ void Set(long lcol) {
+ co = lcol;
+ }
+
+ long AsLong() const {
+ return co;
+ }
+
+ unsigned int GetRed() {
+ return co & 0xff;
+ }
+
+ unsigned int GetGreen() {
+ return (co >> 8) & 0xff;
+ }
+
+ unsigned int GetBlue() {
+ return (co >> 16) & 0xff;
+ }
};
/**
- * Colour pairs hold a desired colour and the colour that the graphics engine
- * allocates to approximate the desired colour.
- * To make palette management more automatic, ColourPairs could register at
- * construction time with a palette management object.
+ * Holds an allocated RGB colour which may be an approximation to the desired colour.
+ */
+class ColourAllocated {
+ long coAllocated;
+
+public:
+
+ ColourAllocated(long lcol=0) {
+ coAllocated = lcol;
+ }
+
+ void Set(long lcol) {
+ coAllocated = lcol;
+ }
+
+ long AsLong() const {
+ return coAllocated;
+ }
+};
+
+/**
+ * Colour pairs hold a desired colour and an allocated colour.
*/
struct ColourPair {
- Colour desired;
- Colour allocated;
+ ColourDesired desired;
+ ColourAllocated allocated;
- ColourPair(Colour desired_=Colour(0,0,0)) {
+ ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
desired = desired_;
- allocated = desired;
+ allocated.Set(desired.AsLong());
}
};
enum {numEntries = 100};
ColourPair entries[numEntries];
#if PLAT_GTK
- GdkColor *allocatedPalette;
+ void *allocatedPalette; // GdkColor *
int allocatedLen;
-#elif PLAT_WIN
- HPALETTE hpal;
-#elif PLAT_WX
- // wxPalette* pal; // **** Is this needed?
#endif
public:
+#if PLAT_WIN
+ void *hpal;
+#endif
bool allowRealization;
Palette();
void WantFind(ColourPair &cp, bool want);
void Allocate(Window &w);
-
- friend class Surface;
};
/**
// Alias another font - caller guarantees not to Release
void SetID(FontID id_) { id = id_; }
friend class Surface;
+ friend class SurfaceImpl;
};
/**
*/
class Surface {
private:
- bool unicodeMode;
-#if PLAT_GTK
- GdkDrawable *drawable;
- GdkGC *gc;
- GdkPixmap *ppixmap;
- int x;
- int y;
- bool inited;
- bool createdGC;
-#elif PLAT_WIN
- HDC hdc;
- bool hdcOwned;
- HPEN pen;
- HPEN penOld;
- HBRUSH brush;
- HBRUSH brushOld;
- HFONT font;
- HFONT fontOld;
- HBITMAP bitmap;
- HBITMAP bitmapOld;
- HPALETTE paletteOld;
-#elif PLAT_WX
- wxDC* hdc;
- bool hdcOwned;
- wxBitmap* bitmap;
- int x;
- int y;
-#endif
-
// Private so Surface objects can not be copied
Surface(const Surface &) {}
Surface &operator=(const Surface &) { return *this; }
-#if PLAT_WIN || PLAT_WX
- void BrushColor(Colour back);
- void SetFont(Font &font_);
-#endif
public:
- Surface();
- ~Surface();
-
- void Init();
- void Init(SurfaceID hdc_);
- void InitPixMap(int width, int height, Surface *surface_);
-
- void Release();
- bool Initialised();
- void PenColour(Colour fore);
- int LogPixelsY();
- int DeviceHeightFont(int points);
- void MoveTo(int x_, int y_);
- void LineTo(int x_, int y_);
- void Polygon(Point *pts, int npts, Colour fore, Colour back);
- void RectangleDraw(PRectangle rc, Colour fore, Colour back);
- void FillRectangle(PRectangle rc, Colour back);
- void FillRectangle(PRectangle rc, Surface &surfacePattern);
- void RoundedRectangle(PRectangle rc, Colour fore, Colour back);
- void Ellipse(PRectangle rc, Colour fore, Colour back);
- void Copy(PRectangle rc, Point from, Surface &surfaceSource);
-
- void DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
- void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
- void MeasureWidths(Font &font_, const char *s, int len, int *positions);
- int WidthText(Font &font_, const char *s, int len);
- int WidthChar(Font &font_, char ch);
- int Ascent(Font &font_);
- int Descent(Font &font_);
- int InternalLeading(Font &font_);
- int ExternalLeading(Font &font_);
- int Height(Font &font_);
- int AverageCharWidth(Font &font_);
-
- int SetPalette(Palette *pal, bool inBackGround);
- void SetClip(PRectangle rc);
- void FlushCachedState();
-
- void SetUnicodeMode(bool unicodeMode_) {
- unicodeMode=unicodeMode_;
- }
+ Surface() {};
+ virtual ~Surface() {};
+ static Surface *Allocate();
+
+ virtual void Init()=0;
+ virtual void Init(SurfaceID sid)=0;
+ virtual void InitPixMap(int width, int height, Surface *surface_)=0;
+
+ virtual void Release()=0;
+ virtual bool Initialised()=0;
+ virtual void PenColour(ColourAllocated fore)=0;
+ virtual int LogPixelsY()=0;
+ virtual int DeviceHeightFont(int points)=0;
+ virtual void MoveTo(int x_, int y_)=0;
+ virtual void LineTo(int x_, int y_)=0;
+ virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
+ virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
+ virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
+
+ virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
+ virtual int WidthText(Font &font_, const char *s, int len)=0;
+ virtual int WidthChar(Font &font_, char ch)=0;
+ virtual int Ascent(Font &font_)=0;
+ virtual int Descent(Font &font_)=0;
+ virtual int InternalLeading(Font &font_)=0;
+ virtual int ExternalLeading(Font &font_)=0;
+ virtual int Height(Font &font_)=0;
+ virtual int AverageCharWidth(Font &font_)=0;
+
+ virtual int SetPalette(Palette *pal, bool inBackGround)=0;
+ virtual void SetClip(PRectangle rc)=0;
+ virtual void FlushCachedState()=0;
+
+ virtual void SetUnicodeMode(bool unicodeMode_)=0;
};
+/**
+ * A simple callback action passing one piece of untyped user data.
+ */
+typedef void (*CallBackAction)(void*);
+
/**
* Class to hide the details of window manipulation.
* Does not own the window which will normally have a longer life than this object.
*/
class Window {
- friend class ListBox;
protected:
WindowID id;
public:
- Window() : id(0) {}
- Window(const Window &source) : id(source.id) {}
+ Window() : id(0), cursorLast(cursorInvalid) {}
+ Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
virtual ~Window();
Window &operator=(WindowID id_) {
id = id_;
void InvalidateAll();
void InvalidateRectangle(PRectangle rc);
virtual void SetFont(Font &font);
- enum Cursor { cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
+ enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
void SetCursor(Cursor curs);
void SetTitle(const char *s);
-#if PLAT_WIN
- LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0);
- int GetDlgCtrlID();
- HINSTANCE GetInstance();
-#endif
+private:
+ Cursor cursorLast;
};
/**
* Listbox management.
*/
+
class ListBox : public Window {
+private:
#if PLAT_GTK
WindowID list;
WindowID scroller;
int desiredVisibleRows;
unsigned int maxItemCharacters;
unsigned int aveCharWidth;
+public:
+ CallBackAction doubleClickAction;
+ void *doubleClickActionData;
public:
ListBox();
virtual ~ListBox();
int Find(const char *prefix);
void GetValue(int n, char *value, int len);
void Sort();
+ void SetDoubleClickAction(CallBackAction action, void *data) {
+ doubleClickAction = action;
+ doubleClickActionData = data;
+ }
};
/**
void Show(Point pt, Window &w);
};
+class ElapsedTime {
+ long bigBit;
+ long littleBit;
+public:
+ ElapsedTime();
+ double Duration(bool reset=false);
+};
+
/**
* Platform class used to retrieve system wide parameters such as double click speed
* and chrome colour. Not a creatable object, more of a module with several functions.
// but gcc warns about this
Platform() {}
~Platform() {}
- static Colour Chrome();
- static Colour ChromeHighlight();
+ static ColourDesired Chrome();
+ static ColourDesired ChromeHighlight();
static const char *DefaultFont();
static int DefaultFontSize();
static unsigned int DoubleClickTime();
static bool IsKeyDown(int key);
static long SendScintilla(
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
+ static bool IsDBCSLeadByte(int codePage, char ch);
// These are utility functions not really tied to a platform
static int Minimum(int a, int b);
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif
+// Shut up annoying Visual C++ warnings:
+#ifdef _MSC_VER
+#pragma warning(disable: 4244 4309 4514 4710)
+#endif
+
#endif
/** @file PropSet.h
** A Java style properties file module.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef PROPSET_H
SString Expand(const char *withVars);
int GetInt(const char *key, int defaultValue=0);
SString GetWild(const char *keybase, const char *filename);
- SString GetNewExpand(const char *keybase, const char *filename);
+ SString GetNewExpand(const char *keybase, const char *filename="");
void Clear();
char *ToString(); // Caller must delete[] the return value
bool GetFirst(char **key, char **val);
char *Allocate(int size);
void SetFromAllocated();
bool InList(const char *s);
- const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
+ const char *GetNearestWord(const char *wordStart, int searchLen = -1,
+ bool ignoreCase = false, SString wordCharacters="");
char *GetNearestWords(const char *wordStart, int searchLen=-1,
bool ignoreCase=false, char otherSeparator='\0');
};
#ifndef SSTRING_H
#define SSTRING_H
-// These functions are implemented because each platform calls them something different
+// These functions are implemented because each platform calls them something different.
int CompareCaseInsensitive(const char *a, const char *b);
int CompareNCaseInsensitive(const char *a, const char *b, int len);
bool EqualCaseInsensitive(const char *a, const char *b);
// While it would be 'better' to use std::string, that doubles the executable size.
// An SString may contain embedded nul characters.
-/**
- * Duplicate a C string.
- * Allocate memory of the given size, or big enough to fit the string if length isn't given;
- * then copy the given string in the allocated memory.
- * @return the pointer to the new string
- */
-inline char *StringDup(
- const char *s, ///< The string to duplicate
- int len=-1) ///< The length of memory to allocate. Optional.
-{
- if (!s)
- return 0;
- if (len == -1)
- len = strlen(s);
- char *sNew = new char[len + 1];
- if (sNew) {
- strncpy(sNew, s, len);
- sNew[len] = '\0';
- }
- return sNew;
-}
-
/**
* @brief A simple string class.
+ *
* Hold the length of the string for quick operations,
* can have a buffer bigger than the string to avoid too many memory allocations and copies.
* May have embedded zeroes as a result of @a substitute, but rely too heavily on C string
* functions to allow reliable manipulations of these strings.
**/
class SString {
- char *s; ///< The C string
- int sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
- int sLen; ///< The size of the string in s
- int sizeGrowth; ///< Minimum growth size when appending strings
+public:
+ /** 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};
+
+private:
+ char *s; ///< The C string
+ lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string
+ lenpos_t sLen; ///< The size of the string in s
+ lenpos_t sizeGrowth; ///< Minimum growth size when appending strings
enum { sizeGrowthDefault = 64 };
+ bool grow(lenpos_t lenNew) {
+ while (sizeGrowth * 6 < lenNew) {
+ sizeGrowth *= 2;
+ }
+ 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;
+ }
-public:
- typedef int size_type;
+ SString &assign(const char *sOther, lenpos_t sSize_=measure_length) {
+ if (!sOther) {
+ sSize_ = 0;
+ } else if (sSize_ == measure_length) {
+ sSize_ = strlen(sOther);
+ }
+ if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
+ if (s && sSize_) {
+ strncpy(s, sOther, sSize_);
+ }
+ s[sSize_] = '\0';
+ sLen = sSize_;
+ } else {
+ delete []s;
+ s = StringAllocate(sOther, sSize_);
+ if (s) {
+ sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
+ sLen = strlen(s);
+ } else {
+ sSize = sLen = 0;
+ }
+ }
+ return *this;
+ }
+public:
SString() : s(0), sSize(0), sLen(0), sizeGrowth(sizeGrowthDefault) {
}
SString(const SString &source) : sizeGrowth(sizeGrowthDefault) {
- s = StringDup(source.s);
+ s = StringAllocate(source.s);
sSize = sLen = (s) ? strlen(s) : 0;
}
SString(const char *s_) : sizeGrowth(sizeGrowthDefault) {
- s = StringDup(s_);
+ s = StringAllocate(s_);
sSize = sLen = (s) ? strlen(s) : 0;
}
- SString(const char *s_, int first, int last) : sizeGrowth(sizeGrowthDefault) {
- s = StringDup(s_ + first, last - first);
+ 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 = StringDup(number);
+ 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() {
sSize = 0;
sLen = 0;
}
- void clear(void) {
+ void clear() {
if (s) {
*s = '\0';
}
sLen = 0;
}
/** Size of buffer. */
- size_type size(void) const { ///<
+ lenpos_t size() const {
if (s)
return sSize;
else
return 0;
}
/** Size of string in buffer. */
- int length() const {
+ lenpos_t length() const {
return sLen;
}
- SString &assign(const char* sOther, int sSize_ = -1) {
- if (!sOther) {
- sSize_ = 0;
- }
- if (sSize_ < 0) {
- sSize_ = strlen(sOther);
- }
- if (sSize > 0 && sSize_ <= sSize) { // Does not allocate new buffer if the current is big enough
- if (s && sSize_) {
- strncpy(s, sOther, sSize_);
- }
- s[sSize_] = '\0';
- sLen = sSize_;
- } else {
- delete []s;
- s = StringDup(sOther, sSize_);
- if (s) {
- sSize = sSize_; // Allow buffer bigger than real string, thus providing space to grow
- sLen = strlen(s);
- } else {
- sSize = sLen = 0;
- }
- }
- return *this;
- }
- SString &assign(const SString& sOther, int sSize_ = -1) {
- return assign(sOther.s, sSize_);
- }
SString &operator=(const char *source) {
return assign(source);
}
else
return false;
}
- void setsizegrowth(int sizeGrowth_) {
+ void setsizegrowth(lenpos_t sizeGrowth_) {
sizeGrowth = sizeGrowth_;
}
const char *c_str() const {
sLen = 0;
return sRet;
}
- char operator[](int i) const {
+ char operator[](lenpos_t i) const {
if (s && i < sSize) // Or < sLen? Depends on the use, both are OK
return s[i];
else
return '\0';
}
- SString &append(const char* sOther, int sLenOther=-1, char sep=0) {
- if (sLenOther < 0)
+ SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') {
+ if (!sOther) {
+ return *this;
+ }
+ if (sLenOther == measure_length) {
sLenOther = strlen(sOther);
+ }
int lenSep = 0;
- if (sLen && sep) // Only add a separator if not empty
+ if (sLen && sep) { // Only add a separator if not empty
lenSep = 1;
- int lenNew = sLen + sLenOther + lenSep;
- if (lenNew + 1 < sSize) {
- // Conservative about growing the buffer: don't do it, unless really needed
+ }
+ lenpos_t lenNew = sLen + sLenOther + lenSep;
+ // Conservative about growing the buffer: don't do it, unless really needed
+ if ((lenNew + 1 < sSize) || (grow(lenNew))) {
if (lenSep) {
s[sLen] = sep;
sLen++;
}
strncpy(&s[sLen], sOther, sLenOther);
- s[sLen + sLenOther] = '\0';
sLen += sLenOther;
- } else {
- // Grow the buffer bigger than really needed, to have room for other appends
- char *sNew = new char[lenNew + sizeGrowth + 1];
- if (sNew) {
- if (s) {
- memcpy(sNew, s, sLen);
- delete []s;
- }
- s = sNew;
- sSize = lenNew + sizeGrowth;
- if (lenSep) {
- s[sLen] = sep;
- sLen++;
- }
- strncpy(&s[sLen], sOther, sLenOther);
- sNew[sLen + sLenOther] = '\0';
- sLen += sLenOther;
- }
+ s[sLen] = '\0';
}
return *this;
}
- SString &operator +=(const char *sOther) {
- return append(sOther, -1);
+ SString &operator+=(const char *sOther) {
+ return append(sOther, static_cast<lenpos_t>(measure_length));
}
- SString &operator +=(const SString &sOther) {
+ SString &operator+=(const SString &sOther) {
return append(sOther.s, sOther.sSize);
}
- SString &operator +=(char ch) {
+ SString &operator+=(char ch) {
return append(&ch, 1);
}
- SString &appendwithseparator(const char* sOther, char sep) {
+ SString &appendwithseparator(const char *sOther, char sep) {
return append(sOther, strlen(sOther), sep);
}
+ SString &insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther=measure_length) {
+ if (!sOther) {
+ return *this;
+ }
+ if (sLenOther == measure_length) {
+ sLenOther = strlen(sOther);
+ }
+ lenpos_t lenNew = sLen + sLenOther;
+ // Conservative about growing the buffer: don't do it, unless really needed
+ if ((lenNew + 1 < sSize) || grow(lenNew)) {
+ lenpos_t moveChars = sLen - pos + 1;
+ for (lenpos_t i = moveChars; i > 0; i--) {
+ s[pos + sLenOther + i - 1] = s[pos + i - 1];
+ }
+ memcpy(s + pos, sOther, sLenOther);
+ sLen = lenNew;
+ }
+ return *this;
+ }
+ /** Remove @a len characters from the @a pos position, included.
+ * Characters at pos + len and beyond replace characters at pos.
+ * If @a len is 0, or greater than the length of the string
+ * starting at @a pos, the string is just truncated at @a pos.
+ */
+ void remove(lenpos_t pos, lenpos_t len) {
+ if (len < 1 || pos + len >= sLen) {
+ s[pos] = '\0';
+ sLen = pos;
+ } else {
+ for (lenpos_t i = pos; i < sLen - len + 1; i++) {
+ s[i] = s[i+len];
+ }
+ sLen -= len;
+ }
+ }
+ /** Read an integral numeric value from the string. */
int value() const {
if (s)
return atoi(s);
else
return 0;
}
- void substitute(char find, char replace) {
+ int search(const char *sFind, lenpos_t start=0) {
+ if (start < sLen) {
+ const char *sFound = strstr(s + start, sFind);
+ if (sFound) {
+ return sFound - s;
+ }
+ }
+ return -1;
+ }
+ bool contains(const char *sFind) {
+ return search(sFind) >= 0;
+ }
+ int substitute(char chFind, char chReplace) {
+ int c = 0;
char *t = s;
while (t) {
- t = strchr(t, find);
+ t = strchr(t, chFind);
if (t) {
- *t = replace;
+ *t = chReplace;
t++;
+ c++;
}
}
+ return c;
+ }
+ int substitute(const char *sFind, const char *sReplace) {
+ int c = 0;
+ lenpos_t lenFind = strlen(sFind);
+ lenpos_t lenReplace = strlen(sReplace);
+ int posFound = search(sFind);
+ while (posFound >= 0) {
+ remove(posFound, lenFind);
+ insert(posFound, sReplace, lenReplace);
+ posFound = search(sFind, posFound + lenReplace);
+ c++;
+ }
+ return c;
+ }
+ int remove(const char *sFind) {
+ return substitute(sFind, "");
+ }
+ /**
+ * Duplicate a C string.
+ * Allocate memory of the given size, or big enough to fit the string if length isn't given;
+ * then copy the given string in the allocated memory.
+ * @return the pointer to the new string
+ */
+ static char *StringAllocate(
+ const char *s, ///< The string to duplicate
+ lenpos_t len=measure_length) ///< The length of memory to allocate. Optional.
+ {
+ if (s == 0) {
+ return 0;
+ }
+ if (len == measure_length) {
+ len = strlen(s);
+ }
+ char *sNew = new char[len + 1];
+ if (sNew) {
+ strncpy(sNew, s, len);
+ sNew[len] = '\0';
+ }
+ return sNew;
}
};
+/**
+ * Duplicate a C string.
+ * Allocate memory of the given size, or big enough to fit the string if length isn't given;
+ * then copy the given string in the allocated memory.
+ * @return the pointer to the new string
+ */
+inline char *StringDup(
+ const char *s, ///< The string to duplicate
+ SString::lenpos_t len=SString::measure_length) ///< The length of memory to allocate. Optional.
+{
+ return SString::StringAllocate(s, len);
+}
+
#endif
/** @file SciLexer.h
** Interface to the added lexer functions in the SciLexer version of the edit control.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition
#define SCLEX_EIFFELKW 24
#define SCLEX_TCL 25
#define SCLEX_NNCRONTAB 26
+#define SCLEX_BULLANT 27
+#define SCLEX_VBSCRIPT 28
+#define SCLEX_ASP 29
+#define SCLEX_PHP 30
+#define SCLEX_BAAN 31
+#define SCLEX_MATLAB 32
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
#define SCE_C_WORD2 16
#define SCE_C_COMMENTDOCKEYWORD 17
#define SCE_C_COMMENTDOCKEYWORDERROR 18
+#define SCE_B_DEFAULT 0
+#define SCE_B_COMMENT 1
+#define SCE_B_NUMBER 2
+#define SCE_B_KEYWORD 3
+#define SCE_B_STRING 4
+#define SCE_B_PREPROCESSOR 5
+#define SCE_B_OPERATOR 6
+#define SCE_B_IDENTIFIER 7
+#define SCE_B_DATE 8
#define SCE_H_DEFAULT 0
#define SCE_H_TAG 1
#define SCE_H_TAGUNKNOWN 2
#define SCE_LUA_OPERATOR 10
#define SCE_LUA_IDENTIFIER 11
#define SCE_LUA_STRINGEOL 12
+#define SCE_LUA_WORD2 13
+#define SCE_LUA_WORD3 14
+#define SCE_LUA_WORD4 15
+#define SCE_LUA_WORD5 16
+#define SCE_LUA_WORD6 17
#define SCE_ERR_DEFAULT 0
#define SCE_ERR_PYTHON 1
#define SCE_ERR_GCC 2
#define SCE_ADA_OPERATOR 6
#define SCE_ADA_IDENTIFIER 7
#define SCE_ADA_STRINGEOL 8
+#define SCE_BAAN_DEFAULT 0
+#define SCE_BAAN_COMMENT 1
+#define SCE_BAAN_COMMENTDOC 2
+#define SCE_BAAN_NUMBER 3
+#define SCE_BAAN_WORD 4
+#define SCE_BAAN_STRING 5
+#define SCE_BAAN_PREPROCESSOR 6
+#define SCE_BAAN_OPERATOR 7
+#define SCE_BAAN_IDENTIFIER 8
+#define SCE_BAAN_STRINGEOL 9
+#define SCE_BAAN_WORD2 10
#define SCE_LISP_DEFAULT 0
#define SCE_LISP_COMMENT 1
#define SCE_LISP_NUMBER 2
#define SCE_NNCRONTAB_STRING 8
#define SCE_NNCRONTAB_ENVIRONMENT 9
#define SCE_NNCRONTAB_IDENTIFIER 10
+#define SCE_MATLAB_DEFAULT 0
+#define SCE_MATLAB_COMMENT 1
+#define SCE_MATLAB_COMMAND 2
+#define SCE_MATLAB_NUMBER 3
+#define SCE_MATLAB_KEYWORD 4
+#define SCE_MATLAB_STRING 5
+#define SCE_MATLAB_OPERATOR 6
+#define SCE_MATLAB_IDENTIFIER 7
//--Autogenerated -- end of section automatically generated from Scintilla.iface
#endif
/** @file Scintilla.h
** Interface to the edit control.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// Most of this file is automatically generated from the Scintilla.iface interface definition
#define SCINTILLA_H
#if PLAT_WIN
-#ifdef STATIC_BUILD
-void Scintilla_RegisterClasses(HINSTANCE hInstance);
-#endif
+// Return false on failure:
+bool Scintilla_RegisterClasses(void *hInstance);
+bool Scintilla_ReleaseResources();
#endif
+int Scintilla_LinkLexers();
// Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
// hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
#define SC_MARK_CIRCLEPLUSCONNECTED 19
#define SC_MARK_CIRCLEMINUS 20
#define SC_MARK_CIRCLEMINUSCONNECTED 21
+#define SC_MARK_BACKGROUND 22
#define SC_MARK_CHARACTER 10000
#define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26
#define SC_MARKNUM_FOLDERSUB 29
#define SC_MARKNUM_FOLDER 30
#define SC_MARKNUM_FOLDEROPEN 31
+#define SC_MASK_FOLDERS 0xFE000000
#define SCI_MARKERDEFINE 2040
#define SCI_MARKERSETFORE 2041
#define SCI_MARKERSETBACK 2042
#define INDIC_TT 2
#define INDIC_DIAGONAL 3
#define INDIC_STRIKE 4
-#define INDIC0_MASK 32
-#define INDIC1_MASK 64
-#define INDIC2_MASK 128
-#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
+#define INDIC0_MASK 0x20
+#define INDIC1_MASK 0x40
+#define INDIC2_MASK 0x80
+#define INDICS_MASK 0xE0
#define SCI_INDICSETSTYLE 2080
#define SCI_INDICGETSTYLE 2081
#define SCI_INDICSETFORE 2082
#define SCI_SETCARETLINEVISIBLE 2096
#define SCI_GETCARETLINEBACK 2097
#define SCI_SETCARETLINEBACK 2098
+#define SCI_STYLESETCHANGEABLE 2099
#define SCI_AUTOCSHOW 2100
#define SCI_AUTOCCANCEL 2101
#define SCI_AUTOCACTIVE 2102
#define SCI_USERLISTSHOW 2117
#define SCI_AUTOCSETAUTOHIDE 2118
#define SCI_AUTOCGETAUTOHIDE 2119
+#define SCI_AUTOCSETDROPRESTOFWORD 2270
+#define SCI_AUTOCGETDROPRESTOFWORD 2271
#define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124
#define SC_TIME_FOREVER 10000000
#define SCI_SETMOUSEDWELLTIME 2264
#define SCI_GETMOUSEDWELLTIME 2265
+#define SCI_WORDSTARTPOSITION 2266
+#define SCI_WORDENDPOSITION 2267
+#define SC_WRAP_NONE 0
+#define SC_WRAP_WORD 1
+#define SCI_SETWRAPMODE 2268
+#define SCI_GETWRAPMODE 2269
+#define SC_CACHE_NONE 0
+#define SC_CACHE_CARET 1
+#define SC_CACHE_PAGE 2
+#define SC_CACHE_DOCUMENT 3
+#define SCI_SETLAYOUTCACHE 2272
+#define SCI_GETLAYOUTCACHE 2273
#define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302
#define SCI_UPPERCASE 2341
#define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343
+#define SCI_DELETEBACKNOTLINE 2344
#define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351
#define SC_CURSORWAIT 3
#define SCI_SETCURSOR 2386
#define SCI_GETCURSOR 2387
+#define SCI_SETCONTROLCHARSYMBOL 2388
+#define SCI_GETCONTROLCHARSYMBOL 2389
#define SCI_WORDPARTLEFT 2390
#define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392
#define SCI_SETVISIBLEPOLICY 2394
#define SCI_DELLINELEFT 2395
#define SCI_DELLINERIGHT 2396
+#define SCI_SETXOFFSET 2397
+#define SCI_GETXOFFSET 2398
#define SCI_GRABFOCUS 2400
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCN_KEY 2005
#define SCN_DOUBLECLICK 2006
#define SCN_UPDATEUI 2007
-#define SCN_CHECKBRACE 2007
#define SCN_MODIFIED 2008
#define SCN_MACRORECORD 2009
#define SCN_MARGINCLICK 2010
#define SCN_NEEDSHOWN 2011
-#define SCN_POSCHANGED 2012
#define SCN_PAINTED 2013
#define SCN_USERLISTSELECTION 2014
#define SCN_URIDROPPED 2015
#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.
struct RangeToFormat {
// hwndFrom is really an environment specifc window handle or pointer
// but most clients of Scintilla.h do not have this type visible.
//WindowID hwndFrom;
- void *hwndFrom;
+ void *hwndFrom;
unsigned int idFrom;
unsigned int code;
};
int y; // SCN_DWELLSTART, SCN_DWELLEND
};
-#define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | \
- (1<<SC_MARKNUM_FOLDEROPEN) | \
- (1<<SC_MARKNUM_FOLDERSUB) | \
- (1<<SC_MARKNUM_FOLDERTAIL) | \
- (1<<SC_MARKNUM_FOLDERMIDTAIL) | \
- (1<<SC_MARKNUM_FOLDEROPENMID) | \
- (1<<SC_MARKNUM_FOLDEREND))
-
// Deprecation section listing all API features that are deprecated and will
// will be removed completely in a future version.
// To enable these features define INCLUDE_DEPRECATED_FEATURES
#ifdef INCLUDE_DEPRECATED_FEATURES
+#define SCN_POSCHANGED 2012
+#define SCN_CHECKBRACE 2007
+
#endif
#endif
## This file defines the interface to Scintilla
+## Copyright 2000-2002 by Neil Hodgson <neilh@scintilla.org>
+## The License.txt file describes the conditions under which this software may be distributed.
+
## A line starting with ## is a pure comment and should be stripped by readers.
## A line starting with #! is for future shbang use
## A line starting with # followed by a space is a documentation comment and refers
## The syntax for evt is <featureType><ws><returnType><ws><name>[=<number]([<param>[,<param>]*])
## Feature names that contain an underscore are defined by Windows, so in these
## cases, using the Windows definition is preferred where available.
+## The feature numbers are stable so features will not be renumbered.
+## Features may be removed but they will go through a period of deprecation
+## before removal which is signalled by moving them into the Deprecated category.
## Types:
## void
## string -> pointer to const character
## stringresult -> pointer to character
## cells -> pointer to array of cells, each cell containing a style byte and character byte
-## charrange -> range of a min and a max position
-## charrangeresult -> like charrange, but output param
-## textrange -> charrange + output string
+## textrange -> range of a min and a max position with an output string
## findtext -> searchrange, text -> foundposition
-## findtextex -> searchrange
## keymod -> integer containing key in low half and modifiers in high half
-## countedstring
## formatrange
+## Types no longer used:
+## findtextex -> searchrange
+## charrange -> range of a min and a max position
+## charrangeresult -> like charrange, but output param
+## countedstring
## point -> x,y
## pointresult -> like point, but output param
## rectangle -> left,top,right,bottom
## Client code should ignore definitions containing types it does not understand, except
## for possibly #defining the constants
+## String arguments may contain NUL ('\0') characters where the calls provide a length
+## argument and retrieve NUL characters. All retrieved strings except for those retrieved
+## by GetLine also have a NUL appended but client code should calculate the size that
+## will be returned rather than relying upon the NUL whenever possible. Allow for the
+## extra NUL character when allocating buffers.
+
cat Basics
################################################
val SC_MARK_CIRCLEMINUS=20
val SC_MARK_CIRCLEMINUSCONNECTED=21
+# Invisible mark that only sets the line background color
+val SC_MARK_BACKGROUND=22
+
val SC_MARK_CHARACTER=10000
# Markers used for outlining column
val SC_MARKNUM_FOLDER=30
val SC_MARKNUM_FOLDEROPEN=31
+val SC_MASK_FOLDERS=0xFE000000
+
# Set the symbol used for a particular marker number.
fun void MarkerDefine=2040(int markerNumber, int markerSymbol)
# Set the background colour used for a particular marker number.
fun void MarkerSetBack=2042(int markerNumber, colour back)
-# Add a marker to a line.
-fun void MarkerAdd=2043(int line, int markerNumber)
+# Add a marker to a line, returning an ID which can be used to find or delete the marker.
+fun int MarkerAdd=2043(int line, int markerNumber)
# Delete a marker from a line
fun void MarkerDelete=2044(int line, int markerNumber)
val INDIC_TT=2
val INDIC_DIAGONAL=3
val INDIC_STRIKE=4
-val INDIC0_MASK=32
-val INDIC1_MASK=64
-val INDIC2_MASK=128
-val INDICS_MASK=224
-##INDIC0_MASK | INDIC1_MASK | INDIC2_MASK
+val INDIC0_MASK=0x20
+val INDIC1_MASK=0x40
+val INDIC2_MASK=0x80
+val INDICS_MASK=0xE0
# Set an indicator to plain, squiggle or TT.
set void IndicSetStyle=2080(int indic, int style)
# Is the background of the line containing the caret in a different colour?
get bool GetCaretLineVisible=2095(,)
-# Display the background of the line containing the caret in a different colour.
+# Dsplay the background of the line containing the caret in a different colour.
set void SetCaretLineVisible=2096(bool show,)
# Get the colour of the background of the line containing the caret.
# Set the colour of the background of the line containing the caret.
set void SetCaretLineBack=2098(colour back,)
+# Set a style to be changeable or not (read only).
+# Experimental feature, currently buggy.
+set void StyleSetChangeable=2099(int style, bool changeable)
+
# Display a auto-completion list.
# The lenEntered parameter indicates how many characters before
# the caret should be used to provide context.
# Retrieve whether auto-completion cancelled by backspacing before start.
get bool AutoCGetCancelAtStart=2111(,)
-# Define a set of character that when typed fills up the selected word.
+# Define a set of characters that when typed will cause the autocompletion to
+# choose the selected item.
set void AutoCSetFillUps=2112(, string characterSet)
# Should a single item auto-completion list automatically choose the item.
# Retrieve whether or not autocompletion is hidden automatically when nothing matches
get bool AutoCGetAutoHide=2119(,)
+# Set whether or not autocompletion deletes any word characters after the inserted text upon completion
+set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,)
+
+# Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
+get bool AutoCGetDropRestOfWord=2271(,)
+
# Set the number of spaces used for one level of indentation.
set void SetIndent=2122(int indentSize,)
# Retrieve the time the mouse must sit still to generate a mouse dwell event
get int GetMouseDwellTime=2265(,)
+# Get position of start of word
+fun int WordStartPosition=2266(position pos, bool onlyWordCharacters)
+
+# Get position of end of word
+fun int WordEndPosition=2267(position pos, bool onlyWordCharacters)
+
+val SC_WRAP_NONE=0
+val SC_WRAP_WORD=1
+
+# Sets whether text is word wrapped
+set void SetWrapMode=2268(int mode,)
+
+# Retrieve whether text is word wrapped
+get int GetWrapMode=2269(,)
+
+val SC_CACHE_NONE=0
+val SC_CACHE_CARET=1
+val SC_CACHE_PAGE=2
+val SC_CACHE_DOCUMENT=3
+
+# Sets the degree of caching of layout information
+set void SetLayoutCache=2272(int mode,)
+
+# Retrieve the degree of caching of layout information
+get int GetLayoutCache=2273(,)
+
## Start of key messages
# Move caret down one line.
fun void LineDown=2300(,)
# Scroll the document up, keeping the caret visible.
fun void LineScrollUp=2343(,)
+# Delete the selection or if no selection, the character before the caret.
+# Will not delete the chraacter before at the start of a line.
+fun void DeleteBackNotLine=2344(,)
+
# Move the caret inside current view if it's not there already
fun void MoveCaretInsideView=2401(,)
# Get cursor type
get int GetCursor=2387(,)
+# Change the way control characters are displayed:
+# If symbol is < 32, keep the drawn way, else, use the given character
+set void SetControlCharSymbol=2388(int symbol,)
+# Get the way control characters are displayed
+get int GetControlCharSymbol=2389(,)
+
# Move to the previous change in capitalistion
fun void WordPartLeft=2390(,)
# Move to the previous change in capitalistion extending selection to new caret position.
# Delete forwards from the current position to the end of the line
fun void DelLineRight=2396(,)
+# Get and Set the xOffset (ie, horizonal scroll position)
+set void SetXOffset=2397(int newOffset,)
+get int GetXOffset=2398(,)
+
# Set the focus to this Scintilla widget.
# GTK+ Specific
fun void GrabFocus=2400(,)
val SCLEX_EIFFELKW=24
val SCLEX_TCL=25
val SCLEX_NNCRONTAB=26
+val SCLEX_BULLANT=27
+val SCLEX_VBSCRIPT=28
+val SCLEX_ASP=29
+val SCLEX_PHP=30
+val SCLEX_BAAN=31
+val SCLEX_MATLAB=32
+
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
val SCLEX_AUTOMATIC=1000
val SCE_P_IDENTIFIER=11
val SCE_P_COMMENTBLOCK=12
val SCE_P_STRINGEOL=13
-# Lexical states for SCLEX_CPP, SCLEX_VB
+# Lexical states for SCLEX_CPP
val SCE_C_DEFAULT=0
val SCE_C_COMMENT=1
val SCE_C_COMMENTLINE=2
val SCE_C_WORD2=16
val SCE_C_COMMENTDOCKEYWORD=17
val SCE_C_COMMENTDOCKEYWORDERROR=18
+# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT
+val SCE_B_DEFAULT=0
+val SCE_B_COMMENT=1
+val SCE_B_NUMBER=2
+val SCE_B_KEYWORD=3
+val SCE_B_STRING=4
+val SCE_B_PREPROCESSOR=5
+val SCE_B_OPERATOR=6
+val SCE_B_IDENTIFIER=7
+val SCE_B_DATE=8
# Lexical states for SCLEX_HTML, SCLEX_XML
val SCE_H_DEFAULT=0
val SCE_H_TAG=1
val SCE_LUA_OPERATOR=10
val SCE_LUA_IDENTIFIER=11
val SCE_LUA_STRINGEOL=12
+val SCE_LUA_WORD2=13
+val SCE_LUA_WORD3=14
+val SCE_LUA_WORD4=15
+val SCE_LUA_WORD5=16
+val SCE_LUA_WORD6=17
# Lexical states for SCLEX_ERRORLIST
val SCE_ERR_DEFAULT=0
val SCE_ERR_PYTHON=1
val SCE_ADA_OPERATOR=6
val SCE_ADA_IDENTIFIER=7
val SCE_ADA_STRINGEOL=8
+# Lexical states for SCLEX_BAAN
+val SCE_BAAN_DEFAULT=0
+val SCE_BAAN_COMMENT=1
+val SCE_BAAN_COMMENTDOC=2
+val SCE_BAAN_NUMBER=3
+val SCE_BAAN_WORD=4
+val SCE_BAAN_STRING=5
+val SCE_BAAN_PREPROCESSOR=6
+val SCE_BAAN_OPERATOR=7
+val SCE_BAAN_IDENTIFIER=8
+val SCE_BAAN_STRINGEOL=9
+val SCE_BAAN_WORD2=10
# Lexical states for SCLEX_LISP
val SCE_LISP_DEFAULT=0
val SCE_LISP_COMMENT=1
val SCE_NNCRONTAB_STRING=8
val SCE_NNCRONTAB_ENVIRONMENT=9
val SCE_NNCRONTAB_IDENTIFIER=10
+# Lexical states for SCLEX_MATLAB
+val SCE_MATLAB_DEFAULT=0
+val SCE_MATLAB_COMMENT=1
+val SCE_MATLAB_COMMAND=2
+val SCE_MATLAB_NUMBER=3
+val SCE_MATLAB_KEYWORD=4
+val SCE_MATLAB_STRING=5
+val SCE_MATLAB_OPERATOR=6
+val SCE_MATLAB_IDENTIFIER=7
# Events
evt void Key=2005(int ch, int modifiers)
evt void DoubleClick=2006(void)
evt void UpdateUI=2007(void)
-# The old name for SCN_UPDATEUI
-val SCN_CHECKBRACE=2007
evt void Modified=2008(int position, int modificationType, string text, int length, int linesAdded, int line, int foldLevelNow, int foldLevelPrev)
-# Optional module for macro recording
evt void MacroRecord=2009(int message, int wParam, int lParam)
evt void MarginClick=2010(int modifiers, int position, int margin)
evt void NeedShown=2011(int position, int length)
-evt void PosChanged=2012(int position)
evt void Painted=2013(void)
evt void UserListSelection=2014(int listType, string text)
evt void URIDropped=2015(string text)
evt void DwellEnd=2017(int position)
cat Deprecated
+
+# The old name for SCN_UPDATEUI
+val SCN_CHECKBRACE=2007
+evt void PosChanged=2012(int position)
/** @file AutoComplete.cxx
** Defines the auto completion list box.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
posStart(0),
startLen(0),
cancelAtStartPos(true),
- autoHide(true) {
+ autoHide(true),
+ dropRestOfWord(false) {
stopChars[0] = '\0';
fillUpChars[0] = '\0';
}
/** @file AutoComplete.h
** Defines the auto completion list box.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef AUTOCOMPLETE_H
/// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos;
bool autoHide;
+ bool dropRestOfWord;
AutoComplete();
~AutoComplete();
startHighlight = 0;
endHighlight = 0;
- colourBG.desired = Colour(0xff, 0xff, 0xff);
- colourUnSel.desired = Colour(0x80, 0x80, 0x80);
- colourSel.desired = Colour(0, 0, 0x80);
- colourShade.desired = Colour(0, 0, 0);
- colourLight.desired = Colour(0xc0, 0xc0, 0xc0);
+ colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
+ colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
+ colourSel.desired = ColourDesired(0, 0, 0x80);
+ colourShade.desired = ColourDesired(0, 0, 0);
+ colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
}
CallTip::~CallTip() {
rcClient.left = x;
rcClient.top = ytext - ascent - 1;
rcClient.right = xEnd;
- surfaceWindow->DrawText(rcClient, font, ytext,
+ surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal, thisStartHighlight,
colourUnSel.allocated, colourBG.allocated);
x = xEnd;
rcClient.top = ytext;
rcClient.left = x;
rcClient.right = xEnd;
- surfaceWindow->DrawText(rcClient, font, ytext,
+ surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisStartHighlight, thisEndHighlight - thisStartHighlight,
colourSel.allocated, colourBG.allocated);
x = xEnd;
chunkLength - thisEndHighlight);
rcClient.left = x;
rcClient.right = xEnd;
- surfaceWindow->DrawText(rcClient, font, ytext,
+ surfaceWindow->DrawTextNoClip(rcClient, font, ytext,
chunkVal + thisEndHighlight, chunkLength - thisEndHighlight,
colourUnSel.allocated, colourBG.allocated);
chunkVal = chunkEnd + 1;
}
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
- const char *faceName, int size) {
- Surface surfaceMeasure;
- surfaceMeasure.Init();
- int deviceHeight = surfaceMeasure.DeviceHeightFont(size);
- font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
+ const char *faceName, int size, bool unicodeMode_) {
if (val)
delete []val;
val = new char[strlen(defn) + 1];
if (!val)
return PRectangle();
strcpy(val, defn);
+ unicodeMode = unicodeMode_;
+ Surface *surfaceMeasure = Surface::Allocate();
+ if (!surfaceMeasure)
+ return PRectangle();
+ surfaceMeasure->Init();
+ surfaceMeasure->SetUnicodeMode(unicodeMode);
startHighlight = 0;
endHighlight = 0;
inCallTipMode = true;
posStartCallTip = pos;
+ int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
+ font.Create(faceName, SC_CHARSET_DEFAULT, deviceHeight, false, false);
// Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r!
int width = 0;
const char *newline;
const char *look = val;
while ((newline = strchr(look, '\n')) != NULL) {
- int thisWidth = surfaceMeasure.WidthText(font, look, newline - look);
+ int thisWidth = surfaceMeasure->WidthText(font, look, newline - look);
width = Platform::Maximum(width, thisWidth);
look = newline + 1;
numLines++;
}
- int lastWidth = surfaceMeasure.WidthText(font, look, strlen(look));
+ int lastWidth = surfaceMeasure->WidthText(font, look, strlen(look));
width = Platform::Maximum(width, lastWidth) + 10;
- int lineHeight = surfaceMeasure.Height(font);
+ int lineHeight = surfaceMeasure->Height(font);
// Extra line for border and an empty line at top and bottom
- int height = lineHeight * numLines - surfaceMeasure.InternalLeading(font) + 2 + 2;
+ int height = lineHeight * numLines - surfaceMeasure->InternalLeading(font) + 2 + 2;
+ delete surfaceMeasure;
return PRectangle(pt.x -5, pt.y + 1, pt.x + width - 5, pt.y + 1 + height);
}
ColourPair colourSel;
ColourPair colourShade;
ColourPair colourLight;
+ bool unicodeMode;
CallTip();
~CallTip();
/// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(int pos, Point pt, const char *defn,
- const char *faceName, int size);
+ const char *faceName, int size, bool unicodeMode_);
void CallTipCancel();
OneLine::OneLine() {
displayLine = 0;
- docLine = 0;
+ //docLine = 0;
visible = true;
+ height = 1;
expanded = true;
}
linesInDoc = 1;
linesInDisplay = 1;
valid = false;
+ docLines = 0;
+ sizeDocLines = 0;
}
ContractionState::~ContractionState() {
void ContractionState::MakeValid() const {
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.
- int lineDisplay = 0;
+ linesInDisplay = 0;
+ for (int lineInDoc=0; lineInDoc<linesInDoc; lineInDoc++) {
+ lines[lineInDoc].displayLine = linesInDisplay;
+ if (lines[lineInDoc].visible) {
+ linesInDisplay += lines[lineInDoc].height;
+ }
+ }
+ if (sizeDocLines < linesInDisplay) {
+ delete []docLines;
+ int *docLinesNew = new int[linesInDisplay + growSize];
+ if (!docLinesNew) {
+ docLines = 0;
+ sizeDocLines = 0;
+ return;
+ }
+ docLines = docLinesNew;
+ sizeDocLines = linesInDisplay + growSize;
+ }
+
+ int lineInDisplay=0;
for (int line=0; line<linesInDoc; line++) {
- lines[line].displayLine = lineDisplay;
if (lines[line].visible) {
- lines[lineDisplay].docLine = line;
- lineDisplay++;
+ for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
+ docLines[lineInDisplay] = line;
+ lineInDisplay++;
+ }
}
}
valid = true;
size = 0;
linesInDoc = 1;
linesInDisplay = 1;
+ delete []docLines;
+ docLines = 0;
+ sizeDocLines = 0;
}
int ContractionState::LinesInDoc() const {
}
int ContractionState::LinesDisplayed() const {
+ if (size != 0) {
+ MakeValid();
+ }
return linesInDisplay;
}
if (lineDisplay <= 0)
return 0;
if (lineDisplay >= linesInDisplay)
- return linesInDoc-1;
+ return linesInDoc;
if (size == 0)
return lineDisplay;
MakeValid();
- return lines[lineDisplay].docLine;
+ if (docLines) { // Valid allocation
+ return docLines[lineDisplay];
+ } else {
+ return 0;
+ }
}
void ContractionState::Grow(int sizeNew) {
Grow(linesInDoc + lineCount + growSize);
}
linesInDoc += lineCount;
- linesInDisplay += lineCount;
for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
lines[i].visible = lines[i - lineCount].visible;
+ lines[i].height = lines[i - lineCount].height;
+ linesInDisplay += lines[i].height;
lines[i].expanded = lines[i - lineCount].expanded;
}
for (int d=0;d<lineCount;d++) {
lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
+ lines[lineDoc+d].height = 1;
lines[lineDoc+d].expanded = true;
}
valid = false;
int deltaDisplayed = 0;
for (int d=0;d<lineCount;d++) {
if (lines[lineDoc+d].visible)
- deltaDisplayed--;
+ deltaDisplayed -= lines[lineDoc+d].height;
}
for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
if (i != 0) // Line zero is always visible
}
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
- if (lineDocStart == 0)
- lineDocStart++;
- if (lineDocStart > lineDocEnd)
- return false;
+ if (lineDocStart == 0)
+ lineDocStart++;
+ if (lineDocStart > lineDocEnd)
+ return false;
if (size == 0) {
Grow(linesInDoc + growSize);
}
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
for (int line=lineDocStart; line <= lineDocEnd; line++) {
if (lines[line].visible != visible) {
- delta += visible ? 1 : -1;
+ delta += visible ? lines[line].height : -lines[line].height;
lines[line].visible = visible;
}
}
}
bool ContractionState::GetExpanded(int lineDoc) const {
- if (size == 0)
+ if (size == 0)
return true;
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
return lines[lineDoc].expanded;
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
if (size == 0) {
+ if (expanded) {
+ // If in completely expanded state then setting
+ // one line to expanded has no effect.
+ return false;
+ }
Grow(linesInDoc + growSize);
}
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
return false;
}
+int ContractionState::GetHeight(int lineDoc) const {
+ if (size == 0)
+ return 1;
+ if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
+ return lines[lineDoc].height;
+ } else {
+ return 1;
+ }
+}
+
+// Set the number of display lines needed for this line.
+// Return true if this is a change.
+bool ContractionState::SetHeight(int lineDoc, int height) {
+ if (lineDoc > linesInDoc)
+ return false;
+ if (size == 0) {
+ if (height == 1) {
+ // If in completely expanded state then all lines
+ // assumed to have height of one so no effect here.
+ return false;
+ }
+ Grow(linesInDoc + growSize);
+ }
+ if (lines[lineDoc].height != height) {
+ lines[lineDoc].height = height;
+ valid = false;
+ return true;
+ } else {
+ return false;
+ }
+}
+
void ContractionState::ShowAll() {
delete []lines;
lines = 0;
class OneLine {
public:
int displayLine; ///< Position within set of visible lines
- int docLine; ///< Inverse of @a displayLine
+ //int docLine; ///< Inverse of @a displayLine
+ int height; ///< Number of display lines needed to show all of the line
bool visible;
bool expanded;
-
+
OneLine();
virtual ~OneLine() {}
};
void Grow(int sizeNew);
enum { growSize = 4000 };
int linesInDoc;
- int linesInDisplay;
+ mutable int linesInDisplay;
mutable OneLine *lines;
int size;
+ mutable int *docLines;
+ mutable int sizeDocLines;
mutable bool valid;
void MakeValid() const;
public:
ContractionState();
virtual ~ContractionState();
-
+
void Clear();
-
- int LinesInDoc() const;
- int LinesDisplayed() const;
+
+ int LinesInDoc() const;
+ int LinesDisplayed() const;
int DisplayFromDoc(int lineDoc) const;
int DocFromDisplay(int lineDisplay) const;
-
+
void InsertLines(int lineDoc, int lineCount);
void DeleteLines(int lineDoc, int lineCount);
-
+
bool GetVisible(int lineDoc) const;
bool SetVisible(int lineDocStart, int lineDocEnd, bool visible);
-
+
bool GetExpanded(int lineDoc) const;
bool SetExpanded(int lineDoc, bool expanded);
- void ShowAll();
+ int GetHeight(int lineDoc) const;
+ bool SetHeight(int lineDoc, int height);
+
+ void ShowAll();
};
#endif
/** @file Document.cxx
** Text document that handles notifications, DBCS, styling, words and end of line.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include "RESearch.h"
// This is ASCII specific but is safe with chars >= 0x80
-inline bool isspacechar(unsigned char ch) {
+static inline bool isspacechar(unsigned char ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
stylingBits = 5;
stylingBitsMask = 0x1F;
stylingMask = 0;
- for (int ch = 0; ch < 256; ch++) {
- wordchars[ch] = isalnum(ch) || ch == '_';
- }
+ SetWordChars(0);
endStyled = 0;
+ styleClock = 0;
enteredCount = 0;
enteredReadOnlyCount = 0;
tabInChars = 8;
return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n');
}
-#if PLAT_WIN
bool Document::IsDBCS(int pos) {
if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) {
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
startLine--;
while (startLine <= pos) {
- if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) {
+ if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine))) {
startLine++;
if (startLine >= pos)
return true;
}
return false;
}
-#else
-// PLAT_GTK or PLAT_WX
-// TODO: support DBCS under GTK+ and WX
-bool Document::IsDBCS(int) {
- return false;
-}
-#endif
int Document::LenChar(int pos) {
if (IsCrLf(pos)) {
// Not between CR and LF
-#if PLAT_WIN
if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) {
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
while (startLine < pos) {
if (atLeadByte)
atLeadByte = false;
- else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine)))
+ else if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine)))
atLeadByte = true;
else
atLeadByte = false;
startLine++;
- //Platform::DebugPrintf("DBCS %s\n", atlead ? "D" : "-");
}
}
}
}
-#endif
return pos;
}
int column = 0;
int line = LineFromPosition(pos);
if ((line >= 0) && (line < LinesTotal())) {
- for (int i = LineStart(line);i < pos;i++) {
+ for (int i = LineStart(line);i < pos;) {
char ch = cb.CharAt(i);
- if (ch == '\t')
+ if (ch == '\t') {
column = NextTab(column, tabInChars);
- else if (ch == '\r')
+ i++;
+ } else if (ch == '\r') {
return column;
- else if (ch == '\n')
+ } else if (ch == '\n') {
return column;
- else
+ } else {
column++;
+ i = MovePositionOutsideChar(i + 1, 1);
+ }
}
}
return column;
}
+int Document::FindColumn(int line, int column) {
+ int position = LineStart(line);
+ int columnCurrent = 0;
+ if ((line >= 0) && (line < LinesTotal())) {
+ while (columnCurrent < column) {
+ char ch = cb.CharAt(position);
+ if (ch == '\t') {
+ columnCurrent = NextTab(columnCurrent, tabInChars);
+ position++;
+ } else if (ch == '\r') {
+ return position;
+ } else if (ch == '\n') {
+ return position;
+ } else {
+ columnCurrent++;
+ position = MovePositionOutsideChar(position + 1, 1);
+ }
+ }
+ }
+ return position;
+}
+
void Document::Indent(bool forwards, int lineBottom, int lineTop) {
// Dedent - suck white space off the front of the line to dedent by equivalent of a tab
for (int line = lineBottom; line >= lineTop; line--) {
EndUndoAction();
}
-bool Document::IsWordChar(unsigned char ch) {
- if ((SC_CP_UTF8 == dbcsCodePage) && (ch > 0x80))
- return true;
- return wordchars[ch];
+Document::charClassification Document::WordCharClass(unsigned char ch) {
+ if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80))
+ return ccWord;
+ return charClass[ch];
}
-int Document::ExtendWordSelect(int pos, int delta) {
+/**
+ * Used by commmands that want to select whole words.
+ * Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0.
+ */
+int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) {
+ charClassification ccStart = ccWord;
if (delta < 0) {
- while (pos > 0 && IsWordChar(cb.CharAt(pos - 1)))
+ if (!onlyWordCharacters)
+ ccStart = WordCharClass(cb.CharAt(pos-1));
+ while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
pos--;
} else {
- while (pos < (Length()) && IsWordChar(cb.CharAt(pos)))
+ if (!onlyWordCharacters)
+ ccStart = WordCharClass(cb.CharAt(pos));
+ while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
pos++;
}
return pos;
}
+/**
+ * Find the start of the next word in either a forward (delta >= 0) or backwards direction
+ * (delta < 0).
+ * This is looking for a transition between character classes although there is also some
+ * additional movement to transit white space.
+ * Used by cursor movement by word commands.
+ */
int Document::NextWordStart(int pos, int delta) {
if (delta < 0) {
- while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))
+ while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccSpace))
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))))
+ if (pos > 0) {
+ charClassification ccStart = WordCharClass(cb.CharAt(pos-1));
+ while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) {
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))))
+ charClassification ccStart = WordCharClass(cb.CharAt(pos));
+ while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
pos++;
- while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))
+ while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccSpace))
pos++;
}
return pos;
}
/**
- * Check that the character before the given position
- * is not a word character.
+ * Check that the character at the given position is a word or punctuation character and that
+ * the previous character is of a different character class.
*/
bool Document::IsWordStartAt(int pos) {
if (pos > 0) {
- return !IsWordChar(CharAt(pos - 1));
+ charClassification ccPos = WordCharClass(CharAt(pos));
+ return (ccPos == ccWord || ccPos == ccPunctuation) &&
+ (ccPos != WordCharClass(CharAt(pos - 1)));
}
return true;
}
/**
- * Check that the character after the given position
- * is not a word character.
+ * Check that the character at the given position is a word or punctuation character and that
+ * the next character is of a different character class.
*/
bool Document::IsWordEndAt(int pos) {
if (pos < Length() - 1) {
- return !IsWordChar(CharAt(pos));
+ charClassification ccPrev = WordCharClass(CharAt(pos-1));
+ return (ccPrev == ccWord || ccPrev == ccPunctuation) &&
+ (ccPrev != WordCharClass(CharAt(pos)));
}
return true;
}
/**
- * Check that the given range is delimited by
- * non word characters.
+ * Check that the given range is has transitions between character classes at both
+ * ends and where the characters on the inside are word or punctuation characters.
*/
bool Document::IsWordAt(int start, int end) {
return IsWordStartAt(start) && IsWordEndAt(end);
void Document::SetWordChars(unsigned char *chars) {
int ch;
for (ch = 0; ch < 256; ch++) {
- wordchars[ch] = false;
+ if (ch == '\r' || ch == '\n')
+ charClass[ch] = ccNewLine;
+ else if (ch < 0x20 || ch == ' ')
+ charClass[ch] = ccSpace;
+ else
+ charClass[ch] = ccPunctuation;
}
if (chars) {
while (*chars) {
- wordchars[*chars] = true;
+ charClass[*chars] = ccWord;
chars++;
}
} else {
for (ch = 0; ch < 256; ch++) {
- wordchars[ch] = isalnum(ch) || ch == '_';
+ if (ch >= 0x80 || isalnum(ch) || ch == '_')
+ charClass[ch] = ccWord;
}
}
}
int prevEndStyled = endStyled;
bool didChange = false;
for (int iPos = 0; iPos < length; iPos++, endStyled++) {
+ PLATFORM_ASSERT(endStyled < Length());
if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
didChange = true;
}
}
bool Document::EnsureStyledTo(int pos) {
+ if (pos > GetEndStyled()) {
+ styleClock++;
+ if (styleClock > 0x100000) {
+ styleClock = 0;
+ }
+ }
// Ask the watchers to style, and stop as soon as one responds.
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
}
bool Document::IsWordPartSeparator(char ch) {
- return ispunct(ch) && IsWordChar(ch);
+ return ispunct(ch) && (WordCharClass(ch) == ccWord);
}
int Document::WordPartLeft(int pos) {
/** @file Document.h
** Text document that handles notifications, DBCS, styling, words and end of line.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef DOCUMENT_H
return (start != invalidPosition) && (end != invalidPosition);
}
+ // Is the position within the range?
bool Contains(Position pos) const {
if (start < end) {
return (pos >= start && pos <= end);
}
}
+ // Is the character after pos within the range?
+ bool ContainsCharacter(Position pos) const {
+ if (start < end) {
+ return (pos >= start && pos < end);
+ } else {
+ return (pos < start && pos >= end);
+ }
+ }
+
bool Contains(Range other) const {
return Contains(other.start) && Contains(other.end);
}
private:
int refCount;
CellBuffer cb;
- bool wordchars[256];
+ enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
+ charClassification charClass[256];
char stylingMask;
int endStyled;
+ int styleClock;
int enteredCount;
int enteredReadOnlyCount;
void SetLineIndentation(int line, int indent);
int GetLineIndentPosition(int line);
int GetColumn(int position);
+ int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
int GetFoldParent(int line);
void Indent(bool forwards);
- int ExtendWordSelect(int pos, int delta);
+ int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
int NextWordStart(int pos, int delta);
int Length() { return cb.Length(); }
long FindText(int minPos, int maxPos, const char *s,
void SetStyles(int length, char *styles);
int GetEndStyled() { return endStyled; }
bool EnsureStyledTo(int pos);
+ int GetStyleClock() { return styleClock; }
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); }
private:
bool IsDBCS(int pos);
- bool IsWordChar(unsigned char ch);
+ charClassification WordCharClass(unsigned char ch);
bool IsWordStartAt(int pos);
bool IsWordEndAt(int pos);
bool IsWordAt(int start, int end);
DocumentAccessor::~DocumentAccessor() {
}
-#if PLAT_WIN
bool DocumentAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte.
return false;
else
- return IsDBCSLeadByteEx(codePage, ch);
+ return Platform::IsDBCSLeadByte(codePage, ch);
}
-#else
-// PLAT_GTK or PLAT_WX
-// TODO: support DBCS under GTK+ and WX
-bool DocumentAccessor::InternalIsLeadByte(char) {
- return false;
-}
-#endif
void DocumentAccessor::Fill(int position) {
if (lenDoc == -1)
void DocumentAccessor::StartAt(unsigned int start, char chMask) {
pdoc->StartStyling(start, chMask);
+ startPosStyling = start;
}
void DocumentAccessor::StartSegment(unsigned int pos) {
chFlags = 0;
chAttr |= chFlags;
for (unsigned int i = startSeg; i <= pos; i++) {
+ PLATFORM_ASSERT((startPosStyling + validLen) < Length());
styleBuf[validLen++] = static_cast<char>(chAttr);
}
}
if (validLen > 0) {
pdoc->SetStyles(validLen, styleBuf);
validLen = 0;
+ startPosStyling += validLen;
}
}
char chFlags;
char chWhile;
unsigned int startSeg;
+ int startPosStyling;
bool InternalIsLeadByte(char ch);
void Fill(int position);
public:
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), id(id_),
- lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
+ lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
+ startSeg(0), startPosStyling(0) {
}
~DocumentAccessor();
char StyleAt(int position);
/** @file Editor.cxx
** Main code for 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.
#include <stdlib.h>
#include "Platform.h"
+#define INCLUDE_DEPRECATED_FEATURES
#include "Scintilla.h"
#include "ContractionState.h"
Timer::Timer() :
ticking(false), ticksToWait(0), tickerID(0) {}
+LineLayout::LineLayout(int maxLineLength_) :
+ lineStarts(0),
+ lenLineStarts(0),
+ lineNumber(-1),
+ inCache(false),
+ maxLineLength(-1),
+ numCharsInLine(0),
+ validity(llInvalid),
+ xHighlightGuide(0),
+ highlightColumn(0),
+ selStart(0),
+ selEnd(0),
+ containsCaret(false),
+ edgeColumn(0),
+ chars(0),
+ styles(0),
+ indicators(0),
+ positions(0),
+ widthLine(wrapWidthInfinite),
+ lines(1) {
+ Resize(maxLineLength_);
+}
+
+LineLayout::~LineLayout() {
+ Free();
+}
+
+void LineLayout::Resize(int maxLineLength_) {
+ if (maxLineLength_ > maxLineLength) {
+ Free();
+ chars = new char[maxLineLength_ + 1];
+ styles = new char[maxLineLength_ + 1];
+ indicators = new char[maxLineLength_ + 1];
+ positions = new int[maxLineLength_ + 1];
+ maxLineLength = maxLineLength_;
+ }
+}
+
+void LineLayout::Free() {
+ delete []chars;
+ chars = 0;
+ delete []styles;
+ styles = 0;
+ delete []indicators;
+ indicators = 0;
+ delete []positions;
+ positions = 0;
+ delete []lineStarts;
+ lineStarts = 0;
+}
+
+void LineLayout::Invalidate(validLevel validity_) {
+ validity = validity_;
+}
+
+void LineLayout::SetLineStart(int line, int start) {
+ if ((line >= lenLineStarts) && (line != 0)) {
+ int newMaxLines = line + 20;
+ int *newLineStarts = new int[newMaxLines];
+ if (!newLineStarts)
+ return;
+ for (int i=0; i<newMaxLines; i++) {
+ if (i < lenLineStarts)
+ newLineStarts[i] = lineStarts[i];
+ else
+ newLineStarts[i] = 0;
+ }
+ delete []lineStarts;
+ lineStarts = newLineStarts;
+ lenLineStarts = newMaxLines;
+ }
+ lineStarts[line] = start;
+}
+
+void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],
+ char bracesMatchStyle, int xHighlight) {
+ if (rangeLine.ContainsCharacter(braces[0])) {
+ int braceOffset = braces[0] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ bracePreviousStyles[0] = styles[braceOffset];
+ styles[braceOffset] = bracesMatchStyle;
+ }
+ }
+ if (rangeLine.ContainsCharacter(braces[1])) {
+ int braceOffset = braces[1] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ bracePreviousStyles[1] = styles[braceOffset];
+ styles[braceOffset] = bracesMatchStyle;
+ }
+ }
+ if ((braces[0] >= rangeLine.start && braces[1] <= rangeLine.end) ||
+ (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) {
+ xHighlightGuide = xHighlight;
+ }
+}
+
+void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) {
+ if (rangeLine.ContainsCharacter(braces[0])) {
+ int braceOffset = braces[0] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ styles[braceOffset] = bracePreviousStyles[0];
+ }
+ }
+ if (rangeLine.ContainsCharacter(braces[1])) {
+ int braceOffset = braces[1] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ styles[braceOffset] = bracePreviousStyles[1];
+ }
+ }
+ xHighlightGuide = 0;
+}
+
+LineLayoutCache::LineLayoutCache() :
+ level(0), length(0), size(0), cache(0),
+ allInvalidated(false), styleClock(-1) {
+ Allocate(0);
+}
+
+LineLayoutCache::~LineLayoutCache() {
+ Deallocate();
+}
+
+void LineLayoutCache::Allocate(int length_) {
+ allInvalidated = false;
+ length = length_;
+ size = length;
+ if (size > 1) {
+ size = (size / 16 + 1) * 16;
+ }
+ if (size > 0) {
+ cache = new LineLayout *[size];
+ }
+ for (int i=0; i<size; i++)
+ cache[i] = 0;
+}
+
+void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
+ int lengthForLevel = 0;
+ if (level == llcCaret) {
+ lengthForLevel = 1;
+ } else if (level == llcPage) {
+ lengthForLevel = linesOnScreen + 1;
+ } else if (level == llcDocument) {
+ lengthForLevel = linesInDoc;
+ }
+ if (lengthForLevel > size) {
+ Deallocate();
+ } else {
+ if (lengthForLevel < length) {
+ for (int i=lengthForLevel; i<length; i++) {
+ delete cache[i];
+ cache[i] = 0;
+ }
+ }
+ Invalidate(LineLayout::llInvalid);
+ }
+ if (!cache) {
+ Allocate(lengthForLevel);
+ }
+}
+
+void LineLayoutCache::Deallocate() {
+ for (int i=0; i<length; i++)
+ delete cache[i];
+ delete []cache;
+ cache = 0;
+ length = 0;
+}
+
+void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
+ if (cache && !allInvalidated) {
+ for (int i=0; i<length; i++) {
+ if (cache[i]) {
+ cache[i]->Invalidate(validity_);
+ }
+ }
+ if (validity_ == LineLayout::llInvalid) {
+ allInvalidated = true;
+ }
+ }
+}
+
+void LineLayoutCache::SetLevel(int level_) {
+ allInvalidated = false;
+ if ((level_ != -1) && (level != level_)) {
+ level = level_;
+ Deallocate();
+ }
+}
+
+LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+ int linesOnScreen, int linesInDoc) {
+ AllocateForLevel(linesOnScreen, linesInDoc);
+ if (styleClock != styleClock_) {
+ Invalidate(LineLayout::llInvalid);
+ styleClock = styleClock_;
+ }
+ allInvalidated = false;
+ int pos = -1;
+ LineLayout *ret = 0;
+ if (((level == llcCaret) || (level == llcPage)) && (lineNumber == lineCaret)) {
+ pos = 0;
+ } else if (level == llcPage) {
+ pos = lineNumber % length;
+ } else if (level == llcDocument) {
+ pos = lineNumber;
+ }
+ if (pos >= 0) {
+ if (cache && (pos < length)) {
+ if (cache[pos]) {
+ if ((cache[pos]->lineNumber != lineNumber) ||
+ (cache[pos]->maxLineLength < maxChars)) {
+ delete cache[pos];
+ cache[pos] = 0;
+ }
+ }
+ if (!cache[pos]) {
+ cache[pos] = new LineLayout(maxChars);
+ }
+ if (cache[pos]) {
+ cache[pos]->lineNumber = lineNumber;
+ cache[pos]->inCache = true;
+ ret = cache[pos];
+ }
+ }
+ }
+
+ if (!ret) {
+ ret = new LineLayout(maxChars);
+ ret->lineNumber = lineNumber;
+ }
+
+ return ret;
+}
+
+void LineLayoutCache::Dispose(LineLayout *ll) {
+ allInvalidated = false;
+ if (ll) {
+ if (!ll->inCache) {
+ delete ll;
+ }
+ }
+}
+
Editor::Editor() {
ctrlID = 0;
printMagnification = 0;
printColourMode = SC_PRINT_NORMAL;
cursorMode = SC_CURSORNORMAL;
+ controlCharSymbol = 0; /* Draw the control characters */
hasFocus = false;
hideSelection = false;
xCaretMargin = 50;
horizontalScrollBarVisible = true;
+ pixmapLine = Surface::Allocate();
+ pixmapSelMargin = Surface::Allocate();
+ pixmapSelPattern = Surface::Allocate();
+ pixmapIndentGuide = Surface::Allocate();
+ pixmapIndentGuideHighlight = Surface::Allocate();
+
currentPos = 0;
anchor = 0;
recordingMacro = false;
foldFlags = 0;
+
+ wrapState = eWrapNone;
+ wrapWidth = LineLayout::wrapWidthInfinite;
+ docLineLastWrapped = -1;
+
+ llc.SetLevel(LineLayoutCache::llcDocument);
}
Editor::~Editor() {
pdoc->Release();
pdoc = 0;
DropGraphics();
+ delete pixmapLine;
+ delete pixmapSelMargin;
+ delete pixmapSelPattern;
+ delete pixmapIndentGuide;
+ delete pixmapIndentGuideHighlight;
}
void Editor::Finalise() {
}
void Editor::DropGraphics() {
- pixmapLine.Release();
- pixmapSelMargin.Release();
- pixmapSelPattern.Release();
- pixmapIndentGuide.Release();
+ pixmapLine->Release();
+ pixmapSelMargin->Release();
+ pixmapSelPattern->Release();
+ pixmapIndentGuide->Release();
}
void Editor::InvalidateStyleData() {
stylesValid = false;
palette.Release();
DropGraphics();
+ llc.Invalidate(LineLayout::llInvalid);
}
void Editor::InvalidateStyleRedraw() {
void Editor::RefreshStyleData() {
if (!stylesValid) {
stylesValid = true;
- Surface surface;
- surface.Init();
- vs.Refresh(surface);
- RefreshColourPalette(palette, true);
- palette.Allocate(wMain);
- RefreshColourPalette(palette, false);
+ AutoSurface surface(IsUnicodeMode());
+ if (surface) {
+ vs.Refresh(*surface);
+ RefreshColourPalette(palette, true);
+ palette.Allocate(wMain);
+ RefreshColourPalette(palette, false);
+ }
SetScrollBars();
}
}
int line = pdoc->LineFromPosition(pos);
int lineVisible = cs.DisplayFromDoc(line);
//Platform::DebugPrintf("line=%d\n", line);
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- pt.y = (lineVisible - topLine) * vs.lineHeight; // + half a lineheight?
- unsigned int posLineStart = pdoc->LineStart(line);
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- if ((pos - posLineStart) > LineLayout::maxLineLength) {
- // very long line so put x at arbitrary large position
- pt.x = ll.positions[LineLayout::maxLineLength] + vs.fixedColumnWidth - xOffset;
- } else {
- pt.x = ll.positions[pos - posLineStart] + vs.fixedColumnWidth - xOffset;
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(line);
+ if (surface && ll) {
+ // -1 because of adding in for visible lines in following loop.
+ pt.y = (lineVisible - topLine - 1) * vs.lineHeight;
+ pt.x = 0;
+ unsigned int posLineStart = pdoc->LineStart(line);
+ LayoutLine(line, surface, vs, ll, wrapWidth);
+ int posInLine = pos - posLineStart;
+ // In case of very long line put x at arbitrary large position
+ if (posInLine > ll->maxLineLength) {
+ pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)];
+ }
+ for (int subLine=0; subLine<ll->lines; subLine++) {
+ if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine+1))) {
+ pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)];
+ }
+ if (posInLine >= ll->LineStart(subLine)) {
+ pt.y += vs.lineHeight;
+ }
+ }
+ pt.x += vs.fixedColumnWidth - xOffset;
}
+ llc.Dispose(ll);
return pt;
}
int Editor::PositionFromLocation(Point pt) {
RefreshStyleData();
pt.x = pt.x - vs.fixedColumnWidth + xOffset;
- int line = cs.DocFromDisplay(pt.y / vs.lineHeight + topLine);
+ int visibleLine = pt.y / vs.lineHeight + topLine;
if (pt.y < 0) { // Division rounds towards 0
- line = cs.DocFromDisplay((pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine);
+ visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine;
}
- if (line < 0)
- return 0;
- if (line >= pdoc->LinesTotal())
+ if (visibleLine < 0)
+ visibleLine = 0;
+ int lineDoc = cs.DocFromDisplay(visibleLine);
+ if (lineDoc >= pdoc->LinesTotal())
return pdoc->Length();
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- unsigned int posLineStart = pdoc->LineStart(line);
-
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- for (int i = 0; i < ll.numCharsInLine; i++) {
- if (pt.x < ((ll.positions[i] + ll.positions[i + 1]) / 2) ||
- ll.chars[i] == '\r' || ll.chars[i] == '\n') {
- return i + posLineStart;
+ AutoSurface surface(IsUnicodeMode());
+ int retVal = 0;
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ int lineStartSet = cs.DisplayFromDoc(lineDoc);
+ int subLine = visibleLine - lineStartSet;
+ if (subLine < ll->lines) {
+ int lineStart = ll->LineStart(subLine);
+ int lineEnd = ll->LineStart(subLine+1);
+ int subLineStart = ll->positions[lineStart];
+ for (int i = lineStart; i < lineEnd; i++) {
+ if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
+ ll->chars[i] == '\r' || ll->chars[i] == '\n') {
+ llc.Dispose(ll);
+ return pdoc->MovePositionOutsideChar(i + posLineStart, 1);
+ }
+ }
+ llc.Dispose(ll);
+ return lineEnd + posLineStart;
}
+ retVal = ll->numCharsInLine + posLineStart;
}
-
- return ll.numCharsInLine + posLineStart;
+ llc.Dispose(ll);
+ return retVal;
}
// Like PositionFromLocation but INVALID_POSITION returned when not near any text.
if (pt.y < 0)
return INVALID_POSITION;
pt.x = pt.x - vs.fixedColumnWidth + xOffset;
- int line = cs.DocFromDisplay(pt.y / vs.lineHeight + topLine);
+ int visibleLine = pt.y / vs.lineHeight + topLine;
if (pt.y < 0) { // Division rounds towards 0
- line = cs.DocFromDisplay((pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine);
+ visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine;
}
- if (line < 0)
+ int lineDoc = cs.DocFromDisplay(visibleLine);
+ if (lineDoc < 0)
return INVALID_POSITION;
- if (line >= pdoc->LinesTotal())
+ if (lineDoc >= pdoc->LinesTotal())
return INVALID_POSITION;
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- unsigned int posLineStart = pdoc->LineStart(line);
-
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- for (int i = 0; i < ll.numCharsInLine; i++) {
- if (pt.x < ((ll.positions[i] + ll.positions[i + 1]) / 2) ||
- ll.chars[i] == '\r' || ll.chars[i] == '\n') {
- return i + posLineStart;
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ int lineStartSet = cs.DisplayFromDoc(lineDoc);
+ int subLine = visibleLine - lineStartSet;
+ if (subLine < ll->lines) {
+ int lineStart = ll->LineStart(subLine);
+ int lineEnd = ll->LineStart(subLine+1);
+ int subLineStart = ll->positions[lineStart];
+ for (int i = lineStart; i < lineEnd; i++) {
+ if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
+ ll->chars[i] == '\r' || ll->chars[i] == '\n') {
+ llc.Dispose(ll);
+ return pdoc->MovePositionOutsideChar(i + posLineStart, 1);
+ }
+ }
}
}
+ llc.Dispose(ll);
return INVALID_POSITION;
}
-int Editor::PositionFromLineX(int line, int x) {
+// Find the document position corresponding to an x coordinate on a particular document line.
+// Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
+int Editor::PositionFromLineX(int lineDoc, int x) {
RefreshStyleData();
- if (line >= pdoc->LinesTotal())
+ if (lineDoc >= pdoc->LinesTotal())
return pdoc->Length();
//Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine);
- Surface surface;
- surface.Init();
- surface.SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- unsigned int posLineStart = pdoc->LineStart(line);
-
- LineLayout ll;
- LayoutLine(line, &surface, vs, ll);
- for (int i = 0; i < ll.numCharsInLine; i++) {
- if (x < ((ll.positions[i] + ll.positions[i + 1]) / 2) ||
- ll.chars[i] == '\r' || ll.chars[i] == '\n') {
- return i + posLineStart;
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ int retVal = 0;
+ if (surface && ll) {
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ retVal = ll->numCharsInLine + posLineStart;
+ int subLine = 0;
+ int lineStart = ll->LineStart(subLine);
+ int lineEnd = ll->LineStart(subLine+1);
+ int subLineStart = ll->positions[lineStart];
+ for (int i = lineStart; i < lineEnd; i++) {
+ if (x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
+ ll->chars[i] == '\r' || ll->chars[i] == '\n') {
+ retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1);
+ break;
+ }
}
}
-
- return ll.numCharsInLine + posLineStart;
+ llc.Dispose(ll);
+ return retVal;
}
void Editor::RedrawRect(PRectangle rc) {
if (maxPos < end)
maxPos = end;
int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(minPos));
- int maxLine = cs.DisplayFromDoc(pdoc->LineFromPosition(maxPos));
+ int lineDocMax = pdoc->LineFromPosition(maxPos);
+ int maxLine = cs.DisplayFromDoc(lineDocMax) + cs.GetHeight(lineDocMax) - 1;
PRectangle rcClient = GetTextRectangle();
PRectangle rc;
rc.left = vs.fixedColumnWidth;
int mask = pdoc->stylingBitsMask;
if (moveDir > 0) {
while ((pos < pdoc->Length()) &&
- (!vs.styles[pdoc->StyleAt(pos - 1) & mask].visible))
+ (vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected()))
pos++;
} else {
while ((pos > 0) &&
- (!vs.styles[pdoc->StyleAt(pos - 1) & mask].visible))
+ (vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected()))
pos--;
}
return pos;
} else {
int lineDisplay = cs.DisplayFromDoc(lineDoc);
if (moveDir > 0) {
- lineDisplay = Platform::Clamp(lineDisplay + 1, 0, cs.LinesDisplayed());
+ // lineDisplay is already line before fold as lines in fold use display line of line after fold
+ lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
return pdoc->LineStart(cs.DocFromDisplay(lineDisplay));
} else {
- // lineDisplay is already line before fold as lines in fold use display line of line before fold
- lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
- return pdoc->LineEndPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay)));
+ lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed());
+ return pdoc->LineEnd(cs.DocFromDisplay(lineDisplay));
}
}
}
void Editor::HorizontalScrollTo(int xPos) {
//Platform::DebugPrintf("HorizontalScroll %d\n", xPos);
- xOffset = xPos;
- if (xOffset < 0)
- xOffset = 0;
- SetHorizontalScrollPos();
- RedrawRect(GetClientRectangle());
+ if (xPos < 0)
+ xPos = 0;
+ if ((wrapState == eWrapNone) && (xOffset != xPos)) {
+ xOffset = xPos;
+ SetHorizontalScrollPos();
+ RedrawRect(GetClientRectangle());
+ }
}
void Editor::MoveCaretInsideView() {
}
}
+int Editor::DisplayFromPosition(int pos) {
+ int lineDoc = pdoc->LineFromPosition(pos);
+ int lineDisplay = cs.DisplayFromDoc(lineDoc);
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ unsigned int posLineStart = pdoc->LineStart(lineDoc);
+ int posInLine = pos - posLineStart;
+ lineDisplay--; // To make up for first increment ahead.
+ for (int subLine=0; subLine<ll->lines; subLine++) {
+ if (posInLine >= ll->LineStart(subLine)) {
+ lineDisplay++;
+ }
+ }
+ }
+ llc.Dispose(ll);
+ return lineDisplay;
+}
+
void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
//Platform::DebugPrintf("EnsureCaretVisible %d %s\n", xOffset, useMargin ? " margin" : " ");
PRectangle rcClient = GetTextRectangle();
Point pt = LocationFromPosition(posCaret);
Point ptEOL = LocationFromPosition(pdoc->LineEndPosition(posCaret));
Point ptBottomCaret = pt;
- int lineCaret = cs.DisplayFromDoc(pdoc->LineFromPosition(posCaret));
+ int lineCaret = DisplayFromPosition(posCaret);
ptBottomCaret.y += vs.lineHeight - 1;
// Ensure the caret is reasonably visible in context:
// If we scroll the display, we use a minimum amount of xMargin.
int offsetLeft = rcClient.left + xMargin;
int offsetRight = rcClient.right - xMargin;
- // If we are in XJUMPS mode, then when the margin is reached, the
+ // If we are in XJUMPS mode, then when the margin is reached, the
// offset jumps so that it won't need to move agin for a while.
if (!(caretPolicy & CARET_XJUMPS)) {
rcClient.left = offsetLeft;
}
// Horizontal positioning
- if (horiz) {
+ if (horiz && (wrapState == eWrapNone)) {
int xOffsetNew = xOffset;
if (pt.x < rcClient.left) {
xOffsetNew = xOffset - (offsetLeft - pt.x);
}
void Editor::ShowCaretAtCurrentPosition() {
- if (!hasFocus) {
+ if (hasFocus) {
+ caret.active = true;
+ caret.on = true;
+ SetTicking(true);
+ } else {
caret.active = false;
caret.on = false;
- return;
}
- caret.active = true;
- caret.on = true;
- SetTicking(true);
+ InvalidateCaret();
}
void Editor::DropCaret() {
InvalidateRange(currentPos, currentPos + 1);
}
+void Editor::NeedWrapping(int docLineStartWrapping) {
+ docLineLastWrapped = docLineStartWrapping - 1;
+ if (docLineLastWrapped < -1)
+ docLineLastWrapped = -1;
+ llc.Invalidate(LineLayout::llPositions);
+}
+
+// Check if wrapping needed and perform any needed wrapping.
+// Return true if wrapping occurred.
+bool Editor::WrapLines() {
+ int goodTopLine = topLine;
+ bool wrapOccurred = false;
+ if (docLineLastWrapped < pdoc->LinesTotal()) {
+ if (wrapState == eWrapNone) {
+ if (wrapWidth != LineLayout::wrapWidthInfinite) {
+ wrapWidth = LineLayout::wrapWidthInfinite;
+ for (int lineDoc=0; lineDoc<pdoc->LinesTotal(); lineDoc++) {
+ cs.SetHeight(lineDoc, 1);
+ }
+ wrapOccurred = true;
+ }
+ docLineLastWrapped = 0x7ffffff;
+ } else {
+ ElapsedTime et;
+ int lineDocTop = cs.DocFromDisplay(topLine);
+ int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);
+ PRectangle rcTextArea = GetClientRectangle();
+ rcTextArea.left = vs.fixedColumnWidth;
+ rcTextArea.right -= vs.rightMarginWidth;
+ wrapWidth = rcTextArea.Width();
+ // Ensure all of the document is styled.
+ pdoc->EnsureStyledTo(pdoc->Length());
+ AutoSurface surface(IsUnicodeMode());
+ if (surface) {
+ int lastLineToWrap = pdoc->LinesTotal();
+ while (docLineLastWrapped <= lastLineToWrap) {
+ docLineLastWrapped++;
+ LineLayout *ll = RetrieveLineLayout(docLineLastWrapped);
+ int linesWrapped = 1;
+ if (ll) {
+ LayoutLine(docLineLastWrapped, surface, vs, ll, wrapWidth);
+ linesWrapped = ll->lines;
+ }
+ llc.Dispose(ll);
+ if (cs.SetHeight(docLineLastWrapped, linesWrapped)) {
+ wrapOccurred = true;
+ }
+ }
+ }
+ goodTopLine = cs.DisplayFromDoc(lineDocTop);
+ if (subLineTop < cs.GetHeight(lineDocTop))
+ goodTopLine += subLineTop;
+ else
+ goodTopLine += cs.GetHeight(lineDocTop);
+ double durWrap = et.Duration(true);
+ Platform::DebugPrintf("Wrap:%9.6g \n", durWrap);
+ }
+ }
+ if (wrapOccurred) {
+ SetScrollBars();
+ SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos()));
+ SetVerticalScrollPos();
+ }
+ return wrapOccurred;
+}
+
int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) {
if (vs.markers[markerCheck].markType == SC_MARK_EMPTY)
return markerDefault;
Surface *surface;
if (bufferedDraw) {
- surface = &pixmapSelMargin;
+ surface = pixmapSelMargin;
} else {
surface = surfWindow;
}
*/
if (vs.ms[margin].mask & SC_MASK_FOLDERS)
// Required because of special way brush is created for selection margin
- surface->FillRectangle(rcSelMargin, pixmapSelPattern);
+ surface->FillRectangle(rcSelMargin, *pixmapSelPattern);
else
surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated);
} else {
}
int visibleLine = topLine;
- int line = cs.DocFromDisplay(visibleLine);
int yposScreen = 0;
- // Work out whether the top line is whitespace located after a
+ // Work out whether the top line is whitespace located after a
// lessening of fold level which implies a 'fold tail' but which should not
// be displayed until the last of a sequence of whitespace.
- bool needWhiteClosure = false;
- int level = pdoc->GetLevel(line);
+ bool needWhiteClosure = false;
+ int level = pdoc->GetLevel(cs.DocFromDisplay(topLine));
if (level & SC_FOLDLEVELWHITEFLAG) {
- int lineBack = line;
+ int lineBack = cs.DocFromDisplay(topLine);
int levelPrev = level;
while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) {
lineBack--;
needWhiteClosure = true;
}
}
-
+
// Old code does not know about new markers needed to distinguish all cases
- int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
+ int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
SC_MARKNUM_FOLDEROPEN);
- int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
+ int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
SC_MARKNUM_FOLDER);
-
+
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
+ PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed());
+
+ int lineDoc = cs.DocFromDisplay(visibleLine);
+ PLATFORM_ASSERT(cs.GetVisible(lineDoc));
+ bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc);
+
// Decide which fold indicator should be displayed
- level = pdoc->GetLevel(line);
- int levelNext = pdoc->GetLevel(line+1);
- int marks = pdoc->GetMark(line);
+ level = pdoc->GetLevel(lineDoc);
+ int levelNext = pdoc->GetLevel(lineDoc+1);
+ int marks = pdoc->GetMark(lineDoc);
+ if (!firstSubLine)
+ marks = 0;
int levelNum = level & SC_FOLDLEVELNUMBERMASK;
int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK;
if (level & SC_FOLDLEVELHEADERFLAG) {
- if (cs.GetExpanded(line)) {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDEROPEN;
- else
- marks |= 1 << folderOpenMid;
+ if (firstSubLine) {
+ if (cs.GetExpanded(lineDoc)) {
+ if (levelNum == SC_FOLDLEVELBASE)
+ marks |= 1 << SC_MARKNUM_FOLDEROPEN;
+ else
+ marks |= 1 << folderOpenMid;
+ } else {
+ if (levelNum == SC_FOLDLEVELBASE)
+ marks |= 1 << SC_MARKNUM_FOLDER;
+ else
+ marks |= 1 << folderEnd;
+ }
} else {
- if (levelNum == SC_FOLDLEVELBASE)
- marks |= 1 << SC_MARKNUM_FOLDER;
- else
- marks |= 1 << folderEnd;
+ marks |= 1 << SC_MARKNUM_FOLDERSUB;
}
needWhiteClosure = false;
} else if (level & SC_FOLDLEVELWHITEFLAG) {
if (!vs.ms[margin].symbol) {
char number[100];
number[0] = '\0';
- sprintf(number, "%d", line + 1);
+ if (firstSubLine)
+ sprintf(number, "%d", lineDoc + 1);
if (foldFlags & 64)
- sprintf(number, "%X", pdoc->GetLevel(line));
+ sprintf(number, "%X", pdoc->GetLevel(lineDoc));
PRectangle rcNumber = rcMarker;
// Right justify
int width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, strlen(number));
int xpos = rcNumber.right - width - 3;
rcNumber.left = xpos;
- if ((visibleLine < cs.LinesDisplayed()) && cs.GetVisible(line)) {
- surface->DrawText(rcNumber, vs.styles[STYLE_LINENUMBER].font,
- rcNumber.top + vs.maxAscent, number, strlen(number),
- vs.styles[STYLE_LINENUMBER].fore.allocated,
- vs.styles[STYLE_LINENUMBER].back.allocated);
- }
+ surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
+ rcNumber.top + vs.maxAscent, number, strlen(number),
+ vs.styles[STYLE_LINENUMBER].fore.allocated,
+ vs.styles[STYLE_LINENUMBER].back.allocated);
}
if (marks) {
}
visibleLine++;
- line = cs.DocFromDisplay(visibleLine);
yposScreen += vs.lineHeight;
}
}
surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back.allocated);
if (bufferedDraw) {
- surfWindow->Copy(rcMargin, Point(), pixmapSelMargin);
+ surfWindow->Copy(rcMargin, Point(), *pixmapSelMargin);
}
}
void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {
int ydiff = (rcTab.bottom - rcTab.top) / 2;
int xhead = rcTab.right - 1 - ydiff;
+ if (xhead <= rcTab.left) {
+ ydiff -= rcTab.left - xhead - 1;
+ xhead = rcTab.left - 1;
+ }
if ((rcTab.left + 2) < (rcTab.right - 1))
surface->MoveTo(rcTab.left + 2, ymid);
else
surface->LineTo(xhead, ymid + ydiff);
}
+static bool IsSpaceOrTab(char ch) {
+ return ch == ' ' || ch == '\t';
+}
+
+LineLayout *Editor::RetrieveLineLayout(int lineNumber) {
+ int posLineStart = pdoc->LineStart(lineNumber);
+ int posLineEnd = pdoc->LineStart(lineNumber + 1);
+ int lineCaret = pdoc->LineFromPosition(currentPos);
+ return llc.Retrieve(lineNumber, lineCaret,
+ posLineEnd - posLineStart, pdoc->GetStyleClock(),
+ LinesOnScreen() + 1, pdoc->LinesTotal());
+}
+
/**
* Fill in the LineLayout data for the given line.
* Copy the given @a line and its styles from the document into local arrays.
* Also determine the x position at which each character starts.
*/
-void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll) {
- int numCharsInLine = 0;
+void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) {
+ if (!ll)
+ return;
int posLineStart = pdoc->LineStart(line);
- int posLineEnd = pdoc->LineStart(line + 1);
- Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;
- char styleByte = 0;
- int styleMask = pdoc->stylingBitsMask;
- ll.xHighlightGuide = 0;
- // If the line is very long, limit the treatment to a length that should fit in the viewport
- if (posLineEnd > (posLineStart + LineLayout::maxLineLength)) {
- posLineEnd = posLineStart + LineLayout::maxLineLength;
- }
- // Fill base line layout
- for (int charInDoc = posLineStart; charInDoc < posLineEnd; charInDoc++) {
- char chDoc = pdoc->CharAt(charInDoc);
- styleByte = pdoc->StyleAt(charInDoc);
- if (vstyle.viewEOL || ((chDoc != '\r') && (chDoc != '\n'))) {
- ll.chars[numCharsInLine] = chDoc;
- ll.styles[numCharsInLine] = static_cast<char>(styleByte & styleMask);
- ll.indicators[numCharsInLine] = static_cast<char>(styleByte & ~styleMask);
- if (vstyle.styles[ll.styles[numCharsInLine]].caseForce == Style::caseUpper)
- ll.chars[numCharsInLine] = static_cast<char>(toupper(chDoc));
- else if (vstyle.styles[ll.styles[numCharsInLine]].caseForce == Style::caseLower)
- ll.chars[numCharsInLine] = static_cast<char>(tolower(chDoc));
- numCharsInLine++;
- }
- }
- // Extra element at the end of the line to hold end x position and act as
- ll.chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character
- ll.styles[numCharsInLine] = styleByte; // For eolFilled
- ll.indicators[numCharsInLine] = 0;
-
- // Layout the line, determining the position of each character,
- // with an extra element at the end for the end of the line.
- int startseg = 0; // Start of the current segment, in char. number
- int startsegx = 0; // Start of the current segment, in pixels
- ll.positions[0] = 0;
- unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
- bool lastSegItalics = false;
-
- for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
- if ((ll.styles[charInLine] != ll.styles[charInLine + 1]) ||
- IsControlCharacter(ll.chars[charInLine]) || IsControlCharacter(ll.chars[charInLine + 1])) {
- ll.positions[startseg] = 0;
- if (vstyle.styles[ll.styles[charInLine]].visible) {
- if (IsControlCharacter(ll.chars[charInLine])) {
- if (ll.chars[charInLine] == '\t') {
- ll.positions[charInLine + 1] = ((((startsegx + 2) /
- tabWidth) + 1) * tabWidth) - startsegx;
- } else {
- const char *ctrlChar = ControlCharacterString(ll.chars[charInLine]);
- // +3 For a blank on front and rounded edge each side:
- ll.positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, ctrlChar, strlen(ctrlChar)) + 3;
+ if (ll->validity == LineLayout::llInvalid) {
+ ll->widthLine = LineLayout::wrapWidthInfinite;
+ ll->lines = 1;
+ int numCharsInLine = 0;
+ if (vstyle.edgeState == EDGE_BACKGROUND) {
+ ll->edgeColumn = pdoc->FindColumn(line, theEdge);
+ if (ll->edgeColumn >= posLineStart) {
+ ll->edgeColumn -= posLineStart;
+ }
+ } else {
+ ll->edgeColumn = -1;
+ }
+
+ int posLineEnd = pdoc->LineStart(line + 1);
+ Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font;
+ char styleByte = 0;
+ int styleMask = pdoc->stylingBitsMask;
+ ll->xHighlightGuide = 0;
+ // If the line is very long, limit the treatment to a length that should fit in the viewport
+ if (posLineEnd > (posLineStart + ll->maxLineLength)) {
+ posLineEnd = posLineStart + ll->maxLineLength;
+ }
+ // Fill base line layout
+ for (int charInDoc = posLineStart; charInDoc < posLineEnd; charInDoc++) {
+ char chDoc = pdoc->CharAt(charInDoc);
+ styleByte = pdoc->StyleAt(charInDoc);
+ if (vstyle.viewEOL || ((chDoc != '\r') && (chDoc != '\n'))) {
+ ll->chars[numCharsInLine] = chDoc;
+ ll->styles[numCharsInLine] = static_cast<char>(styleByte & styleMask);
+ ll->indicators[numCharsInLine] = static_cast<char>(styleByte & ~styleMask);
+ if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper)
+ ll->chars[numCharsInLine] = static_cast<char>(toupper(chDoc));
+ else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower)
+ ll->chars[numCharsInLine] = static_cast<char>(tolower(chDoc));
+ numCharsInLine++;
+ }
+ }
+ // Extra element at the end of the line to hold end x position and act as
+ ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character
+ ll->styles[numCharsInLine] = styleByte; // For eolFilled
+ ll->indicators[numCharsInLine] = 0;
+
+ // Layout the line, determining the position of each character,
+ // with an extra element at the end for the end of the line.
+ int startseg = 0; // Start of the current segment, in char. number
+ int startsegx = 0; // Start of the current segment, in pixels
+ ll->positions[0] = 0;
+ unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
+ bool lastSegItalics = false;
+
+ for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
+ if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) ||
+ IsControlCharacter(ll->chars[charInLine]) || IsControlCharacter(ll->chars[charInLine + 1])) {
+ ll->positions[startseg] = 0;
+ if (vstyle.styles[ll->styles[charInLine]].visible) {
+ if (IsControlCharacter(ll->chars[charInLine])) {
+ if (ll->chars[charInLine] == '\t') {
+ ll->positions[charInLine + 1] = ((((startsegx + 2) /
+ tabWidth) + 1) * tabWidth) - startsegx;
+ } else if (controlCharSymbol < 32) {
+ const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
+ // +3 For a blank on front and rounded edge each side:
+ ll->positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, ctrlChar, strlen(ctrlChar)) + 3;
+ } else {
+ char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
+ surface->MeasureWidths(ctrlCharsFont, cc, 1,
+ ll->positions + startseg + 1);
+ }
+ lastSegItalics = false;
+ } else { // Regular character
+ lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic;
+ int lenSeg = charInLine - startseg + 1;
+ if ((lenSeg == 1) && (' ' == ll->chars[startseg])) {
+ // Over half the segments are single characters and of these about half are space characters.
+ ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth;
+ } else {
+ surface->MeasureWidths(vstyle.styles[ll->styles[charInLine]].font, ll->chars + startseg,
+ lenSeg, ll->positions + startseg + 1);
+ }
}
- lastSegItalics = false;
- } else { // Regular character
- lastSegItalics = vstyle.styles[ll.styles[charInLine]].italic;
- int lenSeg = charInLine - startseg + 1;
- if ((lenSeg == 1) && (' ' == ll.chars[startseg])) {
- // Over half the segments are single characters and of these about half are space characters.
- ll.positions[charInLine + 1] = vstyle.styles[ll.styles[charInLine]].spaceWidth;
- } else {
- surface->MeasureWidths(vstyle.styles[ll.styles[charInLine]].font, ll.chars + startseg,
- lenSeg, ll.positions + startseg + 1);
+ } else { // invisible
+ for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) {
+ ll->positions[posToZero] = 0;
}
}
- } else { // invisible
- for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) {
- ll.positions[posToZero] = 0;
+ for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) {
+ ll->positions[posToIncrease] += startsegx;
}
+ startsegx = ll->positions[charInLine + 1];
+ startseg = charInLine + 1;
}
- for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) {
- ll.positions[posToIncrease] += startsegx;
- }
- startsegx = ll.positions[charInLine + 1];
- startseg = charInLine + 1;
}
+ // Small hack to make lines that end with italics not cut off the edge of the last character
+ if ((startseg > 0) && lastSegItalics) {
+ ll->positions[startseg] += 2;
+ }
+ ll->numCharsInLine = numCharsInLine;
+ ll->validity = LineLayout::llPositions;
+ }
+ // Hard to cope when too narrow, so just assume there is space
+ if (width < 20) {
+ width = 20;
}
- // Small hack to make lines that end with italics not cut off the edge of the last character
- if ((startseg > 0) && lastSegItalics) {
- ll.positions[startseg] += 2;
+ if ((ll->validity == LineLayout::llPositions) || (ll->widthLine != width)) {
+ ll->widthLine = width;
+ if (width == LineLayout::wrapWidthInfinite) {
+ ll->lines = 1;
+ } else {
+ ll->lines = 0;
+ // Calculate line start positions based upon width.
+ // For now this is simplistic - wraps on byte rather than character and
+ // in the middle of words. Should search for spaces or style changes.
+ int lastGoodBreak = 0;
+ int lastLineStart = 0;
+ int startOffset = 0;
+ int p=0;
+ while (p < ll->numCharsInLine) {
+ if ((ll->positions[p+1] - startOffset) >= width) {
+ if (lastGoodBreak == lastLineStart) {
+ // Try moving to start of last character
+ if (p > 0) {
+ lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
+ - posLineStart;
+ }
+ if (lastGoodBreak == lastLineStart) {
+ // Ensure at least one character on line.
+ lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart +1, 1)
+ - posLineStart;
+ }
+ }
+ lastLineStart = lastGoodBreak;
+ ll->lines++;
+ ll->SetLineStart(ll->lines, lastGoodBreak);
+ startOffset = ll->positions[lastGoodBreak];
+ p = lastGoodBreak + 1;
+ continue;
+ }
+ if (p > 0) {
+ if (ll->styles[p] != ll->styles[p-1]) {
+ lastGoodBreak = p;
+ } else if (IsSpaceOrTab(ll->chars[p-1]) && !IsSpaceOrTab(ll->chars[p])) {
+ lastGoodBreak = p;
+ }
+ }
+ p++;
+ }
+ ll->lines++;
+ }
+ ll->validity = LineLayout::llLines;
}
- ll.numCharsInLine = numCharsInLine;
}
void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
- PRectangle rcLine, LineLayout &ll) {
+ PRectangle rcLine, LineLayout *ll, int subLine) {
PRectangle rcSegment = rcLine;
// is taken by an individual character - internal leading gives varying results.
Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font;
+ // See if something overrides the line background color: Either if caret is on the line
+ // and background color is set for that, or if a marker is defined that forces its background
+ // color onto the line, or if a marker is defined but has no selection margin in which to
+ // display itself. These are checked in order with the earlier taking precedence. When
+ // multiple markers cause background override, the color for the highest numbered one is used.
bool overrideBackground = false;
- Colour background = Colour(0, 0, 0);
- if (caret.active && vsDraw.showCaretLineBackground && ll.containsCaret) {
+ ColourAllocated background;
+ if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) {
overrideBackground = true;
background = vsDraw.caretLineBackground.allocated;
}
- if (vsDraw.maskInLine) {
- int marks = pdoc->GetMark(line) & vsDraw.maskInLine;
- if (marks) {
- overrideBackground = true;
- for (int markBit = 0; (markBit < 32) && marks; markBit++) {
- if (marks & 1) {
- background = vsDraw.markers[markBit].back.allocated;
+ if (!overrideBackground) {
+ int marks = pdoc->GetMark(line);
+ for (int markBit = 0; (markBit < 32) && marks; markBit++) {
+ if ((marks & 1) && vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) {
+ background = vsDraw.markers[markBit].back.allocated;
+ overrideBackground = true;
+ }
+ marks >>= 1;
+ }
+ }
+ if (!overrideBackground) {
+ if (vsDraw.maskInLine) {
+ int marks = pdoc->GetMark(line) & vsDraw.maskInLine;
+ if (marks) {
+ overrideBackground = true;
+ for (int markBit = 0; (markBit < 32) && marks; markBit++) {
+ if (marks & 1) {
+ background = vsDraw.markers[markBit].back.allocated;
+ }
+ marks >>= 1;
}
- marks >>= 1;
}
}
}
- bool inIndentation = true;
+ bool inIndentation = subLine == 0; // Do not handle indentation except on first subline.
int indentWidth = pdoc->indentInChars * vsDraw.spaceWidth;
if (indentWidth == 0)
indentWidth = pdoc->tabInChars * vsDraw.spaceWidth;
int posLineEnd = pdoc->LineStart(line + 1);
int styleMask = pdoc->stylingBitsMask;
- int startseg = 0;
- for (int i = 0; i < ll.numCharsInLine; i++) {
+ int startseg = ll->LineStart(subLine);
+ int subLineStart = ll->positions[startseg];
+ int lineStart = 0;
+ int lineEnd = 0;
+ if (subLine < ll->lines) {
+ lineStart = ll->LineStart(subLine);
+ lineEnd = ll->LineStart(subLine+1);
+ }
+ for (int i = lineStart; i < lineEnd; i++) {
int iDoc = i + posLineStart;
// If there is the end of a style run for any reason
- if ((ll.styles[i] != ll.styles[i + 1]) ||
- IsControlCharacter(ll.chars[i]) || IsControlCharacter(ll.chars[i + 1]) ||
- ((ll.selStart != ll.selEnd) && ((iDoc + 1 == ll.selStart) || (iDoc + 1 == ll.selEnd))) ||
- (i == (ll.edgeColumn - 1))) {
- int styleMain = ll.styles[i];
- Colour textBack = vsDraw.styles[styleMain].back.allocated;
- Colour textFore = vsDraw.styles[styleMain].fore.allocated;
- Font &textFont = vsDraw.styles[styleMain].font;
- bool inSelection = (iDoc >= ll.selStart) && (iDoc < ll.selEnd) && (ll.selStart != ll.selEnd);
- if (inSelection) {
- if (vsDraw.selbackset) {
- if (primarySelection)
- textBack = vsDraw.selbackground.allocated;
- else
- textBack = vsDraw.selbackground2.allocated;
- }
- if (vsDraw.selforeset)
- textFore = vsDraw.selforeground.allocated;
- } else {
- if (overrideBackground)
- textBack = background;
- if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll.edgeColumn) && (ll.chars[i] != '\n') && (ll.chars[i] != '\r'))
- textBack = vsDraw.edgecolour.allocated;
- }
- // Manage tab display
- if (ll.chars[i] == '\t') {
- rcSegment.left = ll.positions[i] + xStart;
- rcSegment.right = ll.positions[i + 1] + xStart;
- surface->FillRectangle(rcSegment, textBack);
- if ((vsDraw.viewWhitespace != wsInvisible) || ((inIndentation && vsDraw.viewIndentationGuides))) {
- surface->PenColour(textFore);
+ if ((ll->styles[i] != ll->styles[i + 1]) ||
+ i == (lineEnd-1) ||
+ IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) ||
+ ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) ||
+ (i == (ll->edgeColumn - 1))) {
+ rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
+ rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+ // Only try to draw if really visible - enhances performance by not calling environment to
+ // draw strings that are completely past the right side of the window.
+ //if (rcSegment.left <= rcLine.right) {
+ if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+ int styleMain = ll->styles[i];
+ ColourAllocated textBack = vsDraw.styles[styleMain].back.allocated;
+ ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+ Font &textFont = vsDraw.styles[styleMain].font;
+ bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
+ if (inSelection) {
+ if (vsDraw.selbackset) {
+ if (primarySelection)
+ textBack = vsDraw.selbackground.allocated;
+ else
+ textBack = vsDraw.selbackground2.allocated;
+ }
+ if (vsDraw.selforeset)
+ textFore = vsDraw.selforeground.allocated;
+ } else {
+ if (overrideBackground)
+ textBack = background;
+ if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll->edgeColumn) && (ll->chars[i] != '\n') && (ll->chars[i] != '\r'))
+ textBack = vsDraw.edgecolour.allocated;
}
- if (inIndentation && vsDraw.viewIndentationGuides) {
- for (int xIG = ll.positions[i] / indentWidth * indentWidth; xIG < ll.positions[i + 1]; xIG += indentWidth) {
- if (xIG >= ll.positions[i] && xIG > 0) {
- Point from(0, ((lineVisible & 1) && (vsDraw.lineHeight & 1)) ? 1 : 0);
- PRectangle rcCopyArea(xIG + xStart + 1, rcSegment.top, xIG + xStart + 2, rcSegment.bottom);
- surface->Copy(rcCopyArea, from, (ll.xHighlightGuide == xIG) ?
- pixmapIndentGuideHighlight : pixmapIndentGuide);
+ if (ll->chars[i] == '\t') {
+ // Manage tab display
+ surface->FillRectangle(rcSegment, textBack);
+ if ((vsDraw.viewWhitespace != wsInvisible) || ((inIndentation && vsDraw.viewIndentationGuides))) {
+ surface->PenColour(textFore);
+ }
+ if (inIndentation && vsDraw.viewIndentationGuides) {
+ for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) {
+ if (xIG >= ll->positions[i] && xIG > 0) {
+ Point from(0, ((lineVisible & 1) && (vsDraw.lineHeight & 1)) ? 1 : 0);
+ PRectangle rcCopyArea(xIG + xStart + 1, rcSegment.top, xIG + xStart + 2, rcSegment.bottom);
+ surface->Copy(rcCopyArea, from, (ll->xHighlightGuide == xIG) ?
+ *pixmapIndentGuideHighlight : *pixmapIndentGuide);
+ }
}
}
- }
- if (vsDraw.viewWhitespace != wsInvisible) {
- if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
- rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
- DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ if (vsDraw.viewWhitespace != wsInvisible) {
+ if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+ PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
+ rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
+ DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ }
}
- }
- // Manage control character display
- }
- else if (IsControlCharacter(ll.chars[i])) {
- inIndentation = false;
- const char *ctrlChar = ControlCharacterString(ll.chars[i]);
- rcSegment.left = ll.positions[i] + xStart;
- rcSegment.right = ll.positions[i + 1] + xStart;
- surface->FillRectangle(rcSegment, textBack);
- int normalCharHeight = surface->Ascent(ctrlCharsFont) -
- surface->InternalLeading(ctrlCharsFont);
- PRectangle rcCChar = rcSegment;
- rcCChar.left = rcCChar.left + 1;
- rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
- rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1;
- PRectangle rcCentral = rcCChar;
- rcCentral.top++;
- rcCentral.bottom--;
- surface->FillRectangle(rcCentral, textFore);
- PRectangle rcChar = rcCChar;
- rcChar.left++;
- rcChar.right--;
- surface->DrawTextClipped(rcChar, ctrlCharsFont,
- rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar),
- textBack, textFore);
- // Manage normal display
- }
- else {
- rcSegment.left = ll.positions[startseg] + xStart;
- rcSegment.right = ll.positions[i + 1] + xStart;
- // Only try to draw if really visible - enhances performance by not calling environment to
- // draw strings that are completely past the right side of the window.
- if (rcSegment.left <= rcLine.right) {
- surface->DrawText(rcSegment, textFont,
- rcSegment.top + vsDraw.maxAscent, ll.chars + startseg,
+ } else if (IsControlCharacter(ll->chars[i])) {
+ // Manage control character display
+ inIndentation = false;
+ if (controlCharSymbol < 32) {
+ // Draw the character
+ const char *ctrlChar = ControlCharacterString(ll->chars[i]);
+ surface->FillRectangle(rcSegment, textBack);
+ int normalCharHeight = surface->Ascent(ctrlCharsFont) -
+ surface->InternalLeading(ctrlCharsFont);
+ PRectangle rcCChar = rcSegment;
+ rcCChar.left = rcCChar.left + 1;
+ rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
+ rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1;
+ PRectangle rcCentral = rcCChar;
+ rcCentral.top++;
+ rcCentral.bottom--;
+ surface->FillRectangle(rcCentral, textFore);
+ PRectangle rcChar = rcCChar;
+ rcChar.left++;
+ rcChar.right--;
+ surface->DrawTextClipped(rcChar, ctrlCharsFont,
+ rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar),
+ textBack, textFore);
+ } else {
+ char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
+ surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
+ rcSegment.top + vsDraw.maxAscent,
+ cc, 1, textBack, textFore);
+ }
+ } else {
+ // Manage normal display
+ surface->DrawTextNoClip(rcSegment, textFont,
+ rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
i - startseg + 1, textFore, textBack);
if (vsDraw.viewWhitespace != wsInvisible ||
(inIndentation && vsDraw.viewIndentationGuides)) {
for (int cpos = 0; cpos <= i - startseg; cpos++) {
- if (ll.chars[cpos + startseg] == ' ') {
+ if (ll->chars[cpos + startseg] == ' ') {
if (vsDraw.viewWhitespace != wsInvisible) {
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- int xmid = (ll.positions[cpos + startseg] + ll.positions[cpos + startseg + 1]) / 2;
- PRectangle rcDot(xmid + xStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
+ int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
+ PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
rcDot.right = rcDot.left + 1;
rcDot.bottom = rcDot.top + 1;
surface->FillRectangle(rcDot, textFore);
}
}
if (inIndentation && vsDraw.viewIndentationGuides) {
- int startSpace = ll.positions[cpos + startseg];
+ int startSpace = ll->positions[cpos + startseg];
if (startSpace > 0 && (startSpace % indentWidth == 0)) {
Point from(0, ((lineVisible & 1) && (vsDraw.lineHeight & 1)) ? 1 : 0);
PRectangle rcCopyArea(startSpace + xStart + 1, rcSegment.top, startSpace + xStart + 2, rcSegment.bottom);
- surface->Copy(rcCopyArea, from, (ll.xHighlightGuide == ll.positions[cpos + startseg]) ?
- pixmapIndentGuideHighlight : pixmapIndentGuide);
+ surface->Copy(rcCopyArea, from, (ll->xHighlightGuide == ll->positions[cpos + startseg]) ?
+ *pixmapIndentGuideHighlight : *pixmapIndentGuide);
}
}
} else {
for (int indica = 0; indica <= INDIC_MAX; indica++)
indStart[indica] = 0;
- for (int indicPos = 0; indicPos < ll.numCharsInLine; indicPos++) {
- if (ll.indicators[indicPos] != ll.indicators[indicPos + 1]) {
+ for (int indicPos = 0; indicPos < ll->numCharsInLine; indicPos++) {
+ if (ll->indicators[indicPos] != ll->indicators[indicPos + 1]) {
int mask = 1 << pdoc->stylingBits;
for (int indicnum = 0; mask < 0x100; indicnum++) {
- if ((ll.indicators[indicPos + 1] & mask) && !(ll.indicators[indicPos] & mask)) {
- indStart[indicnum] = ll.positions[indicPos + 1];
+ if ((ll->indicators[indicPos + 1] & mask) && !(ll->indicators[indicPos] & mask)) {
+ indStart[indicnum] = ll->positions[indicPos + 1];
}
- if (!(ll.indicators[indicPos + 1] & mask) && (ll.indicators[indicPos] & mask)) {
+ if (!(ll->indicators[indicPos + 1] & mask) && (ll->indicators[indicPos] & mask)) {
PRectangle rcIndic(
indStart[indicnum] + xStart,
rcLine.top + vsDraw.maxAscent,
- ll.positions[indicPos + 1] + xStart,
+ ll->positions[indicPos + 1] + xStart,
rcLine.top + vsDraw.maxAscent + 3);
vsDraw.indicators[indicnum].Draw(surface, rcIndic);
}
// End of the drawing of the current line
// Fill in a PRectangle representing the end of line characters
- int xEol = ll.positions[ll.numCharsInLine];
+ int xEol = ll->positions[lineEnd] - subLineStart;
rcSegment.left = xEol + xStart;
rcSegment.right = xEol + vsDraw.aveCharWidth + xStart;
- bool eolInSelection = (posLineEnd > ll.selStart) && (posLineEnd <= ll.selEnd) && (ll.selStart != ll.selEnd);
+ bool eolInSelection = (subLine == (ll->lines-1)) &&
+ (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd);
if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
if (primarySelection)
surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated);
} else if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
} else {
- surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
}
rcSegment.left = xEol + vsDraw.aveCharWidth + xStart;
rcSegment.right = rcLine.right;
if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
- } else if (vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].eolFilled) {
- surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated);
+ } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
+ surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
} else {
surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
}
if (vsDraw.edgeState == EDGE_LINE) {
- int edgeX = ll.edgeColumn * vsDraw.spaceWidth;
+ int edgeX = theEdge * vsDraw.spaceWidth;
rcSegment.left = edgeX + xStart;
rcSegment.right = rcSegment.left + 1;
surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n",
// rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
- if (!pixmapSelPattern.Initialised()) {
- pixmapSelPattern.InitPixMap(8, 8, surfaceWindow);
+ if (WrapLines()) {
+ // The wrapping process has changed the height of some lines so abandon this
+ // paint for a complete repaint.
+ paintState = paintAbandoned;
+ return;
+ }
+
+ if (!pixmapSelPattern->Initialised()) {
+ pixmapSelPattern->InitPixMap(8, 8, surfaceWindow);
// This complex procedure is to reproduce the checker board dithered pattern used by windows
// for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half
// way between the chrome colour and the chrome highlight colour making a nice transition
// between the window chrome and the content area. And it works in low colour depths.
PRectangle rcPattern(0, 0, 8, 8);
- if (vs.selbarlight.desired == Colour(0xff, 0xff, 0xff)) {
- pixmapSelPattern.FillRectangle(rcPattern, vs.selbar.allocated);
- pixmapSelPattern.PenColour(vs.selbarlight.allocated);
+ if (vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff)) {
+ pixmapSelPattern->FillRectangle(rcPattern, vs.selbar.allocated);
+ pixmapSelPattern->PenColour(vs.selbarlight.allocated);
for (int stripe = 0; stripe < 8; stripe++) {
- pixmapSelPattern.MoveTo(0, stripe * 2);
- pixmapSelPattern.LineTo(8, stripe * 2 - 8);
+ pixmapSelPattern->MoveTo(0, stripe * 2);
+ pixmapSelPattern->LineTo(8, stripe * 2 - 8);
}
} else {
// User has chosen an unusual chrome colour scheme so just use the highlight edge colour.
- pixmapSelPattern.FillRectangle(rcPattern, vs.selbarlight.allocated);
+ pixmapSelPattern->FillRectangle(rcPattern, vs.selbarlight.allocated);
}
}
- if (!pixmapIndentGuide.Initialised()) {
+ if (!pixmapIndentGuide->Initialised()) {
// 1 extra pixel in height so can handle odd/even positions and so produce a continuous line
- pixmapIndentGuide.InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
- pixmapIndentGuideHighlight.InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
+ pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
+ pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow);
PRectangle rcIG(0, 0, 1, vs.lineHeight);
- pixmapIndentGuide.FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back.allocated);
- pixmapIndentGuide.PenColour(vs.styles[STYLE_INDENTGUIDE].fore.allocated);
- pixmapIndentGuideHighlight.FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated);
- pixmapIndentGuideHighlight.PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated);
+ pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back.allocated);
+ pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore.allocated);
+ pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated);
+ pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated);
for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) {
- pixmapIndentGuide.MoveTo(0, stripe);
- pixmapIndentGuide.LineTo(2, stripe);
- pixmapIndentGuideHighlight.MoveTo(0, stripe);
- pixmapIndentGuideHighlight.LineTo(2, stripe);
+ pixmapIndentGuide->MoveTo(0, stripe);
+ pixmapIndentGuide->LineTo(2, stripe);
+ pixmapIndentGuideHighlight->MoveTo(0, stripe);
+ pixmapIndentGuideHighlight->LineTo(2, stripe);
}
}
if (bufferedDraw) {
- if (!pixmapLine.Initialised()) {
- pixmapLine.InitPixMap(rcClient.Width(), rcClient.Height(),
+ if (!pixmapLine->Initialised()) {
+ pixmapLine->InitPixMap(rcClient.Width(), rcClient.Height(),
surfaceWindow);
- pixmapSelMargin.InitPixMap(vs.fixedColumnWidth,
+ pixmapSelMargin->InitPixMap(vs.fixedColumnWidth,
rcClient.Height(), surfaceWindow);
}
}
surfaceWindow->SetPalette(&palette, true);
- pixmapLine.SetPalette(&palette, !hasFocus);
+ pixmapLine->SetPalette(&palette, !hasFocus);
//Platform::DebugPrintf("Paint: (%3d,%3d) ... (%3d,%3d)\n",
// rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
// Ensure we are styled as far as we are painting.
pdoc->EnsureStyledTo(endPosPaint);
-
+ bool paintAbandonedByStyling = paintState == paintAbandoned;
if (needUpdateUI) {
NotifyUpdateUI();
needUpdateUI = false;
// Either styling or NotifyUpdateUI noticed that painting is needed
// outside the current painting rectangle
//Platform::DebugPrintf("Abandoning paint\n");
+ if (wrapState != eWrapNone) {
+ if (paintAbandonedByStyling) {
+ // Styling has spilled over a line end, such as occurs by starting a multiline
+ // comment. The width of subsequent text may have changed, so rewrap.
+ NeedWrapping(cs.DocFromDisplay(topLine));
+ }
+ }
return;
}
//Platform::DebugPrintf("start display %d, offset = %d\n", pdoc->Length(), xOffset);
Surface *surface = surfaceWindow;
if (bufferedDraw) {
- surface = &pixmapLine;
+ surface = pixmapLine;
}
- surface->SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
+ surface->SetUnicodeMode(IsUnicodeMode());
int visibleLine = topLine + screenLinePaintFirst;
- int line = cs.DocFromDisplay(visibleLine);
int posCaret = currentPos;
if (posDrag >= 0)
surfaceWindow->SetClip(rcTextArea);
// Loop on visible lines
- //GTimer *tim=g_timer_new();
+ //double durLayout = 0.0;
+ //double durPaint = 0.0;
+ //double durCopy = 0.0;
+ //ElapsedTime etWhole;
+ int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times
+ LineLayout *ll = 0;
while (visibleLine < cs.LinesDisplayed() && yposScreen < rcArea.bottom) {
- //g_timer_start(tim);
+
+ int lineDoc = cs.DocFromDisplay(visibleLine);
//Platform::DebugPrintf("Painting line %d\n", line);
+ // Only visible lines should be handled by the code within the loop
+ PLATFORM_ASSERT(cs.GetVisible(lineDoc));
+ int lineStartSet = cs.DisplayFromDoc(lineDoc);
+ int subLine = visibleLine - lineStartSet;
// Copy this line and its styles from the document into local arrays
// and determine the x position at which each character starts.
- LineLayout ll;
- LayoutLine(line, surface, vs, ll);
-
- ll.selStart = SelectionStart(line);
- ll.selEnd = SelectionEnd(line);
- ll.containsCaret = line == lineCaret;
- if (hideSelection) {
- ll.selStart = -1;
- ll.selEnd = -1;
- ll.containsCaret = false;
+ //ElapsedTime et;
+ if (lineDoc != lineDocPrevious) {
+ llc.Dispose(ll);
+ ll = RetrieveLineLayout(lineDoc);
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ lineDocPrevious = lineDoc;
}
- // Need to fix this up so takes account of Unicode and DBCS
- ll.edgeColumn = theEdge;
-
- int posLineStart = pdoc->LineStart(line);
- int posLineEnd = pdoc->LineStart(line + 1);
- //Platform::DebugPrintf("line %d %d - %d\n", line, posLineStart, posLineEnd);
-
- PRectangle rcLine = rcClient;
- rcLine.top = ypos;
- rcLine.bottom = ypos + vs.lineHeight;
-
- // Highlight the current braces if any
- if ((braces[0] >= posLineStart) && (braces[0] < posLineEnd)) {
- int braceOffset = braces[0] - posLineStart;
- if (braceOffset < ll.numCharsInLine)
- ll.styles[braceOffset] = static_cast<char>(bracesMatchStyle);
- }
- if ((braces[1] >= posLineStart) && (braces[1] < posLineEnd)) {
- int braceOffset = braces[1] - posLineStart;
- if (braceOffset < ll.numCharsInLine)
- ll.styles[braceOffset] = static_cast<char>(bracesMatchStyle);
- }
- if ((braces[0] >= posLineStart && braces[1] <= posLineEnd) ||
- (braces[1] >= posLineStart && braces[0] <= posLineEnd)) {
- ll.xHighlightGuide = highlightGuideColumn * vs.spaceWidth;
- }
-
- // Draw the line
- if (cs.GetVisible(line))
- DrawLine(surface, vs, line, visibleLine, xStart, rcLine, ll);
-
- bool expanded = cs.GetExpanded(line);
- if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
- if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
- PRectangle rcFoldLine = rcLine;
- rcFoldLine.bottom = rcFoldLine.top + 1;
- surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ //durLayout += et.Duration(true);
+
+ if (ll) {
+ ll->selStart = SelectionStart(lineDoc);
+ ll->selEnd = SelectionEnd(lineDoc);
+ ll->containsCaret = lineDoc == lineCaret;
+ if (hideSelection) {
+ ll->selStart = -1;
+ ll->selEnd = -1;
+ ll->containsCaret = false;
}
- }
- if ( (expanded && (foldFlags & 8)) || (!expanded && (foldFlags & 16)) ) {
- if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
- PRectangle rcFoldLine = rcLine;
- rcFoldLine.top = rcFoldLine.bottom - 1;
- surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+
+ PRectangle rcLine = rcClient;
+ rcLine.top = ypos;
+ rcLine.bottom = ypos + vs.lineHeight;
+
+ Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1));
+ // Highlight the current braces if any
+ ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle),
+ highlightGuideColumn * vs.spaceWidth);
+
+ // Draw the line
+ DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine);
+ //durPaint += et.Duration(true);
+
+ // Restore the precvious styles for the brace highlights in case layout is in cache.
+ ll->RestoreBracesHighlight(rangeLine, braces);
+
+ bool expanded = cs.GetExpanded(lineDoc);
+ if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
+ if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) {
+ PRectangle rcFoldLine = rcLine;
+ rcFoldLine.bottom = rcFoldLine.top + 1;
+ surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ }
}
- }
-
- // Draw the Caret
- if (line == lineCaret) {
- int offset = Platform::Minimum(posCaret - posLineStart, LineLayout::maxLineLength);
- int xposCaret = ll.positions[offset] + xStart;
- int widthOverstrikeCaret;
- if (posCaret == pdoc->Length()) { // At end of document
- widthOverstrikeCaret = vs.aveCharWidth;
- } else if ((posCaret - posLineStart) >= ll.numCharsInLine) { // At end of line
- widthOverstrikeCaret = vs.aveCharWidth;
- } else {
- widthOverstrikeCaret = ll.positions[offset + 1] - ll.positions[offset];
+ if ( (expanded && (foldFlags & 8)) || (!expanded && (foldFlags & 16)) ) {
+ if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) {
+ PRectangle rcFoldLine = rcLine;
+ rcFoldLine.top = rcFoldLine.bottom - 1;
+ surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ }
}
- if (widthOverstrikeCaret < 3) // Make sure its visible
- widthOverstrikeCaret = 3;
- if (((caret.active && caret.on) || (posDrag >= 0)) && xposCaret >= 0) {
- PRectangle rcCaret = rcLine;
- int caretWidthOffset = 0;
- if ((offset > 0) && (vs.caretWidth > 1))
- caretWidthOffset = 1; // Move back so overlaps both character cells.
- if (posDrag >= 0) {
- rcCaret.left = xposCaret - caretWidthOffset;
- rcCaret.right = rcCaret.left + vs.caretWidth;
- } else {
- if (inOverstrike) {
- rcCaret.top = rcCaret.bottom - 2;
- rcCaret.left = xposCaret + 1;
- rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+
+ // Draw the Caret
+ if (lineDoc == lineCaret) {
+ int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength);
+ if ((offset >= ll->LineStart(subLine)) &&
+ ((offset < ll->LineStart(subLine+1)) || offset == ll->numCharsInLine)) {
+ int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
+ int widthOverstrikeCaret;
+ if (posCaret == pdoc->Length()) { // At end of document
+ widthOverstrikeCaret = vs.aveCharWidth;
+ } else if ((posCaret - rangeLine.start) >= ll->numCharsInLine) { // At end of line
+ widthOverstrikeCaret = vs.aveCharWidth;
} else {
- rcCaret.left = xposCaret - caretWidthOffset;
- rcCaret.right = rcCaret.left + vs.caretWidth;
+ widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset];
+ }
+ if (widthOverstrikeCaret < 3) // Make sure its visible
+ widthOverstrikeCaret = 3;
+ if (((caret.active && caret.on) || (posDrag >= 0)) && xposCaret >= 0) {
+ PRectangle rcCaret = rcLine;
+ int caretWidthOffset = 0;
+ if ((offset > 0) && (vs.caretWidth > 1))
+ caretWidthOffset = 1; // Move back so overlaps both character cells.
+ if (posDrag >= 0) {
+ rcCaret.left = xposCaret - caretWidthOffset;
+ rcCaret.right = rcCaret.left + vs.caretWidth;
+ } else {
+ if (inOverstrike) {
+ rcCaret.top = rcCaret.bottom - 2;
+ rcCaret.left = xposCaret + 1;
+ rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+ } else {
+ rcCaret.left = xposCaret - caretWidthOffset;
+ rcCaret.right = rcCaret.left + vs.caretWidth;
+ }
+ }
+ surface->FillRectangle(rcCaret, vs.caretcolour.allocated);
}
}
- surface->FillRectangle(rcCaret, vs.caretcolour.allocated);
}
- }
-
- if (cs.GetVisible(line)) {
+
if (bufferedDraw) {
Point from(vs.fixedColumnWidth, 0);
PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen,
- rcClient.right, yposScreen + vs.lineHeight);
- surfaceWindow->Copy(rcCopyArea, from, pixmapLine);
+ rcClient.right, yposScreen + vs.lineHeight);
+ surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
}
+ //durCopy += et.Duration(true);
}
-
+
if (!bufferedDraw) {
ypos += vs.lineHeight;
}
yposScreen += vs.lineHeight;
visibleLine++;
- line = cs.DocFromDisplay(visibleLine);
//gdk_flush();
- //g_timer_stop(tim);
- //Platform::DebugPrintf("Paint [%0d] took %g\n", line, g_timer_elapsed(tim, 0));
}
- //g_timer_destroy(tim);
+ llc.Dispose(ll);
+ //if (durPaint < 0.00000001)
+ // durPaint = 0.00000001;
// Right column limit indicator
-
-
-
PRectangle rcBeyondEOF = rcClient;
rcBeyondEOF.left = vs.fixedColumnWidth;
rcBeyondEOF.right = rcBeyondEOF.right;
surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour.allocated);
}
}
+ //Platform::DebugPrintf(
+ //"Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n",
+ //durLayout, durPaint, durLayout / durPaint, durCopy, etWhole.Duration());
NotifyPainted();
}
}
// Space (3 space characters) between line numbers and text when printing.
#define lineNumberPrintSpace " "
-Colour InvertedLight(Colour orig) {
+ColourDesired InvertedLight(ColourDesired orig) {
unsigned int r = orig.GetRed();
unsigned int g = orig.GetGreen();
unsigned int b = orig.GetBlue();
unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye
unsigned int il = 0xff - l;
if (l == 0)
- return Colour(0xff, 0xff, 0xff);
+ return ColourDesired(0xff, 0xff, 0xff);
r = r * il / l;
g = g * il / l;
b = b * il / l;
- return Colour(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff));
+ return ColourDesired(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff));
}
// This is mostly copied from the Paint method but with some things omitted
if (!pfr)
return 0;
- Surface *surface = new Surface();
- surface->Init(pfr->hdc);
- surface->SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
- Surface *surfaceMeasure = new Surface();
- surfaceMeasure->Init(pfr->hdcTarget);
- surfaceMeasure->SetUnicodeMode(SC_CP_UTF8 == pdoc->dbcsCodePage);
+ AutoSurface surface(pfr->hdc, IsUnicodeMode());
+ if (!surface)
+ return 0;
+ AutoSurface surfaceMeasure(pfr->hdcTarget, IsUnicodeMode());
+ if (!surfaceMeasure) {
+ return 0;
+ }
ViewStyle vsPrint(vs);
vsPrint.styles[sty].fore.desired = InvertedLight(vsPrint.styles[sty].fore.desired);
vsPrint.styles[sty].back.desired = InvertedLight(vsPrint.styles[sty].back.desired);
} else if (printColourMode == SC_PRINT_BLACKONWHITE) {
- vsPrint.styles[sty].fore.desired = Colour(0, 0, 0);
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].fore.desired = ColourDesired(0, 0, 0);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITE) {
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
if (sty <= STYLE_DEFAULT) {
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
}
}
}
// White background for the line numbers
- vsPrint.styles[STYLE_LINENUMBER].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff);
vsPrint.Refresh(*surfaceMeasure);
// Ensure colours are set up
// Copy this line and its styles from the document into local arrays
// and determine the x position at which each character starts.
- LineLayout ll;
- LayoutLine(line, surfaceMeasure, vsPrint, ll);
+ LineLayout ll(8000);
+ LayoutLine(line, surfaceMeasure, vsPrint, &ll);
ll.selStart = -1;
ll.selEnd = -1;
ll.containsCaret = false;
- // Need to fix this up so takes account of Unicode and DBCS
- ll.edgeColumn = theEdge;
PRectangle rcLine;
rcLine.left = pfr->rc.left + lineNumberWidth;
// Right justify
rcNumber.left -=
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
- surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
+ surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
ypos + vsPrint.maxAscent, number, strlen(number),
vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
// Draw the line
surface->FlushCachedState();
- DrawLine(surface, vsPrint, line, line, xStart, rcLine, ll);
+ DrawLine(surface, vsPrint, line, line, xStart, rcLine, &ll);
ypos += vsPrint.lineHeight;
line++;
}
}
- delete surface;
- delete surfaceMeasure;
-
return endPosPrint;
}
// Empty method is overridden on GTK+ to show / hide scrollbars
void Editor::ReconfigureScrollBars() {}
-void Editor::SetScrollBarsTo(PRectangle) {
+void Editor::SetScrollBars() {
RefreshStyleData();
int nMax = cs.LinesDisplayed();
- int nPage = cs.LinesDisplayed() - MaxScrollPos() + 1;
+ int nPage = nMax - MaxScrollPos() + 1;
bool modified = ModifyScrollBars(nMax, nPage);
// TODO: ensure always showing as many lines as possible
//Platform::DebugPrintf("end max = %d page = %d\n", nMax, nPage);
}
-void Editor::SetScrollBars() {
- PRectangle rsClient = GetClientRectangle();
- SetScrollBarsTo(rsClient);
+void Editor::ChangeSize() {
+ DropGraphics();
+ SetScrollBars();
+ if (wrapState != eWrapNone) {
+ PRectangle rcTextArea = GetClientRectangle();
+ rcTextArea.left = vs.fixedColumnWidth;
+ rcTextArea.right -= vs.rightMarginWidth;
+ if (wrapWidth != rcTextArea.Width()) {
+ NeedWrapping();
+ Redraw();
+ }
+ }
}
void Editor::AddChar(char ch) {
AddCharUTF(s, 1);
}
-void Editor::AddCharUTF(char *s, unsigned int len) {
+void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool wasSelection = currentPos != anchor;
ClearSelection();
if (inOverstrike && !wasSelection) {
ShowCaretAtCurrentPosition();
SetLastXChosen();
- int byte = static_cast<unsigned char>(s[0]);
- if ((byte < 0xC0) || (1 == len)) {
- // Handles UTF-8 characters between 0x01 and 0x7F and single byte
- // characters when not in UTF-8 mode.
- // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
- // characters representing themselves.
+ if (treatAsDBCS) {
+ NotifyChar((static_cast<unsigned char>(s[0]) << 8) |
+ static_cast<unsigned char>(s[1]));
} else {
- // Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
- // http://www.cl.cam.ac.uk/~mgk25/unicode.html
- // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
- if (byte < 0xE0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- if ((byte2 & 0xC0) == 0x80) {
- // Two-byte-character lead-byte followed by a trail-byte.
- byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
- }
- // A two-byte-character lead-byte not followed by trail-byte
- // represents itself.
- } else if (byte < 0xF0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- int byte3 = static_cast<unsigned char>(s[2]);
- if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
- // Three-byte-character lead byte followed by two trail bytes.
- byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
- (byte3 & 0x3F));
+ int byte = static_cast<unsigned char>(s[0]);
+ if ((byte < 0xC0) || (1 == len)) {
+ // Handles UTF-8 characters between 0x01 and 0x7F and single byte
+ // characters when not in UTF-8 mode.
+ // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
+ // characters representing themselves.
+ } else {
+ // Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
+ // http://www.cl.cam.ac.uk/~mgk25/unicode.html
+ // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
+ if (byte < 0xE0) {
+ int byte2 = static_cast<unsigned char>(s[1]);
+ if ((byte2 & 0xC0) == 0x80) {
+ // Two-byte-character lead-byte followed by a trail-byte.
+ byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
+ }
+ // A two-byte-character lead-byte not followed by trail-byte
+ // represents itself.
+ } else if (byte < 0xF0) {
+ int byte2 = static_cast<unsigned char>(s[1]);
+ int byte3 = static_cast<unsigned char>(s[2]);
+ if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
+ // Three-byte-character lead byte followed by two trail bytes.
+ byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
+ (byte3 & 0x3F));
+ }
+ // A three-byte-character lead-byte not followed by two trail-bytes
+ // represents itself.
}
- // A three-byte-character lead-byte not followed by two trail-bytes
- // represents itself.
}
+ NotifyChar(byte);
}
- NotifyChar(byte);
}
void Editor::ClearSelection() {
return;
}
currentPos = pos;
- int insertPos = currentPos;
int xInsert = XFromPosition(currentPos);
int line = pdoc->LineFromPosition(currentPos);
bool prevCr = false;
pdoc->InsertChar(currentPos, ' ');
currentPos++;
}
- insertPos = currentPos;
}
prevCr = ptr[i] == '\r';
} else {
pdoc->InsertString(currentPos, ptr + i, 1);
currentPos++;
- insertPos = currentPos;
prevCr = false;
}
}
pdoc->EndUndoAction();
- SetEmptySelection(insertPos);
+ SetEmptySelection(pos);
}
bool Editor::CanPaste() {
ShowCaretAtCurrentPosition();
}
-void Editor::DelCharBack() {
+void Editor::DelCharBack(bool allowLineStartDeletion) {
if (currentPos == anchor) {
int lineCurrentPos = pdoc->LineFromPosition(currentPos);
- if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) &&
- pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) {
- pdoc->BeginUndoAction();
- int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
- if (indentation % indentationStep == 0) {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != currentPos)) {
+ if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) &&
+ pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) {
+ pdoc->BeginUndoAction();
+ int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars);
+ if (indentation % indentationStep == 0) {
+ pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ } else {
+ pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep));
+ }
+ SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
+ pdoc->EndUndoAction();
} else {
- pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep));
+ int newPos = pdoc->DelCharBack(currentPos);
+ SetEmptySelection(newPos);
}
- SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
- pdoc->EndUndoAction();
- } else {
- int newPos = pdoc->DelCharBack(currentPos);
- SetEmptySelection(newPos);
}
} else {
ClearSelection();
NotifySavePoint(atSavePoint);
}
+void Editor::CheckModificationForWrap(DocModification mh) {
+ if ((mh.modificationType & SC_MOD_INSERTTEXT) ||
+ (mh.modificationType & SC_MOD_DELETETEXT)) {
+ llc.Invalidate(LineLayout::llInvalid);
+ if (wrapState != eWrapNone) {
+ int lineDoc = pdoc->LineFromPosition(mh.position);
+ if (mh.linesAdded == 0) {
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(lineDoc);
+ if (surface && ll) {
+ LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
+ if (cs.GetHeight(lineDoc) != ll->lines) {
+ NeedWrapping(lineDoc-1);
+ Redraw();
+ }
+ } else {
+ NeedWrapping(lineDoc);
+ }
+ llc.Dispose(ll);
+ } else {
+ NeedWrapping(lineDoc);
+ }
+ }
+ }
+}
+
+// Move a position so it is still after the same character as before the insertion.
+static inline int MovePositionForInsertion(int position, int startInsertion, int length) {
+ if (position > startInsertion) {
+ return position + length;
+ }
+ return position;
+}
+
+// Move a position so it is still after the same character as before the deletion if that
+// character is still present else after the previous surviving character.
+static inline int MovePositionForDeletion(int position, int startDeletion, int length) {
+ if (position > startDeletion) {
+ int endDeletion = startDeletion + length;
+ if (position > endDeletion) {
+ return position - length;
+ } else {
+ return startDeletion;
+ }
+ } else {
+ return position;
+ }
+}
+
void Editor::NotifyModified(Document*, DocModification mh, void *) {
needUpdateUI = true;
if (paintState == painting) {
CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
} else if (paintState == notPainting) {
+ CheckModificationForWrap(mh);
if (mh.modificationType & SC_MOD_CHANGESTYLE) {
if (mh.position < pdoc->LineStart(topLine)) {
// Styling performed before this view
} else {
// Move selection and brace highlights
if (mh.modificationType & SC_MOD_INSERTTEXT) {
- if (currentPos > mh.position) {
- currentPos += mh.length;
- }
- if (anchor > mh.position) {
- anchor += mh.length;
- }
- if (braces[0] > mh.position) {
- braces[0] += mh.length;
- }
- if (braces[1] > mh.position) {
- braces[1] += mh.length;
- }
- } else { // SC_MOD_DELETETEXT
- int endPos = mh.position + mh.length;
- if (currentPos > mh.position) {
- if (currentPos > endPos) {
- currentPos -= mh.length;
- } else {
- currentPos = endPos;
- }
- }
- if (anchor > mh.position) {
- if (anchor > endPos) {
- anchor -= mh.length;
- } else {
- anchor = endPos;
- }
- }
- if (braces[0] > mh.position) {
- if (braces[0] > endPos) {
- braces[0] -= mh.length;
- } else {
- braces[0] = endPos;
- }
- }
- if (braces[1] > mh.position) {
- if (braces[1] > endPos) {
- braces[1] -= mh.length;
- } else {
- braces[1] = endPos;
- }
- }
+ currentPos = MovePositionForInsertion(currentPos, mh.position, mh.length);
+ anchor = MovePositionForInsertion(anchor, mh.position, mh.length);
+ braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length);
+ braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length);
+ } else if (mh.modificationType & SC_MOD_DELETETEXT) {
+ currentPos = MovePositionForDeletion(currentPos, mh.position, mh.length);
+ anchor = MovePositionForDeletion(anchor, mh.position, mh.length);
+ braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length);
+ braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length);
}
if (cs.LinesDisplayed() < cs.LinesInDoc()) {
// Some lines are hidden so may need shown.
NotifyChange(); // Send EN_CHANGE
}
-
-
SCNotification scn;
scn.nmhdr.code = SCN_MODIFIED;
scn.position = mh.position;
case SCI_LINETRANSPOSE:
case SCI_LOWERCASE:
case SCI_UPPERCASE:
+ case SCI_LINESCROLLDOWN:
+ case SCI_LINESCROLLUP:
+ case SCI_DELETEBACKNOTLINE:
break;
// Filter out all others like display changes. Also, newlines are redundant
CancelModes();
break;
case SCI_DELETEBACK:
- DelCharBack();
+ DelCharBack(true);
+ SetLastXChosen();
+ EnsureCaretVisible();
+ break;
+ case SCI_DELETEBACKNOTLINE:
+ DelCharBack(false);
SetLastXChosen();
EnsureCaretVisible();
break;
case SCI_ZOOMIN:
if (vs.zoomLevel < 20)
vs.zoomLevel++;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
case SCI_ZOOMOUT:
if (vs.zoomLevel > -10)
vs.zoomLevel--;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
case SCI_DELWORDLEFT: {
TextToFind *ft = reinterpret_cast<TextToFind *>(lParam);
int lengthFound = strlen(ft->lpstrText);
int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText,
- wParam & SCFIND_MATCHCASE,
- wParam & SCFIND_WHOLEWORD,
- wParam & SCFIND_WORDSTART,
- wParam & SCFIND_REGEXP,
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
&lengthFound);
if (pos != -1) {
ft->chrgText.cpMin = pos;
int lengthFound = strlen(txt);
if (iMessage == SCI_SEARCHNEXT) {
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
- wParam & SCFIND_MATCHCASE,
- wParam & SCFIND_WHOLEWORD,
- wParam & SCFIND_WORDSTART,
- wParam & SCFIND_REGEXP,
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
&lengthFound);
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
- wParam & SCFIND_MATCHCASE,
- wParam & SCFIND_WHOLEWORD,
- wParam & SCFIND_WORDSTART,
- wParam & SCFIND_REGEXP,
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
&lengthFound);
}
long Editor::SearchInTarget(const char *text, int length) {
int lengthFound = length;
int pos = pdoc->FindText(targetStart, targetEnd, text,
- searchFlags & SCFIND_MATCHCASE,
- searchFlags & SCFIND_WHOLEWORD,
- searchFlags & SCFIND_WORDSTART,
- searchFlags & SCFIND_REGEXP,
+ (searchFlags & SCFIND_MATCHCASE) != 0,
+ (searchFlags & SCFIND_WHOLEWORD) != 0,
+ (searchFlags & SCFIND_WORDSTART) != 0,
+ (searchFlags & SCFIND_REGEXP) != 0,
&lengthFound);
if (pos != -1) {
targetStart = pos;
SetSelection(movePos);
} else if (selectionType == selWord) {
// Continue selecting by word
- if (currentPos > originalAnchorPos) { // Moved forward
+ if (movePos >= originalAnchorPos) { // Moved forward
SetSelection(pdoc->ExtendWordSelect(movePos, 1),
pdoc->ExtendWordSelect(originalAnchorPos, -1));
} else { // Moved backward
lastClickTime = curTime;
lastClick = pt;
lastXChosen = pt.x;
+ if (selType == selStream) {
+ SetLastXChosen();
+ }
inDragDrop = false;
EnsureCaretVisible(false);
}
InvalidateCaret();
}
}
- if ((dwellDelay < SC_TIME_FOREVER) &&
+ if ((dwellDelay < SC_TIME_FOREVER) &&
(ticksToDwell > 0) &&
(!HaveMouseCapture())) {
ticksToDwell -= timer.tickSize;
NotifyFocus(hasFocus);
if (hasFocus) {
ShowCaretAtCurrentPosition();
- InvalidateCaret();
} else {
DropCaret();
}
// Reset the contraction state to fully shown.
cs.Clear();
cs.InsertLines(0, pdoc->LinesTotal() - 1);
+ llc.Deallocate();
+ NeedWrapping();
pdoc->AddWatcher(this, 0);
Redraw();
}
// Recurse up from this line to find any folds that prevent this line from being visible
-// and unfold them all.
+// and unfold them all->
void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
+
+ // In case in need of wrapping to ensure DisplayFromDoc works.
+ WrapLines();
+
if (!cs.GetVisible(lineDoc)) {
int lineParent = pdoc->GetFoldParent(lineDoc);
if (lineParent >= 0) {
return length;
}
+bool Editor::IsUnicodeMode() const {
+ return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage);
+}
+
static bool ValidMargin(unsigned long wParam) {
return wParam < ViewStyle::margins;
}
case SCI_SETTEXT:
{
if (lParam == 0)
- return FALSE;
+ return 0;
pdoc->DeleteChars(0, pdoc->Length());
SetEmptySelection(0);
pdoc->InsertString(0, reinterpret_cast<char *>(lParam));
- return TRUE;
+ return 1;
}
case SCI_GETTEXTLENGTH:
break;
case SCI_CANUNDO:
- return pdoc->CanUndo() ? TRUE : FALSE;
+ return pdoc->CanUndo() ? 1 : 0;
case SCI_EMPTYUNDOBUFFER:
pdoc->DeleteUndoHistory();
case SCI_LINESCROLL:
ScrollTo(topLine + lParam);
HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
- return TRUE;
+ return 1;
+
+ case SCI_SETXOFFSET:
+ xOffset = wParam;
+ Redraw();
+ break;
+
+ case SCI_GETXOFFSET:
+ return xOffset;
case SCI_SCROLLCARET:
EnsureCaretVisible();
break;
case SCI_SETREADONLY:
- pdoc->SetReadOnly(wParam);
- return TRUE;
+ pdoc->SetReadOnly(wParam != 0);
+ return 1;
case SCI_GETREADONLY:
return pdoc->IsReadOnly();
}
case SCI_HIDESELECTION:
- hideSelection = wParam;
+ hideSelection = wParam != 0;
Redraw();
break;
case SCI_FORMATRANGE:
- return FormatRange(wParam, reinterpret_cast<RangeToFormat *>(lParam));
+ return FormatRange(wParam != 0, reinterpret_cast<RangeToFormat *>(lParam));
case SCI_GETMARGINLEFT:
return vs.leftMarginWidth;
case SCI_SETMARGINLEFT:
vs.leftMarginWidth = lParam;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
case SCI_SETMARGINRIGHT:
vs.rightMarginWidth = lParam;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
return 0;
case SCI_SETUNDOCOLLECTION:
- pdoc->SetUndoCollection(wParam);
+ pdoc->SetUndoCollection(wParam != 0);
return 0;
case SCI_GETUNDOCOLLECTION:
}
case SCI_CANREDO:
- return pdoc->CanRedo() ? TRUE : FALSE;
+ return pdoc->CanRedo() ? 1 : 0;
case SCI_MARKERLINEFROMHANDLE:
return pdoc->LineFromHandle(wParam);
break;
case SCI_SETBUFFEREDDRAW:
- bufferedDraw = wParam;
+ bufferedDraw = wParam != 0;
break;
case SCI_GETBUFFEREDDRAW:
return pdoc->indentInChars;
case SCI_SETUSETABS:
- pdoc->useTabs = wParam;
+ pdoc->useTabs = wParam != 0;
InvalidateStyleRedraw();
break;
return pdoc->GetLineIndentPosition(wParam);
case SCI_SETTABINDENTS:
- pdoc->tabIndents = wParam;
+ pdoc->tabIndents = wParam != 0;
break;
case SCI_GETTABINDENTS:
return pdoc->tabIndents;
case SCI_SETBACKSPACEUNINDENTS:
- pdoc->backspaceUnindents = wParam;
+ pdoc->backspaceUnindents = wParam != 0;
break;
case SCI_GETBACKSPACEUNINDENTS:
dwellDelay = wParam;
ticksToDwell = dwellDelay;
break;
-
+
case SCI_GETMOUSEDWELLTIME:
return dwellDelay;
-
+
+ case SCI_WORDSTARTPOSITION:
+ return pdoc->ExtendWordSelect(wParam, -1, lParam != 0);
+
+ case SCI_WORDENDPOSITION:
+ return pdoc->ExtendWordSelect(wParam, 1, lParam != 0);
+
+ case SCI_SETWRAPMODE:
+ wrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone;
+ NeedWrapping();
+ xOffset = 0;
+ InvalidateStyleRedraw();
+ ReconfigureScrollBars();
+ break;
+
+ case SCI_GETWRAPMODE:
+ return wrapState;
+
+ case SCI_SETLAYOUTCACHE:
+ llc.SetLevel(wParam);
+ break;
+
+ case SCI_GETLAYOUTCACHE:
+ return llc.GetLevel();
+
case SCI_GETCOLUMN:
return pdoc->GetColumn(wParam);
case SCI_SETHSCROLLBAR :
- horizontalScrollBarVisible = wParam;
- SetScrollBars();
- ReconfigureScrollBars();
+ if (horizontalScrollBarVisible != (wParam != 0)) {
+ horizontalScrollBarVisible = wParam != 0;
+ SetScrollBars();
+ ReconfigureScrollBars();
+ }
break;
case SCI_GETHSCROLLBAR:
return horizontalScrollBarVisible;
case SCI_SETINDENTATIONGUIDES:
- vs.viewIndentationGuides = wParam;
+ vs.viewIndentationGuides = wParam != 0;
Redraw();
break;
return pdoc->dbcsCodePage;
case SCI_SETUSEPALETTE:
- palette.allowRealization = wParam;
+ palette.allowRealization = wParam != 0;
InvalidateStyleRedraw();
break;
break;
case SCI_MARKERSETFORE:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].fore.desired = Colour(lParam);
+ vs.markers[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_MARKERSETBACK:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].back.desired = Colour(lParam);
+ vs.markers[wParam].back.desired = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_SETMARGINWIDTHN:
if (ValidMargin(wParam)) {
vs.ms[wParam].width = lParam;
+ NeedWrapping();
InvalidateStyleRedraw();
}
break;
case SCI_SETMARGINSENSITIVEN:
if (ValidMargin(wParam)) {
- vs.ms[wParam].sensitive = lParam;
+ vs.ms[wParam].sensitive = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETFORE:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].fore.desired = Colour(lParam);
+ vs.styles[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETBACK:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].back.desired = Colour(lParam);
+ vs.styles[wParam].back.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETBOLD:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].bold = lParam;
+ vs.styles[wParam].bold = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETITALIC:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].italic = lParam;
+ vs.styles[wParam].italic = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETEOLFILLED:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].eolFilled = lParam;
+ vs.styles[wParam].eolFilled = lParam != 0;
InvalidateStyleRedraw();
}
break;
break;
case SCI_STYLESETUNDERLINE:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].underline = lParam;
+ vs.styles[wParam].underline = lParam != 0;
InvalidateStyleRedraw();
}
break;
break;
case SCI_STYLESETVISIBLE:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].visible = lParam;
+ vs.styles[wParam].visible = lParam != 0;
+ InvalidateStyleRedraw();
+ }
+ break;
+ case SCI_STYLESETCHANGEABLE:
+ if (wParam <= STYLE_MAX) {
+ vs.styles[wParam].changeable = lParam != 0;
InvalidateStyleRedraw();
}
break;
case SCI_GETCARETLINEVISIBLE:
return vs.showCaretLineBackground;
case SCI_SETCARETLINEVISIBLE:
- vs.showCaretLineBackground = wParam;
+ vs.showCaretLineBackground = wParam != 0;
InvalidateStyleRedraw();
break;
case SCI_GETCARETLINEBACK:
return cs.GetVisible(wParam);
case SCI_SETFOLDEXPANDED:
- if (cs.SetExpanded(wParam, lParam)) {
+ if (cs.SetExpanded(wParam, lParam != 0)) {
RedrawSelMargin();
}
break;
return LinesOnScreen();
case SCI_SETSELFORE:
- vs.selforeset = wParam;
- vs.selforeground.desired = Colour(lParam);
+ vs.selforeset = wParam != 0;
+ vs.selforeground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
- vs.selbackset = wParam;
- vs.selbackground.desired = Colour(lParam);
+ vs.selbackset = wParam != 0;
+ vs.selbackground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETCARETFORE:
- vs.caretcolour.desired = Colour(wParam);
+ vs.caretcolour.desired = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].fore.desired = Colour(lParam);
+ vs.indicators[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_WORDPARTLEFTEXTEND:
case SCI_WORDPARTRIGHT:
case SCI_WORDPARTRIGHTEXTEND:
+ case SCI_DELETEBACKNOTLINE:
return KeyCommand(iMessage);
case SCI_BRACEHIGHLIGHT:
return vs.viewEOL;
case SCI_SETVIEWEOL:
- vs.viewEOL = wParam;
+ vs.viewEOL = wParam != 0;
Redraw();
break;
case SCI_SETZOOM:
vs.zoomLevel = wParam;
+ NeedWrapping();
InvalidateStyleRedraw();
break;
return vs.edgecolour.desired.AsLong();
case SCI_SETEDGECOLOUR:
- vs.edgecolour.desired = Colour(wParam);
+ vs.edgecolour.desired = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_GETDOCPOINTER:
- return reinterpret_cast<long>(pdoc);
+ return reinterpret_cast<sptr_t>(pdoc);
case SCI_SETDOCPOINTER:
SetDocPointer(reinterpret_cast<Document *>(lParam));
case SCI_CREATEDOCUMENT: {
Document *doc = new Document();
doc->AddRef();
- return reinterpret_cast<long>(doc);
+ return reinterpret_cast<sptr_t>(doc);
}
case SCI_ADDREFDOCUMENT:
return (selType == selRectangle) ? 1 : 0;
case SCI_SETOVERTYPE:
- inOverstrike = wParam;
+ inOverstrike = wParam != 0;
break;
case SCI_GETOVERTYPE:
- return inOverstrike ? TRUE : FALSE;
+ return inOverstrike ? 1 : 0;
case SCI_SETFOCUS:
- SetFocusState(wParam);
+ SetFocusState(wParam != 0);
break;
case SCI_GETFOCUS:
return errorStatus;
case SCI_SETMOUSEDOWNCAPTURES:
- mouseDownCaptures = wParam;
+ mouseDownCaptures = wParam != 0;
break;
case SCI_GETMOUSEDOWNCAPTURES:
case SCI_GETCURSOR:
return cursorMode;
+ case SCI_SETCONTROLCHARSYMBOL:
+ controlCharSymbol = wParam;
+ break;
+
+ case SCI_GETCONTROLCHARSYMBOL:
+ return controlCharSymbol;
+
case SCI_STARTRECORD:
recordingMacro = true;
return 0;
/** @file Editor.h
** Defines the main editor class.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef EDITOR_H
bool active;
bool on;
int period;
-
+
Caret();
};
bool ticking;
int ticksToWait;
enum {tickSize = 100};
- int tickerID;
-
+ TickerID tickerID;
+
Timer();
};
/**
*/
class LineLayout {
-public:
+private:
+ friend class LineLayoutCache;
+ int *lineStarts;
+ int lenLineStarts;
/// Drawing is only performed for @a maxLineLength characters on each line.
- enum {maxLineLength = 4000};
+ int lineNumber;
+ bool inCache;
+public:
+ enum { wrapWidthInfinite = 0x7ffffff };
+ int maxLineLength;
int numCharsInLine;
+ enum validLevel { llInvalid, llPositions, llLines } validity;
int xHighlightGuide;
bool highlightColumn;
int selStart;
int selEnd;
bool containsCaret;
int edgeColumn;
- char chars[maxLineLength+1];
- char styles[maxLineLength+1];
- char indicators[maxLineLength+1];
- int positions[maxLineLength+1];
+ char *chars;
+ char *styles;
+ char *indicators;
+ int *positions;
+ char bracePreviousStyles[2];
+
+ // Wrapped line support
+ int widthLine;
+ int lines;
+
+ LineLayout(int maxLineLength_);
+ virtual ~LineLayout();
+ void Resize(int maxLineLength_);
+ void Free();
+ void Invalidate(validLevel validity_);
+ int LineStart(int line) {
+ if (line <= 0) {
+ return 0;
+ } else if ((line >= lines) || !lineStarts) {
+ return numCharsInLine;
+ } else {
+ return lineStarts[line];
+ }
+ }
+ void SetLineStart(int line, int start);
+ void SetBracesHighlight(Range rangeLine, Position braces[],
+ char bracesMatchStyle, int xHighlight);
+ void RestoreBracesHighlight(Range rangeLine, Position braces[]);
+};
+
+/**
+ */
+class LineLayoutCache {
+ int level;
+ int length;
+ int size;
+ LineLayout **cache;
+ bool allInvalidated;
+ int styleClock;
+ void Allocate(int length_);
+ void AllocateForLevel(int linesOnScreen, int linesInDoc);
+public:
+ LineLayoutCache();
+ virtual ~LineLayoutCache();
+ void Deallocate();
+ enum {
+ llcNone=SC_CACHE_NONE,
+ llcCaret=SC_CACHE_CARET,
+ llcPage=SC_CACHE_PAGE,
+ llcDocument=SC_CACHE_DOCUMENT
+ };
+ void Invalidate(LineLayout::validLevel validity_);
+ void SetLevel(int level_);
+ int GetLevel() { return level; }
+ LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+ int linesOnScreen, int linesInDoc);
+ void Dispose(LineLayout *ll);
};
class SelectionText {
}
};
+/**
+ * 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 {
/** Style resources may be expensive to allocate so are cached between uses.
* When a style attribute is changed, this cache is flushed. */
- bool stylesValid;
+ bool stylesValid;
ViewStyle vs;
Palette palette;
int printMagnification;
int printColourMode;
int cursorMode;
+ int controlCharSymbol;
bool hasFocus;
bool hideSelection;
bool inOverstrike;
int errorStatus;
bool mouseDownCaptures;
-
+
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
* the screen. This avoids flashing but is about 30% slower. */
bool bufferedDraw;
int xOffset; ///< Horizontal scrolled amount in pixels
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
bool horizontalScrollBarVisible;
-
- Surface pixmapLine;
- Surface pixmapSelMargin;
- Surface pixmapSelPattern;
- Surface pixmapIndentGuide;
- Surface pixmapIndentGuideHighlight;
+
+ Surface *pixmapLine;
+ Surface *pixmapSelMargin;
+ Surface *pixmapSelPattern;
+ Surface *pixmapIndentGuide;
+ Surface *pixmapIndentGuideHighlight;
+
+ LineLayoutCache llc;
KeyMap kmap;
int searchFlags;
int topLine;
int posTopLine;
-
+
bool needUpdateUI;
Position braces[2];
int bracesMatchStyle;
int highlightGuideColumn;
-
+
int theEdge;
enum { notPainting, painting, paintAbandoned } paintState;
PRectangle rcPaint;
bool paintingAllText;
-
+
int modEventMask;
-
+
SelectionText drag;
enum { selStream, selRectangle, selRectangleFixed } selType;
int xStartSelect;
int xEndSelect;
bool primarySelection;
-
+
int caretPolicy;
int caretSlop;
int visiblePolicy;
int visibleSlop;
-
+
int searchAnchor;
bool recordingMacro;
int foldFlags;
ContractionState cs;
+ // Wrapping support
+ enum { eWrapNone, eWrapWord } wrapState;
+ int wrapWidth;
+ int docLineLastWrapped;
+
Document *pdoc;
Editor();
virtual PRectangle GetClientRectangle();
PRectangle GetTextRectangle();
-
+
int LinesOnScreen();
int LinesToScroll();
int MaxScrollPos();
int PositionFromLineX(int line, int x);
int LineFromLocation(Point pt);
void SetTopLine(int topLineNew);
-
+
void RedrawRect(PRectangle rc);
void Redraw();
void RedrawSelMargin();
PRectangle RectangleFromRange(int start, int end);
void InvalidateRange(int start, int end);
-
+
int CurrentPosition();
bool SelectionEmpty();
int SelectionStart(int line=-1);
virtual void ScrollText(int linesToMove);
void HorizontalScrollTo(int xPos);
void MoveCaretInsideView();
+ int DisplayFromPosition(int pos);
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
void ShowCaretAtCurrentPosition();
void DropCaret();
void InvalidateCaret();
+ void NeedWrapping(int docLineStartWrapping=0);
+ bool WrapLines();
+
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
void PaintSelMargin(Surface *surface, PRectangle &rc);
- void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout &ll);
- void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
- PRectangle rcLine, LineLayout &ll);
+ LineLayout *RetrieveLineLayout(int lineNumber);
+ void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
+ int width=LineLayout::wrapWidthInfinite);
+ void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
+ PRectangle rcLine, LineLayout *ll, int subLine=0);
void Paint(Surface *surfaceWindow, PRectangle rcArea);
long FormatRange(bool draw, RangeToFormat *pfr);
virtual void SetHorizontalScrollPos() = 0;
virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
virtual void ReconfigureScrollBars();
- void SetScrollBarsTo(PRectangle rsClient);
void SetScrollBars();
+ void ChangeSize();
void AddChar(char ch);
- virtual void AddCharUTF(char *s, unsigned int len);
+ virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void ClearSelection();
void ClearAll();
void ClearDocumentStyle();
void Undo();
void Redo();
void DelChar();
- void DelCharBack();
+ void DelCharBack(bool allowLineStartDeletion);
virtual void ClaimSelection() = 0;
virtual void NotifyChange() = 0;
virtual void NotifyFocus(bool focus);
+ virtual int GetCtrlID() { return ctrlID; }
virtual void NotifyParent(SCNotification scn) = 0;
virtual void NotifyStyleToNeeded(int endStyleNeeded);
void NotifyChar(int ch);
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
void NotifyNeedShown(int pos, int len);
void NotifyDwelling(Point pt, bool state);
-
+
void NotifyModifyAttempt(Document *document, void *userData);
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
+ void CheckModificationForWrap(DocModification mh);
void NotifyModified(Document *document, DocModification mh, void *userData);
void NotifyDeleted(Document *document, void *userData);
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
void CheckForChangeOutsidePaint(Range r);
int BraceMatch(int position, int maxReStyle);
void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
-
+
void SetDocPointer(Document *document);
-
+
void Expand(int &line, bool doExpand);
void ToggleContraction(int line);
void EnsureLineVisible(int lineDoc, bool enforcePolicy);
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
-
+
public:
- // Public so scintilla_send_message can use it
+ // Public so the COM thunks can access it.
+ bool IsUnicodeMode() const;
+ // Public so scintilla_send_message can use it.
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
- // Public so scintilla_set_id can use it
- int ctrlID;
+ // Public so scintilla_set_id can use it.
+ int ctrlID;
};
#endif
public:
int style;
ColourPair fore;
- Indicator() : style(INDIC_PLAIN), fore(Colour(0,0,0)) {
+ Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) {
}
void Draw(Surface *surface, PRectangle &rc);
};
return 0;
}
-KeyToCommand KeyMap::MapDefault[] = {
+const KeyToCommand KeyMap::MapDefault[] = {
{SCK_DOWN, SCI_NORM, SCI_LINEDOWN},
{SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND},
{SCK_DOWN, SCI_CTRL, SCI_LINESCROLLDOWN},
KeyToCommand *kmap;
int len;
int alloc;
- static KeyToCommand MapDefault[];
+ static const KeyToCommand MapDefault[];
public:
KeyMap();
/** @file KeyWords.cxx
** Colourise for particular languages.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include "Scintilla.h"
#include "SciLexer.h"
-LexerModule *LexerModule::base = 0;
+const LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_, LexerFunction fnFolder_) :
language(language_),
- languageName(languageName_),
fnLexer(fnLexer_),
- fnFolder(fnFolder_) {
+ fnFolder(fnFolder_),
+ languageName(languageName_) {
next = base;
base = this;
if (language == SCLEX_AUTOMATIC) {
}
}
-LexerModule *LexerModule::Find(int language) {
- LexerModule *lm = base;
+const LexerModule *LexerModule::Find(int language) {
+ const LexerModule *lm = base;
while (lm) {
if (lm->language == language) {
return lm;
return 0;
}
-LexerModule *LexerModule::Find(const char *languageName) {
+const LexerModule *LexerModule::Find(const char *languageName) {
if (languageName) {
- LexerModule *lm = base;
+ const LexerModule *lm = base;
while (lm) {
if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
return lm;
}
void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) const {
if (fnLexer)
fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
}
void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) const {
if (fnFolder) {
int lineCurrent = styler.GetLine(startPos);
// Move back one line in case deletion wrecked current line fold state
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
#ifdef __vms
+#define LINK_LEXERS
+#endif
+
+#ifdef LINK_LEXERS
// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// Taken from wxWindow's stc.cpp. Walter.
int wxForceScintillaLexers(void) {
+ return Scintilla_LinkLexers();
+}
+
+int Scintilla_LinkLexers() {
extern LexerModule lmAda;
extern LexerModule lmAVE;
+ extern LexerModule lmBaan;
extern LexerModule lmBatch;
extern LexerModule lmConf;
extern LexerModule lmCPP;
extern LexerModule lmLISP;
extern LexerModule lmLua;
extern LexerModule lmMake;
+ extern LexerModule lmMatlab;
extern LexerModule lmPascal;
extern LexerModule lmPerl;
extern LexerModule lmProps;
extern LexerModule lmSQL;
extern LexerModule lmVB;
extern LexerModule lmXML;
+ extern LexerModule lmBullant;
if (
&lmAda
&& &lmAVE
+ && &lmBaan
&& &lmConf
&& &lmDiff
&& &lmLatex
&& &lmProps
&& &lmErrorList
&& &lmMake
+ && &lmMatlab
&& &lmBatch
&& &lmPerl
&& &lmPython
&& &lmLISP
&& &lmLua
&& &lmNull
+ && &lmBullant
)
{
return 1;
styler.StartAt(startPos);
- bool fold = styler.GetPropertyInt("fold");
+ bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
}
-inline bool isAdaOperator(char ch) {
+static inline bool isAdaOperator(char ch) {
if (ch == '&' || ch == '\'' || ch == '(' || ch == ')' ||
ch == '*' || ch == '+' || ch == ',' || ch == '-' ||
--- /dev/null
+// 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);
--- /dev/null
+// 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");
/** @file LexCPP.cxx
** Lexer for C++, C, Java, and Javascript.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
return (ch == '(') || (ch == '=') || (ch == ',');
}
-inline bool IsAWordChar(const int ch) {
+static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
-inline bool IsAWordStart(const int ch) {
+static inline bool IsAWordStart(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
-inline bool IsADoxygenChar(const int ch) {
+static inline bool IsADoxygenChar(const int ch) {
return (islower(ch) || ch == '$' || ch == '@' ||
ch == '\\' || ch == '&' || ch == '<' ||
ch == '>' || ch == '#' || ch == '{' ||
ch == '}' || ch == '[' || ch == ']');
}
-inline bool IsStateComment(const int state) {
+static inline bool IsStateComment(const int state) {
return ((state == SCE_C_COMMENT) ||
(state == SCE_C_COMMENTLINE) ||
(state == SCE_C_COMMENTDOC) ||
(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));
}
WordList &keywords2 = *keywordlists[1];
WordList &keywords3 = *keywordlists[2];
- bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor");
+ bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
// Do not leak onto next line
if (initStyle == SCE_C_STRINGEOL)
int chPrevNonWhite = ' ';
int visibleChars = 0;
- int noDocChars = 0;
bool lastWordWasUUID = false;
StyleContext sc(startPos, length, initStyle, styler);
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
- } else if ((sc.ch == '@' || sc.ch == '\\') && (noDocChars == 0)) {
+ } else if (sc.ch == '@' || sc.ch == '\\') {
sc.SetState(SCE_C_COMMENTDOCKEYWORD);
- } else if (sc.atLineEnd) {
- noDocChars = 0;
- } else if (!isspace(sc.ch) && (sc.ch != '*')) {
- noDocChars++;
}
} else if (sc.state == SCE_C_COMMENTLINE || sc.state == SCE_C_COMMENTLINEDOC) {
if (sc.atLineEnd) {
}
} else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
- noDocChars = 0;
sc.SetState(SCE_C_COMMENTDOC);
} else {
sc.SetState(SCE_C_COMMENT);
static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
Accessor &styler) {
- bool foldComment = styler.GetPropertyInt("fold.comment");
- bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
}
}
+ delete []buffer;
}
LexerModule lmConf(SCLEX_CONF, ColouriseConfDoc, "conf");
break;
}
}
+ delete []buffer;
}
LexerModule lmNncrontab(SCLEX_NNCRONTAB, ColouriseNncrontabDoc, "nncrontab");
#include "Scintilla.h"
#include "SciLexer.h"
-inline bool isEiffelOperator(unsigned int ch) {
+static inline bool isEiffelOperator(unsigned int ch) {
// '.' left out as it is used to make up numbers
return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' ||
ch == '(' || ch == ')' || ch == '=' ||
ch == '!' || ch == '@' || ch == '?';
}
-inline bool IsAWordChar(unsigned int ch) {
+static inline bool IsAWordChar(unsigned int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
-inline bool IsAWordStart(unsigned int ch) {
+static inline bool IsAWordStart(unsigned int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
// Scintilla source code edit control
/** @file LexHTML.cxx
** Lexer for HTML.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+ **/
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include "PropSet.h"
#include "Accessor.h"
+#include "StyleContext.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
#define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
#define SCE_HA_PYTHON (SCE_HPA_START - SCE_HP_START)
-enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
-enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
+enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
+enum script_mode { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
-static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, script_type prevValue) {
char s[30 + 1];
unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) {
return iResult;
}
-static int ScriptOfState(int state) {
+static script_type ScriptOfState(int state) {
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
return eScriptPython;
} else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
return eScriptJS;
} else if ((state >= SCE_HPHP_DEFAULT) && (state <= SCE_HPHP_COMMENTLINE)) {
return eScriptPHP;
- } else if ((state >= SCE_H_SGML_DEFAULT) && (state <= SCE_H_SGML_BLOCK_DEFAULT)) {
+ } else if ((state >= SCE_H_SGML_DEFAULT) && (state < SCE_H_SGML_BLOCK_DEFAULT)) {
return eScriptSGML;
} else if (state == SCE_H_SGML_BLOCK_DEFAULT) {
return eScriptSGMLblock;
}
}
-static int statePrintForState(int state, int inScriptType) {
+static int statePrintForState(int state, script_mode inScriptType) {
int StateToPrint;
if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
}
static void classifyWordHTJS(unsigned int start, unsigned int end,
- WordList &keywords, Accessor &styler, int inScriptType) {
+ WordList &keywords, Accessor &styler, script_mode inScriptType) {
char chAttr = SCE_HJ_WORD;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
styler.ColourTo(end, statePrintForState(chAttr, inScriptType));
}
-static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, int inScriptType) {
+static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) {
char chAttr = SCE_HB_IDENTIFIER;
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
if (wordIsNumber)
return SCE_HB_DEFAULT;
}
-static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, int inScriptType) {
- bool wordIsNumber = isdigit(styler[start]);
+static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) {
+ bool wordIsNumber = isdigit(styler[start]) != 0;
char s[30 + 1];
unsigned int i = 0;
for (; i < end - start + 1 && i < 30; i++) {
// Called when in a PHP word
static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char chAttr = SCE_HPHP_DEFAULT;
- bool wordIsNumber = isdigit(styler[start]);
+ bool wordIsNumber = isdigit(styler[start]) != 0;
if (wordIsNumber)
chAttr = SCE_HPHP_NUMBER;
else {
- char s[30 + 1];
+ char s[100 + 1];
unsigned int i = 0;
- for (; i < end - start + 1 && i < 30; i++) {
- s[i] = styler[start + i];
+ for (; i < end - start + 1 && i < 100; i++) {
+ s[i] = static_cast<char>(tolower(styler[start + i]));
}
s[i] = '\0';
if (keywords.InList(s))
}
// Return the first state to reach when entering a scripting language
-static int StateForScript(int scriptLanguage) {
+static int StateForScript(script_type scriptLanguage) {
int Result;
switch (scriptLanguage) {
case eScriptVBS:
return Result;
}
-inline bool ishtmlwordchar(char ch) {
+static inline bool ishtmlwordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#';
}
-inline bool issgmlwordchar(char ch) {
+static inline bool issgmlwordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[';
}
lineState = eScriptJS << 8;
lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4;
}
- int inScriptType = (lineState >> 0) & 0x03; // 2 bits of scripting type
+ script_mode inScriptType = script_mode((lineState >> 0) & 0x03); // 2 bits of scripting mode
bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag
bool tagClosing = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag
- int aspScript = (lineState >> 4) & 0x0F; // 4 bits of script name
- int clientScript = (lineState >> 8) & 0x0F; // 4 bits of script name
+ script_type aspScript = script_type((lineState >> 4) & 0x0F); // 4 bits of script name
+ script_type clientScript = script_type((lineState >> 8) & 0x0F); // 4 bits of script name
int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state
- int scriptLanguage = ScriptOfState(state);
+ script_type scriptLanguage = ScriptOfState(state);
- const bool foldHTML = styler.GetPropertyInt("fold.html", 0);
+ const bool foldHTML = styler.GetPropertyInt("fold.html", 0) != 0;
const bool fold = foldHTML && styler.GetPropertyInt("fold");
- const bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
+ const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
}
}
break;
+ default:
+ break;
}
}
}
break;
case SCE_H_SGML_DEFAULT:
- if (scriptLanguage == eScriptSGMLblock)
- StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
+ case SCE_H_SGML_BLOCK_DEFAULT:
+// if (scriptLanguage == eScriptSGMLblock)
+// StateToPrint = SCE_H_SGML_BLOCK_DEFAULT;
if (ch == '\"') {
styler.ColourTo(i - 1, StateToPrint);
} else if (ch == '[') {
styler.ColourTo(i - 1, StateToPrint);
scriptLanguage = eScriptSGMLblock;
+ state = SCE_H_SGML_BLOCK_DEFAULT;
} else if (ch == ']') {
if (scriptLanguage == eScriptSGMLblock) {
styler.ColourTo(i, StateToPrint);
styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i, SCE_H_SGML_ERROR);
}
+ state = SCE_H_SGML_DEFAULT;
} else if (scriptLanguage == eScriptSGMLblock) {
if ((ch == '!') && (chPrev == '<')) {
styler.ColourTo(i - 2, StateToPrint);
i += size - 1;
visibleChars += size - 1;
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;
}
break;
}
}
+static bool isASPScript(int state) {
+ return
+ (state >= SCE_HJA_START && state <= SCE_HJA_REGEX) ||
+ (state >= SCE_HBA_START && state <= SCE_HBA_STRINGEOL) ||
+ (state >= SCE_HPA_DEFAULT && state <= SCE_HPA_IDENTIFIER);
+}
+
+static void ColouriseHBAPiece(StyleContext &sc, WordList *keywordlists[]) {
+ WordList &keywordsVBS = *keywordlists[2];
+ if (sc.state == SCE_HBA_WORD) {
+ if (!IsAWordChar(sc.ch)) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywordsVBS.InList(s)) {
+ if (strcmp(s, "rem") == 0) {
+ sc.ChangeState(SCE_HBA_COMMENTLINE);
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else {
+ sc.ChangeState(SCE_HBA_IDENTIFIER);
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+ } else if (sc.state == SCE_HBA_NUMBER) {
+ if (!IsAWordChar(sc.ch)) {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else if (sc.state == SCE_HBA_STRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_HBA_DEFAULT);
+ } else if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.ChangeState(SCE_HBA_STRINGEOL);
+ sc.ForwardSetState(SCE_HBA_DEFAULT);
+ }
+ } else if (sc.state == SCE_HBA_COMMENTLINE) {
+ if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+
+ if (sc.state == SCE_HBA_DEFAULT) {
+ if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ sc.SetState(SCE_HBA_NUMBER);
+ } else if (IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HBA_WORD);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_HBA_COMMENTLINE);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_HBA_STRING);
+ }
+ }
+}
+
+static void ColouriseHTMLPiece(StyleContext &sc, WordList *keywordlists[]) {
+ WordList &keywordsTags = *keywordlists[0];
+ if (sc.state == SCE_H_COMMENT) {
+ if (sc.Match("-->")) {
+ sc.Forward();
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+ } else if (sc.state == SCE_H_ENTITY) {
+ if (sc.ch == ';') {
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch)) { // Should check that '#' follows '&', but it is unlikely anyway...
+ sc.ChangeState(SCE_H_TAGUNKNOWN);
+ sc.SetState(SCE_H_DEFAULT);
+ }
+ } else if (sc.state == SCE_H_TAGUNKNOWN) {
+ if (!ishtmlwordchar(static_cast<char>(sc.ch)) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (s[1] == '/') {
+ if (keywordsTags.InList(s + 2)) {
+ sc.ChangeState(SCE_H_TAG);
+ }
+ } else {
+ if (keywordsTags.InList(s + 1)) {
+ sc.ChangeState(SCE_H_TAG);
+ }
+ }
+ if (sc.ch == '>') {
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.Match('/', '>')) {
+ sc.SetState(SCE_H_TAGEND);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else {
+ sc.SetState(SCE_H_OTHER);
+ }
+ }
+ } else if (sc.state == SCE_H_ATTRIBUTE) {
+ if (!ishtmlwordchar(static_cast<char>(sc.ch))) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (!keywordsTags.InList(s)) {
+ sc.ChangeState(SCE_H_ATTRIBUTEUNKNOWN);
+ }
+ sc.SetState(SCE_H_OTHER);
+ }
+ } else if (sc.state == SCE_H_OTHER) {
+ if (sc.ch == '>') {
+ sc.SetState(SCE_H_TAG);
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.Match('/', '>')) {
+ sc.SetState(SCE_H_TAG);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (sc.chPrev == '=') {
+ sc.SetState(SCE_H_VALUE);
+ }
+ } else if (sc.state == SCE_H_DOUBLESTRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_H_OTHER);
+ }
+ } else if (sc.state == SCE_H_SINGLESTRING) {
+ if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_H_OTHER);
+ }
+ } else if (sc.state == SCE_H_NUMBER) {
+ if (!IsADigit(sc.ch)) {
+ sc.SetState(SCE_H_OTHER);
+ }
+ }
+
+ if (sc.state == SCE_H_DEFAULT) {
+ if (sc.ch == '<') {
+ if (sc.Match("<!--"))
+ sc.SetState(SCE_H_COMMENT);
+ else
+ sc.SetState(SCE_H_TAGUNKNOWN);
+ } else if (sc.ch == '&') {
+ sc.SetState(SCE_H_ENTITY);
+ }
+ } else if ((sc.state == SCE_H_OTHER) || (sc.state == SCE_H_VALUE)) {
+ if (sc.ch == '\"') {
+ sc.SetState(SCE_H_DOUBLESTRING);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_H_SINGLESTRING);
+ } else if (IsADigit(sc.ch)) {
+ sc.SetState(SCE_H_NUMBER);
+ } else if (sc.ch == '>') {
+ sc.SetState(SCE_H_TAG);
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ } else if (ishtmlwordchar(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_H_ATTRIBUTE);
+ }
+ }
+}
+
+static void ColouriseASPPiece(StyleContext &sc, WordList *keywordlists[]) {
+ // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
+ if ((sc.state == SCE_H_ASPAT || isASPScript(sc.state)) && sc.Match('%', '>')) {
+ sc.SetState(SCE_H_ASP);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+
+ // Handle some ASP script
+ if (sc.state >= SCE_HBA_START && sc.state <= SCE_HBA_STRINGEOL) {
+ ColouriseHBAPiece(sc, keywordlists);
+ } else if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) {
+ ColouriseHTMLPiece(sc, keywordlists);
+ }
+
+ // Enter new sc.state
+ if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) {
+ if (sc.Match('<', '%')) {
+ if (sc.state == SCE_H_TAGUNKNOWN)
+ sc.ChangeState(SCE_H_ASP);
+ else
+ sc.SetState(SCE_H_ASP);
+ sc.Forward();
+ sc.Forward();
+ if (sc.ch == '@') {
+ sc.ForwardSetState(SCE_H_ASPAT);
+ } else {
+ if (sc.ch == '=') {
+ sc.Forward();
+ }
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+ }
+}
+
+static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ for (; sc.More(); sc.Forward()) {
+ ColouriseASPPiece(sc, keywordlists);
+ }
+ sc.Complete();
+}
+
+static void ColourisePHPPiece(StyleContext &sc, WordList *keywordlists[]) {
+ // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
+ if (sc.state >= SCE_HPHP_DEFAULT && sc.state <= SCE_HPHP_OPERATOR) {
+ if (!isPHPStringState(sc.state) &&
+ (sc.state != SCE_HPHP_COMMENT) &&
+ (sc.Match('?', '>'))) {
+ sc.SetState(SCE_H_QUESTION);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+ }
+
+ if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) {
+ ColouriseHTMLPiece(sc, keywordlists);
+ }
+
+ // Handle some PHP script
+ if (sc.state == SCE_HPHP_WORD) {
+ if (!IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_COMMENTLINE) {
+ if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_COMMENT) {
+ if (sc.Match('*', '/')) {
+ sc.Forward();
+ sc.Forward();
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_HSTRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_SIMPLESTRING) {
+ if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_VARIABLE) {
+ if (!IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_OPERATOR) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+
+ // Enter new sc.state
+ if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) {
+ if (sc.Match("<?php")) {
+ sc.SetState(SCE_H_QUESTION);
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ }
+ if (sc.state == SCE_HPHP_DEFAULT) {
+ if (IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_WORD);
+ } else if (sc.ch == '#') {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match("<!--")) {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match('/', '/')) {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match('/', '*')) {
+ sc.SetState(SCE_HPHP_COMMENT);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_HPHP_HSTRING);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_HPHP_SIMPLESTRING);
+ } else if (sc.ch == '$') {
+ sc.SetState(SCE_HPHP_VARIABLE);
+ } else if (isoperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_HPHP_OPERATOR);
+ }
+ }
+}
+
+static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ for (; sc.More(); sc.Forward()) {
+ ColourisePHPPiece(sc, keywordlists);
+ }
+ sc.Complete();
+}
+
LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
+LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp");
+LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php");
#include "SciLexer.h"
-inline bool isLispoperator(char ch) {
+static inline bool isLispoperator(char ch) {
if (isascii(ch) && isalnum(ch))
return false;
if (ch == '\'' || ch == '(' || ch == ')' )
return false;
}
-inline bool isLispwordstart(char ch) {
+static inline bool isLispwordstart(char ch) {
return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) &&
ch != '\n' && ch != '\r' && ch != '\"';
}
**
** Written by Paul Winwood.
** Folder by Alexey Yutkin.
+ ** Modified by Marcos E. Wurzius
**/
#include <stdlib.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 == '_');
+}
+
+inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+
inline bool isLuaOperator(char ch) {
if (isalnum(ch))
return false;
// '.' left out as it is used to make up numbers
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 false;
}
-static void classifyWordLua(unsigned int start,
- unsigned int end,
- WordList &keywords,
- Accessor &styler) {
- char s[100];
- bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
-
- for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
- s[i] = styler[start + i];
- s[i + 1] = '\0';
- }
-
- char chAttr = SCE_LUA_IDENTIFIER;
-
- if (wordIsNumber)
- chAttr = SCE_LUA_NUMBER;
- else {
- if (keywords.InList(s)) {
- chAttr = SCE_LUA_WORD;
- }
- }
- styler.ColourTo(end, chAttr);
-}
-static void ColouriseLuaDoc(unsigned int startPos,
- int length,
- int initStyle,
- WordList *keywordlists[],
+static void ColouriseLuaDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
-
- styler.StartAt(startPos);
- styler.GetLine(startPos);
-
- int state = initStyle;
- char chPrev = ' ';
- char chNext = styler[startPos];
- unsigned int lengthDoc = startPos + length;
- bool firstChar = true;
-
- /* Must initialize the literalString level, if we are inside such a string.
- * Note: this isn't enough, because literal strings can be nested,
- * we should go back to see at what level we are...
- */
- int literalString = (initStyle == SCE_LUA_LITERALSTRING) ? 1 : 0;
-
- styler.StartSegment(startPos);
- for (unsigned int i = startPos; i <= lengthDoc; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
-
- if (styler.IsLeadByte(ch)) {
- chNext = styler.SafeGetCharAt(i + 2);
- chPrev = ' ';
- i += 1;
- continue;
- }
-
- if (state == SCE_LUA_STRINGEOL) {
- if (ch != '\r' && ch != '\n') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_DEFAULT;
+ 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;
+
+ // Do not leak onto next line
+ if (initStyle == SCE_LUA_STRINGEOL)
+ initStyle = SCE_LUA_DEFAULT;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+ if(startPos == 0 && sc.ch == '#') sc.SetState(SCE_LUA_COMMENTLINE);
+ for (; sc.More(); sc.Forward()) {
+
+ // Handle line continuation generically.
+ if (sc.ch == '\\') {
+ if (sc.Match("\\\n")) {
+ sc.Forward();
+ sc.Forward();
+ continue;
+ }
+ if (sc.Match("\\\r\n")) {
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ continue;
}
}
- if (state == SCE_LUA_LITERALSTRING && ch == '[' && chNext == '[') {
- literalString++;
- } else if (state == SCE_LUA_DEFAULT) {
- if (ch == '-' && chNext == '-') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_COMMENTLINE;
- } else if (ch == '[' && chNext == '[') {
- state = SCE_LUA_LITERALSTRING;
- literalString = 1;
- } else if (ch == '\"') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_STRING;
- } else if (ch == '\'') {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_CHARACTER;
- } else if (ch == '$' && firstChar) {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_PREPROCESSOR;
- } else if (ch == '#' && firstChar) // Should be only on the first line of the file! Cannot be tested here
- {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_COMMENTLINE;
- } else if (isLuaOperator(ch)) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_LUA_OPERATOR);
- } else if (iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_LUA_WORD;
+ // Determine if the current state should terminate.
+ if (sc.state == SCE_LUA_OPERATOR) {
+ sc.SetState(SCE_LUA_DEFAULT);
+ } else if (sc.state == SCE_LUA_NUMBER) {
+ if (!IsAWordChar(sc.ch)) {
+ sc.SetState(SCE_LUA_DEFAULT);
}
- } else if (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 (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);
}
- } else if (ch == '.' && chNext == '.') {
- classifyWordLua(styler.GetStartSegment(), i - 1, keywords, styler);
- styler.ColourTo(i, SCE_LUA_OPERATOR);
- state = SCE_LUA_DEFAULT;
+ sc.SetState(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);
+
+
+ } 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);
}
-
- if (state == SCE_LUA_DEFAULT) {
- if (ch == '-' && chNext == '-') {
- state = SCE_LUA_COMMENTLINE;
- } else if (ch == '\"') {
- state = SCE_LUA_STRING;
- } else if (ch == '\'') {
- state = SCE_LUA_CHARACTER;
- } else if (ch == '$' && firstChar) {
- state = SCE_LUA_PREPROCESSOR;
- } else if (iswordstart(ch)) {
- state = SCE_LUA_WORD;
- } else if (isLuaOperator(ch)) {
- styler.ColourTo(i, SCE_LUA_OPERATOR);
+
+ } else if (sc.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;
+ } else if (sc.ch == '-' && sc.chNext == '-') {
+ sc.SetState(SCE_LUA_COMMENTLINE);
+ } else if (isLuaOperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_LUA_OPERATOR);
}
}
- chPrev = ch;
- firstChar = (ch == '\r' || ch == '\n');
}
- styler.ColourTo(lengthDoc - 1, state);
+ sc.Complete();
}
+
static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[],
Accessor &styler) {
unsigned int lengthDoc = startPos + length;
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
int styleNext = styler.StyleAt(startPos);
char s[10];
for (unsigned int i = startPos; i < lengthDoc; i++) {
int style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
- if (style == SCE_LUA_WORD)
- if ( ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') {
+ if (style == SCE_LUA_WORD) {
+ if ( ch == 'i' || ch == 'e' || ch == 't' || ch == 'd' || ch == 'f') {
for (unsigned int j = 0; j < 8; j++) {
- if (!iswordchar(styler[i + j])) break;
+ if (!iswordchar(styler[i + j]))
+ break;
s[j] = styler[i + j];
s[j + 1] = '\0';
}
-
- if ((strcmp(s, "then") == 0) || (strcmp(s, "do") == 0)
- || (strcmp(s, "function") == 0))
+
+ if ((strcmp(s, "if") == 0) || (strcmp(s, "do") == 0)
+ || (strcmp(s, "function") == 0))
levelCurrent++;
- if (strcmp(s, "end") == 0) levelCurrent--;
+ if ((strcmp(s, "end") == 0) || (strcmp(s, "elseif") == 0))
+ levelCurrent--;
+
}
-
+ }
+ else if (style == SCE_LUA_OPERATOR)
+ {
+ if(ch == '{' || ch == '(')
+ levelCurrent++;
+ else if(ch == '}' || ch == ')')
+ levelCurrent--;
+ }
+
if (atEOL) {
int lev = levelPrev;
- if (visibleChars == 0)
+ if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
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);
}
--- /dev/null
+// Scintilla source code edit control
+/** @file LexMatlab.cxx
+ ** Lexer for Matlab.
+ ** Written by José 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);
#include "Scintilla.h"
#include "SciLexer.h"
+static inline bool AtEOL(Accessor &styler, unsigned int i) {
+ return (styler[i] == '\n') ||
+ ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
+}
+
static void ColouriseBatchLine(
char *lineBuffer,
unsigned int lengthLine,
unsigned int i = 0;
unsigned int state = SCE_BAT_DEFAULT;
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip initial spaces
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip initial spaces
i++;
}
if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
styler.ColourTo(startLine + i, SCE_BAT_HIDE);
i++;
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) { // Skip next spaces
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip next spaces
i++;
}
}
styler.StartAt(startPos);
styler.StartSegment(startPos);
- unsigned int linePos = 0, startLine = startPos;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ unsigned int linePos = 0;
+ unsigned int startLine = startPos;
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >=
- sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
- if (styler[i + 1] == '\n') {
- lineBuffer[linePos++] = styler[++i];
- }
lineBuffer[linePos] = '\0';
ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
linePos = 0;
startLine = i + 1;
}
}
- if (linePos > 0) {
- ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length,
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
keywords, styler);
}
}
unsigned int linePos = 0;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
+ lineBuffer[linePos] = '\0';
ColouriseDiffLine(lineBuffer, i, styler);
linePos = 0;
}
}
- if (linePos > 0)
- ColouriseDiffLine(lineBuffer, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
+ }
}
static void ColourisePropsLine(
Accessor &styler) {
unsigned int i = 0;
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
i++;
- if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
- styler.ColourTo(endPos, 1);
- } else if (lineBuffer[i] == '[') {
- styler.ColourTo(endPos, 2);
- } else if (lineBuffer[i] == '@') {
- styler.ColourTo(startLine + i, 4);
- if (lineBuffer[++i] == '=')
- styler.ColourTo(startLine + i, 3);
- styler.ColourTo(endPos, 0);
- } 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);
+ if (i < lengthLine) {
+ if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
+ styler.ColourTo(endPos, 1);
+ } else if (lineBuffer[i] == '[') {
+ styler.ColourTo(endPos, 2);
+ } else if (lineBuffer[i] == '@') {
+ styler.ColourTo(startLine + i, 4);
+ if (lineBuffer[++i] == '=')
+ styler.ColourTo(startLine + i, 3);
styler.ColourTo(endPos, 0);
} 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);
}
}
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
- unsigned int linePos = 0, startLine = startPos;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ unsigned int linePos = 0;
+ unsigned int startLine = startPos;
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if ((styler[i] == '\r' && styler.SafeGetCharAt(i + 1) != '\n') ||
- styler[i] == '\n' ||
- (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0;
startLine = i + 1;
}
}
- if (linePos > 0)
- ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
+ }
}
static void ColouriseMakeLine(
unsigned int state = SCE_MAKE_DEFAULT;
bool bSpecial = false;
// Skip initial spaces
- while (isspacechar(lineBuffer[i]) && (i < lengthLine)) {
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
i++;
}
if (lineBuffer[i] == '#') { // Comment
}
if (!bSpecial) {
if (lineBuffer[i] == ':') {
+ // We should check that no colouring was made since the beginning of the line,
+ // to avoid colouring stuff like /OUT:file
styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
- unsigned int linePos = 0, startLine = startPos;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ unsigned int linePos = 0;
+ unsigned int startLine = startPos;
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0;
startLine = i + 1;
}
}
- if (linePos > 0) {
- ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
}
}
// Borland warning message
styler.ColourTo(endPos, SCE_ERR_BORLAND);
} else if (strstr(lineBuffer, "at line " ) &&
- strstr(lineBuffer, "at line " ) < lineBuffer + lengthLine &&
+ (strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
strstr(lineBuffer, "file ") &&
- strstr(lineBuffer, "file ") < lineBuffer + lengthLine) {
+ (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
// Lua error message
styler.ColourTo(endPos, SCE_ERR_LUA);
} else if (strstr(lineBuffer, " at " ) &&
- strstr(lineBuffer, " at " ) < lineBuffer + lengthLine &&
+ (strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
strstr(lineBuffer, " line ") &&
- strstr(lineBuffer, " line ") < lineBuffer + lengthLine) {
+ (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine))) {
// perl error message
styler.ColourTo(endPos, SCE_ERR_PERL);
} else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
// Look for <filename>(line,pos)message
int state = 0;
for (unsigned int i = 0; i < lengthLine; i++) {
- if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
+ if ((state == 0) && (lineBuffer[i] == ':') && isdigit(lineBuffer[i + 1])) {
state = 1;
- } else if (state == 0 && lineBuffer[i] == '(') {
+ } else if ((state == 0) && (lineBuffer[i] == '(')) {
state = 10;
- } else if (state == 1 && isdigit(lineBuffer[i])) {
+ } else if ((state == 1) && isdigit(lineBuffer[i])) {
state = 2;
- } else if (state == 2 && lineBuffer[i] == ':') {
+ } else if ((state == 2) && (lineBuffer[i] == ':')) {
state = 3;
break;
- } else if (state == 2 && !isdigit(lineBuffer[i])) {
+ } else if ((state == 2) && !isdigit(lineBuffer[i])) {
state = 99;
- } else if (state == 10 && isdigit(lineBuffer[i])) {
+ } else if ((state == 10) && isdigit(lineBuffer[i])) {
state = 11;
- } else if (state == 11 && lineBuffer[i] == ',') {
+ } else if ((state == 11) && (lineBuffer[i] == ',')) {
state = 14;
- } else if (state == 11 && lineBuffer[i] == ')') {
+ } else if ((state == 11) && (lineBuffer[i] == ')')) {
state = 12;
- } else if (state == 12 && lineBuffer[i] == ':') {
+ } else if ((state == 12) && (lineBuffer[i] == ':')) {
state = 13;
- } else if (state == 14 && lineBuffer[i] == ')') {
+ } else if ((state == 14) && (lineBuffer[i] == ')')) {
state = 15;
break;
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
- for (unsigned int i = startPos; i <= startPos + length; i++) {
+ for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
- if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
+ if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
+ // End of line (or of line buffer) met, colourise it
+ lineBuffer[linePos] = '\0';
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
linePos = 0;
}
}
- if (linePos > 0)
- ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
+ if (linePos > 0) { // Last line does not have ending characters
+ ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
+ }
}
static int isSpecial(char s) {
#include "Scintilla.h"
#include "SciLexer.h"
-
static int classifyWordPascal(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char s[100];
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
styler.StartAt(startPos);
- bool fold = styler.GetPropertyInt("fold");
+ bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
}
chPrev = ch;
}
- styler.ColourTo(lengthDoc, state);
+ styler.ColourTo(lengthDoc - 1, state);
}
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl");
// Scintilla source code edit control
/** @file LexPython.cxx
** Lexer for Python.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+ **/
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
enum kwType { kwOther, kwClass, kwDef, kwImport };
static bool IsPyComment(Accessor &styler, int pos, int len) {
- return len>0 && styler[pos]=='#';
+ return len > 0 && styler[pos] == '#';
}
static bool IsPyStringStart(int ch, int chNext, int chNext2) {
i++;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
- }
- else if (ch == 'u' || ch == 'U') {
+ } else if (ch == 'u' || ch == 'U') {
if (chNext == 'r' || chNext == 'R')
i += 2;
else
}
}
-inline bool IsAWordChar(int ch) {
+static inline bool IsAWordChar(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
-inline bool IsAWordStart(int ch) {
+static inline bool IsAWordStart(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler) {
int endPos = startPos + length;
int lineCurrent = styler.GetLine(startPos);
if (startPos > 0) {
if (lineCurrent > 0) {
- startPos = styler.LineStart(lineCurrent-1);
+ startPos = styler.LineStart(lineCurrent - 1);
if (startPos == 0)
initStyle = SCE_P_DEFAULT;
else
- initStyle = styler.StyleAt(startPos-1);
+ initStyle = styler.StyleAt(startPos - 1);
}
}
kwType kwLast = kwOther;
int spaceFlags = 0;
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
-
+ bool hexadecimal = false;
+
// Python uses a different mask because bad indentation is marked by oring with 32
- StyleContext sc(startPos, endPos-startPos, initStyle, styler, 0x7f);
-
+ StyleContext sc(startPos, endPos - startPos, initStyle, styler, 0x7f);
+
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
}
if (sc.atLineEnd) {
- if ((sc.state == SCE_P_DEFAULT) ||
- (sc.state == SCE_P_TRIPLE) ||
- (sc.state == SCE_P_TRIPLEDOUBLE)) {
+ if ((sc.state == SCE_P_DEFAULT) ||
+ (sc.state == SCE_P_TRIPLE) ||
+ (sc.state == SCE_P_TRIPLEDOUBLE)) {
// Perform colourisation of white space and triple quoted strings at end of each line to allow
// tab marking to work inside white space and triple quoted strings
sc.ForwardSetState(sc.state);
sc.ChangeState(SCE_P_STRINGEOL);
sc.ForwardSetState(SCE_P_DEFAULT);
}
+ if (!sc.More())
+ break;
}
// Check for a state end
kwLast = kwOther;
sc.SetState(SCE_C_DEFAULT);
} else if (sc.state == SCE_P_NUMBER) {
- if (!IsAWordChar(sc.ch)) {
+ if (!IsAWordChar(sc.ch) &&
+ !(!hexadecimal && ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
sc.SetState(SCE_P_DEFAULT);
}
- } else if (sc.state == SCE_P_WORD) {
+ } else if (sc.state == SCE_P_IDENTIFIER) {
if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) {
char s[100];
sc.GetCurrent(s, sizeof(s));
else
kwLast = kwOther;
} else if (style == SCE_P_CLASSNAME) {
- kwLast = kwOther;
+ kwLast = kwOther;
} else if (style == SCE_P_DEFNAME) {
- kwLast = kwOther;
+ kwLast = kwOther;
}
}
} else if ((sc.state == SCE_P_COMMENTLINE) || (sc.state == SCE_P_COMMENTBLOCK)) {
// Check for a new state starting character
if (sc.state == SCE_P_DEFAULT) {
- if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
+ if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ if (sc.ch == '0' && (sc.chNext == 'x' || sc.chNext == 'X')) {
+ hexadecimal = true;
+ } else {
+ hexadecimal = false;
+ }
+ sc.SetState(SCE_P_NUMBER);
+ } else if (isascii(sc.ch) && isoperator(static_cast<char>(sc.ch)) || sc.ch == '`') {
sc.SetState(SCE_P_OPERATOR);
} else if (sc.ch == '#') {
sc.SetState(sc.chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);
- } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
- sc.SetState(SCE_P_NUMBER);
} else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2))) {
int nextIndex = 0;
sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex));
- while (nextIndex > (sc.currentPos+1)) {
+ while (nextIndex > (sc.currentPos + 1)) {
sc.Forward();
}
} else if (IsAWordStart(sc.ch)) {
- sc.SetState(SCE_P_WORD);
+ sc.SetState(SCE_P_IDENTIFIER);
}
}
}
static bool IsCommentLine(int line, Accessor &styler) {
int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line+1) - 1;
+ int eol_pos = styler.LineStart(line + 1) - 1;
for (int i = pos; i < eol_pos; i++) {
char ch = styler[i];
if (ch == '#')
static bool IsQuoteLine(int line, Accessor &styler) {
int style = styler.StyleAt(styler.LineStart(line)) & 31;
- return ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
+ return ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
}
static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
- WordList *[], Accessor &styler) {
+ WordList *[], Accessor &styler) {
const int maxPos = startPos + length;
- const int maxLines = styler.GetLine(maxPos-1); // Requested last line
+ const int maxLines = styler.GetLine(maxPos - 1); // Requested last line
const int docLines = styler.GetLine(styler.Length() - 1); // Available last line
- const bool foldComment = styler.GetPropertyInt("fold.comment.python");
- const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python");
-
+ const bool foldComment = styler.GetPropertyInt("fold.comment.python") != 0;
+ const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0;
+
// Backtrack to previous non-blank line so we can determine indent level
// for any white space lines (needed esp. within triple quoted strings)
// and so we can fix any preceding fold level (which is why we go back
lineCurrent--;
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) &&
- (!IsCommentLine(lineCurrent, styler)) &&
- (!IsQuoteLine(lineCurrent, styler)))
+ (!IsCommentLine(lineCurrent, styler)) &&
+ (!IsQuoteLine(lineCurrent, styler)))
break;
}
int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
-
+
// Set up initial loop state
startPos = styler.LineStart(lineCurrent);
int prev_state = SCE_P_DEFAULT & 31;
if (lineCurrent >= 1)
- prev_state = styler.StyleAt(startPos-1) & 31;
+ prev_state = styler.StyleAt(startPos - 1) & 31;
int prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
int prevComment = 0;
if (lineCurrent >= 1)
// Information about next line is only available if not at end of document
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
- quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE));
+ quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
}
const int quote_start = (quote && !prevQuote);
const int quote_continue = (quote && prevQuote);
const int comment = foldComment && IsCommentLine(lineCurrent, styler);
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);
if ((!quote || !prevQuote) && !comment)
indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
// than screwing up folding.
const int saveIndentNext = indentNext;
while (!quote &&
- (lineNext < docLines) &&
- ((indentNext & SC_FOLDLEVELWHITEFLAG) ||
- (lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) {
+ (lineNext < docLines) &&
+ ((indentNext & SC_FOLDLEVELWHITEFLAG) ||
+ (lineNext <= docLines && styler[styler.LineStart(lineNext)] == '#'))) {
lineNext++;
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
// 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.
const int skip_level = Platform::Maximum(indentCurrentLevel,
- indentNext & SC_FOLDLEVELNUMBERMASK);
-
+ indentNext & SC_FOLDLEVELNUMBERMASK);
+
// Now set all the indent levels on the lines we skipped
int skipLine = lineCurrent + 1;
int skipIndentNext = saveIndentNext;
skipLine++;
skipIndentNext = styler.IndentAmount(skipLine, &spaceFlags, NULL);
}
-
+
// Set fold header on non-quote/non-comment line
if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
static void ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
char s[100];
- bool wordIsNumber = isdigit(styler[start]);
+ bool wordIsNumber = isdigit(styler[start]) != 0;
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
chPrev = ch;
}
if (state == SCE_P_WORD) {
- ClassifyWordRb(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
+ ClassifyWordRb(styler.GetStartSegment(), lengthDoc-1, keywords, styler, prevWord);
} else {
- styler.ColourTo(lengthDoc, state);
+ styler.ColourTo(lengthDoc-1, state);
}
}
/** @file LexSQL.cxx
** Lexer for SQL.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
styler.StartAt(startPos);
- bool fold = styler.GetPropertyInt("fold");
+ bool fold = styler.GetPropertyInt("fold") != 0;
int lineCurrent = styler.GetLine(startPos);
int spaceFlags = 0;
#include "PropSet.h"
#include "Accessor.h"
+#include "StyleContext.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
-static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
+static bool IsVBComment(Accessor &styler, int pos, int len) {
+ return len>0 && styler[pos]=='\'';
+}
- 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 inline bool IsTypeCharacter(const int ch) {
+ return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$';
}
-static bool IsVBComment(Accessor &styler, int pos, int len) {
- return len>0 && styler[pos]=='\'';
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsADateCharacter(const int ch) {
+ return (ch < 0x80) &&
+ (isalnum(ch) || ch == '|' || ch == '-' || ch == '/' || ch == ':' || ch == ' ' || ch == '\t');
}
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+ WordList *keywordlists[], Accessor &styler, bool vbScriptSyntax) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
int visibleChars = 0;
- int state = initStyle;
- char chNext = styler[startPos];
- styler.StartSegment(startPos);
- int lengthDoc = startPos + length;
- for (int i = startPos; i < lengthDoc; i++) {
- char ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
-
- if (styler.IsLeadByte(ch)) {
- chNext = styler.SafeGetCharAt(i + 2);
- i += 1;
- continue;
- }
-
- if (ch == '\r' || ch == '\n') {
- // End of line
- if (state == SCE_C_COMMENTLINE || state == SCE_C_PREPROCESSOR) {
- styler.ColourTo(i - 1, state);
- state = SCE_C_DEFAULT;
- }
- visibleChars = 0;
- }
- if (!isspacechar(ch))
- visibleChars++;
-
- if (state == SCE_C_DEFAULT) {
- if (iswordstart(ch)) {
- styler.ColourTo(i - 1, state);
- state = SCE_C_WORD;
- } else if (ch == '\'') {
- styler.ColourTo(i - 1, state);
- state = SCE_C_COMMENTLINE;
- } else if (ch == '\"') {
- styler.ColourTo(i - 1, state);
- state = SCE_C_STRING;
- } else if (ch == '#' && visibleChars == 1) {
- // Preprocessor commands are alone on their line
- styler.ColourTo(i - 1, state);
- state = SCE_C_PREPROCESSOR;
- } else if (ch == '&' && tolower(chNext) == 'h') {
- styler.ColourTo(i - 1, state);
- state = SCE_C_WORD;
- } else if (isoperator(ch)) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_C_OPERATOR);
- }
- } else if (state == SCE_C_WORD) {
- if (!iswordchar(ch)) {
- state = classifyWordVB(styler.GetStartSegment(), i - 1, keywords, styler);
- if (state == SCE_C_DEFAULT) {
- if (ch == '\'') {
- state = SCE_C_COMMENTLINE;
- } else if (ch == '\"') {
- state = SCE_C_STRING;
- } else if (isoperator(ch)) {
- styler.ColourTo(i - 1, state);
- styler.ColourTo(i, SCE_C_OPERATOR);
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+
+ if (sc.state == SCE_B_OPERATOR) {
+ sc.SetState(SCE_B_DEFAULT);
+ } else if (sc.state == SCE_B_KEYWORD) {
+ if (!IsAWordChar(sc.ch)) {
+ if (vbScriptSyntax || !IsTypeCharacter(sc.ch)) {
+ if (sc.ch == ']')
+ sc.Forward();
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywords.InList(s)) {
+ if (strcmp(s, "rem") == 0) {
+ sc.ChangeState(SCE_B_COMMENT);
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else {
+ sc.ChangeState(SCE_B_IDENTIFIER);
+ sc.SetState(SCE_B_DEFAULT);
}
}
}
- } else {
- if (state == SCE_C_STRING) {
- // VB doubles quotes to preserve them
- if (ch == '\"') {
- styler.ColourTo(i, state);
- state = SCE_C_DEFAULT;
- i++;
- ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
+ } else if (sc.state == SCE_B_NUMBER) {
+ if (!IsAWordChar(sc.ch)) {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else if (sc.state == SCE_B_STRING) {
+ // VB doubles quotes to preserve them, so just end this string
+ // state now as a following quote will start again
+ if (sc.ch == '\"') {
+ if (tolower(sc.chNext) == 'c') {
+ sc.Forward();
}
+ sc.ForwardSetState(SCE_B_DEFAULT);
+ }
+ } else if (sc.state == SCE_B_COMMENT) {
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_B_DEFAULT);
+ }
+ } else if (sc.state == SCE_B_PREPROCESSOR) {
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_B_DEFAULT);
}
- if (state == SCE_C_DEFAULT) { // One of the above succeeded
- if (ch == '\'') {
- state = SCE_C_COMMENTLINE;
- } else if (ch == '\"') {
- state = SCE_C_STRING;
- } else if (iswordstart(ch)) {
- state = SCE_C_WORD;
+ } else 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) {
- int lengthDoc = startPos + length;
+ int endPos = startPos + length;
// Backtrack to previous line in case need to fix its fold status
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) {
lineCurrent--;
startPos = styler.LineStart(lineCurrent);
- if (startPos == 0)
- initStyle = SCE_P_DEFAULT;
- else
- initStyle = styler.StyleAt(startPos-1);
}
}
- int state = initStyle & 31;
int spaceFlags = 0;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsVBComment);
- if ((state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE))
- indentCurrent |= SC_FOLDLEVELWHITEFLAG;
char chNext = styler[startPos];
- for (int i = startPos; i < lengthDoc; i++) {
+ for (int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
- int style = styler.StyleAt(i) & 31;
- if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
+ if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsVBComment);
- if ((style == SCE_P_TRIPLE) || (style== SCE_P_TRIPLEDOUBLE))
- indentNext |= SC_FOLDLEVELWHITEFLAG;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
}
}
-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);
+
#include "Scintilla.h"
#include "LineMarker.h"
-static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
+static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
PRectangle rc;
rc.left = centreX - armSize;
rc.top = centreY - armSize;
surface->RectangleDraw(rc, back, fore);
}
-static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
+static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
PRectangle rcCircle;
rcCircle.left = centreX - armSize;
rcCircle.top = centreY - armSize;
surface->Ellipse(rcCircle, back, fore);
}
-static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
+static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore);
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
-static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
+static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
rcSmall.bottom = rc.bottom - 2;
surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
- } else if (markType == SC_MARK_EMPTY) {
+ } else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND) {
// An invisible marker so don't draw anything
} else if (markType == SC_MARK_VLINE) {
ColourPair back;
LineMarker() {
markType = SC_MARK_CIRCLE;
- fore = Colour(0,0,0);
- back = Colour(0xff,0xff,0xff);
+ fore = ColourDesired(0,0,0);
+ back = ColourDesired(0xff,0xff,0xff);
}
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
};
/** @file PropSet.cxx
** A Java style properties file module.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// Maintain a dictionary of properties
}
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) {
- while (*a && *b) {
- if (*a != *b) {
- char upperA = MakeUpperCase(*a);
- char upperB = MakeUpperCase(*b);
- if (upperA != upperB)
- return upperA - upperB;
- }
- a++;
- b++;
- }
- // Either *a or *b is nul
- return *a - *b;
+ while (*a && *b) {
+ if (*a != *b) {
+ char upperA = MakeUpperCase(*a);
+ char upperB = MakeUpperCase(*b);
+ if (upperA != upperB)
+ return upperA - upperB;
+ }
+ a++;
+ b++;
+ }
+ // Either *a or *b is nul
+ return *a - *b;
}
int CompareNCaseInsensitive(const char *a, const char *b, int len) {
- while (*a && *b && len) {
- if (*a != *b) {
- char upperA = MakeUpperCase(*a);
- char upperB = MakeUpperCase(*b);
- if (upperA != upperB)
- return upperA - upperB;
- }
- a++;
- b++;
- len--;
- }
- if (len == 0)
- return 0;
- else
- // Either *a or *b is nul
- return *a - *b;
+ while (*a && *b && len) {
+ if (*a != *b) {
+ char upperA = MakeUpperCase(*a);
+ char upperB = MakeUpperCase(*b);
+ if (upperA != upperB)
+ return upperA - upperB;
+ }
+ a++;
+ b++;
+ len--;
+ }
+ if (len == 0)
+ return 0;
+ else
+ // Either *a or *b is nul
+ return *a - *b;
}
-
bool EqualCaseInsensitive(const char *a, const char *b) {
return 0 == CompareCaseInsensitive(a, b);
}
lenVal = strlen(val);
unsigned int hash = HashString(key, lenKey);
for (Property *p = props[hash % hashRoots]; p; p = p->next) {
- if ((hash == p->hash) &&
- ((strlen(p->key) == static_cast<unsigned int>(lenKey)) &&
+ if ((hash == p->hash) &&
+ ((strlen(p->key) == static_cast<unsigned int>(lenKey)) &&
(0 == strncmp(p->key, key, lenKey)))) {
// Replace current value
delete [](p->val);
* The length of the word to compare is passed too.
* Letter case can be ignored or preserved (default).
*/
-const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/) {
+const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */) {
int start = 0; // lower bound of the api array block to search
int end = len - 1; // upper bound of the api array block to search
int pivot; // index of api array element just being compared
pivot = (start + end) >> 1;
word = wordsNoCase[pivot];
cond = CompareNCaseInsensitive(wordStart, word, searchLen);
- if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
- return word; // result must not be freed with free()
+ if (!cond && (!wordCharacters.contains(word[searchLen])))
+ return word; // result must not be freed with free()
else if (cond > 0)
start = pivot + 1;
else if (cond <= 0)
pivot = (start + end) >> 1;
word = words[pivot];
cond = strncmp(wordStart, word, searchLen);
- if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
+ if (!cond && (!wordCharacters.contains(word[searchLen])))
return word; // result must not be freed with free()
else if (cond > 0)
start = pivot + 1;
if (!cond) {
// Find first match
while ((pivot > start) &&
- (0 == CompareNCaseInsensitive(wordStart,
+ (0 == CompareNCaseInsensitive(wordStart,
wordsNoCase[pivot-1], searchLen))) {
--pivot;
}
// Grab each match
while ((pivot <= end) &&
- (0 == CompareNCaseInsensitive(wordStart,
+ (0 == CompareNCaseInsensitive(wordStart,
wordsNoCase[pivot], searchLen))) {
wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1;
wordsNear.append(wordsNoCase[pivot], wordlen, ' ');
if (!cond) {
// Find first match
while ((pivot > start) &&
- (0 == strncmp(wordStart,
- words[pivot-1], searchLen))) {
+ (0 == strncmp(wordStart,
+ words[pivot-1], searchLen))) {
--pivot;
}
// Grab each match
while ((pivot <= end) &&
- (0 == strncmp(wordStart,
- words[pivot], searchLen))) {
+ (0 == strncmp(wordStart,
+ words[pivot], searchLen))) {
wordlen = LengthWord(words[pivot], otherSeparator) + 1;
wordsNear.append(words[pivot], wordlen, ' ');
++pivot;
* Modification history:
*
* $Log$
- * Revision 1.2 2001/10/18 01:24:58 RD
- * Updated to version 1.40 of Scintilla
+ * Revision 1.3 2002/03/18 22:31:00 RD
+ * Updated wxSTC from Scintilla 1.40 to Scintilla 1.45
*
* Revision 1.6 2001/04/29 13:32:10 nyamatongwe
* Addition of new target methods - versions of ReplaceTarget that take counted
/** @file ScintillaBase.cxx
** An enhanced subclass of Editor with calltips, autocomplete and context menu.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
ct.RefreshColourPalette(pal, want);
}
-void ScintillaBase::AddCharUTF(char *s, unsigned int len) {
+void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool acActiveBeforeCharAdded = ac.Active();
if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s))
- Editor::AddCharUTF(s, len);
+ Editor::AddCharUTF(s, len, treatAsDBCS);
if (acActiveBeforeCharAdded)
AutoCompleteChanged(s[0]);
}
AutoCompleteMove(5000);
return 0;
case SCI_DELETEBACK:
- DelCharBack();
+ DelCharBack(true);
+ AutoCompleteChanged();
+ EnsureCaretVisible();
+ return 0;
+ case SCI_DELETEBACKNOTLINE:
+ DelCharBack(false);
AutoCompleteChanged();
EnsureCaretVisible();
return 0;
(iMessage != SCI_CHARRIGHT) &&
(iMessage != SCI_CHARLEFTEXTEND) &&
(iMessage != SCI_EDITTOGGLEOVERTYPE) &&
- (iMessage != SCI_DELETEBACK)
+ (iMessage != SCI_DELETEBACK) &&
+ (iMessage != SCI_DELETEBACKNOTLINE)
) {
ct.CallTipCancel();
}
- if (iMessage == SCI_DELETEBACK) {
+ if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
if (currentPos <= ct.posStartCallTip) {
ct.CallTipCancel();
}
return Editor::KeyCommand(iMessage);
}
+void ScintillaBase::AutoCompleteDoubleClick(void* p) {
+ ScintillaBase* sci = reinterpret_cast<ScintillaBase*>(p);
+ sci->AutoCompleteCompleted();
+}
+
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
//Platform::DebugPrintf("AutoComplete %s\n", list);
ct.CallTipCancel();
pdoc->InsertString(currentPos, list + lenEntered);
SetEmptySelection(currentPos + strlen(list + lenEntered));
}
- return ;
+ return;
}
}
ac.Start(wMain, idAutoComplete, currentPos, lenEntered);
ac.lb.SetPositionRelative(rcac, wMain);
ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font);
ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth);
+ ac.lb.SetDoubleClickAction(AutoCompleteDoubleClick, this);
ac.SetList(list);
scn.lParam = 0;
scn.text = userListSelected.c_str();
NotifyParent(scn);
- return ;
+ return;
}
Position firstPos = ac.posStart - ac.startLen;
- if (currentPos < firstPos)
- return ;
- if (currentPos != firstPos) {
- pdoc->DeleteChars(firstPos, currentPos - firstPos);
+ Position endPos = currentPos;
+ if (ac.dropRestOfWord)
+ endPos = pdoc->ExtendWordSelect(endPos, 1, true);
+ if (endPos < firstPos)
+ return;
+ pdoc->BeginUndoAction();
+ if (endPos != firstPos) {
+ pdoc->DeleteChars(firstPos, endPos - firstPos);
}
SetEmptySelection(ac.posStart);
if (item != -1) {
pdoc->InsertString(firstPos, piece.c_str());
SetEmptySelection(firstPos + piece.length());
}
+ pdoc->EndUndoAction();
}
void ScintillaBase::ContextMenu(Point pt) {
styleStart = styler.StyleAt(start - 1);
styler.SetCodePage(pdoc->dbcsCodePage);
- if (lexCurrent) { // Should always succeed as null lexer should always be available
+ if (lexCurrent && (len > 0)) { // Should always succeed as null lexer should always be available
lexCurrent->Lex(start, len, styleStart, keyWordLists, styler);
styler.Flush();
if (styler.GetPropertyInt("fold")) {
int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);
endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);
Colourise(endStyled, endStyleNeeded);
- return ;
+ return;
}
#endif
Editor::NotifyStyleToNeeded(endStyleNeeded);
break;
case SCI_AUTOCSETCANCELATSTART:
- ac.cancelAtStartPos = wParam;
+ ac.cancelAtStartPos = wParam != 0;
break;
case SCI_AUTOCGETCANCELATSTART:
break;
case SCI_AUTOCSETCHOOSESINGLE:
- ac.chooseSingle = wParam;
+ ac.chooseSingle = wParam != 0;
break;
case SCI_AUTOCGETCHOOSESINGLE:
return ac.chooseSingle;
case SCI_AUTOCSETIGNORECASE:
- ac.ignoreCase = wParam;
+ ac.ignoreCase = wParam != 0;
break;
case SCI_AUTOCGETIGNORECASE:
break;
case SCI_AUTOCSETAUTOHIDE:
- ac.autoHide = wParam;
+ ac.autoHide = wParam != 0;
break;
case SCI_AUTOCGETAUTOHIDE:
return ac.autoHide;
+ case SCI_AUTOCSETDROPRESTOFWORD:
+ ac.dropRestOfWord = wParam != 0;
+ break;
+
+ case SCI_AUTOCGETDROPRESTOFWORD:
+ return ac.dropRestOfWord;
+
case SCI_CALLTIPSHOW: {
AutoCompleteCancel();
if (!ct.wCallTip.Created()) {
PRectangle rc = ct.CallTipStart(currentPos, pt,
reinterpret_cast<char *>(lParam),
vs.styles[STYLE_DEFAULT].fontName,
- vs.styles[STYLE_DEFAULT].sizeZoomed);
+ vs.styles[STYLE_DEFAULT].sizeZoomed,
+ IsUnicodeMode());
// If the call-tip window would be out of the client
// space, adjust so it displays above the text.
PRectangle rcClient = GetClientRectangle();
break;
case SCI_CALLTIPSETBACK:
- ct.colourBG = Colour(wParam);
+ ct.colourBG = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_USEPOPUP:
- displayPopupMenu = wParam;
+ displayPopupMenu = wParam != 0;
break;
#ifdef SCI_LEXER
/** @file ScintillaBase.h
** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef SCINTILLABASE_H
enum {
idCallTip=1,
idAutoComplete=2,
-
+
idcmdUndo=10,
idcmdRedo=11,
idcmdCut=12,
int listType; ///< 0 is an autocomplete list
SString userListSelected; ///< Receives listbox selected string
-
+
#ifdef SCI_LEXER
int lexLanguage;
- LexerModule *lexCurrent;
+ const LexerModule *lexCurrent;
PropSet props;
enum {numWordLists=6};
WordList *keyWordLists[numWordLists+1];
virtual void Finalise() = 0;
virtual void RefreshColourPalette(Palette &pal, bool want);
-
- virtual void AddCharUTF(char *s, unsigned int len);
+
+ virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void Command(int cmdId);
virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage);
-
+
void AutoCompleteStart(int lenEntered, const char *list);
void AutoCompleteCancel();
void AutoCompleteMove(int delta);
void AutoCompleteChanged(char ch=0);
void AutoCompleteCompleted(char fillUp='\0');
void AutoCompleteMoveToCurrentWord();
+ static void AutoCompleteDoubleClick(void* p);
virtual void CreateCallTipWindow(PRectangle rc) = 0;
-
+
virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0;
void ContextMenu(Point pt);
-
+
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
virtual void NotifyStyleToNeeded(int endStyleNeeded);
Style::Style() {
aliasOfDefaultFont = true;
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
- false, false, false, false, caseMixed, true);
+ false, false, false, false, caseMixed, true, true);
}
Style::Style(const Style &source) {
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, 0,
- false, false, false, false, caseMixed, true);
+ false, false, false, false, caseMixed, true, true);
fore.desired = source.fore.desired;
back.desired = source.back.desired;
characterSet = source.characterSet;
underline = source.underline;
caseForce = source.caseForce;
visible = source.visible;
+ changeable = source.changeable;
}
Style::~Style() {
Style &Style::operator=(const Style &source) {
if (this == &source)
return * this;
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, SC_CHARSET_DEFAULT,
- false, false, false, false, caseMixed, true);
+ false, false, false, false, caseMixed, true, true);
fore.desired = source.fore.desired;
back.desired = source.back.desired;
characterSet = source.characterSet;
underline = source.underline;
caseForce = source.caseForce;
visible = source.visible;
+ changeable = source.changeable;
return *this;
}
-void Style::Clear(Colour fore_, Colour back_, int size_,
+void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_,
- bool underline_, ecaseForced caseForce_, bool visible_) {
+ bool underline_, ecaseForced caseForce_,
+ bool visible_, bool changeable_) {
fore.desired = fore_;
back.desired = back_;
characterSet = characterSet_;
underline = underline_;
caseForce = caseForce_;
visible = visible_;
+ changeable = changeable_;
if (aliasOfDefaultFont)
font.SetID(0);
else
source.eolFilled,
source.underline,
source.caseForce,
- source.visible);
+ source.visible,
+ source.changeable);
}
bool Style::EquivalentFontTo(const Style *other) const {
enum ecaseForced {caseMixed, caseUpper, caseLower};
ecaseForced caseForce;
bool visible;
+ bool changeable;
Font font;
int sizeZoomed;
Style(const Style &source);
~Style();
Style &operator=(const Style &source);
- void Clear(Colour fore_, Colour back_,
+ void Clear(ColourDesired fore_, ColourDesired back_,
int size_,
const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_,
- bool underline_, ecaseForced caseForce_, bool visible_);
+ bool underline_, ecaseForced caseForce_,
+ bool visible_, bool changeable_);
void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0);
+ bool IsProtected() { return !(changeable && visible);} ;
};
#endif
styler.ColourTo(currentPos - 1, state);
}
bool More() {
- return currentPos <= endPos;
+ return currentPos < endPos;
}
void Forward() {
- atLineStart = atLineEnd;
- // A lot of this is repeated from the constructor - TODO: merge code
- chPrev = ch;
- currentPos++;
- if (ch >= 0x100)
+ if (currentPos < endPos) {
+ atLineStart = atLineEnd;
+ // A lot of this is repeated from the constructor - TODO: merge code
+ chPrev = ch;
currentPos++;
- ch = chNext;
- chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
- if (styler.IsLeadByte(static_cast<char>(chNext))) {
- chNext = chNext << 8;
- chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
+ if (ch >= 0x100)
+ currentPos++;
+ ch = chNext;
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1));
+ if (styler.IsLeadByte(static_cast<char>(chNext))) {
+ chNext = chNext << 8;
+ chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2));
+ }
+ // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix)
+ // Avoid triggering two times on Dos/Win
+ // End of line
+ 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_) {
state = state_;
}
return true;
}
+ bool MatchIgnoreCase(const char *s) {
+ if (tolower(ch) != *s)
+ return false;
+ s++;
+ if (tolower(chNext) != *s)
+ return false;
+ s++;
+ for (int n=2; *s; n++) {
+ if (*s != tolower((styler.SafeGetCharAt(currentPos+n))))
+ return false;
+ s++;
+ }
+ return true;
+ }
// Non-inline
void GetCurrent(char *s, int len);
void GetCurrentLowered(char *s, int len);
}
unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
-#ifdef USE_API
- return ::MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, tlen);
-#else
unsigned int ui=0;
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
unsigned int i=0;
ui++;
}
return ui;
-#endif
}
ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE;
- indicators[0].fore = Colour(0, 0x7f, 0);
+ indicators[0].fore = ColourDesired(0, 0x7f, 0);
indicators[1].style = INDIC_TT;
- indicators[1].fore = Colour(0, 0, 0xff);
+ indicators[1].fore = ColourDesired(0, 0, 0xff);
indicators[2].style = INDIC_PLAIN;
- indicators[2].fore = Colour(0xff, 0, 0);
+ indicators[2].fore = ColourDesired(0xff, 0, 0);
lineHeight = 1;
maxAscent = 1;
spaceWidth = 8;
selforeset = false;
- selforeground.desired = Colour(0xff, 0, 0);
+ selforeground.desired = ColourDesired(0xff, 0, 0);
selbackset = true;
- selbackground.desired = Colour(0xc0, 0xc0, 0xc0);
- selbackground2.desired = Colour(0xb0, 0xb0, 0xb0);
+ selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+ selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
selbar.desired = Platform::Chrome();
selbarlight.desired = Platform::ChromeHighlight();
- styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0);
+ styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
- caretcolour.desired = Colour(0, 0, 0);
+ caretcolour.desired = ColourDesired(0, 0, 0);
showCaretLineBackground = false;
- caretLineBackground.desired = Colour(0xff, 0xff, 0);
- edgecolour.desired = Colour(0xc0, 0xc0, 0xc0);
+ caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
+ edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
edgeState = EDGE_NONE;
caretWidth = 1;
}
void ViewStyle::ResetDefaultStyle() {
- styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
+ styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
+ ColourDesired(0xff,0xff,0xff),
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT,
- false, false, false, false, Style::caseMixed, true);
+ false, false, false, false, Style::caseMixed, true, true);
}
void ViewStyle::ClearStyles() {
WindowAccessor::~WindowAccessor() {
}
-#if PLAT_WIN
bool WindowAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte.
return false;
else
- return IsDBCSLeadByteEx(codePage, ch);
+ return Platform::IsDBCSLeadByte(codePage, ch);
}
-#else
-// PLAT_GTK or PLAT_WX
-// TODO: support DBCS under GTK+ and WX
-bool WindowAccessor::InternalIsLeadByte(char) {
- return false;
-}
-#endif
void WindowAccessor::Fill(int position) {
if (lenDoc == -1)
#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;
- }
-}
//----------------------------------------------------------------------
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
+// forces the linking of the lexer modules
+int Scintilla_LinkLexers();
+
//----------------------------------------------------------------------
// Constructor and Destructor
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
wxDefaultValidator, name)
{
- wxForceScintillaLexers();
+ Scintilla_LinkLexers();
m_swx = new ScintillaWX(this);
m_stopWatch.Start();
m_lastKeyDownConsumed = FALSE;
}
// Set the symbol used for a particular marker number,
-// and optionally the for and background colours.
+// and optionally the fore and background colours.
void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground,
const wxColour& background) {
SendMsg(2042, markerNumber, wxColourAsLong(back));
}
-// Add a marker to a line.
-void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
- SendMsg(2043, line, markerNumber);
+// Add a marker to a line, returning an ID which can be used to find or delete the marker.
+int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
+ return SendMsg(2043, line, markerNumber);
}
// Delete a marker from a line
return SendMsg(2095, 0, 0) != 0;
}
-// Display the background of the line containing the caret in a different colour.
+// Dsplay the background of the line containing the caret in a different colour.
void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
SendMsg(2096, show, 0);
}
SendMsg(2098, wxColourAsLong(back), 0);
}
+// Set a style to be changeable or not (read only).
+// Experimental feature, currently buggy.
+void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
+ SendMsg(2099, style, changeable);
+}
+
// Display a auto-completion list.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
return SendMsg(2111, 0, 0) != 0;
}
-// Define a set of character that when typed fills up the selected word.
+// Define a set of characters that when typed will cause the autocompletion to
+// choose the selected item.
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
SendMsg(2112, 0, (long)characterSet.c_str());
}
return SendMsg(2119, 0, 0) != 0;
}
+// Set whether or not autocompletion deletes any word characters after the inserted text upon completion
+void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
+ SendMsg(2270, dropRestOfWord, 0);
+}
+
+// Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
+bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
+ return SendMsg(2271, 0, 0) != 0;
+}
+
// Set the number of spaces used for one level of indentation.
void wxStyledTextCtrl::SetIndent(int indentSize) {
SendMsg(2122, indentSize, 0);
return SendMsg(2265, 0, 0);
}
+// Get position of start of word
+int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
+ return SendMsg(2266, pos, onlyWordCharacters);
+}
+
+// Get position of end of word
+int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
+ return SendMsg(2267, pos, onlyWordCharacters);
+}
+
+// Sets whether text is word wrapped
+void wxStyledTextCtrl::SetWrapMode(int mode) {
+ SendMsg(2268, mode, 0);
+}
+
+// Retrieve whether text is word wrapped
+int wxStyledTextCtrl::GetWrapMode() {
+ return SendMsg(2269, 0, 0);
+}
+
+// Sets the degree of caching of layout information
+void wxStyledTextCtrl::SetLayoutCache(int mode) {
+ SendMsg(2272, mode, 0);
+}
+
+// Retrieve the degree of caching of layout information
+int wxStyledTextCtrl::GetLayoutCache() {
+ return SendMsg(2273, 0, 0);
+}
+
+// Delete the selection or if no selection, the character before the caret.
+// Will not delete the chraacter before at the start of a line.
+void wxStyledTextCtrl::DeleteBackNotLine() {
+ SendMsg(2344, 0, 0);
+}
+
// Move the caret inside current view if it's not there already
void wxStyledTextCtrl::MoveCaretInsideView() {
SendMsg(2401, 0, 0);
return SendMsg(2387, 0, 0);
}
+// Change the way control characters are displayed:
+// If symbol is < 32, keep the drawn way, else, use the given character
+void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
+ SendMsg(2388, symbol, 0);
+}
+
+// Get the way control characters are displayed
+int wxStyledTextCtrl::GetControlCharSymbol() {
+ return SendMsg(2389, 0, 0);
+}
+
// Move to the previous change in capitalistion
void wxStyledTextCtrl::WordPartLeft() {
SendMsg(2390, 0, 0);
SendMsg(2396, 0, 0);
}
+// Get and Set the xOffset (ie, horizonal scroll position)
+void wxStyledTextCtrl::SetXOffset(int newOffset) {
+ SendMsg(2397, newOffset, 0);
+}
+int wxStyledTextCtrl::GetXOffset() {
+ return SendMsg(2398, 0, 0);
+}
+
// Start notifying the container of all key presses and commands.
void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0);
evt.SetLength(scn.length);
break;
- case SCN_POSCHANGED:
- evt.SetEventType(wxEVT_STC_POSCHANGED);
- break;
-
case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED);
break;
#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;
- }
-}
//----------------------------------------------------------------------
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
+// forces the linking of the lexer modules
+int Scintilla_LinkLexers();
+
//----------------------------------------------------------------------
// Constructor and Destructor
style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
wxDefaultValidator, name)
{
- wxForceScintillaLexers();
+ Scintilla_LinkLexers();
m_swx = new ScintillaWX(this);
m_stopWatch.Start();
m_lastKeyDownConsumed = FALSE;
evt.SetLength(scn.length);
break;
- case SCN_POSCHANGED:
- evt.SetEventType(wxEVT_STC_POSCHANGED);
- break;
-
case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED);
break;
%(VALUES)s
// END of generated section
-//----------------------------------------------------------------------
-// Others
-
-#define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | \
- (1 << wxSTC_MARKNUM_FOLDEROPEN) | \
- (1 << wxSTC_MARKNUM_FOLDERSUB) | \
- (1 << wxSTC_MARKNUM_FOLDERTAIL) | \
- (1 << wxSTC_MARKNUM_FOLDERMIDTAIL) | \
- (1 << wxSTC_MARKNUM_FOLDEROPENMID) | \
- (1 << wxSTC_MARKNUM_FOLDEREND))
-
-
-
-
//----------------------------------------------------------------------
class ScintillaWX; // forward declare
Added wxBufferedDC.
+Upgraded wxSTC from Scintilla 1.40 to Scintilla 1.45
+
UNICODE!
#define wxStyledTextCtrl_MarkerAdd(_swigobj,_swigarg0,_swigarg1) (_swigobj->MarkerAdd(_swigarg0,_swigarg1))
static PyObject *_wrap_wxStyledTextCtrl_MarkerAdd(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
+ int _result;
wxStyledTextCtrl * _arg0;
int _arg1;
int _arg2;
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
- wxStyledTextCtrl_MarkerAdd(_arg0,_arg1,_arg2);
+ _result = (int )wxStyledTextCtrl_MarkerAdd(_arg0,_arg1,_arg2);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
-} Py_INCREF(Py_None);
- _resultobj = Py_None;
+} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
return _resultobj;
}
+#define wxStyledTextCtrl_StyleSetChangeable(_swigobj,_swigarg0,_swigarg1) (_swigobj->StyleSetChangeable(_swigarg0,_swigarg1))
+static PyObject *_wrap_wxStyledTextCtrl_StyleSetChangeable(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ wxStyledTextCtrl * _arg0;
+ int _arg1;
+ bool _arg2;
+ PyObject * _argo0 = 0;
+ int tempbool2;
+ char *_kwnames[] = { "self","style","changeable", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oii:wxStyledTextCtrl_StyleSetChangeable",_kwnames,&_argo0,&_arg1,&tempbool2))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_StyleSetChangeable. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+ _arg2 = (bool ) tempbool2;
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ wxStyledTextCtrl_StyleSetChangeable(_arg0,_arg1,_arg2);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} Py_INCREF(Py_None);
+ _resultobj = Py_None;
+ return _resultobj;
+}
+
#define wxStyledTextCtrl_AutoCompShow(_swigobj,_swigarg0,_swigarg1) (_swigobj->AutoCompShow(_swigarg0,_swigarg1))
static PyObject *_wrap_wxStyledTextCtrl_AutoCompShow(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
return _resultobj;
}
+#define wxStyledTextCtrl_AutoCompSetDropRestOfWord(_swigobj,_swigarg0) (_swigobj->AutoCompSetDropRestOfWord(_swigarg0))
+static PyObject *_wrap_wxStyledTextCtrl_AutoCompSetDropRestOfWord(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ wxStyledTextCtrl * _arg0;
+ bool _arg1;
+ PyObject * _argo0 = 0;
+ int tempbool1;
+ char *_kwnames[] = { "self","dropRestOfWord", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextCtrl_AutoCompSetDropRestOfWord",_kwnames,&_argo0,&tempbool1))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_AutoCompSetDropRestOfWord. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+ _arg1 = (bool ) tempbool1;
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ wxStyledTextCtrl_AutoCompSetDropRestOfWord(_arg0,_arg1);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} Py_INCREF(Py_None);
+ _resultobj = Py_None;
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_AutoCompGetDropRestOfWord(_swigobj) (_swigobj->AutoCompGetDropRestOfWord())
+static PyObject *_wrap_wxStyledTextCtrl_AutoCompGetDropRestOfWord(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ bool _result;
+ wxStyledTextCtrl * _arg0;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextCtrl_AutoCompGetDropRestOfWord",_kwnames,&_argo0))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_AutoCompGetDropRestOfWord. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ _result = (bool )wxStyledTextCtrl_AutoCompGetDropRestOfWord(_arg0);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} _resultobj = Py_BuildValue("i",_result);
+ return _resultobj;
+}
+
#define wxStyledTextCtrl_SetIndent(_swigobj,_swigarg0) (_swigobj->SetIndent(_swigarg0))
static PyObject *_wrap_wxStyledTextCtrl_SetIndent(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
return _resultobj;
}
+#define wxStyledTextCtrl_WordStartPosition(_swigobj,_swigarg0,_swigarg1) (_swigobj->WordStartPosition(_swigarg0,_swigarg1))
+static PyObject *_wrap_wxStyledTextCtrl_WordStartPosition(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ int _result;
+ wxStyledTextCtrl * _arg0;
+ int _arg1;
+ bool _arg2;
+ PyObject * _argo0 = 0;
+ int tempbool2;
+ char *_kwnames[] = { "self","pos","onlyWordCharacters", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oii:wxStyledTextCtrl_WordStartPosition",_kwnames,&_argo0,&_arg1,&tempbool2))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_WordStartPosition. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+ _arg2 = (bool ) tempbool2;
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ _result = (int )wxStyledTextCtrl_WordStartPosition(_arg0,_arg1,_arg2);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} _resultobj = Py_BuildValue("i",_result);
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_WordEndPosition(_swigobj,_swigarg0,_swigarg1) (_swigobj->WordEndPosition(_swigarg0,_swigarg1))
+static PyObject *_wrap_wxStyledTextCtrl_WordEndPosition(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ int _result;
+ wxStyledTextCtrl * _arg0;
+ int _arg1;
+ bool _arg2;
+ PyObject * _argo0 = 0;
+ int tempbool2;
+ char *_kwnames[] = { "self","pos","onlyWordCharacters", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oii:wxStyledTextCtrl_WordEndPosition",_kwnames,&_argo0,&_arg1,&tempbool2))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_WordEndPosition. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+ _arg2 = (bool ) tempbool2;
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ _result = (int )wxStyledTextCtrl_WordEndPosition(_arg0,_arg1,_arg2);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} _resultobj = Py_BuildValue("i",_result);
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_SetWrapMode(_swigobj,_swigarg0) (_swigobj->SetWrapMode(_swigarg0))
+static PyObject *_wrap_wxStyledTextCtrl_SetWrapMode(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ wxStyledTextCtrl * _arg0;
+ int _arg1;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self","mode", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextCtrl_SetWrapMode",_kwnames,&_argo0,&_arg1))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_SetWrapMode. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ wxStyledTextCtrl_SetWrapMode(_arg0,_arg1);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} Py_INCREF(Py_None);
+ _resultobj = Py_None;
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_GetWrapMode(_swigobj) (_swigobj->GetWrapMode())
+static PyObject *_wrap_wxStyledTextCtrl_GetWrapMode(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ int _result;
+ wxStyledTextCtrl * _arg0;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextCtrl_GetWrapMode",_kwnames,&_argo0))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_GetWrapMode. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ _result = (int )wxStyledTextCtrl_GetWrapMode(_arg0);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} _resultobj = Py_BuildValue("i",_result);
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_SetLayoutCache(_swigobj,_swigarg0) (_swigobj->SetLayoutCache(_swigarg0))
+static PyObject *_wrap_wxStyledTextCtrl_SetLayoutCache(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ wxStyledTextCtrl * _arg0;
+ int _arg1;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self","mode", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextCtrl_SetLayoutCache",_kwnames,&_argo0,&_arg1))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_SetLayoutCache. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ wxStyledTextCtrl_SetLayoutCache(_arg0,_arg1);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} Py_INCREF(Py_None);
+ _resultobj = Py_None;
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_GetLayoutCache(_swigobj) (_swigobj->GetLayoutCache())
+static PyObject *_wrap_wxStyledTextCtrl_GetLayoutCache(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ int _result;
+ wxStyledTextCtrl * _arg0;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextCtrl_GetLayoutCache",_kwnames,&_argo0))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_GetLayoutCache. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ _result = (int )wxStyledTextCtrl_GetLayoutCache(_arg0);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} _resultobj = Py_BuildValue("i",_result);
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_DeleteBackNotLine(_swigobj) (_swigobj->DeleteBackNotLine())
+static PyObject *_wrap_wxStyledTextCtrl_DeleteBackNotLine(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ wxStyledTextCtrl * _arg0;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextCtrl_DeleteBackNotLine",_kwnames,&_argo0))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_DeleteBackNotLine. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ wxStyledTextCtrl_DeleteBackNotLine(_arg0);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} Py_INCREF(Py_None);
+ _resultobj = Py_None;
+ return _resultobj;
+}
+
#define wxStyledTextCtrl_MoveCaretInsideView(_swigobj) (_swigobj->MoveCaretInsideView())
static PyObject *_wrap_wxStyledTextCtrl_MoveCaretInsideView(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
return _resultobj;
}
+#define wxStyledTextCtrl_SetControlCharSymbol(_swigobj,_swigarg0) (_swigobj->SetControlCharSymbol(_swigarg0))
+static PyObject *_wrap_wxStyledTextCtrl_SetControlCharSymbol(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ wxStyledTextCtrl * _arg0;
+ int _arg1;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self","symbol", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextCtrl_SetControlCharSymbol",_kwnames,&_argo0,&_arg1))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_SetControlCharSymbol. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ wxStyledTextCtrl_SetControlCharSymbol(_arg0,_arg1);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} Py_INCREF(Py_None);
+ _resultobj = Py_None;
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_GetControlCharSymbol(_swigobj) (_swigobj->GetControlCharSymbol())
+static PyObject *_wrap_wxStyledTextCtrl_GetControlCharSymbol(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ int _result;
+ wxStyledTextCtrl * _arg0;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextCtrl_GetControlCharSymbol",_kwnames,&_argo0))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_GetControlCharSymbol. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ _result = (int )wxStyledTextCtrl_GetControlCharSymbol(_arg0);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} _resultobj = Py_BuildValue("i",_result);
+ return _resultobj;
+}
+
#define wxStyledTextCtrl_WordPartLeft(_swigobj) (_swigobj->WordPartLeft())
static PyObject *_wrap_wxStyledTextCtrl_WordPartLeft(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
return _resultobj;
}
+#define wxStyledTextCtrl_SetXOffset(_swigobj,_swigarg0) (_swigobj->SetXOffset(_swigarg0))
+static PyObject *_wrap_wxStyledTextCtrl_SetXOffset(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ wxStyledTextCtrl * _arg0;
+ int _arg1;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self","newOffset", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextCtrl_SetXOffset",_kwnames,&_argo0,&_arg1))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_SetXOffset. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ wxStyledTextCtrl_SetXOffset(_arg0,_arg1);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} Py_INCREF(Py_None);
+ _resultobj = Py_None;
+ return _resultobj;
+}
+
+#define wxStyledTextCtrl_GetXOffset(_swigobj) (_swigobj->GetXOffset())
+static PyObject *_wrap_wxStyledTextCtrl_GetXOffset(PyObject *self, PyObject *args, PyObject *kwargs) {
+ PyObject * _resultobj;
+ int _result;
+ wxStyledTextCtrl * _arg0;
+ PyObject * _argo0 = 0;
+ char *_kwnames[] = { "self", NULL };
+
+ self = self;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextCtrl_GetXOffset",_kwnames,&_argo0))
+ return NULL;
+ if (_argo0) {
+ if (_argo0 == Py_None) { _arg0 = NULL; }
+ else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
+ PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_GetXOffset. Expected _wxStyledTextCtrl_p.");
+ return NULL;
+ }
+ }
+{
+ PyThreadState* __tstate = wxPyBeginAllowThreads();
+ _result = (int )wxStyledTextCtrl_GetXOffset(_arg0);
+
+ wxPyEndAllowThreads(__tstate);
+ if (PyErr_Occurred()) return NULL;
+} _resultobj = Py_BuildValue("i",_result);
+ return _resultobj;
+}
+
#define wxStyledTextCtrl_StartRecord(_swigobj) (_swigobj->StartRecord())
static PyObject *_wrap_wxStyledTextCtrl_StartRecord(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
{ "wxStyledTextCtrl_SetLexer", (PyCFunction) _wrap_wxStyledTextCtrl_SetLexer, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_StopRecord", (PyCFunction) _wrap_wxStyledTextCtrl_StopRecord, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_StartRecord", (PyCFunction) _wrap_wxStyledTextCtrl_StartRecord, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_GetXOffset", (PyCFunction) _wrap_wxStyledTextCtrl_GetXOffset, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_SetXOffset", (PyCFunction) _wrap_wxStyledTextCtrl_SetXOffset, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_DelLineRight", (PyCFunction) _wrap_wxStyledTextCtrl_DelLineRight, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_DelLineLeft", (PyCFunction) _wrap_wxStyledTextCtrl_DelLineLeft, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetVisiblePolicy", (PyCFunction) _wrap_wxStyledTextCtrl_SetVisiblePolicy, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_WordPartRight", (PyCFunction) _wrap_wxStyledTextCtrl_WordPartRight, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_WordPartLeftExtend", (PyCFunction) _wrap_wxStyledTextCtrl_WordPartLeftExtend, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_WordPartLeft", (PyCFunction) _wrap_wxStyledTextCtrl_WordPartLeft, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_GetControlCharSymbol", (PyCFunction) _wrap_wxStyledTextCtrl_GetControlCharSymbol, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_SetControlCharSymbol", (PyCFunction) _wrap_wxStyledTextCtrl_SetControlCharSymbol, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetCursor", (PyCFunction) _wrap_wxStyledTextCtrl_GetCursor, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetCursor", (PyCFunction) _wrap_wxStyledTextCtrl_SetCursor, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetMouseDownCaptures", (PyCFunction) _wrap_wxStyledTextCtrl_GetMouseDownCaptures, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_BraceHighlight", (PyCFunction) _wrap_wxStyledTextCtrl_BraceHighlight, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_LineLength", (PyCFunction) _wrap_wxStyledTextCtrl_LineLength, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_MoveCaretInsideView", (PyCFunction) _wrap_wxStyledTextCtrl_MoveCaretInsideView, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_DeleteBackNotLine", (PyCFunction) _wrap_wxStyledTextCtrl_DeleteBackNotLine, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_GetLayoutCache", (PyCFunction) _wrap_wxStyledTextCtrl_GetLayoutCache, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_SetLayoutCache", (PyCFunction) _wrap_wxStyledTextCtrl_SetLayoutCache, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_GetWrapMode", (PyCFunction) _wrap_wxStyledTextCtrl_GetWrapMode, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_SetWrapMode", (PyCFunction) _wrap_wxStyledTextCtrl_SetWrapMode, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_WordEndPosition", (PyCFunction) _wrap_wxStyledTextCtrl_WordEndPosition, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_WordStartPosition", (PyCFunction) _wrap_wxStyledTextCtrl_WordStartPosition, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetMouseDwellTime", (PyCFunction) _wrap_wxStyledTextCtrl_GetMouseDwellTime, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetMouseDwellTime", (PyCFunction) _wrap_wxStyledTextCtrl_SetMouseDwellTime, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetBackSpaceUnIndents", (PyCFunction) _wrap_wxStyledTextCtrl_GetBackSpaceUnIndents, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetUseTabs", (PyCFunction) _wrap_wxStyledTextCtrl_SetUseTabs, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetIndent", (PyCFunction) _wrap_wxStyledTextCtrl_GetIndent, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetIndent", (PyCFunction) _wrap_wxStyledTextCtrl_SetIndent, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_AutoCompGetDropRestOfWord", (PyCFunction) _wrap_wxStyledTextCtrl_AutoCompGetDropRestOfWord, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_AutoCompSetDropRestOfWord", (PyCFunction) _wrap_wxStyledTextCtrl_AutoCompSetDropRestOfWord, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_AutoCompGetAutoHide", (PyCFunction) _wrap_wxStyledTextCtrl_AutoCompGetAutoHide, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_AutoCompSetAutoHide", (PyCFunction) _wrap_wxStyledTextCtrl_AutoCompSetAutoHide, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_UserListShow", (PyCFunction) _wrap_wxStyledTextCtrl_UserListShow, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_AutoCompActive", (PyCFunction) _wrap_wxStyledTextCtrl_AutoCompActive, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_AutoCompCancel", (PyCFunction) _wrap_wxStyledTextCtrl_AutoCompCancel, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_AutoCompShow", (PyCFunction) _wrap_wxStyledTextCtrl_AutoCompShow, METH_VARARGS | METH_KEYWORDS },
+ { "wxStyledTextCtrl_StyleSetChangeable", (PyCFunction) _wrap_wxStyledTextCtrl_StyleSetChangeable, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetCaretLineBack", (PyCFunction) _wrap_wxStyledTextCtrl_SetCaretLineBack, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetCaretLineBack", (PyCFunction) _wrap_wxStyledTextCtrl_GetCaretLineBack, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetCaretLineVisible", (PyCFunction) _wrap_wxStyledTextCtrl_SetCaretLineVisible, METH_VARARGS | METH_KEYWORDS },
PyDict_SetItemString(d,"wxSTC_MARK_CIRCLEPLUSCONNECTED", PyInt_FromLong((long) 19));
PyDict_SetItemString(d,"wxSTC_MARK_CIRCLEMINUS", PyInt_FromLong((long) 20));
PyDict_SetItemString(d,"wxSTC_MARK_CIRCLEMINUSCONNECTED", PyInt_FromLong((long) 21));
+ PyDict_SetItemString(d,"wxSTC_MARK_BACKGROUND", PyInt_FromLong((long) 22));
PyDict_SetItemString(d,"wxSTC_MARK_CHARACTER", PyInt_FromLong((long) 10000));
PyDict_SetItemString(d,"wxSTC_MARKNUM_FOLDEREND", PyInt_FromLong((long) 25));
PyDict_SetItemString(d,"wxSTC_MARKNUM_FOLDEROPENMID", PyInt_FromLong((long) 26));
PyDict_SetItemString(d,"wxSTC_MARKNUM_FOLDERSUB", PyInt_FromLong((long) 29));
PyDict_SetItemString(d,"wxSTC_MARKNUM_FOLDER", PyInt_FromLong((long) 30));
PyDict_SetItemString(d,"wxSTC_MARKNUM_FOLDEROPEN", PyInt_FromLong((long) 31));
+ PyDict_SetItemString(d,"wxSTC_MASK_FOLDERS", PyInt_FromLong((long) 0xFE000000));
PyDict_SetItemString(d,"wxSTC_MARGIN_SYMBOL", PyInt_FromLong((long) 0));
PyDict_SetItemString(d,"wxSTC_MARGIN_NUMBER", PyInt_FromLong((long) 1));
PyDict_SetItemString(d,"wxSTC_STYLE_DEFAULT", PyInt_FromLong((long) 32));
PyDict_SetItemString(d,"wxSTC_INDIC_TT", PyInt_FromLong((long) 2));
PyDict_SetItemString(d,"wxSTC_INDIC_DIAGONAL", PyInt_FromLong((long) 3));
PyDict_SetItemString(d,"wxSTC_INDIC_STRIKE", PyInt_FromLong((long) 4));
- PyDict_SetItemString(d,"wxSTC_INDIC0_MASK", PyInt_FromLong((long) 32));
- PyDict_SetItemString(d,"wxSTC_INDIC1_MASK", PyInt_FromLong((long) 64));
- PyDict_SetItemString(d,"wxSTC_INDIC2_MASK", PyInt_FromLong((long) 128));
- PyDict_SetItemString(d,"wxSTC_INDICS_MASK", PyInt_FromLong((long) 224));
+ PyDict_SetItemString(d,"wxSTC_INDIC0_MASK", PyInt_FromLong((long) 0x20));
+ PyDict_SetItemString(d,"wxSTC_INDIC1_MASK", PyInt_FromLong((long) 0x40));
+ PyDict_SetItemString(d,"wxSTC_INDIC2_MASK", PyInt_FromLong((long) 0x80));
+ PyDict_SetItemString(d,"wxSTC_INDICS_MASK", PyInt_FromLong((long) 0xE0));
PyDict_SetItemString(d,"wxSTC_PRINT_NORMAL", PyInt_FromLong((long) 0));
PyDict_SetItemString(d,"wxSTC_PRINT_INVERTLIGHT", PyInt_FromLong((long) 1));
PyDict_SetItemString(d,"wxSTC_PRINT_BLACKONWHITE", PyInt_FromLong((long) 2));
PyDict_SetItemString(d,"wxSTC_FOLDLEVELHEADERFLAG", PyInt_FromLong((long) 0x2000));
PyDict_SetItemString(d,"wxSTC_FOLDLEVELNUMBERMASK", PyInt_FromLong((long) 0x0FFF));
PyDict_SetItemString(d,"wxSTC_TIME_FOREVER", PyInt_FromLong((long) 10000000));
+ PyDict_SetItemString(d,"wxSTC_WRAP_NONE", PyInt_FromLong((long) 0));
+ PyDict_SetItemString(d,"wxSTC_WRAP_WORD", PyInt_FromLong((long) 1));
+ PyDict_SetItemString(d,"wxSTC_CACHE_NONE", PyInt_FromLong((long) 0));
+ PyDict_SetItemString(d,"wxSTC_CACHE_CARET", PyInt_FromLong((long) 1));
+ PyDict_SetItemString(d,"wxSTC_CACHE_PAGE", PyInt_FromLong((long) 2));
+ PyDict_SetItemString(d,"wxSTC_CACHE_DOCUMENT", PyInt_FromLong((long) 3));
PyDict_SetItemString(d,"wxSTC_CMD_LINEDOWN", PyInt_FromLong((long) 2300));
PyDict_SetItemString(d,"wxSTC_CMD_LINEDOWNEXTEND", PyInt_FromLong((long) 2301));
PyDict_SetItemString(d,"wxSTC_CMD_LINEUP", PyInt_FromLong((long) 2302));
PyDict_SetItemString(d,"wxSTC_CMD_UPPERCASE", PyInt_FromLong((long) 2341));
PyDict_SetItemString(d,"wxSTC_CMD_LINESCROLLDOWN", PyInt_FromLong((long) 2342));
PyDict_SetItemString(d,"wxSTC_CMD_LINESCROLLUP", PyInt_FromLong((long) 2343));
+ PyDict_SetItemString(d,"wxSTC_CMD_DELETEBACKNOTLINE", PyInt_FromLong((long) 2344));
PyDict_SetItemString(d,"wxSTC_EDGE_NONE", PyInt_FromLong((long) 0));
PyDict_SetItemString(d,"wxSTC_EDGE_LINE", PyInt_FromLong((long) 1));
PyDict_SetItemString(d,"wxSTC_EDGE_BACKGROUND", PyInt_FromLong((long) 2));
PyDict_SetItemString(d,"wxSTC_LEX_EIFFELKW", PyInt_FromLong((long) 24));
PyDict_SetItemString(d,"wxSTC_LEX_TCL", PyInt_FromLong((long) 25));
PyDict_SetItemString(d,"wxSTC_LEX_NNCRONTAB", PyInt_FromLong((long) 26));
+ PyDict_SetItemString(d,"wxSTC_LEX_BULLANT", PyInt_FromLong((long) 27));
+ PyDict_SetItemString(d,"wxSTC_LEX_VBSCRIPT", PyInt_FromLong((long) 28));
+ PyDict_SetItemString(d,"wxSTC_LEX_ASP", PyInt_FromLong((long) 29));
+ PyDict_SetItemString(d,"wxSTC_LEX_PHP", PyInt_FromLong((long) 30));
+ PyDict_SetItemString(d,"wxSTC_LEX_BAAN", PyInt_FromLong((long) 31));
+ PyDict_SetItemString(d,"wxSTC_LEX_MATLAB", PyInt_FromLong((long) 32));
PyDict_SetItemString(d,"wxSTC_LEX_AUTOMATIC", PyInt_FromLong((long) 1000));
PyDict_SetItemString(d,"wxSTC_P_DEFAULT", PyInt_FromLong((long) 0));
PyDict_SetItemString(d,"wxSTC_P_COMMENTLINE", PyInt_FromLong((long) 1));
PyDict_SetItemString(d,"wxSTC_C_WORD2", PyInt_FromLong((long) 16));
PyDict_SetItemString(d,"wxSTC_C_COMMENTDOCKEYWORD", PyInt_FromLong((long) 17));
PyDict_SetItemString(d,"wxSTC_C_COMMENTDOCKEYWORDERROR", PyInt_FromLong((long) 18));
+ PyDict_SetItemString(d,"wxSTC_B_DEFAULT", PyInt_FromLong((long) 0));
+ PyDict_SetItemString(d,"wxSTC_B_COMMENT", PyInt_FromLong((long) 1));
+ PyDict_SetItemString(d,"wxSTC_B_NUMBER", PyInt_FromLong((long) 2));
+ PyDict_SetItemString(d,"wxSTC_B_KEYWORD", PyInt_FromLong((long) 3));
+ PyDict_SetItemString(d,"wxSTC_B_STRING", PyInt_FromLong((long) 4));
+ PyDict_SetItemString(d,"wxSTC_B_PREPROCESSOR", PyInt_FromLong((long) 5));
+ PyDict_SetItemString(d,"wxSTC_B_OPERATOR", PyInt_FromLong((long) 6));
+ PyDict_SetItemString(d,"wxSTC_B_IDENTIFIER", PyInt_FromLong((long) 7));
+ PyDict_SetItemString(d,"wxSTC_B_DATE", PyInt_FromLong((long) 8));
PyDict_SetItemString(d,"wxSTC_H_DEFAULT", PyInt_FromLong((long) 0));
PyDict_SetItemString(d,"wxSTC_H_TAG", PyInt_FromLong((long) 1));
PyDict_SetItemString(d,"wxSTC_H_TAGUNKNOWN", PyInt_FromLong((long) 2));
PyDict_SetItemString(d,"wxSTC_LUA_OPERATOR", PyInt_FromLong((long) 10));
PyDict_SetItemString(d,"wxSTC_LUA_IDENTIFIER", PyInt_FromLong((long) 11));
PyDict_SetItemString(d,"wxSTC_LUA_STRINGEOL", PyInt_FromLong((long) 12));
+ PyDict_SetItemString(d,"wxSTC_LUA_WORD2", PyInt_FromLong((long) 13));
+ PyDict_SetItemString(d,"wxSTC_LUA_WORD3", PyInt_FromLong((long) 14));
+ PyDict_SetItemString(d,"wxSTC_LUA_WORD4", PyInt_FromLong((long) 15));
+ PyDict_SetItemString(d,"wxSTC_LUA_WORD5", PyInt_FromLong((long) 16));
+ PyDict_SetItemString(d,"wxSTC_LUA_WORD6", PyInt_FromLong((long) 17));
PyDict_SetItemString(d,"wxSTC_ERR_DEFAULT", PyInt_FromLong((long) 0));
PyDict_SetItemString(d,"wxSTC_ERR_PYTHON", PyInt_FromLong((long) 1));
PyDict_SetItemString(d,"wxSTC_ERR_GCC", PyInt_FromLong((long) 2));
PyDict_SetItemString(d,"wxSTC_ADA_OPERATOR", PyInt_FromLong((long) 6));
PyDict_SetItemString(d,"wxSTC_ADA_IDENTIFIER", PyInt_FromLong((long) 7));
PyDict_SetItemString(d,"wxSTC_ADA_STRINGEOL", PyInt_FromLong((long) 8));
+ PyDict_SetItemString(d,"wxSTC_BAAN_DEFAULT", PyInt_FromLong((long) 0));
+ PyDict_SetItemString(d,"wxSTC_BAAN_COMMENT", PyInt_FromLong((long) 1));
+ PyDict_SetItemString(d,"wxSTC_BAAN_COMMENTDOC", PyInt_FromLong((long) 2));
+ PyDict_SetItemString(d,"wxSTC_BAAN_NUMBER", PyInt_FromLong((long) 3));
+ PyDict_SetItemString(d,"wxSTC_BAAN_WORD", PyInt_FromLong((long) 4));
+ PyDict_SetItemString(d,"wxSTC_BAAN_STRING", PyInt_FromLong((long) 5));
+ PyDict_SetItemString(d,"wxSTC_BAAN_PREPROCESSOR", PyInt_FromLong((long) 6));
+ PyDict_SetItemString(d,"wxSTC_BAAN_OPERATOR", PyInt_FromLong((long) 7));
+ PyDict_SetItemString(d,"wxSTC_BAAN_IDENTIFIER", PyInt_FromLong((long) 8));
+ PyDict_SetItemString(d,"wxSTC_BAAN_STRINGEOL", PyInt_FromLong((long) 9));
+ PyDict_SetItemString(d,"wxSTC_BAAN_WORD2", PyInt_FromLong((long) 10));
PyDict_SetItemString(d,"wxSTC_LISP_DEFAULT", PyInt_FromLong((long) 0));
PyDict_SetItemString(d,"wxSTC_LISP_COMMENT", PyInt_FromLong((long) 1));
PyDict_SetItemString(d,"wxSTC_LISP_NUMBER", PyInt_FromLong((long) 2));
PyDict_SetItemString(d,"wxSTC_NNCRONTAB_STRING", PyInt_FromLong((long) 8));
PyDict_SetItemString(d,"wxSTC_NNCRONTAB_ENVIRONMENT", PyInt_FromLong((long) 9));
PyDict_SetItemString(d,"wxSTC_NNCRONTAB_IDENTIFIER", PyInt_FromLong((long) 10));
- PyDict_SetItemString(d,"wxSTC_MASK_FOLDERS", PyInt_FromLong((long) ((1<<(30))|(1<<(31))|(1<<(29))|(1<<(28))|(1<<(27))|(1<<(26))|(1<<(25)))));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_DEFAULT", PyInt_FromLong((long) 0));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_COMMENT", PyInt_FromLong((long) 1));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_COMMAND", PyInt_FromLong((long) 2));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_NUMBER", PyInt_FromLong((long) 3));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_KEYWORD", PyInt_FromLong((long) 4));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_STRING", PyInt_FromLong((long) 5));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_OPERATOR", PyInt_FromLong((long) 6));
+ PyDict_SetItemString(d,"wxSTC_MATLAB_IDENTIFIER", PyInt_FromLong((long) 7));
PyDict_SetItemString(d,"wxSTCNameStr", PyString_FromString("wxSTCNameStr"));
PyDict_SetItemString(d,"wxEVT_STC_CHANGE", PyInt_FromLong((long) wxEVT_STC_CHANGE));
PyDict_SetItemString(d,"wxEVT_STC_STYLENEEDED", PyInt_FromLong((long) wxEVT_STC_STYLENEEDED));
def SetCaretLineBack(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_SetCaretLineBack,(self,) + _args, _kwargs)
return val
+ def StyleSetChangeable(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_StyleSetChangeable,(self,) + _args, _kwargs)
+ return val
def AutoCompShow(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_AutoCompShow,(self,) + _args, _kwargs)
return val
def AutoCompGetAutoHide(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_AutoCompGetAutoHide,(self,) + _args, _kwargs)
return val
+ def AutoCompSetDropRestOfWord(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_AutoCompSetDropRestOfWord,(self,) + _args, _kwargs)
+ return val
+ def AutoCompGetDropRestOfWord(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_AutoCompGetDropRestOfWord,(self,) + _args, _kwargs)
+ return val
def SetIndent(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_SetIndent,(self,) + _args, _kwargs)
return val
def GetMouseDwellTime(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_GetMouseDwellTime,(self,) + _args, _kwargs)
return val
+ def WordStartPosition(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_WordStartPosition,(self,) + _args, _kwargs)
+ return val
+ def WordEndPosition(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_WordEndPosition,(self,) + _args, _kwargs)
+ return val
+ def SetWrapMode(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_SetWrapMode,(self,) + _args, _kwargs)
+ return val
+ def GetWrapMode(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_GetWrapMode,(self,) + _args, _kwargs)
+ return val
+ def SetLayoutCache(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_SetLayoutCache,(self,) + _args, _kwargs)
+ return val
+ def GetLayoutCache(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_GetLayoutCache,(self,) + _args, _kwargs)
+ return val
+ def DeleteBackNotLine(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_DeleteBackNotLine,(self,) + _args, _kwargs)
+ return val
def MoveCaretInsideView(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_MoveCaretInsideView,(self,) + _args, _kwargs)
return val
def GetCursor(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_GetCursor,(self,) + _args, _kwargs)
return val
+ def SetControlCharSymbol(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_SetControlCharSymbol,(self,) + _args, _kwargs)
+ return val
+ def GetControlCharSymbol(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_GetControlCharSymbol,(self,) + _args, _kwargs)
+ return val
def WordPartLeft(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_WordPartLeft,(self,) + _args, _kwargs)
return val
def DelLineRight(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_DelLineRight,(self,) + _args, _kwargs)
return val
+ def SetXOffset(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_SetXOffset,(self,) + _args, _kwargs)
+ return val
+ def GetXOffset(self, *_args, **_kwargs):
+ val = apply(stc_c.wxStyledTextCtrl_GetXOffset,(self,) + _args, _kwargs)
+ return val
def StartRecord(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_StartRecord,(self,) + _args, _kwargs)
return val
wxSTC_MARK_CIRCLEPLUSCONNECTED = stc_c.wxSTC_MARK_CIRCLEPLUSCONNECTED
wxSTC_MARK_CIRCLEMINUS = stc_c.wxSTC_MARK_CIRCLEMINUS
wxSTC_MARK_CIRCLEMINUSCONNECTED = stc_c.wxSTC_MARK_CIRCLEMINUSCONNECTED
+wxSTC_MARK_BACKGROUND = stc_c.wxSTC_MARK_BACKGROUND
wxSTC_MARK_CHARACTER = stc_c.wxSTC_MARK_CHARACTER
wxSTC_MARKNUM_FOLDEREND = stc_c.wxSTC_MARKNUM_FOLDEREND
wxSTC_MARKNUM_FOLDEROPENMID = stc_c.wxSTC_MARKNUM_FOLDEROPENMID
wxSTC_MARKNUM_FOLDERSUB = stc_c.wxSTC_MARKNUM_FOLDERSUB
wxSTC_MARKNUM_FOLDER = stc_c.wxSTC_MARKNUM_FOLDER
wxSTC_MARKNUM_FOLDEROPEN = stc_c.wxSTC_MARKNUM_FOLDEROPEN
+wxSTC_MASK_FOLDERS = stc_c.wxSTC_MASK_FOLDERS
wxSTC_MARGIN_SYMBOL = stc_c.wxSTC_MARGIN_SYMBOL
wxSTC_MARGIN_NUMBER = stc_c.wxSTC_MARGIN_NUMBER
wxSTC_STYLE_DEFAULT = stc_c.wxSTC_STYLE_DEFAULT
wxSTC_FOLDLEVELHEADERFLAG = stc_c.wxSTC_FOLDLEVELHEADERFLAG
wxSTC_FOLDLEVELNUMBERMASK = stc_c.wxSTC_FOLDLEVELNUMBERMASK
wxSTC_TIME_FOREVER = stc_c.wxSTC_TIME_FOREVER
+wxSTC_WRAP_NONE = stc_c.wxSTC_WRAP_NONE
+wxSTC_WRAP_WORD = stc_c.wxSTC_WRAP_WORD
+wxSTC_CACHE_NONE = stc_c.wxSTC_CACHE_NONE
+wxSTC_CACHE_CARET = stc_c.wxSTC_CACHE_CARET
+wxSTC_CACHE_PAGE = stc_c.wxSTC_CACHE_PAGE
+wxSTC_CACHE_DOCUMENT = stc_c.wxSTC_CACHE_DOCUMENT
wxSTC_CMD_LINEDOWN = stc_c.wxSTC_CMD_LINEDOWN
wxSTC_CMD_LINEDOWNEXTEND = stc_c.wxSTC_CMD_LINEDOWNEXTEND
wxSTC_CMD_LINEUP = stc_c.wxSTC_CMD_LINEUP
wxSTC_CMD_UPPERCASE = stc_c.wxSTC_CMD_UPPERCASE
wxSTC_CMD_LINESCROLLDOWN = stc_c.wxSTC_CMD_LINESCROLLDOWN
wxSTC_CMD_LINESCROLLUP = stc_c.wxSTC_CMD_LINESCROLLUP
+wxSTC_CMD_DELETEBACKNOTLINE = stc_c.wxSTC_CMD_DELETEBACKNOTLINE
wxSTC_EDGE_NONE = stc_c.wxSTC_EDGE_NONE
wxSTC_EDGE_LINE = stc_c.wxSTC_EDGE_LINE
wxSTC_EDGE_BACKGROUND = stc_c.wxSTC_EDGE_BACKGROUND
wxSTC_LEX_EIFFELKW = stc_c.wxSTC_LEX_EIFFELKW
wxSTC_LEX_TCL = stc_c.wxSTC_LEX_TCL
wxSTC_LEX_NNCRONTAB = stc_c.wxSTC_LEX_NNCRONTAB
+wxSTC_LEX_BULLANT = stc_c.wxSTC_LEX_BULLANT
+wxSTC_LEX_VBSCRIPT = stc_c.wxSTC_LEX_VBSCRIPT
+wxSTC_LEX_ASP = stc_c.wxSTC_LEX_ASP
+wxSTC_LEX_PHP = stc_c.wxSTC_LEX_PHP
+wxSTC_LEX_BAAN = stc_c.wxSTC_LEX_BAAN
+wxSTC_LEX_MATLAB = stc_c.wxSTC_LEX_MATLAB
wxSTC_LEX_AUTOMATIC = stc_c.wxSTC_LEX_AUTOMATIC
wxSTC_P_DEFAULT = stc_c.wxSTC_P_DEFAULT
wxSTC_P_COMMENTLINE = stc_c.wxSTC_P_COMMENTLINE
wxSTC_C_WORD2 = stc_c.wxSTC_C_WORD2
wxSTC_C_COMMENTDOCKEYWORD = stc_c.wxSTC_C_COMMENTDOCKEYWORD
wxSTC_C_COMMENTDOCKEYWORDERROR = stc_c.wxSTC_C_COMMENTDOCKEYWORDERROR
+wxSTC_B_DEFAULT = stc_c.wxSTC_B_DEFAULT
+wxSTC_B_COMMENT = stc_c.wxSTC_B_COMMENT
+wxSTC_B_NUMBER = stc_c.wxSTC_B_NUMBER
+wxSTC_B_KEYWORD = stc_c.wxSTC_B_KEYWORD
+wxSTC_B_STRING = stc_c.wxSTC_B_STRING
+wxSTC_B_PREPROCESSOR = stc_c.wxSTC_B_PREPROCESSOR
+wxSTC_B_OPERATOR = stc_c.wxSTC_B_OPERATOR
+wxSTC_B_IDENTIFIER = stc_c.wxSTC_B_IDENTIFIER
+wxSTC_B_DATE = stc_c.wxSTC_B_DATE
wxSTC_H_DEFAULT = stc_c.wxSTC_H_DEFAULT
wxSTC_H_TAG = stc_c.wxSTC_H_TAG
wxSTC_H_TAGUNKNOWN = stc_c.wxSTC_H_TAGUNKNOWN
wxSTC_LUA_OPERATOR = stc_c.wxSTC_LUA_OPERATOR
wxSTC_LUA_IDENTIFIER = stc_c.wxSTC_LUA_IDENTIFIER
wxSTC_LUA_STRINGEOL = stc_c.wxSTC_LUA_STRINGEOL
+wxSTC_LUA_WORD2 = stc_c.wxSTC_LUA_WORD2
+wxSTC_LUA_WORD3 = stc_c.wxSTC_LUA_WORD3
+wxSTC_LUA_WORD4 = stc_c.wxSTC_LUA_WORD4
+wxSTC_LUA_WORD5 = stc_c.wxSTC_LUA_WORD5
+wxSTC_LUA_WORD6 = stc_c.wxSTC_LUA_WORD6
wxSTC_ERR_DEFAULT = stc_c.wxSTC_ERR_DEFAULT
wxSTC_ERR_PYTHON = stc_c.wxSTC_ERR_PYTHON
wxSTC_ERR_GCC = stc_c.wxSTC_ERR_GCC
wxSTC_ADA_OPERATOR = stc_c.wxSTC_ADA_OPERATOR
wxSTC_ADA_IDENTIFIER = stc_c.wxSTC_ADA_IDENTIFIER
wxSTC_ADA_STRINGEOL = stc_c.wxSTC_ADA_STRINGEOL
+wxSTC_BAAN_DEFAULT = stc_c.wxSTC_BAAN_DEFAULT
+wxSTC_BAAN_COMMENT = stc_c.wxSTC_BAAN_COMMENT
+wxSTC_BAAN_COMMENTDOC = stc_c.wxSTC_BAAN_COMMENTDOC
+wxSTC_BAAN_NUMBER = stc_c.wxSTC_BAAN_NUMBER
+wxSTC_BAAN_WORD = stc_c.wxSTC_BAAN_WORD
+wxSTC_BAAN_STRING = stc_c.wxSTC_BAAN_STRING
+wxSTC_BAAN_PREPROCESSOR = stc_c.wxSTC_BAAN_PREPROCESSOR
+wxSTC_BAAN_OPERATOR = stc_c.wxSTC_BAAN_OPERATOR
+wxSTC_BAAN_IDENTIFIER = stc_c.wxSTC_BAAN_IDENTIFIER
+wxSTC_BAAN_STRINGEOL = stc_c.wxSTC_BAAN_STRINGEOL
+wxSTC_BAAN_WORD2 = stc_c.wxSTC_BAAN_WORD2
wxSTC_LISP_DEFAULT = stc_c.wxSTC_LISP_DEFAULT
wxSTC_LISP_COMMENT = stc_c.wxSTC_LISP_COMMENT
wxSTC_LISP_NUMBER = stc_c.wxSTC_LISP_NUMBER
wxSTC_NNCRONTAB_STRING = stc_c.wxSTC_NNCRONTAB_STRING
wxSTC_NNCRONTAB_ENVIRONMENT = stc_c.wxSTC_NNCRONTAB_ENVIRONMENT
wxSTC_NNCRONTAB_IDENTIFIER = stc_c.wxSTC_NNCRONTAB_IDENTIFIER
-wxSTC_MASK_FOLDERS = stc_c.wxSTC_MASK_FOLDERS
+wxSTC_MATLAB_DEFAULT = stc_c.wxSTC_MATLAB_DEFAULT
+wxSTC_MATLAB_COMMENT = stc_c.wxSTC_MATLAB_COMMENT
+wxSTC_MATLAB_COMMAND = stc_c.wxSTC_MATLAB_COMMAND
+wxSTC_MATLAB_NUMBER = stc_c.wxSTC_MATLAB_NUMBER
+wxSTC_MATLAB_KEYWORD = stc_c.wxSTC_MATLAB_KEYWORD
+wxSTC_MATLAB_STRING = stc_c.wxSTC_MATLAB_STRING
+wxSTC_MATLAB_OPERATOR = stc_c.wxSTC_MATLAB_OPERATOR
+wxSTC_MATLAB_IDENTIFIER = stc_c.wxSTC_MATLAB_IDENTIFIER
wxSTCNameStr = stc_c.wxSTCNameStr
wxEVT_STC_CHANGE = stc_c.wxEVT_STC_CHANGE
wxEVT_STC_STYLENEEDED = stc_c.wxEVT_STC_STYLENEEDED
<FONT color=#a020f0>#define wxSTC_MARK_CIRCLEPLUSCONNECTED </FONT><FONT color=#ff00ff>19</FONT>
<FONT color=#a020f0>#define wxSTC_MARK_CIRCLEMINUS </FONT><FONT color=#ff00ff>20</FONT>
<FONT color=#a020f0>#define wxSTC_MARK_CIRCLEMINUSCONNECTED </FONT><FONT color=#ff00ff>21</FONT>
+
+<FONT color=#0000ff>// Invisible mark that only sets the line background color</FONT>
+<FONT color=#a020f0>#define wxSTC_MARK_BACKGROUND </FONT><FONT color=#ff00ff>22</FONT>
<FONT color=#a020f0>#define wxSTC_MARK_CHARACTER </FONT><FONT color=#ff00ff>10000</FONT>
<FONT color=#0000ff>// Markers used for outlining column</FONT>
<FONT color=#a020f0>#define wxSTC_MARKNUM_FOLDERSUB </FONT><FONT color=#ff00ff>29</FONT>
<FONT color=#a020f0>#define wxSTC_MARKNUM_FOLDER </FONT><FONT color=#ff00ff>30</FONT>
<FONT color=#a020f0>#define wxSTC_MARKNUM_FOLDEROPEN </FONT><FONT color=#ff00ff>31</FONT>
+<FONT color=#a020f0>#define wxSTC_MASK_FOLDERS </FONT><FONT color=#ff00ff>0xFE000000</FONT>
<FONT color=#a020f0>#define wxSTC_MARGIN_SYMBOL </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_MARGIN_NUMBER </FONT><FONT color=#ff00ff>1</FONT>
<FONT color=#a020f0>#define wxSTC_INDIC_TT </FONT><FONT color=#ff00ff>2</FONT>
<FONT color=#a020f0>#define wxSTC_INDIC_DIAGONAL </FONT><FONT color=#ff00ff>3</FONT>
<FONT color=#a020f0>#define wxSTC_INDIC_STRIKE </FONT><FONT color=#ff00ff>4</FONT>
-<FONT color=#a020f0>#define wxSTC_INDIC0_MASK </FONT><FONT color=#ff00ff>32</FONT>
-<FONT color=#a020f0>#define wxSTC_INDIC1_MASK </FONT><FONT color=#ff00ff>64</FONT>
-<FONT color=#a020f0>#define wxSTC_INDIC2_MASK </FONT><FONT color=#ff00ff>128</FONT>
-<FONT color=#a020f0>#define wxSTC_INDICS_MASK </FONT><FONT color=#ff00ff>224</FONT>
+<FONT color=#a020f0>#define wxSTC_INDIC0_MASK </FONT><FONT color=#ff00ff>0x20</FONT>
+<FONT color=#a020f0>#define wxSTC_INDIC1_MASK </FONT><FONT color=#ff00ff>0x40</FONT>
+<FONT color=#a020f0>#define wxSTC_INDIC2_MASK </FONT><FONT color=#ff00ff>0x80</FONT>
+<FONT color=#a020f0>#define wxSTC_INDICS_MASK </FONT><FONT color=#ff00ff>0xE0</FONT>
<FONT color=#0000ff>// PrintColourMode - use same colours as screen.</FONT>
<FONT color=#a020f0>#define wxSTC_PRINT_NORMAL </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_FOLDLEVELHEADERFLAG </FONT><FONT color=#ff00ff>0x2000</FONT>
<FONT color=#a020f0>#define wxSTC_FOLDLEVELNUMBERMASK </FONT><FONT color=#ff00ff>0x0FFF</FONT>
<FONT color=#a020f0>#define wxSTC_TIME_FOREVER </FONT><FONT color=#ff00ff>10000000</FONT>
+<FONT color=#a020f0>#define wxSTC_WRAP_NONE </FONT><FONT color=#ff00ff>0</FONT>
+<FONT color=#a020f0>#define wxSTC_WRAP_WORD </FONT><FONT color=#ff00ff>1</FONT>
+<FONT color=#a020f0>#define wxSTC_CACHE_NONE </FONT><FONT color=#ff00ff>0</FONT>
+<FONT color=#a020f0>#define wxSTC_CACHE_CARET </FONT><FONT color=#ff00ff>1</FONT>
+<FONT color=#a020f0>#define wxSTC_CACHE_PAGE </FONT><FONT color=#ff00ff>2</FONT>
+<FONT color=#a020f0>#define wxSTC_CACHE_DOCUMENT </FONT><FONT color=#ff00ff>3</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEDOWN </FONT><FONT color=#ff00ff>2300</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEDOWNEXTEND </FONT><FONT color=#ff00ff>2301</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEUP </FONT><FONT color=#ff00ff>2302</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_UPPERCASE </FONT><FONT color=#ff00ff>2341</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINESCROLLDOWN </FONT><FONT color=#ff00ff>2342</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINESCROLLUP </FONT><FONT color=#ff00ff>2343</FONT>
+<FONT color=#a020f0>#define wxSTC_CMD_DELETEBACKNOTLINE </FONT><FONT color=#ff00ff>2344</FONT>
<FONT color=#a020f0>#define wxSTC_EDGE_NONE </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_EDGE_LINE </FONT><FONT color=#ff00ff>1</FONT>
<FONT color=#a020f0>#define wxSTC_EDGE_BACKGROUND </FONT><FONT color=#ff00ff>2</FONT>
<FONT color=#a020f0>#define wxSTC_LEX_EIFFELKW </FONT><FONT color=#ff00ff>24</FONT>
<FONT color=#a020f0>#define wxSTC_LEX_TCL </FONT><FONT color=#ff00ff>25</FONT>
<FONT color=#a020f0>#define wxSTC_LEX_NNCRONTAB </FONT><FONT color=#ff00ff>26</FONT>
+<FONT color=#a020f0>#define wxSTC_LEX_BULLANT </FONT><FONT color=#ff00ff>27</FONT>
+<FONT color=#a020f0>#define wxSTC_LEX_VBSCRIPT </FONT><FONT color=#ff00ff>28</FONT>
+<FONT color=#a020f0>#define wxSTC_LEX_ASP </FONT><FONT color=#ff00ff>29</FONT>
+<FONT color=#a020f0>#define wxSTC_LEX_PHP </FONT><FONT color=#ff00ff>30</FONT>
+<FONT color=#a020f0>#define wxSTC_LEX_BAAN </FONT><FONT color=#ff00ff>31</FONT>
+<FONT color=#a020f0>#define wxSTC_LEX_MATLAB </FONT><FONT color=#ff00ff>32</FONT>
<FONT color=#0000ff>// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a</FONT>
<FONT color=#0000ff>// value assigned in sequence from SCLEX_AUTOMATIC+1.</FONT>
<FONT color=#a020f0>#define wxSTC_P_COMMENTBLOCK </FONT><FONT color=#ff00ff>12</FONT>
<FONT color=#a020f0>#define wxSTC_P_STRINGEOL </FONT><FONT color=#ff00ff>13</FONT>
-<FONT color=#0000ff>// Lexical states for SCLEX_CPP, SCLEX_VB</FONT>
+<FONT color=#0000ff>// Lexical states for SCLEX_CPP</FONT>
<FONT color=#a020f0>#define wxSTC_C_DEFAULT </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_C_COMMENT </FONT><FONT color=#ff00ff>1</FONT>
<FONT color=#a020f0>#define wxSTC_C_COMMENTLINE </FONT><FONT color=#ff00ff>2</FONT>
<FONT color=#a020f0>#define wxSTC_C_COMMENTDOCKEYWORD </FONT><FONT color=#ff00ff>17</FONT>
<FONT color=#a020f0>#define wxSTC_C_COMMENTDOCKEYWORDERROR </FONT><FONT color=#ff00ff>18</FONT>
+<FONT color=#0000ff>// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT</FONT>
+<FONT color=#a020f0>#define wxSTC_B_DEFAULT </FONT><FONT color=#ff00ff>0</FONT>
+<FONT color=#a020f0>#define wxSTC_B_COMMENT </FONT><FONT color=#ff00ff>1</FONT>
+<FONT color=#a020f0>#define wxSTC_B_NUMBER </FONT><FONT color=#ff00ff>2</FONT>
+<FONT color=#a020f0>#define wxSTC_B_KEYWORD </FONT><FONT color=#ff00ff>3</FONT>
+<FONT color=#a020f0>#define wxSTC_B_STRING </FONT><FONT color=#ff00ff>4</FONT>
+<FONT color=#a020f0>#define wxSTC_B_PREPROCESSOR </FONT><FONT color=#ff00ff>5</FONT>
+<FONT color=#a020f0>#define wxSTC_B_OPERATOR </FONT><FONT color=#ff00ff>6</FONT>
+<FONT color=#a020f0>#define wxSTC_B_IDENTIFIER </FONT><FONT color=#ff00ff>7</FONT>
+<FONT color=#a020f0>#define wxSTC_B_DATE </FONT><FONT color=#ff00ff>8</FONT>
+
<FONT color=#0000ff>// Lexical states for SCLEX_HTML, SCLEX_XML</FONT>
<FONT color=#a020f0>#define wxSTC_H_DEFAULT </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_H_TAG </FONT><FONT color=#ff00ff>1</FONT>
<FONT color=#a020f0>#define wxSTC_LUA_OPERATOR </FONT><FONT color=#ff00ff>10</FONT>
<FONT color=#a020f0>#define wxSTC_LUA_IDENTIFIER </FONT><FONT color=#ff00ff>11</FONT>
<FONT color=#a020f0>#define wxSTC_LUA_STRINGEOL </FONT><FONT color=#ff00ff>12</FONT>
+<FONT color=#a020f0>#define wxSTC_LUA_WORD2 </FONT><FONT color=#ff00ff>13</FONT>
+<FONT color=#a020f0>#define wxSTC_LUA_WORD3 </FONT><FONT color=#ff00ff>14</FONT>
+<FONT color=#a020f0>#define wxSTC_LUA_WORD4 </FONT><FONT color=#ff00ff>15</FONT>
+<FONT color=#a020f0>#define wxSTC_LUA_WORD5 </FONT><FONT color=#ff00ff>16</FONT>
+<FONT color=#a020f0>#define wxSTC_LUA_WORD6 </FONT><FONT color=#ff00ff>17</FONT>
<FONT color=#0000ff>// Lexical states for SCLEX_ERRORLIST</FONT>
<FONT color=#a020f0>#define wxSTC_ERR_DEFAULT </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_ADA_IDENTIFIER </FONT><FONT color=#ff00ff>7</FONT>
<FONT color=#a020f0>#define wxSTC_ADA_STRINGEOL </FONT><FONT color=#ff00ff>8</FONT>
+<FONT color=#0000ff>// Lexical states for SCLEX_BAAN</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_DEFAULT </FONT><FONT color=#ff00ff>0</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_COMMENT </FONT><FONT color=#ff00ff>1</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_COMMENTDOC </FONT><FONT color=#ff00ff>2</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_NUMBER </FONT><FONT color=#ff00ff>3</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_WORD </FONT><FONT color=#ff00ff>4</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_STRING </FONT><FONT color=#ff00ff>5</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_PREPROCESSOR </FONT><FONT color=#ff00ff>6</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_OPERATOR </FONT><FONT color=#ff00ff>7</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_IDENTIFIER </FONT><FONT color=#ff00ff>8</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_STRINGEOL </FONT><FONT color=#ff00ff>9</FONT>
+<FONT color=#a020f0>#define wxSTC_BAAN_WORD2 </FONT><FONT color=#ff00ff>10</FONT>
+
<FONT color=#0000ff>// Lexical states for SCLEX_LISP</FONT>
<FONT color=#a020f0>#define wxSTC_LISP_DEFAULT </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_LISP_COMMENT </FONT><FONT color=#ff00ff>1</FONT>
<FONT color=#a020f0>#define wxSTC_NNCRONTAB_ENVIRONMENT </FONT><FONT color=#ff00ff>9</FONT>
<FONT color=#a020f0>#define wxSTC_NNCRONTAB_IDENTIFIER </FONT><FONT color=#ff00ff>10</FONT>
-<FONT color=#0000ff>// END of generated section</FONT>
-<FONT color=#0000ff>//----------------------------------------------------------------------</FONT>
-<FONT color=#0000ff>// Others</FONT>
-
-<FONT color=#a020f0>#define wxSTC_MASK_FOLDERS ((</FONT><FONT color=#ff00ff>1</FONT><FONT color=#a020f0> << wxSTC_MARKNUM_FOLDER) | (</FONT><FONT color=#ff00ff>1</FONT><FONT color=#a020f0> << wxSTC_MARKNUM_FOLDEROPEN))</FONT>
-
-
+<FONT color=#0000ff>// Lexical states for SCLEX_MATLAB</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_DEFAULT </FONT><FONT color=#ff00ff>0</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_COMMENT </FONT><FONT color=#ff00ff>1</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_COMMAND </FONT><FONT color=#ff00ff>2</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_NUMBER </FONT><FONT color=#ff00ff>3</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_KEYWORD </FONT><FONT color=#ff00ff>4</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_STRING </FONT><FONT color=#ff00ff>5</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_OPERATOR </FONT><FONT color=#ff00ff>6</FONT>
+<FONT color=#a020f0>#define wxSTC_MATLAB_IDENTIFIER </FONT><FONT color=#ff00ff>7</FONT>
+<FONT color=#0000ff>// END of generated section</FONT>
<FONT color=#0000ff>//----------------------------------------------------------------------</FONT>
<B><FONT color=#2e8b57>class</FONT></B> ScintillaWX; <FONT color=#0000ff>// forward declare</FONT>
<B><FONT color=#2e8b57>void</FONT></B> SetCodePage(<B><FONT color=#2e8b57>int</FONT></B> codePage);
<FONT color=#0000ff>// Set the symbol used for a particular marker number,</FONT>
- <FONT color=#0000ff>// and optionally the for and background colours.</FONT>
+ <FONT color=#0000ff>// and optionally the fore and background colours.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> MarkerDefine(<B><FONT color=#2e8b57>int</FONT></B> markerNumber, <B><FONT color=#2e8b57>int</FONT></B> markerSymbol,
<B><FONT color=#2e8b57>const</FONT></B> wxColour& foreground = wxNullColour,
<B><FONT color=#2e8b57>const</FONT></B> wxColour& background = wxNullColour);
<FONT color=#0000ff>// Set the background colour used for a particular marker number.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> MarkerSetBackground(<B><FONT color=#2e8b57>int</FONT></B> markerNumber, <B><FONT color=#2e8b57>const</FONT></B> wxColour& back);
- <FONT color=#0000ff>// Add a marker to a line.</FONT>
- <B><FONT color=#2e8b57>void</FONT></B> MarkerAdd(<B><FONT color=#2e8b57>int</FONT></B> line, <B><FONT color=#2e8b57>int</FONT></B> markerNumber);
+ <FONT color=#0000ff>// Add a marker to a line, returning an ID which can be used to find or delete the marker.</FONT>
+ <B><FONT color=#2e8b57>int</FONT></B> MarkerAdd(<B><FONT color=#2e8b57>int</FONT></B> line, <B><FONT color=#2e8b57>int</FONT></B> markerNumber);
<FONT color=#0000ff>// Delete a marker from a line</FONT>
<B><FONT color=#2e8b57>void</FONT></B> MarkerDelete(<B><FONT color=#2e8b57>int</FONT></B> line, <B><FONT color=#2e8b57>int</FONT></B> markerNumber);
<FONT color=#0000ff>// Is the background of the line containing the caret in a different colour?</FONT>
<B><FONT color=#2e8b57>bool</FONT></B> GetCaretLineVisible();
- <FONT color=#0000ff>// Display the background of the line containing the caret in a different colour.</FONT>
+ <FONT color=#0000ff>// Dsplay the background of the line containing the caret in a different colour.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> SetCaretLineVisible(<B><FONT color=#2e8b57>bool</FONT></B> show);
<FONT color=#0000ff>// Get the colour of the background of the line containing the caret.</FONT>
<FONT color=#0000ff>// Set the colour of the background of the line containing the caret.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> SetCaretLineBack(<B><FONT color=#2e8b57>const</FONT></B> wxColour& back);
+ <FONT color=#0000ff>// Set a style to be changeable or not (read only).</FONT>
+ <FONT color=#0000ff>// Experimental feature, currently buggy.</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> StyleSetChangeable(<B><FONT color=#2e8b57>int</FONT></B> style, <B><FONT color=#2e8b57>bool</FONT></B> changeable);
+
<FONT color=#0000ff>// Display a auto-completion list.</FONT>
<FONT color=#0000ff>// The lenEntered parameter indicates how many characters before</FONT>
<FONT color=#0000ff>// the caret should be used to provide context.</FONT>
<FONT color=#0000ff>// Retrieve whether auto-completion cancelled by backspacing before start.</FONT>
<B><FONT color=#2e8b57>bool</FONT></B> AutoCompGetCancelAtStart();
- <FONT color=#0000ff>// Define a set of character that when typed fills up the selected word.</FONT>
+ <FONT color=#0000ff>// Define a set of characters that when typed will cause the autocompletion to</FONT>
+ <FONT color=#0000ff>// choose the selected item.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> AutoCompSetFillUps(<B><FONT color=#2e8b57>const</FONT></B> wxString& characterSet);
<FONT color=#0000ff>// Should a single item auto-completion list automatically choose the item.</FONT>
<FONT color=#0000ff>// Retrieve whether or not autocompletion is hidden automatically when nothing matches</FONT>
<B><FONT color=#2e8b57>bool</FONT></B> AutoCompGetAutoHide();
+ <FONT color=#0000ff>// Set whether or not autocompletion deletes any word characters after the inserted text upon completion</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> AutoCompSetDropRestOfWord(<B><FONT color=#2e8b57>bool</FONT></B> dropRestOfWord);
+
+ <FONT color=#0000ff>// Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion</FONT>
+ <B><FONT color=#2e8b57>bool</FONT></B> AutoCompGetDropRestOfWord();
+
<FONT color=#0000ff>// Set the number of spaces used for one level of indentation.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> SetIndent(<B><FONT color=#2e8b57>int</FONT></B> indentSize);
<FONT color=#0000ff>// Retrieve the time the mouse must sit still to generate a mouse dwell event</FONT>
<B><FONT color=#2e8b57>int</FONT></B> GetMouseDwellTime();
+ <FONT color=#0000ff>// Get position of start of word</FONT>
+ <B><FONT color=#2e8b57>int</FONT></B> WordStartPosition(<B><FONT color=#2e8b57>int</FONT></B> pos, <B><FONT color=#2e8b57>bool</FONT></B> onlyWordCharacters);
+
+ <FONT color=#0000ff>// Get position of end of word</FONT>
+ <B><FONT color=#2e8b57>int</FONT></B> WordEndPosition(<B><FONT color=#2e8b57>int</FONT></B> pos, <B><FONT color=#2e8b57>bool</FONT></B> onlyWordCharacters);
+
+ <FONT color=#0000ff>// Sets whether text is word wrapped</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> SetWrapMode(<B><FONT color=#2e8b57>int</FONT></B> mode);
+
+ <FONT color=#0000ff>// Retrieve whether text is word wrapped</FONT>
+ <B><FONT color=#2e8b57>int</FONT></B> GetWrapMode();
+
+ <FONT color=#0000ff>// Sets the degree of caching of layout information</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> SetLayoutCache(<B><FONT color=#2e8b57>int</FONT></B> mode);
+
+ <FONT color=#0000ff>// Retrieve the degree of caching of layout information</FONT>
+ <B><FONT color=#2e8b57>int</FONT></B> GetLayoutCache();
+
+ <FONT color=#0000ff>// Delete the selection or if no selection, the character before the caret.</FONT>
+ <FONT color=#0000ff>// Will not delete the chraacter before at the start of a line.</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> DeleteBackNotLine();
+
<FONT color=#0000ff>// Move the caret inside current view if it's not there already</FONT>
<B><FONT color=#2e8b57>void</FONT></B> MoveCaretInsideView();
<FONT color=#0000ff>// Get cursor type</FONT>
<B><FONT color=#2e8b57>int</FONT></B> GetCursor();
+ <FONT color=#0000ff>// Change the way control characters are displayed:</FONT>
+ <FONT color=#0000ff>// If symbol is < 32, keep the drawn way, else, use the given character</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> SetControlCharSymbol(<B><FONT color=#2e8b57>int</FONT></B> symbol);
+
+ <FONT color=#0000ff>// Get the way control characters are displayed</FONT>
+ <B><FONT color=#2e8b57>int</FONT></B> GetControlCharSymbol();
+
<FONT color=#0000ff>// Move to the previous change in capitalistion</FONT>
<B><FONT color=#2e8b57>void</FONT></B> WordPartLeft();
<FONT color=#0000ff>// Delete forwards from the current position to the end of the line</FONT>
<B><FONT color=#2e8b57>void</FONT></B> DelLineRight();
+ <FONT color=#0000ff>// Get and Set the xOffset (ie, horizonal scroll position)</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> SetXOffset(<B><FONT color=#2e8b57>int</FONT></B> newOffset);
+ <B><FONT color=#2e8b57>int</FONT></B> GetXOffset();
+
<FONT color=#0000ff>// Start notifying the container of all key presses and commands.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> StartRecord();
<FONT color=#0000ff>// Send a message to Scintilla</FONT>
<B><FONT color=#2e8b57>long</FONT></B> SendMsg(<B><FONT color=#2e8b57>int</FONT></B> msg, <B><FONT color=#2e8b57>long</FONT></B> wp=<FONT color=#ff00ff>0</FONT>, <B><FONT color=#2e8b57>long</FONT></B> lp=<FONT color=#ff00ff>0</FONT>);
+
+ <FONT color=#0000ff>// Set the vertical scrollbar to use instead of the ont that's built-in.</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> SetVScrollBar(wxScrollBar* bar) { m_vScrollBar = bar; }
+
+
+ <FONT color=#0000ff>// Set the horizontal scrollbar to use instead of the ont that's built-in.</FONT>
+ <B><FONT color=#2e8b57>void</FONT></B> SetHScrollBar(wxScrollBar* bar) { m_hScrollBar = bar; }
+
<FONT color=#0000ff>//----------------------------------------------------------------------</FONT>
<FONT color=#0000ff>// Event handlers</FONT>
<B><FONT color=#2e8b57>void</FONT></B> OnPaint(wxPaintEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnScrollWin(wxScrollWinEvent& evt);
+ <B><FONT color=#2e8b57>void</FONT></B> OnScroll(wxScrollEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnSize(wxSizeEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnMouseLeftDown(wxMouseEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnMouseMove(wxMouseEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnMouseLeftUp(wxMouseEvent& evt);
+ <B><FONT color=#2e8b57>void</FONT></B> OnMouseRightUp(wxMouseEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnContextMenu(wxContextMenuEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnMouseWheel(wxMouseEvent& evt);
<B><FONT color=#2e8b57>void</FONT></B> OnChar(wxKeyEvent& evt);
ScintillaWX* m_swx;
wxStopWatch m_stopWatch;
+ wxScrollBar* m_vScrollBar;
+ wxScrollBar* m_hScrollBar;
<B><FONT color=#2e8b57>bool</FONT></B> m_lastKeyDownConsumed;
<B><FONT color=#2e8b57>class</FONT></B> wxStyledTextEvent : <B><FONT color=#804040>public</FONT></B> wxCommandEvent {
<B><FONT color=#804040>public</FONT></B>:
wxStyledTextEvent(wxEventType commandType=<FONT color=#ff00ff>0</FONT>, <B><FONT color=#2e8b57>int</FONT></B> id=<FONT color=#ff00ff>0</FONT>);
+<FONT color=#a020f0>#ifndef SWIG</FONT>
+ wxStyledTextEvent(<B><FONT color=#2e8b57>const</FONT></B> wxStyledTextEvent& event);
+<FONT color=#a020f0>#endif</FONT>
~wxStyledTextEvent() {}
<B><FONT color=#2e8b57>void</FONT></B> SetPosition(<B><FONT color=#2e8b57>int</FONT></B> pos) { m_position = pos; }
<B><FONT color=#2e8b57>bool</FONT></B> GetControl() <B><FONT color=#2e8b57>const</FONT></B>;
<B><FONT color=#2e8b57>bool</FONT></B> GetAlt() <B><FONT color=#2e8b57>const</FONT></B>;
- <B><FONT color=#2e8b57>void</FONT></B> CopyObject(wxObject& obj) <B><FONT color=#2e8b57>const</FONT></B>;
+ <B><FONT color=#2e8b57>virtual</FONT></B> wxEvent* Clone() <B><FONT color=#2e8b57>const</FONT></B> { <B><FONT color=#804040>return</FONT></B> <B><FONT color=#804040>new</FONT></B> wxStyledTextEvent(*<B><FONT color=#804040>this</FONT></B>); }
<FONT color=#a020f0>#ifndef SWIG</FONT>
<B><FONT color=#804040>private</FONT></B>:
<FONT color=#a020f0>#define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -</FONT><FONT color=#ff00ff>1</FONT><FONT color=#a020f0>, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) </FONT><FONT color=#ff00ff>NULL</FONT><FONT color=#a020f0> ),</FONT>
<FONT color=#a020f0>#define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -</FONT><FONT color=#ff00ff>1</FONT><FONT color=#a020f0>, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) </FONT><FONT color=#ff00ff>NULL</FONT><FONT color=#a020f0> ),</FONT>
<FONT color=#a020f0>#define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -</FONT><FONT color=#ff00ff>1</FONT><FONT color=#a020f0>, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) </FONT><FONT color=#ff00ff>NULL</FONT><FONT color=#a020f0> ),</FONT>
-
<FONT color=#a020f0>#endif</FONT>
<FONT color=#0000ff>//----------------------------------------------------------------------</FONT>
self.SetMarginType(2, wxSTC_MARGIN_SYMBOL)
self.SetMarginMask(2, wxSTC_MASK_FOLDERS)
self.SetMarginSensitive(2, true)
- self.SetMarginWidth(2, 15)
- self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, "navy", "navy")
- self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "navy", "navy")
+ self.SetMarginWidth(2, 12)
+
+ if 0: # simple folder marks, like the old version
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, "navy", "navy")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, "navy", "navy")
+ # Set these to an invisible mark
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BACKGROUND, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_BACKGROUND, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_BACKGROUND, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_BACKGROUND, "white", "black")
+
+ else: # more involved "outlining" folder marks
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, "white", "black")
+ self.MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, "white", "black")
EVT_STC_UPDATEUI(self, ID, self.OnUpdateUI)
stc_defines = defines[:]
stc_defines.append( ('__WX__', None) )
stc_defines.append( ('SCI_LEXER', None) )
+ stc_defines.append( ('LINK_LEXERS', None) )
ext = Extension('stc_c',
'%s/scintilla/src/LexAda.cxx' % STCLOC,
'%s/scintilla/src/LexAVE.cxx' % STCLOC,
+ '%s/scintilla/src/LexBaan.cxx' % STCLOC,
+ '%s/scintilla/src/LexBullant.cxx' % STCLOC,
'%s/scintilla/src/LexCPP.cxx' % STCLOC,
'%s/scintilla/src/LexConf.cxx' % STCLOC,
'%s/scintilla/src/LexCrontab.cxx' % STCLOC,
'%s/scintilla/src/LexHTML.cxx' % STCLOC,
'%s/scintilla/src/LexLisp.cxx' % STCLOC,
'%s/scintilla/src/LexLua.cxx' % STCLOC,
+ '%s/scintilla/src/LexMatlab.cxx' % STCLOC,
'%s/scintilla/src/LexOthers.cxx' % STCLOC,
'%s/scintilla/src/LexPascal.cxx' % STCLOC,
'%s/scintilla/src/LexPerl.cxx' % STCLOC,