From 3032c371bd9231f097226869e80bf56543ae2cab Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Tue, 4 Apr 2000 09:17:32 +0000 Subject: Split a Document based Accessor (DocumentAccessor) off from the old accessor which is now called WindowAccessor. Accessor.h defines a common interface which is the type consumed by the lexers. --- gtk/makefile | 8 ++-- include/Accessor.h | 102 +++++++++++++------------------------------------- include/KeyWords.h | 4 +- src/KeyWords.cxx | 2 +- src/LexCPP.cxx | 4 +- src/LexHTML.cxx | 20 +++++----- src/LexOthers.cxx | 16 ++++---- src/LexPerl.cxx | 6 +-- src/LexPython.cxx | 6 +-- src/LexSQL.cxx | 4 +- src/LexVB.cxx | 4 +- src/ScintillaBase.cxx | 5 ++- vcbuild/SciLexer.dsp | 16 +++++--- win32/PlatWin.cxx | 47 +++++++++++++++++++++++ win32/makefile | 9 +++-- win32/makefile_bor | 15 +++++--- win32/makefile_vc | 16 +++++--- 17 files changed, 149 insertions(+), 135 deletions(-) diff --git a/gtk/makefile b/gtk/makefile index b1b07c92f..51e317957 100644 --- a/gtk/makefile +++ b/gtk/makefile @@ -26,14 +26,12 @@ LEXOBJS = LexCPP.o LexHTML.o LexOthers.o LexPerl.o LexPython.o LexSQL.o LexVB.o all: $(COMPLIB) $(LEXOBJS) -$(COMPLIB): Accessor.o KeyWords.o Document.o CallTip.o \ +$(COMPLIB): DocumentAccessor.o WindowAccessor.o KeyWords.o Document.o CallTip.o \ ScintillaBase.o ContractionState.o Editor.o PropSet.o PlatGTK.o \ KeyMap.o LineMarker.o ScintillaGTK.o CellBuffer.o ViewStyle.o \ Style.o Indicator.o AutoComplete.o $(AR) rc $@ $^ -Accessor.o: Accessor.cxx Platform.h PropSet.h Accessor.h Scintilla.h \ - WinDefs.h AutoComplete.o: AutoComplete.cxx Platform.h AutoComplete.h CallTip.o: CallTip.cxx Platform.h CallTip.h CellBuffer.o: CellBuffer.cxx Platform.h Scintilla.h WinDefs.h \ @@ -41,6 +39,8 @@ CellBuffer.o: CellBuffer.cxx Platform.h Scintilla.h WinDefs.h \ ContractionState.o: ContractionState.cxx Platform.h ContractionState.h Document.o: Document.cxx Platform.h Scintilla.h WinDefs.h CellBuffer.h \ Document.h +DocumentAccessor.o: Accessor.cxx Platform.h PropSet.h Accessor.h \ + DocumentAccessor.h Scintilla.h WinDefs.h Editor.o: Editor.cxx Platform.h Scintilla.h WinDefs.h \ ContractionState.h CellBuffer.h KeyMap.h Indicator.h LineMarker.h \ Style.h ViewStyle.h Document.h Editor.h @@ -82,6 +82,8 @@ ScintillaGTK.o: ScintillaGTK.cxx Platform.h Scintilla.h WinDefs.h \ Style.o: Style.cxx Platform.h Style.h ViewStyle.o: ViewStyle.cxx Platform.h Scintilla.h WinDefs.h \ Indicator.h LineMarker.h Style.h ViewStyle.h +WindowAccessor.o: WindowAccessor.cxx Platform.h PropSet.h Accessor.h \ + WindowAccessor.h Scintilla.h WinDefs.h clean: rm -f *.o SciTE diff --git a/include/Accessor.h b/include/Accessor.h index 031ad7a91..fc67f07c0 100644 --- a/include/Accessor.h +++ b/include/Accessor.h @@ -5,84 +5,34 @@ enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8}; -class Accessor { -protected: - // bufferSize is a trade off between time taken to copy the characters and SendMessage overhead - // slopSize positions the buffer before the desired position in case there is some backtracking - enum {bufferSize=4000, slopSize=bufferSize/8}; - char buf[bufferSize+1]; - WindowID id; - PropSet &props; - int startPos; - int endPos; - int lenDoc; - int offset; // Optional but including an offset makes GCC generate better code - int codePage; - bool InternalIsLeadByte(char ch); - void Fill(int position); -public: - Accessor(WindowID id_, PropSet &props_, int offset_=0) : - id(id_), props(props_), startPos(0x7FFFFFFF), endPos(0), - lenDoc(-1), offset(offset_), codePage(0) { - } - void SetCodePage(int codePage_) { codePage = codePage_; } - char operator[](int position) { - position += offset; - if (position < startPos || position >= endPos) { - Fill(position); - } - return buf[position - startPos]; - } - char SafeGetCharAt(int position, char chDefault=' ') { - // Safe version of operator[], returning a defined value for invalid position - position += offset; - if (position < startPos || position >= endPos) { - Fill(position); - if (position < startPos || position >= endPos) { - // Position is outside range of document - return chDefault; - } - } - return buf[position - startPos]; - } - bool IsLeadByte(char ch) { - return codePage && InternalIsLeadByte(ch); - } - char StyleAt(int position); - int GetLine(int position); - int LineStart(int line); - int LevelAt(int line); - int Length(); - void Flush() { - startPos = 0x7FFFFFFF; - lenDoc = -1; - } - int GetLineState(int line); - int SetLineState(int line, int state); - PropSet &GetPropSet() { return props; } -}; +class BufferAccess; -class StylingContext; +typedef bool (*PFNIsCommentLeader)(BufferAccess &styler, int pos, int len); -typedef bool (*PFNIsCommentLeader)(StylingContext &styler, int pos, int len); - -class StylingContext : public Accessor { - char styleBuf[bufferSize]; - int validLen; - char chFlags; - char chWhile; - unsigned int startSeg; +// Interface to data in a Scintilla +class BufferAccess { public: - StylingContext(WindowID id_, PropSet &props_, int offset_=0) : - Accessor(id_,props_,offset_), validLen(0), chFlags(0) {} - void StartAt(unsigned int start, char chMask=31); - void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; - unsigned int GetStartSegment() { return startSeg; } - void StartSegment(unsigned int pos); - void ColourTo(unsigned int pos, int chAttr); - int GetLine(int position); - void SetLevel(int line, int level); - void Flush(); - int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); + virtual void SetCodePage(int codePage_)=0; + virtual char operator[](int position)=0; + virtual char SafeGetCharAt(int position, char chDefault=' ')=0; + virtual bool IsLeadByte(char ch)=0; + virtual char StyleAt(int position)=0; + virtual int GetLine(int position)=0; + virtual int LineStart(int line)=0; + virtual int LevelAt(int line)=0; + virtual int Length()=0; + virtual void Flush()=0; + virtual int GetLineState(int line)=0; + virtual int SetLineState(int line, int state)=0; + virtual PropSet &GetPropSet()=0; + + // Style setting + virtual void StartAt(unsigned int start, char chMask=31)=0; + virtual void SetFlags(char chFlags_, char chWhile_)=0; + virtual unsigned int GetStartSegment()=0; + virtual void StartSegment(unsigned int pos)=0; + virtual void ColourTo(unsigned int pos, int chAttr)=0; + virtual void SetLevel(int line, int level)=0; + virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0; }; diff --git a/include/KeyWords.h b/include/KeyWords.h index 1b42ecdd9..65c54379b 100644 --- a/include/KeyWords.h +++ b/include/KeyWords.h @@ -4,7 +4,7 @@ // The License.txt file describes the conditions under which this software may be distributed. typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], StylingContext &styler); + WordList *keywordlists[], BufferAccess &styler); class LexerModule { static LexerModule *base; @@ -14,7 +14,7 @@ class LexerModule { public: LexerModule(int language_, LexerFunction fn_); static void Colourise(unsigned int startPos, int lengthDoc, int initStyle, - int language, WordList *keywordlists[], StylingContext &styler); + int language, WordList *keywordlists[], BufferAccess &styler); }; inline bool iswordchar(char ch) { diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx index 5d6d9c6cf..7cc69bd28 100644 --- a/src/KeyWords.cxx +++ b/src/KeyWords.cxx @@ -26,7 +26,7 @@ LexerModule::LexerModule(int language_, LexerFunction fn_) : } void LexerModule::Colourise(unsigned int startPos, int lengthDoc, int initStyle, - int language, WordList *keywordlists[], StylingContext &styler) { + int language, WordList *keywordlists[], BufferAccess &styler) { LexerModule *lm = base; while (lm) { if (lm->language == language) { diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index 4afae231f..d3c00164f 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -17,7 +17,7 @@ #include "Scintilla.h" #include "SciLexer.h" -static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) { +static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); bool wordIsUUID = false; @@ -39,7 +39,7 @@ static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keyw } static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - StylingContext &styler) { + BufferAccess &styler) { WordList &keywords = *keywordlists[0]; diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index ae2de8ff2..490bed6ee 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -18,7 +18,7 @@ #include "SciLexer.h" enum { eScriptNone, eScriptJS, eScriptVBS, eScriptPython }; -static int segIsScriptingIndicator(StylingContext &styler, unsigned int start, unsigned int end, int prevValue) { +static int segIsScriptingIndicator(BufferAccess &styler, unsigned int start, unsigned int end, int prevValue) { char s[100]; s[0] = '\0'; for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -38,7 +38,7 @@ static int segIsScriptingIndicator(StylingContext &styler, unsigned int start, u return prevValue; } -static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) { +static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler) { bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.') || (styler[start] == '-') || (styler[start] == '#'); char chAttr = SCE_H_ATTRIBUTEUNKNOWN; @@ -58,7 +58,7 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k } static int classifyTagHTML(unsigned int start, unsigned int end, - WordList &keywords, StylingContext &styler) { + WordList &keywords, BufferAccess &styler) { char s[100]; // Copy after the '<' unsigned int i = 0; @@ -86,7 +86,7 @@ static int classifyTagHTML(unsigned int start, unsigned int end, } static void classifyWordHTJS(unsigned int start, unsigned int end, - WordList &keywords, StylingContext &styler) { + WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -104,7 +104,7 @@ static void classifyWordHTJS(unsigned int start, unsigned int end, } static void classifyWordHTJSA(unsigned int start, unsigned int end, - WordList &keywords, StylingContext &styler) { + WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -121,7 +121,7 @@ static void classifyWordHTJSA(unsigned int start, unsigned int end, styler.ColourTo(end, chAttr); } -static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) { +static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -145,7 +145,7 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw return SCE_HB_DEFAULT; } -static int classifyWordHTVBA(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) { +static int classifyWordHTVBA(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -169,7 +169,7 @@ static int classifyWordHTVBA(unsigned int start, unsigned int end, WordList &key return SCE_HBA_DEFAULT; } -static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler, char *prevWord) { +static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler, char *prevWord) { char s[100]; bool wordIsNumber = isdigit(styler[start]); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -189,7 +189,7 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key strcpy(prevWord, s); } -static void classifyWordHTPyA(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler, char *prevWord) { +static void classifyWordHTPyA(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler, char *prevWord) { char s[100]; bool wordIsNumber = isdigit(styler[start]); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -226,7 +226,7 @@ static bool isLineEnd(char ch) { } static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - StylingContext &styler) { + BufferAccess &styler) { WordList &keywords=*keywordlists[0]; WordList &keywords2=*keywordlists[1]; diff --git a/src/LexOthers.cxx b/src/LexOthers.cxx index d2a0d563b..abaf3ce75 100644 --- a/src/LexOthers.cxx +++ b/src/LexOthers.cxx @@ -17,7 +17,7 @@ #include "Scintilla.h" #include "SciLexer.h" -static void ColouriseBatchLine(char *lineBuffer, int endLine, StylingContext &styler) { +static void ColouriseBatchLine(char *lineBuffer, int endLine, BufferAccess &styler) { if (0 == strncmp(lineBuffer, "REM", 3)) { styler.ColourTo(endLine, 1); } else if (0 == strncmp(lineBuffer, "rem", 3)) { @@ -33,7 +33,7 @@ static void ColouriseBatchLine(char *lineBuffer, int endLine, StylingContext &st } } -static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) { +static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], BufferAccess &styler) { char lineBuffer[1024]; styler.StartAt(startPos); styler.StartSegment(startPos); @@ -49,7 +49,7 @@ static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList * ColouriseBatchLine(lineBuffer, startPos + length, styler); } -static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, StylingContext &styler) { +static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, BufferAccess &styler) { int i = 0; while (isspace(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces i++; @@ -75,7 +75,7 @@ static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, } } -static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) { +static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], BufferAccess &styler) { char lineBuffer[1024]; styler.StartAt(startPos); styler.StartSegment(startPos); @@ -96,7 +96,7 @@ static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList * ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler); } -static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) { +static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, BufferAccess &styler) { int i = 0; while (isspace(lineBuffer[i]) && (i < lengthLine)) i++; @@ -107,7 +107,7 @@ static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, Styl } } -static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) { +static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], BufferAccess &styler) { char lineBuffer[1024]; styler.StartAt(startPos); styler.StartSegment(startPos); @@ -123,7 +123,7 @@ static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[ ColouriseMakeLine(lineBuffer, linePos, startPos + length, styler); } -static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) { +static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, BufferAccess &styler) { if (lineBuffer[0] == '>') { // Command or return status styler.ColourTo(endPos, 4); @@ -178,7 +178,7 @@ static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, } } -static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) { +static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], BufferAccess &styler) { char lineBuffer[1024]; styler.StartAt(startPos); styler.StartSegment(startPos); diff --git a/src/LexPerl.cxx b/src/LexPerl.cxx index f9170b9c3..c52aa8c4f 100644 --- a/src/LexPerl.cxx +++ b/src/LexPerl.cxx @@ -31,7 +31,7 @@ inline bool isPerlOperator(char ch) { return false; } -static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) { +static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -54,7 +54,7 @@ static bool isEndVar(char ch) { ch != '_' && ch != '\''; } -static bool isMatch(StylingContext &styler, int lengthDoc, int pos, const char *val) { +static bool isMatch(BufferAccess &styler, int lengthDoc, int pos, const char *val) { if ((pos + static_cast(strlen(val))) >= lengthDoc) { return false; } @@ -90,7 +90,7 @@ static char opposite(char ch) { } static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], StylingContext &styler) { + WordList *keywordlists[], BufferAccess &styler) { // Lexer for perl often has to backtrack to start of current style to determine // which characters are being used as quotes, how deeply nested is the diff --git a/src/LexPython.cxx b/src/LexPython.cxx index d7830b0b7..fcaa541ac 100644 --- a/src/LexPython.cxx +++ b/src/LexPython.cxx @@ -17,7 +17,7 @@ #include "Scintilla.h" #include "SciLexer.h" -static void classifyWordPy(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler, char *prevWord) { +static void classifyWordPy(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler, char *prevWord) { char s[100]; bool wordIsNumber = isdigit(styler[start]); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -37,12 +37,12 @@ static void classifyWordPy(unsigned int start, unsigned int end, WordList &keywo strcpy(prevWord, s); } -static bool IsPyComment(StylingContext &styler, int pos, int len) { +static bool IsPyComment(BufferAccess &styler, int pos, int len) { return len>0 && styler[pos]=='#'; } static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], StylingContext &styler) { + WordList *keywordlists[], BufferAccess &styler) { // Python uses a different mask because bad indentation is marked by oring with 32 styler.StartAt(startPos, 127); diff --git a/src/LexSQL.cxx b/src/LexSQL.cxx index 900f8ddc2..6433776ca 100644 --- a/src/LexSQL.cxx +++ b/src/LexSQL.cxx @@ -17,7 +17,7 @@ #include "Scintilla.h" #include "SciLexer.h" -static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) { +static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { @@ -35,7 +35,7 @@ static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keyw } static void ColouriseSQLDoc(unsigned int startPos, int length, - int initStyle, WordList *keywordlists[], StylingContext &styler) { + int initStyle, WordList *keywordlists[], BufferAccess &styler) { WordList &keywords = *keywordlists[0]; diff --git a/src/LexVB.cxx b/src/LexVB.cxx index a78ea07b5..2b2154f21 100644 --- a/src/LexVB.cxx +++ b/src/LexVB.cxx @@ -17,7 +17,7 @@ #include "Scintilla.h" #include "SciLexer.h" -static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) { +static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, BufferAccess &styler) { char s[100]; bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); @@ -43,7 +43,7 @@ static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywor } static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], StylingContext &styler) { + WordList *keywordlists[], BufferAccess &styler) { WordList &keywords = *keywordlists[0]; diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 21f984044..76177f242 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -15,6 +15,8 @@ #include "SciLexer.h" #include "PropSet.h" #include "Accessor.h" +#include "WindowAccessor.h" +#include "DocumentAccessor.h" #include "KeyWords.h" #endif #include "ContractionState.h" @@ -276,7 +278,8 @@ void ScintillaBase::Colourise(int start, int end) { end = lengthDoc; int len = end - start; - StylingContext styler(wMain.GetID(), props); + //WindowAccessor styler(wMain.GetID(), props); + DocumentAccessor styler(pdoc, props); int styleStart = 0; if (start > 0) diff --git a/vcbuild/SciLexer.dsp b/vcbuild/SciLexer.dsp index 678ba7d3e..b0a7e20d3 100644 --- a/vcbuild/SciLexer.dsp +++ b/vcbuild/SciLexer.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib imm32.lib comctl32.lib /nologo /dll /machine:I386 /out:"Release/SciLexer.dll" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib imm32.lib comctl32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "SciLexer - Win32 Debug" @@ -81,7 +81,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib imm32.lib comctl32.lib /nologo /dll /debug /machine:I386 /out:"Debug/SciLexer.dll" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib imm32.lib comctl32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept !ENDIF @@ -94,10 +94,6 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=..\src\Accessor.cxx -# End Source File -# Begin Source File - SOURCE=..\src\AutoComplete.cxx # End Source File # Begin Source File @@ -118,6 +114,10 @@ SOURCE=..\src\Document.cxx # End Source File # Begin Source File +SOURCE=..\src\DocumentAccessor.cxx +# End Source File +# Begin Source File + SOURCE=..\src\Editor.cxx # End Source File # Begin Source File @@ -192,6 +192,10 @@ SOURCE=..\src\Style.cxx SOURCE=..\src\ViewStyle.cxx # End Source File +# Begin Source File + +SOURCE=..\src\WindowAccessor.cxx +# End Source File # End Group # Begin Group "Header Files" diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index f5a4f98e2..17ca7cc03 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -323,12 +323,20 @@ void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) { surfaceSource.hdc, from.x, from.y, SRCCOPY); } +#define ASCII_ONLY 1 + void Surface::DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back) { SetFont(font_); ::SetTextColor(hdc, fore.AsLong()); ::SetBkColor(hdc, back.AsLong()); RECT rcw = RectFromPRectangle(rc); +#ifdef ASCII_ONLY ::ExtTextOut(hdc, rc.left, ybase, ETO_OPAQUE, &rcw, s, len, NULL); +#else + wchar_t tbuf[20000]; + int tlen = MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, sizeof(tbuf)); + ::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE, &rcw, tbuf, tlen, NULL); +#endif } void Surface::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back) { @@ -336,13 +344,25 @@ void Surface::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char ::SetTextColor(hdc, fore.AsLong()); ::SetBkColor(hdc, back.AsLong()); RECT rcw = RectFromPRectangle(rc); +#ifdef ASCII_ONLY ::ExtTextOut(hdc, rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, s, len, NULL); +#else + wchar_t tbuf[20000]; + int tlen = MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, sizeof(tbuf)); + ::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, tbuf, tlen, NULL); +#endif } int Surface::WidthText(Font &font_, const char *s, int len) { SetFont(font_); SIZE sz; +#ifdef ASCII_ONLY ::GetTextExtentPoint32(hdc, s, len, &sz); +#else + wchar_t tbuf[20000]; + int tlen = MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, sizeof(tbuf)); + ::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz); +#endif return sz.cx; } @@ -350,7 +370,34 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions) SetFont(font_); SIZE sz; int fit = 0; +#ifdef ASCII_ONLY ::GetTextExtentExPoint(hdc, s, len, 30000, &fit, positions, &sz); +#else + wchar_t tbuf[20000]; + int poses[20000]; + int tlen = MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, sizeof(tbuf)); + ::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, poses, &sz); + int ui=0; + const unsigned char *us = reinterpret_cast(s); + int i=0; + while (i