Undoing Eric's changes on the main branch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7014 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2000-03-31 17:44:48 +00:00
parent 64a3ee5fd2
commit 88b780d9f9
70 changed files with 5002 additions and 7192 deletions

View File

@ -29,13 +29,6 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
Indicator.o \
KeyMap.o \
KeyWords.o \
LexCPP.o \
LexHTML.o \
LexOthers.o \
LexPerl.o \
LexPython.o \
LexSQL.o \
LexVB.o \
LineMarker.o \
PropSet.o \
ScintillaBase.o \

View File

@ -4,7 +4,6 @@
// Robin Dunn <robin@aldunn.com>
// The License.txt file describes the conditions under which this software may be distributed.
#include <ctype.h>
#include "Platform.h"
#include "wx/stc/stc.h"
@ -182,14 +181,7 @@ void Surface::BrushColor(Colour back) {
}
void Surface::SetFont(Font &font_) {
// I think the following check is valid.
// It eliminates a crash for me. -- eric@sourcegear.com
if (font_.GetID())
{
hdc->SetFont(*font_.GetID());
}
hdc->SetFont(*font_.GetID());
}
int Surface::LogPixelsY() {
@ -352,11 +344,7 @@ void Surface::SetClip(PRectangle rc) {
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
}
void Surface::FlushCachedState() {
// TODO Is there anything we need to do here? eric@sourcegear.com
// TODO I had to add this method when I merged new Scintilla code
// TODO from Neil.
}
Window::~Window() {
}

View File

@ -14,8 +14,6 @@
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include <ctype.h>
#include "ScintillaWX.h"
#include "wx/stc/stc.h"

View File

@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
@ -22,9 +22,11 @@ CFG=StcVC - Win32 Debug
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "StcVC - Win32 Release"
@ -38,12 +40,11 @@ CPP=cl.exe
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
RSC=rc.exe
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
@ -63,12 +64,11 @@ LIB32=link.exe -lib
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
RSC=rc.exe
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
@ -179,34 +179,6 @@ SOURCE=.\scintilla\src\KeyWords.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexCPP.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexHTML.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexOthers.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexPerl.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexPython.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexSQL.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexVB.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LineMarker.cxx
# End Source File
# Begin Source File

View File

@ -3,8 +3,6 @@
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
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
@ -17,15 +15,12 @@ protected:
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) {
lenDoc(-1), offset(offset_) {
}
void SetCodePage(int codePage_) { codePage = codePage_; }
char operator[](int position) {
position += offset;
if (position < startPos || position >= endPos) {
@ -45,9 +40,6 @@ public:
}
return buf[position - startPos];
}
bool IsLeadByte(char ch) {
return codePage && InternalIsLeadByte(ch);
}
char StyleAt(int position);
int GetLine(int position);
int LineStart(int line);
@ -62,10 +54,6 @@ public:
PropSet &GetPropSet() { return props; }
};
class StylingContext;
typedef bool (*PFNIsCommentLeader)(StylingContext &styler, int pos, int len);
class StylingContext : public Accessor {
char styleBuf[bufferSize];
int validLen;
@ -77,12 +65,12 @@ public:
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_; };
void ColourSegment(unsigned int start, unsigned int end, int chAttr);
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);
};

View File

@ -3,39 +3,6 @@
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// 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);
class LexerModule {
static LexerModule *base;
LexerModule *next;
int language;
LexerFunction fn;
public:
LexerModule(int language_, LexerFunction fn_);
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle,
int language, WordList *keywordlists[], StylingContext &styler);
};
inline bool iswordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '_';
}
inline bool iswordstart(char ch) {
return isalnum(ch) || ch == '_';
}
inline bool isoperator(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 == '~')
return true;
return false;
}
void ColouriseDoc(int codePage, int startPos, int lengthDoc, int initStyle,
int language, WordList *keywordlists[], StylingContext &styler);

View File

@ -213,8 +213,6 @@ public:
void Release();
FontID GetID() { return id; }
// Alias another font - caller guarantees not to Release
void SetID(FontID id_) { id = id_; }
friend class Surface;
};
@ -292,7 +290,6 @@ public:
int SetPalette(Palette *pal, bool inBackGround);
void SetClip(PRectangle rc);
void FlushCachedState();
};
// Class to hide the details of window manipulation

View File

@ -35,8 +35,6 @@
#define SCE_P_DEFNAME 9
#define SCE_P_OPERATOR 10
#define SCE_P_IDENTIFIER 11
#define SCE_P_COMMENTBLOCK 12
#define SCE_P_STRINGEOL 13
// Lexical states for SCLEX_CPP, SCLEX_VB
#define SCE_C_DEFAULT 0
@ -47,7 +45,7 @@
#define SCE_C_WORD 5
#define SCE_C_STRING 6
#define SCE_C_CHARACTER 7
#define SCE_C_UUID 8
#define SCE_C_PUNTUATION 8
#define SCE_C_PREPROCESSOR 9
#define SCE_C_OPERATOR 10
#define SCE_C_IDENTIFIER 11
@ -65,85 +63,49 @@
#define SCE_H_OTHER 8
#define SCE_H_COMMENT 9
#define SCE_H_ENTITY 10
// XML and ASP
#define SCE_H_TAGEND 11
#define SCE_H_XMLSTART 12
#define SCE_H_XMLEND 13
#define SCE_H_SCRIPT 14
#define SCE_H_ASP 15
#define SCE_H_ASPAT 16
// Embedded Javascript
#define SCE_HJ_START 40
#define SCE_HJ_DEFAULT 41
#define SCE_HJ_COMMENT 42
#define SCE_HJ_COMMENTLINE 43
#define SCE_HJ_COMMENTDOC 44
#define SCE_HJ_NUMBER 45
#define SCE_HJ_WORD 46
#define SCE_HJ_KEYWORD 47
#define SCE_HJ_DOUBLESTRING 48
#define SCE_HJ_SINGLESTRING 49
#define SCE_HJ_SYMBOLS 50
#define SCE_HJ_STRINGEOL 51
// ASP Javascript
#define SCE_HJA_START 55
#define SCE_HJA_DEFAULT 56
#define SCE_HJA_COMMENT 57
#define SCE_HJA_COMMENTLINE 58
#define SCE_HJA_COMMENTDOC 59
#define SCE_HJA_NUMBER 60
#define SCE_HJA_WORD 61
#define SCE_HJA_KEYWORD 62
#define SCE_HJA_DOUBLESTRING 63
#define SCE_HJA_SINGLESTRING 64
#define SCE_HJA_SYMBOLS 65
#define SCE_HJA_STRINGEOL 66
#define SCE_HJ_START 11
#define SCE_HJ_DEFAULT 12
#define SCE_HJ_COMMENT 13
#define SCE_HJ_COMMENTLINE 14
#define SCE_HJ_COMMENTDOC 15
#define SCE_HJ_NUMBER 16
#define SCE_HJ_WORD 17
#define SCE_HJ_KEYWORD 18
#define SCE_HJ_DOUBLESTRING 19
#define SCE_HJ_SINGLESTRING 20
#define SCE_HJ_SYMBOLS 21
#define SCE_HJ_STRINGEOL 28
// XML and ASP
#define SCE_H_TAGEND 22
#define SCE_H_XMLSTART 23
#define SCE_H_XMLEND 24
#define SCE_H_SCRIPT 25
#define SCE_H_ASP 26
#define SCE_H_ASPAT 27
// Embedded VBScript
#define SCE_HB_START 70
#define SCE_HB_DEFAULT 71
#define SCE_HB_COMMENTLINE 72
#define SCE_HB_NUMBER 73
#define SCE_HB_WORD 74
#define SCE_HB_STRING 75
#define SCE_HB_IDENTIFIER 76
#define SCE_HB_STRINGEOL 77
// ASP VBScript
#define SCE_HBA_START 80
#define SCE_HBA_DEFAULT 81
#define SCE_HBA_COMMENTLINE 82
#define SCE_HBA_NUMBER 83
#define SCE_HBA_WORD 84
#define SCE_HBA_STRING 85
#define SCE_HBA_IDENTIFIER 86
#define SCE_HBA_STRINGEOL 87
#define SCE_HB_START 40
#define SCE_HB_DEFAULT 41
#define SCE_HB_COMMENTLINE 42
#define SCE_HB_NUMBER 43
#define SCE_HB_WORD 44
#define SCE_HB_STRING 45
#define SCE_HB_IDENTIFIER 46
#define SCE_HB_STRINGEOL 47
// Embedded Python
#define SCE_HP_START 90
#define SCE_HP_DEFAULT 91
#define SCE_HP_COMMENTLINE 92
#define SCE_HP_NUMBER 93
#define SCE_HP_STRING 94
#define SCE_HP_CHARACTER 95
#define SCE_HP_WORD 96
#define SCE_HP_TRIPLE 97
#define SCE_HP_TRIPLEDOUBLE 98
#define SCE_HP_CLASSNAME 99
#define SCE_HP_DEFNAME 100
#define SCE_HP_OPERATOR 101
#define SCE_HP_IDENTIFIER 102
// ASP Python
#define SCE_HPA_START 105
#define SCE_HPA_DEFAULT 106
#define SCE_HPA_COMMENTLINE 107
#define SCE_HPA_NUMBER 108
#define SCE_HPA_STRING 109
#define SCE_HPA_CHARACTER 110
#define SCE_HPA_WORD 111
#define SCE_HPA_TRIPLE 112
#define SCE_HPA_TRIPLEDOUBLE 113
#define SCE_HPA_CLASSNAME 114
#define SCE_HPA_DEFNAME 115
#define SCE_HPA_OPERATOR 116
#define SCE_HPA_IDENTIFIER 117
#define SCE_HP_START 50
#define SCE_HP_DEFAULT 51
#define SCE_HP_COMMENTLINE 52
#define SCE_HP_NUMBER 53
#define SCE_HP_STRING 54
#define SCE_HP_CHARACTER 55
#define SCE_HP_WORD 56
#define SCE_HP_TRIPLE 57
#define SCE_HP_TRIPLEDOUBLE 58
#define SCE_HP_CLASSNAME 59
#define SCE_HP_DEFNAME 60
#define SCE_HP_OPERATOR 61
#define SCE_HP_IDENTIFIER 62
// Lexical states for SCLEX_PERL
#define SCE_PL_DEFAULT 0

View File

@ -156,7 +156,7 @@ extern "C" {
#define STYLE_BRACELIGHT 34
#define STYLE_BRACEBAD 35
#define STYLE_CONTROLCHAR 36
#define STYLE_MAX 127
#define STYLE_MAX 63
#define SCI_STYLECLEARALL SCI_START + 50
#define SCI_STYLESETFORE SCI_START + 51
@ -279,11 +279,6 @@ extern "C" {
#define SCI_ZOOMOUT SCI_START + 334
#define SCI_DELWORDLEFT SCI_START + 335
#define SCI_DELWORDRIGHT SCI_START + 336
#define SCI_LINECUT SCI_START + 337
#define SCI_LINEDELETE SCI_START + 338
#define SCI_LINETRANSPOSE SCI_START + 339
#define SCI_LOWERCASE SCI_START + 340
#define SCI_UPPERCASE SCI_START + 341
#define SCI_LINELENGTH SCI_START + 350
#define SCI_BRACEHIGHLIGHT SCI_START + 351
@ -316,8 +311,6 @@ extern "C" {
// OR this with CARET_SLOP to reposition whenever outside slop border
#define SCI_SETCARETPOLICY SCI_START + 369
#define SCI_LINESONSCREEN SCI_START + 370
#define SCI_USEPOPUP SCI_START + 371
// GTK+ Specific
#define SCI_GRABFOCUS SCI_START + 400
@ -349,7 +342,6 @@ typedef void (tMacroRecorder)(UINT iMessage, WPARAM wParam, LPARAM lParam,
#define SC_PERFORMED_UNDO 0x20
#define SC_PERFORMED_REDO 0x40
#define SC_LASTSTEPINUNDOREDO 0x100
#define SC_MOD_CHANGEMARKER 0x200
#define SC_MODEVENTMASKALL 0x377

View File

@ -4,7 +4,6 @@
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include "Platform.h"
@ -13,17 +12,6 @@
#include "Accessor.h"
#include "Scintilla.h"
bool Accessor::InternalIsLeadByte(char ch) {
#if PLAT_GTK
// TODO: support DBCS under GTK+
return false;
#elif PLAT_WIN
return IsDBCSLeadByteEx(codePage, ch);
#elif PLAT_WX
return false;
#endif
}
void Accessor::Fill(int position) {
if (lenDoc == -1)
lenDoc = Platform::SendScintilla(id, WM_GETTEXTLENGTH, 0, 0);
@ -75,31 +63,35 @@ void StylingContext::StartAt(unsigned int start, char chMask) {
Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask);
}
void StylingContext::ColourSegment(unsigned int start, unsigned int end, int chAttr) {
// Only perform styling if non empty range
if (end != start - 1) {
if (end < start) {
Platform::DebugPrintf("Bad colour positions %d - %d\n", start, end);
}
if (validLen + (end - start + 1) >= bufferSize)
Flush();
if (validLen + (end - start + 1) >= bufferSize) {
// Too big for buffer so send directly
Platform::SendScintilla(id, SCI_SETSTYLING, end - start + 1, chAttr);
} else {
if (chAttr != chWhile)
chFlags = 0;
chAttr |= chFlags;
for (unsigned int i = start; i <= end; i++) {
styleBuf[validLen++] = chAttr;
}
}
}
}
void StylingContext::StartSegment(unsigned int pos) {
startSeg = pos;
}
void StylingContext::ColourTo(unsigned int pos, int chAttr) {
// Only perform styling if non empty range
if (pos != startSeg - 1) {
if (pos < startSeg) {
Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
}
if (validLen + (pos - startSeg + 1) >= bufferSize)
Flush();
if (validLen + (pos - startSeg + 1) >= bufferSize) {
// Too big for buffer so send directly
Platform::SendScintilla(id, SCI_SETSTYLING, pos - startSeg + 1, chAttr);
} else {
if (chAttr != chWhile)
chFlags = 0;
chAttr |= chFlags;
for (unsigned int i = startSeg; i <= pos; i++) {
styleBuf[validLen++] = chAttr;
}
}
}
ColourSegment(startSeg, pos, chAttr);
startSeg = pos+1;
}
@ -118,49 +110,3 @@ void StylingContext::Flush() {
validLen = 0;
}
}
int StylingContext::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
int end = Length();
int spaceFlags = 0;
// Determines the indentation level of the current line and also checks for consistent
// indentation compared to the previous line.
// Indentation is judged consistent when the indentation whitespace of each line lines
// the same or the indentation of one line is a prefix of the other.
int pos = LineStart(line);
char ch = (*this)[pos];
int indent = 0;
bool inPrevPrefix = line > 0;
int posPrev = inPrevPrefix ? LineStart(line-1) : 0;
while ((ch == ' ' || ch == '\t') && (pos < end)) {
if (inPrevPrefix) {
char chPrev = (*this)[posPrev++];
if (chPrev == ' ' || chPrev == '\t') {
if (chPrev != ch)
spaceFlags |= wsInconsistent;
} else {
inPrevPrefix = false;
}
}
if (ch == ' ') {
spaceFlags |= wsSpace;
indent++;
} else { // Tab
spaceFlags |= wsTab;
if (spaceFlags & wsSpace)
spaceFlags |= wsSpaceTab;
indent = (indent / 8 + 1) * 8;
}
ch = (*this)[++pos];
}
*flags = spaceFlags;
indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment...
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
return indent | SC_FOLDLEVELWHITEFLAG;
else
return indent;
}

View File

@ -344,186 +344,6 @@ void Action::Grab(Action *source) {
source->lenData = 0;
}
// The undo history stores a sequence of user operations that represent the user's view of the
// commands executed on the text.
// Each user operation contains a sequence of text insertion and text deletion actions.
// All the user operations are stored in a list of individual actions with 'start' actions used
// as delimiters between user operations.
// Initially there is one start action in the history.
// As each action is performed, it is recorded in the history. The action may either become
// part of the current user operation or may start a new user operation. If it is to be part of the
// current operation, then it overwrites the current last action. If it is to be part of a new
// operation, it is appended after the current last action.
// After writing the new action, a new start action is appended at the end of the history.
// The decision of whether to start a new user operation is based upon two factors. If a
// compound operation has been explicitly started by calling BeginUndoAction and no matching
// EndUndoAction (these calls nest) has been called, then the action is coalesced into the current
// operation. If there is no outstanding BeginUndoAction call then a new operation is started
// unless it looks as if the new action is caused by the user typing or deleting a stream of text.
// Sequences that look like typing or deletion are coalesced into a single user operation.
UndoHistory::UndoHistory() {
lenActions = 100;
actions = new Action[lenActions];
maxAction = 0;
currentAction = 0;
undoSequenceDepth = 0;
savePoint = 0;
actions[currentAction].Create(startAction);
}
UndoHistory::~UndoHistory() {
delete []actions;
actions = 0;
}
void UndoHistory::EnsureUndoRoom() {
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
if (currentAction >= 2) {
// Have to test that there is room for 2 more actions in the array
// as two actions may be created by this function
if (currentAction >= (lenActions - 2)) {
// Run out of undo nodes so extend the array
int lenActionsNew = lenActions * 2;
Action *actionsNew = new Action[lenActionsNew];
if (!actionsNew)
return;
for (int act = 0; act <= currentAction; act++)
actionsNew[act].Grab(&actions[act]);
delete []actions;
lenActions = lenActionsNew;
actions = actionsNew;
}
}
}
void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
//Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
// actions[currentAction - 1].position, actions[currentAction - 1].lenData);
if (currentAction >= 1) {
if (0 == undoSequenceDepth) {
// Top level actions may not always be coalesced
Action &actPrevious = actions[currentAction - 1];
// See if current action can be coalesced into previous action
// Will work if both are inserts or deletes and position is same
if (at != actPrevious.at) {
currentAction++;
} else if (currentAction == savePoint) {
currentAction++;
} else if ((at == removeAction) &&
((position + lengthData * 2) != actPrevious.position)) {
// Removals must be at same position to coalesce
currentAction++;
} else if ((at == insertAction) &&
(position != (actPrevious.position + actPrevious.lenData*2))) {
// Insertions must be immediately after to coalesce
currentAction++;
} else {
//Platform::DebugPrintf("action coalesced\n");
}
} else {
currentAction++;
}
} else {
currentAction++;
}
actions[currentAction].Create(at, position, data, lengthData);
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
void UndoHistory::BeginUndoAction() {
EnsureUndoRoom();
if (undoSequenceDepth == 0) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
undoSequenceDepth++;
}
void UndoHistory::EndUndoAction() {
EnsureUndoRoom();
undoSequenceDepth--;
if (0 == undoSequenceDepth) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
}
void UndoHistory::DropUndoSequence() {
undoSequenceDepth = 0;
}
void UndoHistory::DeleteUndoHistory() {
for (int i = 1; i < maxAction; i++)
actions[i].Destroy();
maxAction = 0;
currentAction = 0;
actions[currentAction].Create(startAction);
savePoint = 0;
}
void UndoHistory::SetSavePoint() {
savePoint = currentAction;
}
bool UndoHistory::IsSavePoint() const {
return savePoint == currentAction;
}
bool UndoHistory::CanUndo() const {
return (currentAction > 0) && (maxAction > 0);
}
int UndoHistory::StartUndo() {
// Drop any trailing startAction
if (actions[currentAction].at == startAction && currentAction > 0)
currentAction--;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act > 0) {
act--;
}
return currentAction - act;
}
const Action &UndoHistory::UndoStep() {
return actions[currentAction--];
}
bool UndoHistory::CanRedo() const {
return maxAction > currentAction;
}
int UndoHistory::StartRedo() {
// Drop any leading startAction
if (actions[currentAction].at == startAction && currentAction < maxAction)
currentAction++;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act < maxAction) {
act++;
}
return act - currentAction;
}
const Action &UndoHistory::RedoStep() {
return actions[currentAction++];
}
CellBuffer::CellBuffer(int initialLength) {
body = new char[initialLength];
size = initialLength;
@ -532,12 +352,23 @@ CellBuffer::CellBuffer(int initialLength) {
gaplen = initialLength;
part2body = body + gaplen;
readOnly = false;
lenActions = 100;
actions = new Action[lenActions];
maxAction = 0;
currentAction = 0;
collectingUndo = undoCollectAutoStart;
undoSequenceDepth = 0;
savePoint = 0;
actions[currentAction].Create(startAction);
}
CellBuffer::~CellBuffer() {
delete []body;
body = 0;
delete []actions;
actions = 0;
}
void CellBuffer::GapTo(int position) {
@ -655,7 +486,7 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) {
for (int i = 0; i < insertLength / 2; i++) {
data[i] = s[i * 2];
}
uh.AppendAction(insertAction, position, data, insertLength / 2);
AppendAction(insertAction, position, data, insertLength / 2);
}
BasicInsertString(position, s, insertLength);
@ -694,6 +525,48 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mas
return changed;
}
void CellBuffer::EnsureUndoRoom() {
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
if (currentAction >= 2) {
// Have to test that there is room for 2 more actions in the array
// as two actions may be created by this function
if (currentAction >= (lenActions - 2)) {
// Run out of undo nodes so extend the array
int lenActionsNew = lenActions * 2;
Action *actionsNew = new Action[lenActionsNew];
if (!actionsNew)
return;
for (int act = 0; act <= currentAction; act++)
actionsNew[act].Grab(&actions[act]);
delete []actions;
lenActions = lenActionsNew;
actions = actionsNew;
}
}
}
void CellBuffer::AppendAction(actionType at, int position, char *data, int lengthData) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
if (currentAction >= 2) {
// See if current action can be coalesced into previous action
// Will work if both are inserts or deletes and position is same or two different
if ((at != actions[currentAction - 1].at) || (abs(position - actions[currentAction - 1].position) > 2)) {
currentAction++;
} else if (currentAction == savePoint) {
currentAction++;
}
} else {
currentAction++;
}
actions[currentAction].Create(at, position, data, lengthData);
if ((collectingUndo == undoCollectAutoStart) && (0 == undoSequenceDepth)) {
currentAction++;
actions[currentAction].Create(startAction);
}
maxAction = currentAction;
}
const char *CellBuffer::DeleteChars(int position, int deleteLength) {
// InsertString and DeleteChars are the bottleneck though which all changes occur
char *data = 0;
@ -704,7 +577,7 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength) {
for (int i = 0; i < deleteLength / 2; i++) {
data[i] = ByteAt(position + i * 2);
}
uh.AppendAction(removeAction, position, data, deleteLength / 2);
AppendAction(removeAction, position, data, deleteLength / 2);
}
BasicDeleteChars(position, deleteLength);
@ -743,11 +616,11 @@ void CellBuffer::SetReadOnly(bool set) {
}
void CellBuffer::SetSavePoint() {
uh.SetSavePoint();
savePoint = currentAction;
}
bool CellBuffer::IsSavePoint() {
return uh.IsSavePoint();
return savePoint == currentAction;
}
int CellBuffer::AddMark(int line, int markerNum) {
@ -919,7 +792,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
undoCollectionType CellBuffer::SetUndoCollection(undoCollectionType collectUndo) {
collectingUndo = collectUndo;
uh.DropUndoSequence();
undoSequenceDepth = 0;
return collectingUndo;
}
@ -927,28 +800,69 @@ bool CellBuffer::IsCollectingUndo() {
return collectingUndo;
}
void CellBuffer::AppendUndoStartAction() {
EnsureUndoRoom();
// Finish any currently active undo sequence
undoSequenceDepth = 0;
if (actions[currentAction].at != startAction) {
undoSequenceDepth++;
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
void CellBuffer::BeginUndoAction() {
uh.BeginUndoAction();
EnsureUndoRoom();
if (undoSequenceDepth == 0) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
undoSequenceDepth++;
}
void CellBuffer::EndUndoAction() {
uh.EndUndoAction();
EnsureUndoRoom();
undoSequenceDepth--;
if (0 == undoSequenceDepth) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
}
void CellBuffer::DeleteUndoHistory() {
uh.DeleteUndoHistory();
for (int i = 1; i < maxAction; i++)
actions[i].Destroy();
maxAction = 0;
currentAction = 0;
savePoint = 0;
}
bool CellBuffer::CanUndo() {
return (!readOnly) && (uh.CanUndo());
return (!readOnly) && ((currentAction > 0) && (maxAction > 0));
}
int CellBuffer::StartUndo() {
return uh.StartUndo();
// Drop any trailing startAction
if (actions[currentAction].at == startAction && currentAction > 0)
currentAction--;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act > 0) {
act--;
}
return currentAction - act;
}
const Action &CellBuffer::UndoStep() {
const Action &actionStep = uh.UndoStep();
const Action &actionStep = actions[currentAction];
if (actionStep.at == insertAction) {
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
} else if (actionStep.at == removeAction) {
@ -960,19 +874,29 @@ const Action &CellBuffer::UndoStep() {
BasicInsertString(actionStep.position, styledData, actionStep.lenData*2);
delete []styledData;
}
currentAction--;
return actionStep;
}
bool CellBuffer::CanRedo() {
return (!readOnly) && (uh.CanRedo());
return (!readOnly) && (maxAction > currentAction);
}
int CellBuffer::StartRedo() {
return uh.StartRedo();
// Drop any leading startAction
if (actions[currentAction].at == startAction && currentAction < maxAction)
currentAction++;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act < maxAction) {
act++;
}
return act - currentAction;
}
const Action &CellBuffer::RedoStep() {
const Action &actionStep = uh.RedoStep();
const Action &actionStep = actions[currentAction];
if (actionStep.at == insertAction) {
char *styledData = new char[actionStep.lenData * 2];
for (int i = 0; i < actionStep.lenData; i++) {
@ -984,6 +908,7 @@ const Action &CellBuffer::RedoStep() {
} else if (actionStep.at == removeAction) {
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
}
currentAction++;
return actionStep;
}

View File

@ -89,42 +89,6 @@ public:
enum undoCollectionType { undoCollectNone, undoCollectAutoStart, undoCollectManualStart };
class UndoHistory {
Action *actions;
int lenActions;
int maxAction;
int currentAction;
int undoSequenceDepth;
int savePoint;
void EnsureUndoRoom();
public:
UndoHistory();
~UndoHistory();
void AppendAction(actionType at, int position, char *data, int length);
void BeginUndoAction();
void EndUndoAction();
void DropUndoSequence();
void DeleteUndoHistory();
// The save point is a marker in the undo stack where the container has stated that
// the buffer was saved. Undo and redo can move over the save point.
void SetSavePoint();
bool IsSavePoint() const;
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// called that many times. Similarly for redo.
bool CanUndo() const;
int StartUndo();
const Action &UndoStep();
bool CanRedo() const;
int StartRedo();
const Action &RedoStep();
};
// Holder for an expandable array of characters that supports undo and line markers
// Based on article "Data Structures in a Bit-Mapped Text Editor"
// by Wilfred J. Hansen, Byte January 1987, page 183
@ -138,8 +102,13 @@ private:
char *part2body;
bool readOnly;
Action *actions;
int lenActions;
int maxAction;
int currentAction;
undoCollectionType collectingUndo;
UndoHistory uh;
int undoSequenceDepth;
int savePoint;
LineVector lv;
@ -148,6 +117,9 @@ private:
void GapTo(int position);
void RoomFor(int insertionLength);
void EnsureUndoRoom();
void AppendAction(actionType at, int position, char *data, int length);
inline char ByteAt(int position);
void SetByteAt(int position, char ch);
@ -198,11 +170,12 @@ public:
undoCollectionType SetUndoCollection(undoCollectionType collectUndo);
bool IsCollectingUndo();
void AppendUndoStartAction();
void BeginUndoAction();
void EndUndoAction();
void DeleteUndoHistory();
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// To perform an undo, StartUndo is called to retreive the number of steps, then UndoStep is
// called that many times. Similarly for redo.
bool CanUndo();
int StartUndo();

View File

@ -108,8 +108,8 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
return;
}
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
if ((linesInDoc + lineCount + 2) >= size) {
Grow(linesInDoc + lineCount + growSize);
if ((linesInDoc + 2) >= size) {
Grow(size + growSize);
}
linesInDoc += lineCount;
linesInDisplay += lineCount;
@ -155,7 +155,7 @@ bool ContractionState::GetVisible(int lineDoc) const {
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
if (size == 0) {
Grow(linesInDoc + growSize);
Grow(lineDocEnd + growSize);
}
// TODO: modify docLine members to mirror displayLine
int delta = 0;
@ -191,7 +191,7 @@ bool ContractionState::GetExpanded(int lineDoc) const {
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
if (size == 0) {
Grow(linesInDoc + growSize);
Grow(lineDoc + growSize);
}
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
if (lines[lineDoc].expanded != expanded) {

View File

@ -65,54 +65,26 @@ void Document::SetSavePoint() {
NotifySavePoint(true);
}
int Document::AddMark(int line, int markerNum) {
int prev = cb.AddMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh);
return prev;
}
void Document::DeleteMark(int line, int markerNum) {
cb.DeleteMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh);
}
void Document::DeleteMarkFromHandle(int markerHandle) {
cb.DeleteMarkFromHandle(markerHandle);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh);
}
void Document::DeleteAllMarks(int markerNum) {
cb.DeleteAllMarks(markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh);
}
int Document::LineStart(int line) {
return cb.LineStart(line);
}
int Document::LineEnd(int line) {
if (line == LinesTotal() - 1) {
return LineStart(line + 1);
} else {
int position = LineStart(line + 1) - 1;
// When line terminator is CR+LF, may need to go back one more
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
position--;
}
return position;
}
}
int Document::LineFromPosition(int pos) {
return cb.LineFromPosition(pos);
}
int Document::LineEndPosition(int position) {
return LineEnd(LineFromPosition(position));
int line = LineFromPosition(position);
if (line == LinesTotal() - 1) {
position = LineStart(line + 1);
} else {
position = LineStart(line + 1) - 1;
// When line terminator is CR+LF, may need to go back one more
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
position--;
}
}
return position;
}
int Document::VCHomePosition(int position) {
@ -152,10 +124,7 @@ int Document::GetLastChild(int lineParent, int level) {
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
int maxLine = LinesTotal();
int lineMaxSubord = lineParent;
while (lineMaxSubord < maxLine-1) {
EnsureStyledTo(LineStart(lineMaxSubord+2));
if (!IsSubordinate(level, GetLevel(lineMaxSubord+1)))
break;
while ((lineMaxSubord < maxLine-1) && IsSubordinate(level, GetLevel(lineMaxSubord+1))) {
lineMaxSubord++;
}
if (lineMaxSubord > lineParent) {
@ -338,7 +307,6 @@ int Document::Undo() {
enteredCount++;
bool startSavePoint = cb.IsSavePoint();
int steps = cb.StartUndo();
//Platform::DebugPrintf("Steps=%d\n", steps);
for (int step=0; step<steps; step++) {
int prevLinesTotal = LinesTotal();
const Action &action = cb.UndoStep();
@ -427,11 +395,6 @@ void Document::InsertString(int position, const char *s, int insertLength) {
}
}
void Document::ChangeChar(int pos, char ch) {
DeleteChars(pos, 1);
InsertChar(pos, ch);
}
void Document::DelChar(int pos) {
if (IsCrLf(pos)) {
DeleteChars(pos, 2);
@ -642,25 +605,6 @@ int Document::LinesTotal() {
return cb.Lines();
}
void Document::ChangeCase(Range r, bool makeUpperCase) {
for (int pos=r.start; pos<r.end; pos++) {
char ch = CharAt(pos);
if (dbcsCodePage && IsDBCS(pos)) {
pos++;
} else {
if (makeUpperCase) {
if (islower(ch)) {
ChangeChar(pos, toupper(ch));
}
} else {
if (isupper(ch)) {
ChangeChar(pos, tolower(ch));
}
}
}
}
}
void Document::SetWordChars(unsigned char *chars) {
int ch;
for (ch = 0; ch < 256; ch++) {
@ -727,13 +671,6 @@ void Document::SetStyles(int length, char *styles) {
}
}
bool Document::EnsureStyledTo(int pos) {
// 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);
return pos <= GetEndStyled();
}
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
for (int i = 0; i < lenWatchers; i++) {
if ((watchers[i].watcher == watcher) &&

View File

@ -111,6 +111,7 @@ public:
undoCollectionType SetUndoCollection(undoCollectionType collectUndo) {
return cb.SetUndoCollection(collectUndo);
}
void AppendUndoStartAction() { cb.AppendUndoStartAction(); }
void BeginUndoAction() { cb.BeginUndoAction(); }
void EndUndoAction() { cb.EndUndoAction(); }
void SetSavePoint();
@ -122,7 +123,6 @@ public:
void InsertChar(int pos, char ch);
void InsertString(int position, const char *s);
void InsertString(int position, const char *s, int insertLength);
void ChangeChar(int pos, char ch);
void DelChar(int pos);
int DelCharBack(int pos);
@ -132,13 +132,12 @@ public:
}
char StyleAt(int position) { return cb.StyleAt(position); }
int GetMark(int line) { return cb.GetMark(line); }
int AddMark(int line, int markerNum);
void DeleteMark(int line, int markerNum);
void DeleteMarkFromHandle(int markerHandle);
void DeleteAllMarks(int markerNum);
int AddMark(int line, int markerNum) { return cb.AddMark(line, markerNum); }
void DeleteMark(int line, int markerNum) { cb.DeleteMark(line, markerNum); }
void DeleteMarkFromHandle(int markerHandle) { cb.DeleteMarkFromHandle(markerHandle); }
void DeleteAllMarks(int markerNum) { cb.DeleteAllMarks(markerNum); }
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
int LineStart(int line);
int LineEnd(int line);
int LineEndPosition(int position);
int VCHomePosition(int position);
@ -155,15 +154,12 @@ public:
long FindText(WORD iMessage,WPARAM wParam,LPARAM lParam);
int LinesTotal();
void ChangeCase(Range r, bool makeUpperCase);
void SetWordChars(unsigned char *chars);
void SetStylingBits(int bits);
void StartStyling(int position, char mask);
void SetStyleFor(int length, char style);
void SetStyles(int length, char *styles);
int GetEndStyled() { return endStyled; }
bool EnsureStyledTo(int pos);
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); }
@ -221,7 +217,6 @@ public:
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
};
#endif

View File

@ -88,8 +88,6 @@ Editor::Editor() {
modEventMask = SC_MODEVENTMASKALL;
displayPopupMenu = true;
pdoc = new Document();
pdoc ->AddRef();
pdoc->AddWatcher(this, 0);
@ -633,7 +631,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
int line = cs.DocFromDisplay(visibleLine);
int yposScreen = 0;
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
while (line < pdoc->LinesTotal() && yposScreen < rcMargin.bottom) {
int marks = pdoc->GetMark(line);
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
if (cs.GetExpanded(line)) {
@ -650,7 +648,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
char number[100];
number[0] = '\0';
sprintf(number, "%d", line + 1);
if (foldFlags & 64)
if (foldFlags & 8)
sprintf(number, "%X", pdoc->GetLevel(line));
int xpos = 0;
PRectangle rcNumber=rcMarker;
@ -855,7 +853,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
} 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
// Only try do 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,
@ -993,9 +991,10 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
ypos += screenLinePaintFirst * vs.lineHeight;
int yposScreen = screenLinePaintFirst * vs.lineHeight;
// Ensure we are styled as far as we are painting.
pdoc->EnsureStyledTo(endPosPaint);
if (endPosPaint > pdoc->GetEndStyled()) {
// Notify container to do some more styling
NotifyStyleNeeded(endPosPaint);
}
if (needUpdateUI) {
NotifyUpdateUI();
needUpdateUI = false;
@ -1010,7 +1009,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
}
if (paintState == paintAbandoned) {
// Either styling or NotifyUpdateUI noticed that painting is needed
// Either NotifyStyleNeeded or NotifyUpdateUI noticed that painting is needed
// outside the current painting rectangle
//Platform::DebugPrintf("Abandoning paint\n");
return;
@ -1068,21 +1067,13 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
if (cs.GetVisible(line))
DrawLine(surface, vs, line, xStart, rcLine, ll);
bool expanded = cs.GetExpanded(line);
if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
if (foldFlags & 2) {
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.bottom = rcFoldLine.top + 1;
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
}
}
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);
}
}
// Draw the Caret
if (line == lineCaret) {
@ -1213,9 +1204,10 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
if (linePrintLast < pdoc->LinesTotal())
endPosPrint = pdoc->LineStart(linePrintLast + 1);
// Ensure we are styled to where we are formatting.
pdoc->EnsureStyledTo(endPosPrint);
if (endPosPrint > pdoc->GetEndStyled()) {
// Notify container to do some more styling
NotifyStyleNeeded(endPosPrint);
}
int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
int ypos = pfr->rc.top;
int line = linePrintStart;
@ -1236,27 +1228,20 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
PRectangle rcNumber = rcLine;
rcNumber.right = rcNumber.left + lineNumberWidth;
// Right justify
rcNumber.left -=
rcNumber.left += lineNumberWidth -
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
ypos + vsPrint.maxAscent, number, strlen(number),
vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
}
// When printing, the hdc and hdcTarget may be the same, so
// changing the state of surfaceMeasure may change the underlying
// state of surface. Therefore, any cached state is discarded before
// using each surface.
// Copy this line and its styles from the document into local arrays
// and determine the x position at which each character starts.
surfaceMeasure->FlushCachedState();
LineLayout ll;
LayoutLine(line, surfaceMeasure, vsPrint, ll);
// Draw the line
surface->FlushCachedState();
DrawLine(surface, vsPrint, line, xStart, rcLine, ll);
ypos += vsPrint.lineHeight;
@ -1436,10 +1421,6 @@ void Editor::NotifyStyleNeeded(int endStyleNeeded) {
NotifyParent(scn);
}
void Editor::NotifyStyleNeeded(Document*, void *, int endStyleNeeded) {
NotifyStyleNeeded(endStyleNeeded);
}
void Editor::NotifyChar(char ch) {
SCNotification scn;
scn.nmhdr.code = SCN_CHARADDED;
@ -1618,10 +1599,6 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) {
SetScrollBars();
}
if (mh.modificationType & SC_MOD_CHANGEMARKER) {
RedrawSelMargin();
}
// If client wants to see this modification
if (mh.modificationType & modEventMask) {
if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
@ -1700,11 +1677,6 @@ void Editor::NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam) {
case SCI_VCHOMEEXTEND:
case SCI_DELWORDLEFT:
case SCI_DELWORDRIGHT:
case SCI_LINECUT:
case SCI_LINEDELETE:
case SCI_LINETRANSPOSE:
case SCI_LOWERCASE:
case SCI_UPPERCASE:
break;
// Filter out all others (display changes, etc)
@ -1740,60 +1712,6 @@ void Editor::PageMove(int direction, bool extend) {
}
}
void Editor::ChangeCaseOfSelection(bool makeUpperCase) {
pdoc->BeginUndoAction();
int startCurrent = currentPos;
int startAnchor = anchor;
if (selType == selRectangle) {
int lineStart = pdoc->LineFromPosition(SelectionStart());
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
for (int line=lineStart; line <= lineEnd; line++) {
pdoc->ChangeCase(
Range(SelectionStart(line), SelectionEnd(line)),
makeUpperCase);
}
// Would be nicer to keep the rectangular selection but this is complex
selType = selStream;
SetSelection(startCurrent, startCurrent);
} else {
pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()),
makeUpperCase);
SetSelection(startCurrent, startAnchor);
}
pdoc->EndUndoAction();
}
void Editor::LineTranspose() {
int line = pdoc->LineFromPosition(currentPos);
if (line > 0) {
int startPrev = pdoc->LineStart(line-1);
int endPrev = pdoc->LineEnd(line-1);
int start = pdoc->LineStart(line);
int end = pdoc->LineEnd(line);
int startNext = pdoc->LineStart(line+1);
if (end < pdoc->Length()) {
end = startNext;
char *thisLine = CopyRange(start, end);
pdoc->DeleteChars(start, end-start);
pdoc->InsertString(startPrev, thisLine, end-start);
MovePositionTo(startPrev+end-start);
delete []thisLine;
} else {
// Last line so line has no line end
char *thisLine = CopyRange(start, end);
char *prevEnd = CopyRange(endPrev, start);
pdoc->DeleteChars(endPrev, end-endPrev);
pdoc->InsertString(startPrev, thisLine, end-start);
pdoc->InsertString(startPrev + end-start, prevEnd, start-endPrev);
MovePositionTo(startPrev + end-endPrev);
delete []thisLine;
delete []prevEnd;
}
}
}
int Editor::KeyCommand(UINT iMessage) {
Point pt = LocationFromPosition(currentPos);
@ -1966,40 +1884,8 @@ int Editor::KeyCommand(UINT iMessage) {
case SCI_DELWORDRIGHT: {
int endWord = pdoc->NextWordStart(currentPos, 1);
pdoc->DeleteChars(currentPos, endWord - currentPos);
MovePositionTo(currentPos);
}
break;
case SCI_LINECUT: {
int lineStart = pdoc->LineFromPosition(currentPos);
int lineEnd = pdoc->LineFromPosition(anchor);
if (lineStart > lineEnd) {
int t = lineEnd;
lineEnd = lineStart;
lineStart = t;
}
int start = pdoc->LineStart(lineStart);
int end = pdoc->LineStart(lineEnd+1);
SetSelection(start,end);
Cut();
}
break;
case SCI_LINEDELETE: {
int line = pdoc->LineFromPosition(currentPos);
int start = pdoc->LineStart(line);
int end = pdoc->LineStart(line+1);
pdoc->DeleteChars(start, end-start);
MovePositionTo(start);
}
break;
case SCI_LINETRANSPOSE:
LineTranspose();
break;
case SCI_LOWERCASE:
ChangeCaseOfSelection(false);
break;
case SCI_UPPERCASE:
ChangeCaseOfSelection(true);
break;
}
return 0;
}
@ -2225,11 +2111,7 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul
int positionWasInSelection = PositionInSelection(position);
bool positionOnEdgeOfSelection =
(position == SelectionStart()) || (position == SelectionEnd());
if ((!inDragDrop) || !(0 == positionWasInSelection) ||
(positionOnEdgeOfSelection && !moving)) {
if ((!inDragDrop) || !(0 == positionWasInSelection)) {
int selStart = SelectionStart();
int selEnd = SelectionEnd();
@ -2684,10 +2566,6 @@ void Editor::SetDocPointer(Document *document) {
pdoc = document;
}
pdoc->AddRef();
// Reset the contraction state to fully shown.
cs.Clear();
cs.InsertLines(0, pdoc->LinesTotal()-1);
pdoc->AddWatcher(this, 0);
Redraw();
SetScrollBars();
@ -2802,7 +2680,6 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
case WM_PASTE:
Paste();
SetLastXChosen();
EnsureCaretVisible();
break;
case WM_CLEAR:
@ -3184,8 +3061,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
#ifdef INCLUDE_DEPRECATED_FEATURES
case SCI_APPENDUNDOSTARTACTION:
// Not just deprecated - now dead
//pdoc->AppendUndoStartAction();
pdoc->AppendUndoStartAction();
return 0;
#endif
@ -3384,15 +3260,18 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
break;
case SCI_MARKERADD: {
int markerID = pdoc->AddMark(wParam, lParam);
RedrawSelMargin();
return markerID;
}
case SCI_MARKERDELETE:
pdoc->DeleteMark(wParam, lParam);
RedrawSelMargin();
break;
case SCI_MARKERDELETEALL:
pdoc->DeleteAllMarks(static_cast<int>(wParam));
RedrawSelMargin();
break;
case SCI_MARKERGET:
@ -3512,7 +3391,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (lParam == 0)
return 0;
if (wParam <= STYLE_MAX) {
vs.SetStyleFontName(wParam, reinterpret_cast<const char *>(lParam));
strcpy(vs.styles[wParam].fontName, reinterpret_cast<char *>(lParam));
InvalidateStyleRedraw();
}
break;
@ -3613,14 +3492,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
caretSlop = lParam;
break;
case SCI_LINESONSCREEN:
return LinesOnScreen();
case SCI_USEPOPUP:
displayPopupMenu = wParam;
break;
#ifdef INCLUDE_DEPRECATED_FEATURES
#ifdef INCLUDE_DEPRECATED_FEATURES
case SCI_SETFORE:
vs.styles[STYLE_DEFAULT].fore.desired = Colour(wParam);
InvalidateStyleRedraw();
@ -3740,11 +3612,6 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
case SCI_ZOOMOUT:
case SCI_DELWORDLEFT:
case SCI_DELWORDRIGHT:
case SCI_LINECUT:
case SCI_LINEDELETE:
case SCI_LINETRANSPOSE:
case SCI_LOWERCASE:
case SCI_UPPERCASE:
return KeyCommand(iMessage);
case SCI_BRACEHIGHLIGHT:

View File

@ -116,8 +116,6 @@ protected: // ScintillaBase subclass needs access to much of Editor
int searchAnchor;
int displayPopupMenu;
#ifdef MACRO_SUPPORT
int recordingMacro;
#endif
@ -220,16 +218,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
void NotifyModified(Document *document, DocModification mh, void *userData);
void NotifyDeleted(Document *document, void *userData);
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
#ifdef MACRO_SUPPORT
void NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam);
#endif
void PageMove(int direction, bool extend=false);
void ChangeCaseOfSelection(bool makeUpperCase);
void LineTranspose();
virtual int KeyCommand(UINT iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/);
int KeyDown(int key, bool shift, bool ctrl, bool alt);

View File

@ -61,36 +61,36 @@ UINT KeyMap::Find(int key, int modifiers) {
}
KeyToCommand KeyMap::MapDefault[] = {
VK_DOWN, SCI_NORM, SCI_LINEDOWN,
VK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND,
VK_UP, SCI_NORM, SCI_LINEUP,
VK_UP, SCI_SHIFT, SCI_LINEUPEXTEND,
VK_DOWN, SCI_NORM, SCI_LINEDOWN,
VK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND,
VK_UP, SCI_NORM, SCI_LINEUP,
VK_UP, SCI_SHIFT, SCI_LINEUPEXTEND,
VK_LEFT, SCI_NORM, SCI_CHARLEFT,
VK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND,
VK_LEFT, SCI_CTRL, SCI_WORDLEFT,
VK_LEFT, SCI_CSHIFT, SCI_WORDLEFTEXTEND,
VK_RIGHT, SCI_NORM, SCI_CHARRIGHT,
VK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND,
VK_RIGHT, SCI_CTRL, SCI_WORDRIGHT,
VK_RIGHT, SCI_CSHIFT, SCI_WORDRIGHTEXTEND,
VK_HOME, SCI_NORM, SCI_VCHOME,
VK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND,
VK_HOME, SCI_CTRL, SCI_DOCUMENTSTART,
VK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND,
VK_RIGHT, SCI_NORM, SCI_CHARRIGHT,
VK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND,
VK_RIGHT, SCI_CTRL, SCI_WORDRIGHT,
VK_RIGHT, SCI_CSHIFT, SCI_WORDRIGHTEXTEND,
VK_HOME, SCI_NORM, SCI_VCHOME,
VK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND,
VK_HOME, SCI_CTRL, SCI_DOCUMENTSTART,
VK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND,
VK_END, SCI_NORM, SCI_LINEEND,
VK_END, SCI_SHIFT, SCI_LINEENDEXTEND,
VK_END, SCI_CTRL, SCI_DOCUMENTEND,
VK_END, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND,
VK_PRIOR, SCI_NORM, SCI_PAGEUP,
VK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND,
VK_NEXT, SCI_NORM, SCI_PAGEDOWN,
VK_NEXT, SCI_SHIFT, SCI_PAGEDOWNEXTEND,
VK_PRIOR, SCI_NORM, SCI_PAGEUP,
VK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND,
VK_NEXT, SCI_NORM, SCI_PAGEDOWN,
VK_NEXT, SCI_SHIFT, SCI_PAGEDOWNEXTEND,
VK_DELETE, SCI_NORM, WM_CLEAR,
VK_DELETE, SCI_SHIFT, WM_CUT,
VK_DELETE, SCI_CTRL, SCI_DELWORDRIGHT,
VK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE,
VK_INSERT, SCI_SHIFT, WM_PASTE,
VK_INSERT, SCI_CTRL, WM_COPY,
VK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE,
VK_INSERT, SCI_SHIFT, WM_PASTE,
VK_INSERT, SCI_CTRL, WM_COPY,
VK_ESCAPE, SCI_NORM, SCI_CANCEL,
VK_BACK, SCI_NORM, SCI_DELETEBACK,
VK_BACK, SCI_CTRL, SCI_DELWORDLEFT,
@ -103,14 +103,9 @@ KeyToCommand KeyMap::MapDefault[] = {
VK_TAB, SCI_NORM, SCI_TAB,
VK_TAB, SCI_SHIFT, SCI_BACKTAB,
VK_RETURN, SCI_NORM, SCI_NEWLINE,
'L', SCI_CTRL, SCI_FORMFEED,
VK_ADD, SCI_CTRL, SCI_ZOOMIN,
VK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT,
//'L', SCI_CTRL, SCI_FORMFEED,
'L', SCI_CTRL, SCI_LINECUT,
'L', SCI_CSHIFT, SCI_LINEDELETE,
'T', SCI_CTRL, SCI_LINETRANSPOSE,
'U', SCI_CTRL, SCI_LOWERCASE,
'U', SCI_CSHIFT, SCI_UPPERCASE,
0,0,0,
};

View File

@ -11,7 +11,6 @@
#define SCI_CTRL LEFT_CTRL_PRESSED
#define SCI_ALT LEFT_ALT_PRESSED
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
class KeyToCommand {
public:

File diff suppressed because it is too large Load Diff

View File

@ -1,255 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexCPP.cxx - lexer for C++, C, Java, and Javascript
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
char s[100];
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
bool wordIsUUID = false;
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
}
char chAttr = SCE_C_IDENTIFIER;
if (wordIsNumber)
chAttr = SCE_C_NUMBER;
else {
if (keywords.InList(s)) {
chAttr = SCE_C_WORD;
wordIsUUID = strcmp(s, "uuid") == 0;
}
}
styler.ColourTo(end, chAttr);
return wordIsUUID;
}
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
StylingContext &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
bool fold = styler.GetPropSet().GetInt("fold");
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
int state = initStyle;
char chPrev = ' ';
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
int visChars = 0;
styler.StartSegment(startPos);
bool lastWordWasUUID = false;
for (unsigned int i = startPos; i <= lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((fold) && ((ch == '\r' && chNext != '\n') || (ch == '\n'))) {
int lev = levelPrev;
if (visChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
visChars = 0;
levelPrev = levelCurrent;
}
if (!isspace(ch))
visChars++;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_C_STRINGEOL) {
if (ch != '\r' && ch != '\n') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
}
if (state == SCE_C_DEFAULT) {
if (iswordstart(ch)) {
styler.ColourTo(i-1, state);
if (lastWordWasUUID) {
state = SCE_C_UUID;
lastWordWasUUID = false;
} else {
state = SCE_C_WORD;
}
} else if (ch == '/' && chNext == '*') {
styler.ColourTo(i-1, state);
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i-1, state);
state = SCE_C_STRING;
} else if (ch == '\'') {
styler.ColourTo(i-1, state);
state = SCE_C_CHARACTER;
} else if (ch == '#') {
styler.ColourTo(i-1, state);
state = SCE_C_PREPROCESSOR;
} else if (isoperator(ch)) {
styler.ColourTo(i-1, state);
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
} else if (state == SCE_C_WORD) {
if (!iswordchar(ch)) {
lastWordWasUUID = classifyWordCpp(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_C_DEFAULT;
if (ch == '/' && chNext == '*') {
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_C_STRING;
} else if (ch == '\'') {
state = SCE_C_CHARACTER;
} else if (ch == '#') {
state = SCE_C_PREPROCESSOR;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
}
} else {
if (state == SCE_C_PREPROCESSOR) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_COMMENT) {
if (ch == '/' && chPrev == '*') {
if (((i > styler.GetStartSegment() + 2) || (
(initStyle == SCE_C_COMMENT) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTDOC) {
if (ch == '/' && chPrev == '*') {
if (((i > styler.GetStartSegment() + 3) || (
(initStyle == SCE_C_COMMENTDOC) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_STRING) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, state);
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;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_C_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, state);
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;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_C_UUID) {
if (ch == '\r' || ch == '\n' || ch == ')') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
}
if (state == SCE_C_DEFAULT) { // One of the above succeeded
if (ch == '/' && chNext == '*') {
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_C_STRING;
} else if (ch == '\'') {
state = SCE_C_CHARACTER;
} else if (ch == '#') {
state = SCE_C_PREPROCESSOR;
} else if (iswordstart(ch)) {
state = SCE_C_WORD;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
}
}
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 lmCPP(SCLEX_CPP, ColouriseCppDoc);

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexOthers.cxx - lexers for properties files, batch files, make files and error lists
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void ColouriseBatchLine(char *lineBuffer, int endLine, StylingContext &styler) {
if (0 == strncmp(lineBuffer, "REM", 3)) {
styler.ColourTo(endLine, 1);
} else if (0 == strncmp(lineBuffer, "rem", 3)) {
styler.ColourTo(endLine, 1);
} else if (0 == strncmp(lineBuffer, "SET", 3)) {
styler.ColourTo(endLine, 2);
} else if (0 == strncmp(lineBuffer, "set", 3)) {
styler.ColourTo(endLine, 2);
} else if (lineBuffer[0] == ':') {
styler.ColourTo(endLine, 3);
} else {
styler.ColourTo(endLine, 0);
}
}
static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
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)) {
ColouriseBatchLine(lineBuffer, i, styler);
linePos = 0;
}
}
if (linePos > 0)
ColouriseBatchLine(lineBuffer, startPos + length, styler);
}
static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, StylingContext &styler) {
int i = 0;
while (isspace(lineBuffer[i]) && (i < lengthLine)) // 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 {
while (lineBuffer[i] != '=' && (i < lengthLine)) // Search the '=' character
i++;
if (lineBuffer[i] == '=') {
styler.ColourTo(startLine+i-1, 0);
styler.ColourTo(startLine+i, 3);
styler.ColourTo(endPos, 0);
} else {
styler.ColourTo(endPos, 0);
}
}
}
static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
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)) {
lineBuffer[linePos] = '\0';
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0;
startLine = i+1;
}
}
if (linePos > 0)
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
}
static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
int i = 0;
while (isspace(lineBuffer[i]) && (i < lengthLine))
i++;
if (lineBuffer[i] == '#' || lineBuffer[i] == '!') {
styler.ColourTo(endPos, 1);
} else {
styler.ColourTo(endPos, 0);
}
}
static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
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)) {
ColouriseMakeLine(lineBuffer, linePos, i, styler);
linePos = 0;
}
}
if (linePos > 0)
ColouriseMakeLine(lineBuffer, linePos, startPos + length, styler);
}
static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
if (lineBuffer[0] == '>') {
// Command or return status
styler.ColourTo(endPos, 4);
} else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
styler.ColourTo(endPos, 1);
} else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
// Borland error message
styler.ColourTo(endPos, 5);
} else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
// Borland warning message
styler.ColourTo(endPos, 5);
} else {
// Look for <filename>:<line>:message
// Look for <filename>(line)message
// Look for <filename>(line,pos)message
int state = 0;
for (int i = 0; i < lengthLine; i++) {
if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
state = 1;
} else if (state == 0 && lineBuffer[i] == '(') {
state = 10;
} else if (state == 1 && isdigit(lineBuffer[i])) {
state = 2;
} else if (state == 2 && lineBuffer[i] == ':') {
state = 3;
break;
} else if (state == 2 && !isdigit(lineBuffer[i])) {
state = 99;
} else if (state == 10 && isdigit(lineBuffer[i])) {
state = 11;
} else if (state == 11 && lineBuffer[i] == ',') {
state = 14;
} else if (state == 11 && lineBuffer[i] == ')') {
state = 12;
break;
} else if (state == 12 && lineBuffer[i] == ':') {
state = 13;
} else if (state == 14 && lineBuffer[i] == ')') {
state = 15;
break;
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
state = 99;
}
}
if (state == 3) {
styler.ColourTo(endPos, 2);
} else if ((state == 14) || (state == 15)) {
styler.ColourTo(endPos, 3);
} else {
styler.ColourTo(endPos, 0);
}
}
}
static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
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)) {
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
linePos = 0;
}
}
if (linePos > 0)
ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
}
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc);
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc);
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc);
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc);

View File

@ -1,488 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexPerl.cxx - lexer for subset of Perl
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
inline bool isPerlOperator(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 == '~')
return true;
return false;
}
static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, StylingContext &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_PL_IDENTIFIER;
if (wordIsNumber)
chAttr = SCE_PL_NUMBER;
else {
if (keywords.InList(s))
chAttr = SCE_PL_WORD;
}
styler.ColourTo(end, chAttr);
return chAttr;
}
static bool isEndVar(char ch) {
return !isalnum(ch) && ch != '#' && ch != '$' &&
ch != '_' && ch != '\'';
}
static bool isMatch(StylingContext &styler, int lengthDoc, int pos, const char *val) {
if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
return false;
}
while (*val) {
if (*val != styler[pos++]) {
return false;
}
val++;
}
return true;
}
static bool isOKQuote(char ch) {
if (isalnum(ch))
return false;
if (isspace(ch))
return false;
if (iscntrl(ch))
return false;
return true;
}
static char opposite(char ch) {
if (ch == '(')
return ')';
if (ch == '[')
return ']';
if (ch == '{')
return '}';
if (ch == '<')
return '>';
return ch;
}
static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], StylingContext &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
// start position and what the termination string is for here documents
WordList &keywords = *keywordlists[0];
char sooked[100];
int quotes = 0;
char quoteDown = 'd';
char quoteUp = 'd';
int quoteRep = 1;
int sookedpos = 0;
bool preferRE = true;
sooked[sookedpos] = '\0';
int state = initStyle;
int lengthDoc = startPos + length;
// If in a long distance lexical state, seek to the beginning to find quote characters
if (state == SCE_PL_HERE || state == SCE_PL_REGEX ||
state == SCE_PL_REGSUBST || state == SCE_PL_LONGQUOTE) {
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
startPos--;
}
state = SCE_PL_DEFAULT;
}
styler.StartAt(startPos);
char chPrev = ' ';
char chNext = styler[startPos];
styler.StartSegment(startPos);
for (int i = startPos; i <= lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2);
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_PL_DEFAULT) {
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
if (ch == 's' && !isalnum(chNext)) {
state = SCE_PL_REGSUBST;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 2;
} else if (ch == 'm' && !isalnum(chNext)) {
state = SCE_PL_REGEX;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 1;
} else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) {
state = SCE_PL_REGSUBST;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 2;
i++;
chNext = chNext2;
} else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) {
state = SCE_PL_LONGQUOTE;
i++;
chNext = chNext2;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 1;
} else {
state = SCE_PL_WORD;
preferRE = false;
}
} else if (ch == '#') {
styler.ColourTo(i - 1, state);
state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i - 1, state);
state = SCE_PL_STRING;
} else if (ch == '\'') {
if (chPrev == '&') {
// Archaic call
styler.ColourTo(i, state);
} else {
styler.ColourTo(i - 1, state);
state = SCE_PL_CHARACTER;
}
} else if (ch == '`') {
styler.ColourTo(i - 1, state);
state = SCE_PL_BACKTICKS;
} else if (ch == '$') {
preferRE = false;
styler.ColourTo(i - 1, state);
if (isalnum(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
state = SCE_PL_SCALAR;
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_SCALAR);
i++;
ch = ' ';
chNext = ' ';
} else {
styler.ColourTo(i, SCE_PL_SCALAR);
}
} else if (ch == '@') {
preferRE = false;
styler.ColourTo(i - 1, state);
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
state = SCE_PL_ARRAY;
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_ARRAY);
i++;
ch = ' ';
} else {
styler.ColourTo(i, SCE_PL_ARRAY);
}
} else if (ch == '%') {
preferRE = false;
styler.ColourTo(i - 1, state);
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
state = SCE_PL_HASH;
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_HASH);
i++;
ch = ' ';
} else {
styler.ColourTo(i, SCE_PL_HASH);
}
} else if (ch == '*') {
styler.ColourTo(i - 1, state);
state = SCE_PL_SYMBOLTABLE;
} else if (ch == '/' && preferRE) {
styler.ColourTo(i - 1, state);
state = SCE_PL_REGEX;
quoteUp = '/';
quoteDown = '/';
quotes = 1;
quoteRep = 1;
} else if (ch == '<' && chNext == '<') {
styler.ColourTo(i - 1, state);
state = SCE_PL_HERE;
i++;
ch = chNext;
chNext = chNext2;
quotes = 0;
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (ch == '=' && isalpha(chNext)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_POD;
quotes = 0;
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (isPerlOperator(ch)) {
if (ch == ')' || ch == ']')
preferRE = false;
else
preferRE = true;
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_PL_OPERATOR);
}
} else if (state == SCE_PL_WORD) {
if (!iswordchar(ch) && ch != '\'') { // Archaic Perl has quotes inside names
if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) {
styler.ColourTo(i, SCE_PL_DATASECTION);
state = SCE_PL_DATASECTION;
} else if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) {
styler.ColourTo(i, SCE_PL_DATASECTION);
state = SCE_PL_DATASECTION;
} else {
if (classifyWordPerl(styler.GetStartSegment(), i - 1, keywords, styler) == SCE_PL_WORD)
preferRE = true;
state = SCE_PL_DEFAULT;
if (ch == '#') {
state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_PL_STRING;
} else if (ch == '\'') {
state = SCE_PL_CHARACTER;
} else if (ch == '<' && chNext == '<') {
state = SCE_PL_HERE;
quotes = 0;
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (isPerlOperator(ch)) {
if (ch == ')' || ch == ']')
preferRE = false;
else
preferRE = true;
styler.ColourTo(i, SCE_PL_OPERATOR);
state = SCE_PL_DEFAULT;
}
}
}
} else {
if (state == SCE_PL_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_HERE) {
if (isalnum(ch) && quotes < 2) {
sooked[sookedpos++] = ch;
sooked[sookedpos] = '\0';
if (quotes == 0)
quotes = 1;
} else {
quotes++;
}
if (quotes > 1 && isMatch(styler, lengthDoc, i, sooked)) {
styler.ColourTo(i + sookedpos - 1, SCE_PL_HERE);
state = SCE_PL_DEFAULT;
i += sookedpos;
chNext = ' ';
}
} else if (state == SCE_PL_STRING) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_CHARACTER) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_BACKTICKS) {
if (ch == '`') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_POD) {
if (ch == '=') {
if (isMatch(styler, lengthDoc, i, "=cut")) {
styler.ColourTo(i - 1 + 4, state);
i += 4;
state = SCE_PL_DEFAULT;
chNext = ' ';
ch = ' ';
}
}
} else if (state == SCE_PL_SCALAR) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_ARRAY) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_HASH) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_SYMBOLTABLE) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_REF) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_REGEX) {
if (!quoteUp && !isspace(ch)) {
quoteUp = ch;
quoteDown = opposite(ch);
quotes++;
} else {
if (ch == quoteDown && chPrev != '\\') {
quotes--;
if (quotes == 0) {
quoteRep--;
if (quoteUp == quoteDown) {
quotes++;
}
}
if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
} else if (ch == quoteUp && chPrev != '\\') {
quotes++;
} else if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
}
} else if (state == SCE_PL_REGSUBST) {
if (!quoteUp && !isspace(ch)) {
quoteUp = ch;
quoteDown = opposite(ch);
quotes++;
} else {
if (ch == quoteDown && chPrev != '\\') {
quotes--;
if (quotes == 0) {
quoteRep--;
}
if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
if (quoteUp == quoteDown) {
quotes++;
}
} else if (ch == quoteUp && chPrev != '\\') {
quotes++;
} else if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
}
} else if (state == SCE_PL_LONGQUOTE) {
if (!quoteDown && !isspace(ch)) {
quoteUp = ch;
quoteDown = opposite(quoteUp);
quotes++;
} else if (ch == quoteDown) {
quotes--;
if (quotes == 0) {
quoteRep--;
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
if (quoteUp == quoteDown) {
quotes++;
}
}
} else if (ch == quoteUp) {
quotes++;
}
}
if (state == SCE_PL_DEFAULT) { // One of the above succeeded
if (ch == '#') {
state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_PL_STRING;
} else if (ch == '\'') {
state = SCE_PL_CHARACTER;
} else if (iswordstart(ch)) {
state = SCE_PL_WORD;
preferRE = false;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_PL_OPERATOR);
}
}
}
chPrev = ch;
}
styler.ColourTo(lengthDoc, state);
}
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc);

View File

@ -1,254 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexPython.cxx - lexer for Python
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void classifyWordPy(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler, char *prevWord) {
char s[100];
bool wordIsNumber = isdigit(styler[start]);
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
}
char chAttr = SCE_P_IDENTIFIER;
if (0 == strcmp(prevWord, "class"))
chAttr = SCE_P_CLASSNAME;
else if (0 == strcmp(prevWord, "def"))
chAttr = SCE_P_DEFNAME;
else if (wordIsNumber)
chAttr = SCE_P_NUMBER;
else if (keywords.InList(s))
chAttr = SCE_P_WORD;
styler.ColourTo(end, chAttr);
strcpy(prevWord, s);
}
static bool IsPyComment(StylingContext &styler, int pos, int len) {
return len>0 && styler[pos]=='#';
}
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], StylingContext &styler) {
// Python uses a different mask because bad indentation is marked by oring with 32
styler.StartAt(startPos, 127);
WordList &keywords = *keywordlists[0];
//Platform::DebugPrintf("Python coloured\n");
bool fold = styler.GetPropSet().GetInt("fold");
int whingeLevel = styler.GetPropSet().GetInt("tab.timmy.whinge.level");
char prevWord[200];
prevWord[0] = '\0';
if (length == 0)
return ;
int lineCurrent = styler.GetLine(startPos);
int spaceFlags = 0;
// TODO: Need to check previous line for indentation for both folding and bad indentation
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
int state = initStyle & 31;
char chPrev = ' ';
char chPrev2 = ' ';
char chNext = styler[startPos];
char chNext2 = styler[startPos];
styler.StartSegment(startPos);
int lengthDoc = startPos + length;
bool atStartLine = true;
for (int i = startPos; i <= lengthDoc; i++) {
if (atStartLine) {
if (whingeLevel == 1) {
styler.SetFlags((spaceFlags & wsInconsistent) ? 64 : 0, state);
} else if (whingeLevel == 2) {
styler.SetFlags((spaceFlags & wsSpaceTab) ? 64 : 0, state);
} else if (whingeLevel == 3) {
styler.SetFlags((spaceFlags & wsSpace) ? 64 : 0, state);
} else if (whingeLevel == 4) {
styler.SetFlags((spaceFlags & wsTab) ? 64 : 0, state);
}
atStartLine = false;
}
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
chNext2 = styler.SafeGetCharAt(i + 2);
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
// Perform colourisation of white space and triple quoted strings at end of each line to allow
// tab marking to work inside white space and triple quoted strings
styler.ColourTo(i, state);
}
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsPyComment);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
// Line after is blank so check the next - maybe should continue further?
int spaceFlags2 = 0;
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsPyComment);
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
}
indentCurrent = indentNext;
if (fold) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
atStartLine = true;
}
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
chPrev2 = ' ';
i += 1;
continue;
}
if (state == SCE_P_STRINGEOL) {
if (ch != '\r' && ch != '\n') {
styler.ColourTo(i - 1, state);
state = SCE_P_DEFAULT;
}
}
if (state == SCE_P_DEFAULT) {
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_P_WORD;
} else if (ch == '#') {
styler.ColourTo(i - 1, state);
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i - 1, state);
if (chNext == '\"' && chNext2 == '\"') {
i += 2;
state = SCE_P_TRIPLEDOUBLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_STRING;
}
} else if (ch == '\'') {
styler.ColourTo(i - 1, state);
if (chNext == '\'' && chNext2 == '\'') {
i += 2;
state = SCE_P_TRIPLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_CHARACTER;
}
} else if (isoperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_P_OPERATOR);
}
} else if (state == SCE_P_WORD) {
if (!iswordchar(ch)) {
classifyWordPy(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
state = SCE_P_DEFAULT;
if (ch == '#') {
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (ch == '\"') {
if (chNext == '\"' && chNext2 == '\"') {
i += 2;
state = SCE_P_TRIPLEDOUBLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_STRING;
}
} else if (ch == '\'') {
if (chNext == '\'' && chNext2 == '\'') {
i += 2;
state = SCE_P_TRIPLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_CHARACTER;
}
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_P_OPERATOR);
}
}
} else {
if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_STRING) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_P_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_P_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_TRIPLE) {
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_TRIPLEDOUBLE) {
if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
}
}
chPrev2 = chPrev;
chPrev = ch;
}
if (state == SCE_P_WORD) {
classifyWordPy(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
} else {
styler.ColourTo(lengthDoc, state);
}
}
LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc);

View File

@ -1,158 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexSQL.cxx - lexer for SQL
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keywords, StylingContext &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] = toupper(styler[start + i]);
s[i + 1] = '\0';
}
char chAttr = SCE_C_IDENTIFIER;
if (wordIsNumber)
chAttr = SCE_C_NUMBER;
else {
if (keywords.InList(s))
chAttr = SCE_C_WORD;
}
styler.ColourTo(end, chAttr);
}
static void ColouriseSQLDoc(unsigned int startPos, int length,
int initStyle, WordList *keywordlists[], StylingContext &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
bool fold = styler.GetPropSet().GetInt("fold");
int lineCurrent = styler.GetLine(startPos);
int spaceFlags = 0;
int indentCurrent = 0;
int state = initStyle;
char chPrev = ' ';
char chNext = styler[startPos];
styler.StartSegment(startPos);
unsigned int lengthDoc = startPos + length;
bool prevCr = false;
for (unsigned int i = startPos; i <= lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags);
int lev = indentCurrent;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags);
if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
if (fold) {
styler.SetLevel(lineCurrent, lev);
}
}
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_WORD;
} else if (ch == '/' && chNext == '*') {
styler.ColourTo(i - 1, state);
state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') {
styler.ColourTo(i - 1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '\'') {
styler.ColourTo(i - 1, state);
state = SCE_C_STRING;
} else if (isoperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_C_OPERATOR);
}
} else if (state == SCE_C_WORD) {
if (!iswordchar(ch)) {
classifyWordSQL(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_C_DEFAULT;
if (ch == '/' && chNext == '*') {
state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\'') {
state = SCE_C_STRING;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
}
}
} else {
if (state == SCE_C_COMMENT) {
if (ch == '/' && chPrev == '*') {
if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_C_COMMENT) &&
(styler.GetStartSegment() == startPos)))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_STRING) {
if (ch == '\'') {
if ( chNext == '\'' ) {
i++;
} else {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
i++;
}
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
if (state == SCE_C_DEFAULT) { // One of the above succeeded
if (ch == '/' && chNext == '*') {
state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\'') {
state = SCE_C_STRING;
} else if (iswordstart(ch)) {
state = SCE_C_WORD;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
}
}
}
chPrev = ch;
}
styler.ColourTo(lengthDoc - 1, state);
}
LexerModule lmSQL(SCLEX_SQL, ColouriseSQLDoc);

View File

@ -1,118 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexVB.cxx - lexer for Visual Basic and VBScript
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, StylingContext &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] = tolower(styler[start + i]);
s[i + 1] = '\0';
}
char chAttr = SCE_C_DEFAULT;
if (wordIsNumber)
chAttr = SCE_C_NUMBER;
else {
if (keywords.InList(s)) {
chAttr = SCE_C_WORD;
if (strcmp(s, "rem") == 0)
chAttr = SCE_C_COMMENTLINE;
}
}
styler.ColourTo(end, chAttr);
if (chAttr == SCE_C_COMMENTLINE)
return SCE_C_COMMENTLINE;
else
return SCE_C_DEFAULT;
}
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], StylingContext &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
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 (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 (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 (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_C_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);
}
}
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;
}
}
}
}
styler.ColourTo(lengthDoc, state);
}
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc);

View File

@ -27,7 +27,6 @@ bool EqualCaseInsensitive(const char *a, const char *b) {
// Get a line of input. If end of line escaped with '\\' then continue reading.
static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
bool continuation = true;
s[0] = '\0';
while ((len > 1) && lenData > 0) {
char ch = *fpc;
fpc++;
@ -47,7 +46,6 @@ static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
} else {
continuation = false;
*s++ = ch;
*s = '\0';
len--;
}
}
@ -255,9 +253,6 @@ void PropSet::ReadFromMemory(const char *data, int len) {
if (isalpha(linebuf[0]))
Set(linebuf);
}
// If there is a final line:
if (isalpha(linebuf[0]))
Set(linebuf);
}
}

View File

@ -30,7 +30,7 @@ class SVector {
return;
}
size = newSize;
for (unsigned int i=0; i<len; i++) {
for (int i=0; i<len; i++) {
newv[i] = v[i];
}
delete []v;
@ -94,13 +94,13 @@ public:
size = 0;
len = 0;
}
void SetLength(unsigned int newLength) {
if (newLength > len) {
if (newLength >= size) {
SizeTo(newLength);
void SetLength(int newLen) {
if (newLen > len) {
if (newLen >= size) {
SizeTo(newLen);
}
}
len = newLength;
len = newLen;
}
int Length() const {
return len;

View File

@ -276,14 +276,15 @@ void ScintillaBase::Colourise(int start, int end) {
end = lengthDoc;
int len = end - start;
PropSet props;
StylingContext styler(wMain.GetID(), props);
int styleStart = 0;
if (start > 0)
styleStart = styler.StyleAt(start - 1);
styler.SetCodePage(pdoc->dbcsCodePage);
LexerModule::Colourise(start, len, styleStart, lexLanguage, keyWordLists, styler);
ColouriseDoc(pdoc->dbcsCodePage, start, len, styleStart, lexLanguage, keyWordLists, styler);
styler.Flush();
}
#endif

View File

@ -10,31 +10,23 @@
#include "Style.h"
Style::Style() {
aliasOfDefaultFont = true;
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
Platform::DefaultFontSize(), 0,
false, false, false);
Clear();
}
Style::~Style() {
if (aliasOfDefaultFont)
font.SetID(0);
else
font.Release();
aliasOfDefaultFont = false;
font.Release();
}
Style &Style::operator=(const Style &source) {
if (this == &source)
return *this;
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
0, 0,
false, false, false);
Clear();
fore.desired = source.fore.desired;
back.desired = source.back.desired;
bold = source.bold;
italic = source.italic;
size = source.size;
strcpy(fontName, source.fontName);
eolFilled = source.eolFilled;
return *this;
}
@ -46,48 +38,18 @@ void Style::Clear(Colour fore_, Colour back_, int size_, const char *fontName_,
bold = bold_;
italic = italic_;
size = size_;
fontName = fontName_;
strcpy(fontName, fontName_);
eolFilled = eolFilled_;
if (aliasOfDefaultFont)
font.SetID(0);
else
font.Release();
aliasOfDefaultFont = false;
font.Release();
}
bool Style::EquivalentFontTo(const Style *other) const {
if (bold != other->bold ||
italic != other->italic ||
size != other->size)
return false;
if (fontName == other->fontName)
return true;
if (!fontName)
return false;
if (!other->fontName)
return false;
return strcmp(fontName, other->fontName) == 0;
}
void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) {
void Style::Realise(Surface &surface, int zoomLevel) {
int sizeZoomed = size + zoomLevel;
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
sizeZoomed = 2;
if (aliasOfDefaultFont)
font.SetID(0);
else
font.Release();
int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
aliasOfDefaultFont = defaultStyle &&
(EquivalentFontTo(defaultStyle) || !fontName);
if (aliasOfDefaultFont) {
font.SetID(defaultStyle->font.GetID());
} else if (fontName) {
font.Create(fontName, deviceHeight, bold, italic);
} else {
font.SetID(0);
}
font.Create(fontName, deviceHeight, bold, italic);
ascent = surface.Ascent(font);
descent = surface.Descent(font);

View File

@ -10,11 +10,10 @@ class Style {
public:
ColourPair fore;
ColourPair back;
bool aliasOfDefaultFont;
bool bold;
bool italic;
int size;
const char *fontName;
char fontName[100];
bool eolFilled;
Font font;
@ -28,12 +27,11 @@ public:
Style();
~Style();
Style &operator=(const Style &source);
void Clear(Colour fore_, Colour back_,
int size_,
const char *fontName_,
bool bold_, bool italic_, bool eolFilled_);
bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle=0);
void Clear(Colour fore_=Colour(0,0,0), Colour back_=Colour(0xff,0xff,0xff),
int size_=Platform::DefaultFontSize(),
const char *fontName_=Platform::DefaultFont(),
bool bold_=false, bool italic_=false, bool eolFilled_=false);
void Realise(Surface &surface, int zoomLevel);
};
#endif

View File

@ -17,46 +17,14 @@ MarginStyle::MarginStyle() :
symbol(false), width(16), mask(0xffffffff), sensitive(false) {
}
// A list of the fontnames - avoids wasting space in each style
FontNames::FontNames() {
max = 0;
}
FontNames::~FontNames() {
Clear();
}
void FontNames::Clear() {
for (int i=0;i<max;i++) {
delete []names[i];
}
max = 0;
}
const char *FontNames::Save(const char *name) {
if (!name)
return 0;
for (int i=0;i<max;i++) {
if (strcmp(names[i], name) == 0) {
return names[i];
}
}
names[max] = new char[strlen(name) + 1];
strcpy(names[max], name);
max++;
return names[max-1];
}
ViewStyle::ViewStyle() {
Init();
}
ViewStyle::ViewStyle(const ViewStyle &source) {
Init();
for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
for (int sty=0;sty<=STYLE_MAX;sty++) {
styles[sty] = source.styles[sty];
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
}
for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
markers[mrk] = source.markers[mrk];
@ -91,9 +59,6 @@ ViewStyle::~ViewStyle() {
}
void ViewStyle::Init() {
fontNames.Clear();
ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE;
indicators[0].fore = Colour(0, 0x7f, 0);
indicators[1].style = INDIC_TT;
@ -171,17 +136,14 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
void ViewStyle::Refresh(Surface &surface) {
selbar.desired = Platform::Chrome();
selbarlight.desired = Platform::ChromeHighlight();
styles[STYLE_DEFAULT].Realise(surface, zoomLevel);
maxAscent = styles[STYLE_DEFAULT].ascent;
maxDescent = styles[STYLE_DEFAULT].descent;
maxAscent = 1;
maxDescent = 1;
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
if (i != STYLE_DEFAULT) {
styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]);
if (maxAscent < styles[i].ascent)
maxAscent = styles[i].ascent;
if (maxDescent < styles[i].descent)
maxDescent = styles[i].descent;
}
styles[i].Realise(surface, zoomLevel);
if (maxAscent < styles[i].ascent)
maxAscent = styles[i].ascent;
if (maxDescent < styles[i].descent)
maxDescent = styles[i].descent;
}
lineHeight = maxAscent + maxDescent;
@ -200,14 +162,12 @@ void ViewStyle::Refresh(Surface &surface) {
}
void ViewStyle::ResetDefaultStyle() {
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
false, false, false);
styles[STYLE_DEFAULT].Clear();
}
void ViewStyle::ClearStyles() {
// Reset all styles to be like the default style
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
for (int i=0; i<=STYLE_MAX; i++) {
if (i != STYLE_DEFAULT) {
styles[i].Clear(
styles[STYLE_DEFAULT].fore.desired,
@ -215,13 +175,9 @@ void ViewStyle::ClearStyles() {
styles[STYLE_DEFAULT].size,
styles[STYLE_DEFAULT].fontName,
styles[STYLE_DEFAULT].bold,
styles[STYLE_DEFAULT].italic,
styles[STYLE_DEFAULT].eolFilled);
styles[STYLE_DEFAULT].italic);
}
}
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
}
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
styles[styleIndex].fontName = fontNames.Save(name);
}

View File

@ -15,20 +15,8 @@ public:
MarginStyle();
};
class FontNames {
private:
char *names[STYLE_MAX + 1];
int max;
public:
FontNames();
~FontNames();
void Clear();
const char *Save(const char *name);
};
class ViewStyle {
public:
FontNames fontNames;
Style styles[STYLE_MAX + 1];
LineMarker markers[MARKER_MAX + 1];
Indicator indicators[INDIC_MAX + 1];
@ -66,7 +54,6 @@ public:
void Refresh(Surface &surface);
void ResetDefaultStyle();
void ClearStyles();
void SetStyleFontName(int styleIndex, const char *name);
};
#endif

View File

@ -5,7 +5,7 @@
// derive directly from the Scintilla classes, but instead
// delegates most things to the real Scintilla class.
// This allows the use of Scintilla without polluting the
// namespace with all the classes and identifiers from Scintilla.
// namespace with all the classes and itentifiers from Scintilla.
//
// Author: Robin Dunn
//
@ -15,53 +15,11 @@
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include <ctype.h>
#include "wx/stc/stc.h"
#include "ScintillaWX.h"
#include <wx/tokenzr.h>
// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// them away. (eric@sourcegear.com)
int wxForceScintillaLexers(void)
{
extern LexerModule lmCPP;
extern LexerModule lmHTML;
extern LexerModule lmXML;
extern LexerModule lmProps;
extern LexerModule lmErrorList;
extern LexerModule lmMake;
extern LexerModule lmBatch;
extern LexerModule lmPerl;
extern LexerModule lmPython;
extern LexerModule lmSQL;
extern LexerModule lmVB;
if (
&lmCPP
&& &lmHTML
&& &lmXML
&& &lmProps
&& &lmErrorList
&& &lmMake
&& &lmBatch
&& &lmPerl
&& &lmPython
&& &lmSQL
&& &lmVB
)
{
return 1;
}
else
{
return 0;
}
}
//----------------------------------------------------------------------
const wxChar* wxSTCNameStr = "stcwindow";

View File

@ -29,13 +29,6 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
Indicator.o \
KeyMap.o \
KeyWords.o \
LexCPP.o \
LexHTML.o \
LexOthers.o \
LexPerl.o \
LexPython.o \
LexSQL.o \
LexVB.o \
LineMarker.o \
PropSet.o \
ScintillaBase.o \

View File

@ -4,7 +4,6 @@
// Robin Dunn <robin@aldunn.com>
// The License.txt file describes the conditions under which this software may be distributed.
#include <ctype.h>
#include "Platform.h"
#include "wx/stc/stc.h"
@ -182,14 +181,7 @@ void Surface::BrushColor(Colour back) {
}
void Surface::SetFont(Font &font_) {
// I think the following check is valid.
// It eliminates a crash for me. -- eric@sourcegear.com
if (font_.GetID())
{
hdc->SetFont(*font_.GetID());
}
hdc->SetFont(*font_.GetID());
}
int Surface::LogPixelsY() {
@ -352,11 +344,7 @@ void Surface::SetClip(PRectangle rc) {
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
}
void Surface::FlushCachedState() {
// TODO Is there anything we need to do here? eric@sourcegear.com
// TODO I had to add this method when I merged new Scintilla code
// TODO from Neil.
}
Window::~Window() {
}

View File

@ -14,8 +14,6 @@
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include <ctype.h>
#include "ScintillaWX.h"
#include "wx/stc/stc.h"

View File

@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
@ -22,9 +22,11 @@ CFG=StcVC - Win32 Debug
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "StcVC - Win32 Release"
@ -38,12 +40,11 @@ CPP=cl.exe
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
RSC=rc.exe
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
@ -63,12 +64,11 @@ LIB32=link.exe -lib
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
RSC=rc.exe
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
@ -179,34 +179,6 @@ SOURCE=.\scintilla\src\KeyWords.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexCPP.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexHTML.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexOthers.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexPerl.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexPython.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexSQL.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LexVB.cxx
# End Source File
# Begin Source File
SOURCE=.\scintilla\src\LineMarker.cxx
# End Source File
# Begin Source File

View File

@ -3,8 +3,6 @@
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
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
@ -17,15 +15,12 @@ protected:
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) {
lenDoc(-1), offset(offset_) {
}
void SetCodePage(int codePage_) { codePage = codePage_; }
char operator[](int position) {
position += offset;
if (position < startPos || position >= endPos) {
@ -45,9 +40,6 @@ public:
}
return buf[position - startPos];
}
bool IsLeadByte(char ch) {
return codePage && InternalIsLeadByte(ch);
}
char StyleAt(int position);
int GetLine(int position);
int LineStart(int line);
@ -62,10 +54,6 @@ public:
PropSet &GetPropSet() { return props; }
};
class StylingContext;
typedef bool (*PFNIsCommentLeader)(StylingContext &styler, int pos, int len);
class StylingContext : public Accessor {
char styleBuf[bufferSize];
int validLen;
@ -77,12 +65,12 @@ public:
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_; };
void ColourSegment(unsigned int start, unsigned int end, int chAttr);
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);
};

View File

@ -3,39 +3,6 @@
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// 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);
class LexerModule {
static LexerModule *base;
LexerModule *next;
int language;
LexerFunction fn;
public:
LexerModule(int language_, LexerFunction fn_);
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle,
int language, WordList *keywordlists[], StylingContext &styler);
};
inline bool iswordchar(char ch) {
return isalnum(ch) || ch == '.' || ch == '_';
}
inline bool iswordstart(char ch) {
return isalnum(ch) || ch == '_';
}
inline bool isoperator(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 == '~')
return true;
return false;
}
void ColouriseDoc(int codePage, int startPos, int lengthDoc, int initStyle,
int language, WordList *keywordlists[], StylingContext &styler);

View File

@ -213,8 +213,6 @@ public:
void Release();
FontID GetID() { return id; }
// Alias another font - caller guarantees not to Release
void SetID(FontID id_) { id = id_; }
friend class Surface;
};
@ -292,7 +290,6 @@ public:
int SetPalette(Palette *pal, bool inBackGround);
void SetClip(PRectangle rc);
void FlushCachedState();
};
// Class to hide the details of window manipulation

View File

@ -35,8 +35,6 @@
#define SCE_P_DEFNAME 9
#define SCE_P_OPERATOR 10
#define SCE_P_IDENTIFIER 11
#define SCE_P_COMMENTBLOCK 12
#define SCE_P_STRINGEOL 13
// Lexical states for SCLEX_CPP, SCLEX_VB
#define SCE_C_DEFAULT 0
@ -47,7 +45,7 @@
#define SCE_C_WORD 5
#define SCE_C_STRING 6
#define SCE_C_CHARACTER 7
#define SCE_C_UUID 8
#define SCE_C_PUNTUATION 8
#define SCE_C_PREPROCESSOR 9
#define SCE_C_OPERATOR 10
#define SCE_C_IDENTIFIER 11
@ -65,85 +63,49 @@
#define SCE_H_OTHER 8
#define SCE_H_COMMENT 9
#define SCE_H_ENTITY 10
// XML and ASP
#define SCE_H_TAGEND 11
#define SCE_H_XMLSTART 12
#define SCE_H_XMLEND 13
#define SCE_H_SCRIPT 14
#define SCE_H_ASP 15
#define SCE_H_ASPAT 16
// Embedded Javascript
#define SCE_HJ_START 40
#define SCE_HJ_DEFAULT 41
#define SCE_HJ_COMMENT 42
#define SCE_HJ_COMMENTLINE 43
#define SCE_HJ_COMMENTDOC 44
#define SCE_HJ_NUMBER 45
#define SCE_HJ_WORD 46
#define SCE_HJ_KEYWORD 47
#define SCE_HJ_DOUBLESTRING 48
#define SCE_HJ_SINGLESTRING 49
#define SCE_HJ_SYMBOLS 50
#define SCE_HJ_STRINGEOL 51
// ASP Javascript
#define SCE_HJA_START 55
#define SCE_HJA_DEFAULT 56
#define SCE_HJA_COMMENT 57
#define SCE_HJA_COMMENTLINE 58
#define SCE_HJA_COMMENTDOC 59
#define SCE_HJA_NUMBER 60
#define SCE_HJA_WORD 61
#define SCE_HJA_KEYWORD 62
#define SCE_HJA_DOUBLESTRING 63
#define SCE_HJA_SINGLESTRING 64
#define SCE_HJA_SYMBOLS 65
#define SCE_HJA_STRINGEOL 66
#define SCE_HJ_START 11
#define SCE_HJ_DEFAULT 12
#define SCE_HJ_COMMENT 13
#define SCE_HJ_COMMENTLINE 14
#define SCE_HJ_COMMENTDOC 15
#define SCE_HJ_NUMBER 16
#define SCE_HJ_WORD 17
#define SCE_HJ_KEYWORD 18
#define SCE_HJ_DOUBLESTRING 19
#define SCE_HJ_SINGLESTRING 20
#define SCE_HJ_SYMBOLS 21
#define SCE_HJ_STRINGEOL 28
// XML and ASP
#define SCE_H_TAGEND 22
#define SCE_H_XMLSTART 23
#define SCE_H_XMLEND 24
#define SCE_H_SCRIPT 25
#define SCE_H_ASP 26
#define SCE_H_ASPAT 27
// Embedded VBScript
#define SCE_HB_START 70
#define SCE_HB_DEFAULT 71
#define SCE_HB_COMMENTLINE 72
#define SCE_HB_NUMBER 73
#define SCE_HB_WORD 74
#define SCE_HB_STRING 75
#define SCE_HB_IDENTIFIER 76
#define SCE_HB_STRINGEOL 77
// ASP VBScript
#define SCE_HBA_START 80
#define SCE_HBA_DEFAULT 81
#define SCE_HBA_COMMENTLINE 82
#define SCE_HBA_NUMBER 83
#define SCE_HBA_WORD 84
#define SCE_HBA_STRING 85
#define SCE_HBA_IDENTIFIER 86
#define SCE_HBA_STRINGEOL 87
#define SCE_HB_START 40
#define SCE_HB_DEFAULT 41
#define SCE_HB_COMMENTLINE 42
#define SCE_HB_NUMBER 43
#define SCE_HB_WORD 44
#define SCE_HB_STRING 45
#define SCE_HB_IDENTIFIER 46
#define SCE_HB_STRINGEOL 47
// Embedded Python
#define SCE_HP_START 90
#define SCE_HP_DEFAULT 91
#define SCE_HP_COMMENTLINE 92
#define SCE_HP_NUMBER 93
#define SCE_HP_STRING 94
#define SCE_HP_CHARACTER 95
#define SCE_HP_WORD 96
#define SCE_HP_TRIPLE 97
#define SCE_HP_TRIPLEDOUBLE 98
#define SCE_HP_CLASSNAME 99
#define SCE_HP_DEFNAME 100
#define SCE_HP_OPERATOR 101
#define SCE_HP_IDENTIFIER 102
// ASP Python
#define SCE_HPA_START 105
#define SCE_HPA_DEFAULT 106
#define SCE_HPA_COMMENTLINE 107
#define SCE_HPA_NUMBER 108
#define SCE_HPA_STRING 109
#define SCE_HPA_CHARACTER 110
#define SCE_HPA_WORD 111
#define SCE_HPA_TRIPLE 112
#define SCE_HPA_TRIPLEDOUBLE 113
#define SCE_HPA_CLASSNAME 114
#define SCE_HPA_DEFNAME 115
#define SCE_HPA_OPERATOR 116
#define SCE_HPA_IDENTIFIER 117
#define SCE_HP_START 50
#define SCE_HP_DEFAULT 51
#define SCE_HP_COMMENTLINE 52
#define SCE_HP_NUMBER 53
#define SCE_HP_STRING 54
#define SCE_HP_CHARACTER 55
#define SCE_HP_WORD 56
#define SCE_HP_TRIPLE 57
#define SCE_HP_TRIPLEDOUBLE 58
#define SCE_HP_CLASSNAME 59
#define SCE_HP_DEFNAME 60
#define SCE_HP_OPERATOR 61
#define SCE_HP_IDENTIFIER 62
// Lexical states for SCLEX_PERL
#define SCE_PL_DEFAULT 0

View File

@ -156,7 +156,7 @@ extern "C" {
#define STYLE_BRACELIGHT 34
#define STYLE_BRACEBAD 35
#define STYLE_CONTROLCHAR 36
#define STYLE_MAX 127
#define STYLE_MAX 63
#define SCI_STYLECLEARALL SCI_START + 50
#define SCI_STYLESETFORE SCI_START + 51
@ -279,11 +279,6 @@ extern "C" {
#define SCI_ZOOMOUT SCI_START + 334
#define SCI_DELWORDLEFT SCI_START + 335
#define SCI_DELWORDRIGHT SCI_START + 336
#define SCI_LINECUT SCI_START + 337
#define SCI_LINEDELETE SCI_START + 338
#define SCI_LINETRANSPOSE SCI_START + 339
#define SCI_LOWERCASE SCI_START + 340
#define SCI_UPPERCASE SCI_START + 341
#define SCI_LINELENGTH SCI_START + 350
#define SCI_BRACEHIGHLIGHT SCI_START + 351
@ -316,8 +311,6 @@ extern "C" {
// OR this with CARET_SLOP to reposition whenever outside slop border
#define SCI_SETCARETPOLICY SCI_START + 369
#define SCI_LINESONSCREEN SCI_START + 370
#define SCI_USEPOPUP SCI_START + 371
// GTK+ Specific
#define SCI_GRABFOCUS SCI_START + 400
@ -349,7 +342,6 @@ typedef void (tMacroRecorder)(UINT iMessage, WPARAM wParam, LPARAM lParam,
#define SC_PERFORMED_UNDO 0x20
#define SC_PERFORMED_REDO 0x40
#define SC_LASTSTEPINUNDOREDO 0x100
#define SC_MOD_CHANGEMARKER 0x200
#define SC_MODEVENTMASKALL 0x377

View File

@ -4,7 +4,6 @@
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include "Platform.h"
@ -13,17 +12,6 @@
#include "Accessor.h"
#include "Scintilla.h"
bool Accessor::InternalIsLeadByte(char ch) {
#if PLAT_GTK
// TODO: support DBCS under GTK+
return false;
#elif PLAT_WIN
return IsDBCSLeadByteEx(codePage, ch);
#elif PLAT_WX
return false;
#endif
}
void Accessor::Fill(int position) {
if (lenDoc == -1)
lenDoc = Platform::SendScintilla(id, WM_GETTEXTLENGTH, 0, 0);
@ -75,31 +63,35 @@ void StylingContext::StartAt(unsigned int start, char chMask) {
Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask);
}
void StylingContext::ColourSegment(unsigned int start, unsigned int end, int chAttr) {
// Only perform styling if non empty range
if (end != start - 1) {
if (end < start) {
Platform::DebugPrintf("Bad colour positions %d - %d\n", start, end);
}
if (validLen + (end - start + 1) >= bufferSize)
Flush();
if (validLen + (end - start + 1) >= bufferSize) {
// Too big for buffer so send directly
Platform::SendScintilla(id, SCI_SETSTYLING, end - start + 1, chAttr);
} else {
if (chAttr != chWhile)
chFlags = 0;
chAttr |= chFlags;
for (unsigned int i = start; i <= end; i++) {
styleBuf[validLen++] = chAttr;
}
}
}
}
void StylingContext::StartSegment(unsigned int pos) {
startSeg = pos;
}
void StylingContext::ColourTo(unsigned int pos, int chAttr) {
// Only perform styling if non empty range
if (pos != startSeg - 1) {
if (pos < startSeg) {
Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
}
if (validLen + (pos - startSeg + 1) >= bufferSize)
Flush();
if (validLen + (pos - startSeg + 1) >= bufferSize) {
// Too big for buffer so send directly
Platform::SendScintilla(id, SCI_SETSTYLING, pos - startSeg + 1, chAttr);
} else {
if (chAttr != chWhile)
chFlags = 0;
chAttr |= chFlags;
for (unsigned int i = startSeg; i <= pos; i++) {
styleBuf[validLen++] = chAttr;
}
}
}
ColourSegment(startSeg, pos, chAttr);
startSeg = pos+1;
}
@ -118,49 +110,3 @@ void StylingContext::Flush() {
validLen = 0;
}
}
int StylingContext::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
int end = Length();
int spaceFlags = 0;
// Determines the indentation level of the current line and also checks for consistent
// indentation compared to the previous line.
// Indentation is judged consistent when the indentation whitespace of each line lines
// the same or the indentation of one line is a prefix of the other.
int pos = LineStart(line);
char ch = (*this)[pos];
int indent = 0;
bool inPrevPrefix = line > 0;
int posPrev = inPrevPrefix ? LineStart(line-1) : 0;
while ((ch == ' ' || ch == '\t') && (pos < end)) {
if (inPrevPrefix) {
char chPrev = (*this)[posPrev++];
if (chPrev == ' ' || chPrev == '\t') {
if (chPrev != ch)
spaceFlags |= wsInconsistent;
} else {
inPrevPrefix = false;
}
}
if (ch == ' ') {
spaceFlags |= wsSpace;
indent++;
} else { // Tab
spaceFlags |= wsTab;
if (spaceFlags & wsSpace)
spaceFlags |= wsSpaceTab;
indent = (indent / 8 + 1) * 8;
}
ch = (*this)[++pos];
}
*flags = spaceFlags;
indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment...
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
return indent | SC_FOLDLEVELWHITEFLAG;
else
return indent;
}

View File

@ -344,186 +344,6 @@ void Action::Grab(Action *source) {
source->lenData = 0;
}
// The undo history stores a sequence of user operations that represent the user's view of the
// commands executed on the text.
// Each user operation contains a sequence of text insertion and text deletion actions.
// All the user operations are stored in a list of individual actions with 'start' actions used
// as delimiters between user operations.
// Initially there is one start action in the history.
// As each action is performed, it is recorded in the history. The action may either become
// part of the current user operation or may start a new user operation. If it is to be part of the
// current operation, then it overwrites the current last action. If it is to be part of a new
// operation, it is appended after the current last action.
// After writing the new action, a new start action is appended at the end of the history.
// The decision of whether to start a new user operation is based upon two factors. If a
// compound operation has been explicitly started by calling BeginUndoAction and no matching
// EndUndoAction (these calls nest) has been called, then the action is coalesced into the current
// operation. If there is no outstanding BeginUndoAction call then a new operation is started
// unless it looks as if the new action is caused by the user typing or deleting a stream of text.
// Sequences that look like typing or deletion are coalesced into a single user operation.
UndoHistory::UndoHistory() {
lenActions = 100;
actions = new Action[lenActions];
maxAction = 0;
currentAction = 0;
undoSequenceDepth = 0;
savePoint = 0;
actions[currentAction].Create(startAction);
}
UndoHistory::~UndoHistory() {
delete []actions;
actions = 0;
}
void UndoHistory::EnsureUndoRoom() {
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
if (currentAction >= 2) {
// Have to test that there is room for 2 more actions in the array
// as two actions may be created by this function
if (currentAction >= (lenActions - 2)) {
// Run out of undo nodes so extend the array
int lenActionsNew = lenActions * 2;
Action *actionsNew = new Action[lenActionsNew];
if (!actionsNew)
return;
for (int act = 0; act <= currentAction; act++)
actionsNew[act].Grab(&actions[act]);
delete []actions;
lenActions = lenActionsNew;
actions = actionsNew;
}
}
}
void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
//Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
// actions[currentAction - 1].position, actions[currentAction - 1].lenData);
if (currentAction >= 1) {
if (0 == undoSequenceDepth) {
// Top level actions may not always be coalesced
Action &actPrevious = actions[currentAction - 1];
// See if current action can be coalesced into previous action
// Will work if both are inserts or deletes and position is same
if (at != actPrevious.at) {
currentAction++;
} else if (currentAction == savePoint) {
currentAction++;
} else if ((at == removeAction) &&
((position + lengthData * 2) != actPrevious.position)) {
// Removals must be at same position to coalesce
currentAction++;
} else if ((at == insertAction) &&
(position != (actPrevious.position + actPrevious.lenData*2))) {
// Insertions must be immediately after to coalesce
currentAction++;
} else {
//Platform::DebugPrintf("action coalesced\n");
}
} else {
currentAction++;
}
} else {
currentAction++;
}
actions[currentAction].Create(at, position, data, lengthData);
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
void UndoHistory::BeginUndoAction() {
EnsureUndoRoom();
if (undoSequenceDepth == 0) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
undoSequenceDepth++;
}
void UndoHistory::EndUndoAction() {
EnsureUndoRoom();
undoSequenceDepth--;
if (0 == undoSequenceDepth) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
}
void UndoHistory::DropUndoSequence() {
undoSequenceDepth = 0;
}
void UndoHistory::DeleteUndoHistory() {
for (int i = 1; i < maxAction; i++)
actions[i].Destroy();
maxAction = 0;
currentAction = 0;
actions[currentAction].Create(startAction);
savePoint = 0;
}
void UndoHistory::SetSavePoint() {
savePoint = currentAction;
}
bool UndoHistory::IsSavePoint() const {
return savePoint == currentAction;
}
bool UndoHistory::CanUndo() const {
return (currentAction > 0) && (maxAction > 0);
}
int UndoHistory::StartUndo() {
// Drop any trailing startAction
if (actions[currentAction].at == startAction && currentAction > 0)
currentAction--;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act > 0) {
act--;
}
return currentAction - act;
}
const Action &UndoHistory::UndoStep() {
return actions[currentAction--];
}
bool UndoHistory::CanRedo() const {
return maxAction > currentAction;
}
int UndoHistory::StartRedo() {
// Drop any leading startAction
if (actions[currentAction].at == startAction && currentAction < maxAction)
currentAction++;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act < maxAction) {
act++;
}
return act - currentAction;
}
const Action &UndoHistory::RedoStep() {
return actions[currentAction++];
}
CellBuffer::CellBuffer(int initialLength) {
body = new char[initialLength];
size = initialLength;
@ -532,12 +352,23 @@ CellBuffer::CellBuffer(int initialLength) {
gaplen = initialLength;
part2body = body + gaplen;
readOnly = false;
lenActions = 100;
actions = new Action[lenActions];
maxAction = 0;
currentAction = 0;
collectingUndo = undoCollectAutoStart;
undoSequenceDepth = 0;
savePoint = 0;
actions[currentAction].Create(startAction);
}
CellBuffer::~CellBuffer() {
delete []body;
body = 0;
delete []actions;
actions = 0;
}
void CellBuffer::GapTo(int position) {
@ -655,7 +486,7 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) {
for (int i = 0; i < insertLength / 2; i++) {
data[i] = s[i * 2];
}
uh.AppendAction(insertAction, position, data, insertLength / 2);
AppendAction(insertAction, position, data, insertLength / 2);
}
BasicInsertString(position, s, insertLength);
@ -694,6 +525,48 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mas
return changed;
}
void CellBuffer::EnsureUndoRoom() {
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
if (currentAction >= 2) {
// Have to test that there is room for 2 more actions in the array
// as two actions may be created by this function
if (currentAction >= (lenActions - 2)) {
// Run out of undo nodes so extend the array
int lenActionsNew = lenActions * 2;
Action *actionsNew = new Action[lenActionsNew];
if (!actionsNew)
return;
for (int act = 0; act <= currentAction; act++)
actionsNew[act].Grab(&actions[act]);
delete []actions;
lenActions = lenActionsNew;
actions = actionsNew;
}
}
}
void CellBuffer::AppendAction(actionType at, int position, char *data, int lengthData) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
if (currentAction >= 2) {
// See if current action can be coalesced into previous action
// Will work if both are inserts or deletes and position is same or two different
if ((at != actions[currentAction - 1].at) || (abs(position - actions[currentAction - 1].position) > 2)) {
currentAction++;
} else if (currentAction == savePoint) {
currentAction++;
}
} else {
currentAction++;
}
actions[currentAction].Create(at, position, data, lengthData);
if ((collectingUndo == undoCollectAutoStart) && (0 == undoSequenceDepth)) {
currentAction++;
actions[currentAction].Create(startAction);
}
maxAction = currentAction;
}
const char *CellBuffer::DeleteChars(int position, int deleteLength) {
// InsertString and DeleteChars are the bottleneck though which all changes occur
char *data = 0;
@ -704,7 +577,7 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength) {
for (int i = 0; i < deleteLength / 2; i++) {
data[i] = ByteAt(position + i * 2);
}
uh.AppendAction(removeAction, position, data, deleteLength / 2);
AppendAction(removeAction, position, data, deleteLength / 2);
}
BasicDeleteChars(position, deleteLength);
@ -743,11 +616,11 @@ void CellBuffer::SetReadOnly(bool set) {
}
void CellBuffer::SetSavePoint() {
uh.SetSavePoint();
savePoint = currentAction;
}
bool CellBuffer::IsSavePoint() {
return uh.IsSavePoint();
return savePoint == currentAction;
}
int CellBuffer::AddMark(int line, int markerNum) {
@ -919,7 +792,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
undoCollectionType CellBuffer::SetUndoCollection(undoCollectionType collectUndo) {
collectingUndo = collectUndo;
uh.DropUndoSequence();
undoSequenceDepth = 0;
return collectingUndo;
}
@ -927,28 +800,69 @@ bool CellBuffer::IsCollectingUndo() {
return collectingUndo;
}
void CellBuffer::AppendUndoStartAction() {
EnsureUndoRoom();
// Finish any currently active undo sequence
undoSequenceDepth = 0;
if (actions[currentAction].at != startAction) {
undoSequenceDepth++;
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
void CellBuffer::BeginUndoAction() {
uh.BeginUndoAction();
EnsureUndoRoom();
if (undoSequenceDepth == 0) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
undoSequenceDepth++;
}
void CellBuffer::EndUndoAction() {
uh.EndUndoAction();
EnsureUndoRoom();
undoSequenceDepth--;
if (0 == undoSequenceDepth) {
if (actions[currentAction].at != startAction) {
currentAction++;
actions[currentAction].Create(startAction);
maxAction = currentAction;
}
}
}
void CellBuffer::DeleteUndoHistory() {
uh.DeleteUndoHistory();
for (int i = 1; i < maxAction; i++)
actions[i].Destroy();
maxAction = 0;
currentAction = 0;
savePoint = 0;
}
bool CellBuffer::CanUndo() {
return (!readOnly) && (uh.CanUndo());
return (!readOnly) && ((currentAction > 0) && (maxAction > 0));
}
int CellBuffer::StartUndo() {
return uh.StartUndo();
// Drop any trailing startAction
if (actions[currentAction].at == startAction && currentAction > 0)
currentAction--;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act > 0) {
act--;
}
return currentAction - act;
}
const Action &CellBuffer::UndoStep() {
const Action &actionStep = uh.UndoStep();
const Action &actionStep = actions[currentAction];
if (actionStep.at == insertAction) {
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
} else if (actionStep.at == removeAction) {
@ -960,19 +874,29 @@ const Action &CellBuffer::UndoStep() {
BasicInsertString(actionStep.position, styledData, actionStep.lenData*2);
delete []styledData;
}
currentAction--;
return actionStep;
}
bool CellBuffer::CanRedo() {
return (!readOnly) && (uh.CanRedo());
return (!readOnly) && (maxAction > currentAction);
}
int CellBuffer::StartRedo() {
return uh.StartRedo();
// Drop any leading startAction
if (actions[currentAction].at == startAction && currentAction < maxAction)
currentAction++;
// Count the steps in this action
int act = currentAction;
while (actions[act].at != startAction && act < maxAction) {
act++;
}
return act - currentAction;
}
const Action &CellBuffer::RedoStep() {
const Action &actionStep = uh.RedoStep();
const Action &actionStep = actions[currentAction];
if (actionStep.at == insertAction) {
char *styledData = new char[actionStep.lenData * 2];
for (int i = 0; i < actionStep.lenData; i++) {
@ -984,6 +908,7 @@ const Action &CellBuffer::RedoStep() {
} else if (actionStep.at == removeAction) {
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
}
currentAction++;
return actionStep;
}

View File

@ -89,42 +89,6 @@ public:
enum undoCollectionType { undoCollectNone, undoCollectAutoStart, undoCollectManualStart };
class UndoHistory {
Action *actions;
int lenActions;
int maxAction;
int currentAction;
int undoSequenceDepth;
int savePoint;
void EnsureUndoRoom();
public:
UndoHistory();
~UndoHistory();
void AppendAction(actionType at, int position, char *data, int length);
void BeginUndoAction();
void EndUndoAction();
void DropUndoSequence();
void DeleteUndoHistory();
// The save point is a marker in the undo stack where the container has stated that
// the buffer was saved. Undo and redo can move over the save point.
void SetSavePoint();
bool IsSavePoint() const;
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// called that many times. Similarly for redo.
bool CanUndo() const;
int StartUndo();
const Action &UndoStep();
bool CanRedo() const;
int StartRedo();
const Action &RedoStep();
};
// Holder for an expandable array of characters that supports undo and line markers
// Based on article "Data Structures in a Bit-Mapped Text Editor"
// by Wilfred J. Hansen, Byte January 1987, page 183
@ -138,8 +102,13 @@ private:
char *part2body;
bool readOnly;
Action *actions;
int lenActions;
int maxAction;
int currentAction;
undoCollectionType collectingUndo;
UndoHistory uh;
int undoSequenceDepth;
int savePoint;
LineVector lv;
@ -148,6 +117,9 @@ private:
void GapTo(int position);
void RoomFor(int insertionLength);
void EnsureUndoRoom();
void AppendAction(actionType at, int position, char *data, int length);
inline char ByteAt(int position);
void SetByteAt(int position, char ch);
@ -198,11 +170,12 @@ public:
undoCollectionType SetUndoCollection(undoCollectionType collectUndo);
bool IsCollectingUndo();
void AppendUndoStartAction();
void BeginUndoAction();
void EndUndoAction();
void DeleteUndoHistory();
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
// To perform an undo, StartUndo is called to retreive the number of steps, then UndoStep is
// called that many times. Similarly for redo.
bool CanUndo();
int StartUndo();

View File

@ -108,8 +108,8 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
return;
}
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
if ((linesInDoc + lineCount + 2) >= size) {
Grow(linesInDoc + lineCount + growSize);
if ((linesInDoc + 2) >= size) {
Grow(size + growSize);
}
linesInDoc += lineCount;
linesInDisplay += lineCount;
@ -155,7 +155,7 @@ bool ContractionState::GetVisible(int lineDoc) const {
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
if (size == 0) {
Grow(linesInDoc + growSize);
Grow(lineDocEnd + growSize);
}
// TODO: modify docLine members to mirror displayLine
int delta = 0;
@ -191,7 +191,7 @@ bool ContractionState::GetExpanded(int lineDoc) const {
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
if (size == 0) {
Grow(linesInDoc + growSize);
Grow(lineDoc + growSize);
}
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
if (lines[lineDoc].expanded != expanded) {

View File

@ -65,54 +65,26 @@ void Document::SetSavePoint() {
NotifySavePoint(true);
}
int Document::AddMark(int line, int markerNum) {
int prev = cb.AddMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh);
return prev;
}
void Document::DeleteMark(int line, int markerNum) {
cb.DeleteMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
NotifyModified(mh);
}
void Document::DeleteMarkFromHandle(int markerHandle) {
cb.DeleteMarkFromHandle(markerHandle);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh);
}
void Document::DeleteAllMarks(int markerNum) {
cb.DeleteAllMarks(markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
NotifyModified(mh);
}
int Document::LineStart(int line) {
return cb.LineStart(line);
}
int Document::LineEnd(int line) {
if (line == LinesTotal() - 1) {
return LineStart(line + 1);
} else {
int position = LineStart(line + 1) - 1;
// When line terminator is CR+LF, may need to go back one more
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
position--;
}
return position;
}
}
int Document::LineFromPosition(int pos) {
return cb.LineFromPosition(pos);
}
int Document::LineEndPosition(int position) {
return LineEnd(LineFromPosition(position));
int line = LineFromPosition(position);
if (line == LinesTotal() - 1) {
position = LineStart(line + 1);
} else {
position = LineStart(line + 1) - 1;
// When line terminator is CR+LF, may need to go back one more
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
position--;
}
}
return position;
}
int Document::VCHomePosition(int position) {
@ -152,10 +124,7 @@ int Document::GetLastChild(int lineParent, int level) {
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
int maxLine = LinesTotal();
int lineMaxSubord = lineParent;
while (lineMaxSubord < maxLine-1) {
EnsureStyledTo(LineStart(lineMaxSubord+2));
if (!IsSubordinate(level, GetLevel(lineMaxSubord+1)))
break;
while ((lineMaxSubord < maxLine-1) && IsSubordinate(level, GetLevel(lineMaxSubord+1))) {
lineMaxSubord++;
}
if (lineMaxSubord > lineParent) {
@ -338,7 +307,6 @@ int Document::Undo() {
enteredCount++;
bool startSavePoint = cb.IsSavePoint();
int steps = cb.StartUndo();
//Platform::DebugPrintf("Steps=%d\n", steps);
for (int step=0; step<steps; step++) {
int prevLinesTotal = LinesTotal();
const Action &action = cb.UndoStep();
@ -427,11 +395,6 @@ void Document::InsertString(int position, const char *s, int insertLength) {
}
}
void Document::ChangeChar(int pos, char ch) {
DeleteChars(pos, 1);
InsertChar(pos, ch);
}
void Document::DelChar(int pos) {
if (IsCrLf(pos)) {
DeleteChars(pos, 2);
@ -642,25 +605,6 @@ int Document::LinesTotal() {
return cb.Lines();
}
void Document::ChangeCase(Range r, bool makeUpperCase) {
for (int pos=r.start; pos<r.end; pos++) {
char ch = CharAt(pos);
if (dbcsCodePage && IsDBCS(pos)) {
pos++;
} else {
if (makeUpperCase) {
if (islower(ch)) {
ChangeChar(pos, toupper(ch));
}
} else {
if (isupper(ch)) {
ChangeChar(pos, tolower(ch));
}
}
}
}
}
void Document::SetWordChars(unsigned char *chars) {
int ch;
for (ch = 0; ch < 256; ch++) {
@ -727,13 +671,6 @@ void Document::SetStyles(int length, char *styles) {
}
}
bool Document::EnsureStyledTo(int pos) {
// 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);
return pos <= GetEndStyled();
}
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
for (int i = 0; i < lenWatchers; i++) {
if ((watchers[i].watcher == watcher) &&

View File

@ -111,6 +111,7 @@ public:
undoCollectionType SetUndoCollection(undoCollectionType collectUndo) {
return cb.SetUndoCollection(collectUndo);
}
void AppendUndoStartAction() { cb.AppendUndoStartAction(); }
void BeginUndoAction() { cb.BeginUndoAction(); }
void EndUndoAction() { cb.EndUndoAction(); }
void SetSavePoint();
@ -122,7 +123,6 @@ public:
void InsertChar(int pos, char ch);
void InsertString(int position, const char *s);
void InsertString(int position, const char *s, int insertLength);
void ChangeChar(int pos, char ch);
void DelChar(int pos);
int DelCharBack(int pos);
@ -132,13 +132,12 @@ public:
}
char StyleAt(int position) { return cb.StyleAt(position); }
int GetMark(int line) { return cb.GetMark(line); }
int AddMark(int line, int markerNum);
void DeleteMark(int line, int markerNum);
void DeleteMarkFromHandle(int markerHandle);
void DeleteAllMarks(int markerNum);
int AddMark(int line, int markerNum) { return cb.AddMark(line, markerNum); }
void DeleteMark(int line, int markerNum) { cb.DeleteMark(line, markerNum); }
void DeleteMarkFromHandle(int markerHandle) { cb.DeleteMarkFromHandle(markerHandle); }
void DeleteAllMarks(int markerNum) { cb.DeleteAllMarks(markerNum); }
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
int LineStart(int line);
int LineEnd(int line);
int LineEndPosition(int position);
int VCHomePosition(int position);
@ -155,15 +154,12 @@ public:
long FindText(WORD iMessage,WPARAM wParam,LPARAM lParam);
int LinesTotal();
void ChangeCase(Range r, bool makeUpperCase);
void SetWordChars(unsigned char *chars);
void SetStylingBits(int bits);
void StartStyling(int position, char mask);
void SetStyleFor(int length, char style);
void SetStyles(int length, char *styles);
int GetEndStyled() { return endStyled; }
bool EnsureStyledTo(int pos);
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
int GetLineState(int line) { return cb.GetLineState(line); }
@ -221,7 +217,6 @@ public:
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
};
#endif

View File

@ -88,8 +88,6 @@ Editor::Editor() {
modEventMask = SC_MODEVENTMASKALL;
displayPopupMenu = true;
pdoc = new Document();
pdoc ->AddRef();
pdoc->AddWatcher(this, 0);
@ -633,7 +631,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
int line = cs.DocFromDisplay(visibleLine);
int yposScreen = 0;
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
while (line < pdoc->LinesTotal() && yposScreen < rcMargin.bottom) {
int marks = pdoc->GetMark(line);
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
if (cs.GetExpanded(line)) {
@ -650,7 +648,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
char number[100];
number[0] = '\0';
sprintf(number, "%d", line + 1);
if (foldFlags & 64)
if (foldFlags & 8)
sprintf(number, "%X", pdoc->GetLevel(line));
int xpos = 0;
PRectangle rcNumber=rcMarker;
@ -855,7 +853,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
} 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
// Only try do 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,
@ -993,9 +991,10 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
ypos += screenLinePaintFirst * vs.lineHeight;
int yposScreen = screenLinePaintFirst * vs.lineHeight;
// Ensure we are styled as far as we are painting.
pdoc->EnsureStyledTo(endPosPaint);
if (endPosPaint > pdoc->GetEndStyled()) {
// Notify container to do some more styling
NotifyStyleNeeded(endPosPaint);
}
if (needUpdateUI) {
NotifyUpdateUI();
needUpdateUI = false;
@ -1010,7 +1009,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
}
if (paintState == paintAbandoned) {
// Either styling or NotifyUpdateUI noticed that painting is needed
// Either NotifyStyleNeeded or NotifyUpdateUI noticed that painting is needed
// outside the current painting rectangle
//Platform::DebugPrintf("Abandoning paint\n");
return;
@ -1068,21 +1067,13 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
if (cs.GetVisible(line))
DrawLine(surface, vs, line, xStart, rcLine, ll);
bool expanded = cs.GetExpanded(line);
if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
if (foldFlags & 2) {
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.bottom = rcFoldLine.top + 1;
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
}
}
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);
}
}
// Draw the Caret
if (line == lineCaret) {
@ -1213,9 +1204,10 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
if (linePrintLast < pdoc->LinesTotal())
endPosPrint = pdoc->LineStart(linePrintLast + 1);
// Ensure we are styled to where we are formatting.
pdoc->EnsureStyledTo(endPosPrint);
if (endPosPrint > pdoc->GetEndStyled()) {
// Notify container to do some more styling
NotifyStyleNeeded(endPosPrint);
}
int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
int ypos = pfr->rc.top;
int line = linePrintStart;
@ -1236,27 +1228,20 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
PRectangle rcNumber = rcLine;
rcNumber.right = rcNumber.left + lineNumberWidth;
// Right justify
rcNumber.left -=
rcNumber.left += lineNumberWidth -
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
ypos + vsPrint.maxAscent, number, strlen(number),
vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
}
// When printing, the hdc and hdcTarget may be the same, so
// changing the state of surfaceMeasure may change the underlying
// state of surface. Therefore, any cached state is discarded before
// using each surface.
// Copy this line and its styles from the document into local arrays
// and determine the x position at which each character starts.
surfaceMeasure->FlushCachedState();
LineLayout ll;
LayoutLine(line, surfaceMeasure, vsPrint, ll);
// Draw the line
surface->FlushCachedState();
DrawLine(surface, vsPrint, line, xStart, rcLine, ll);
ypos += vsPrint.lineHeight;
@ -1436,10 +1421,6 @@ void Editor::NotifyStyleNeeded(int endStyleNeeded) {
NotifyParent(scn);
}
void Editor::NotifyStyleNeeded(Document*, void *, int endStyleNeeded) {
NotifyStyleNeeded(endStyleNeeded);
}
void Editor::NotifyChar(char ch) {
SCNotification scn;
scn.nmhdr.code = SCN_CHARADDED;
@ -1618,10 +1599,6 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) {
SetScrollBars();
}
if (mh.modificationType & SC_MOD_CHANGEMARKER) {
RedrawSelMargin();
}
// If client wants to see this modification
if (mh.modificationType & modEventMask) {
if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
@ -1700,11 +1677,6 @@ void Editor::NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam) {
case SCI_VCHOMEEXTEND:
case SCI_DELWORDLEFT:
case SCI_DELWORDRIGHT:
case SCI_LINECUT:
case SCI_LINEDELETE:
case SCI_LINETRANSPOSE:
case SCI_LOWERCASE:
case SCI_UPPERCASE:
break;
// Filter out all others (display changes, etc)
@ -1740,60 +1712,6 @@ void Editor::PageMove(int direction, bool extend) {
}
}
void Editor::ChangeCaseOfSelection(bool makeUpperCase) {
pdoc->BeginUndoAction();
int startCurrent = currentPos;
int startAnchor = anchor;
if (selType == selRectangle) {
int lineStart = pdoc->LineFromPosition(SelectionStart());
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
for (int line=lineStart; line <= lineEnd; line++) {
pdoc->ChangeCase(
Range(SelectionStart(line), SelectionEnd(line)),
makeUpperCase);
}
// Would be nicer to keep the rectangular selection but this is complex
selType = selStream;
SetSelection(startCurrent, startCurrent);
} else {
pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()),
makeUpperCase);
SetSelection(startCurrent, startAnchor);
}
pdoc->EndUndoAction();
}
void Editor::LineTranspose() {
int line = pdoc->LineFromPosition(currentPos);
if (line > 0) {
int startPrev = pdoc->LineStart(line-1);
int endPrev = pdoc->LineEnd(line-1);
int start = pdoc->LineStart(line);
int end = pdoc->LineEnd(line);
int startNext = pdoc->LineStart(line+1);
if (end < pdoc->Length()) {
end = startNext;
char *thisLine = CopyRange(start, end);
pdoc->DeleteChars(start, end-start);
pdoc->InsertString(startPrev, thisLine, end-start);
MovePositionTo(startPrev+end-start);
delete []thisLine;
} else {
// Last line so line has no line end
char *thisLine = CopyRange(start, end);
char *prevEnd = CopyRange(endPrev, start);
pdoc->DeleteChars(endPrev, end-endPrev);
pdoc->InsertString(startPrev, thisLine, end-start);
pdoc->InsertString(startPrev + end-start, prevEnd, start-endPrev);
MovePositionTo(startPrev + end-endPrev);
delete []thisLine;
delete []prevEnd;
}
}
}
int Editor::KeyCommand(UINT iMessage) {
Point pt = LocationFromPosition(currentPos);
@ -1966,40 +1884,8 @@ int Editor::KeyCommand(UINT iMessage) {
case SCI_DELWORDRIGHT: {
int endWord = pdoc->NextWordStart(currentPos, 1);
pdoc->DeleteChars(currentPos, endWord - currentPos);
MovePositionTo(currentPos);
}
break;
case SCI_LINECUT: {
int lineStart = pdoc->LineFromPosition(currentPos);
int lineEnd = pdoc->LineFromPosition(anchor);
if (lineStart > lineEnd) {
int t = lineEnd;
lineEnd = lineStart;
lineStart = t;
}
int start = pdoc->LineStart(lineStart);
int end = pdoc->LineStart(lineEnd+1);
SetSelection(start,end);
Cut();
}
break;
case SCI_LINEDELETE: {
int line = pdoc->LineFromPosition(currentPos);
int start = pdoc->LineStart(line);
int end = pdoc->LineStart(line+1);
pdoc->DeleteChars(start, end-start);
MovePositionTo(start);
}
break;
case SCI_LINETRANSPOSE:
LineTranspose();
break;
case SCI_LOWERCASE:
ChangeCaseOfSelection(false);
break;
case SCI_UPPERCASE:
ChangeCaseOfSelection(true);
break;
}
return 0;
}
@ -2225,11 +2111,7 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul
int positionWasInSelection = PositionInSelection(position);
bool positionOnEdgeOfSelection =
(position == SelectionStart()) || (position == SelectionEnd());
if ((!inDragDrop) || !(0 == positionWasInSelection) ||
(positionOnEdgeOfSelection && !moving)) {
if ((!inDragDrop) || !(0 == positionWasInSelection)) {
int selStart = SelectionStart();
int selEnd = SelectionEnd();
@ -2684,10 +2566,6 @@ void Editor::SetDocPointer(Document *document) {
pdoc = document;
}
pdoc->AddRef();
// Reset the contraction state to fully shown.
cs.Clear();
cs.InsertLines(0, pdoc->LinesTotal()-1);
pdoc->AddWatcher(this, 0);
Redraw();
SetScrollBars();
@ -2802,7 +2680,6 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
case WM_PASTE:
Paste();
SetLastXChosen();
EnsureCaretVisible();
break;
case WM_CLEAR:
@ -3184,8 +3061,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
#ifdef INCLUDE_DEPRECATED_FEATURES
case SCI_APPENDUNDOSTARTACTION:
// Not just deprecated - now dead
//pdoc->AppendUndoStartAction();
pdoc->AppendUndoStartAction();
return 0;
#endif
@ -3384,15 +3260,18 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
break;
case SCI_MARKERADD: {
int markerID = pdoc->AddMark(wParam, lParam);
RedrawSelMargin();
return markerID;
}
case SCI_MARKERDELETE:
pdoc->DeleteMark(wParam, lParam);
RedrawSelMargin();
break;
case SCI_MARKERDELETEALL:
pdoc->DeleteAllMarks(static_cast<int>(wParam));
RedrawSelMargin();
break;
case SCI_MARKERGET:
@ -3512,7 +3391,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (lParam == 0)
return 0;
if (wParam <= STYLE_MAX) {
vs.SetStyleFontName(wParam, reinterpret_cast<const char *>(lParam));
strcpy(vs.styles[wParam].fontName, reinterpret_cast<char *>(lParam));
InvalidateStyleRedraw();
}
break;
@ -3613,14 +3492,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
caretSlop = lParam;
break;
case SCI_LINESONSCREEN:
return LinesOnScreen();
case SCI_USEPOPUP:
displayPopupMenu = wParam;
break;
#ifdef INCLUDE_DEPRECATED_FEATURES
#ifdef INCLUDE_DEPRECATED_FEATURES
case SCI_SETFORE:
vs.styles[STYLE_DEFAULT].fore.desired = Colour(wParam);
InvalidateStyleRedraw();
@ -3740,11 +3612,6 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
case SCI_ZOOMOUT:
case SCI_DELWORDLEFT:
case SCI_DELWORDRIGHT:
case SCI_LINECUT:
case SCI_LINEDELETE:
case SCI_LINETRANSPOSE:
case SCI_LOWERCASE:
case SCI_UPPERCASE:
return KeyCommand(iMessage);
case SCI_BRACEHIGHLIGHT:

View File

@ -116,8 +116,6 @@ protected: // ScintillaBase subclass needs access to much of Editor
int searchAnchor;
int displayPopupMenu;
#ifdef MACRO_SUPPORT
int recordingMacro;
#endif
@ -220,16 +218,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
void NotifyModified(Document *document, DocModification mh, void *userData);
void NotifyDeleted(Document *document, void *userData);
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
#ifdef MACRO_SUPPORT
void NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam);
#endif
void PageMove(int direction, bool extend=false);
void ChangeCaseOfSelection(bool makeUpperCase);
void LineTranspose();
virtual int KeyCommand(UINT iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/);
int KeyDown(int key, bool shift, bool ctrl, bool alt);

View File

@ -61,36 +61,36 @@ UINT KeyMap::Find(int key, int modifiers) {
}
KeyToCommand KeyMap::MapDefault[] = {
VK_DOWN, SCI_NORM, SCI_LINEDOWN,
VK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND,
VK_UP, SCI_NORM, SCI_LINEUP,
VK_UP, SCI_SHIFT, SCI_LINEUPEXTEND,
VK_DOWN, SCI_NORM, SCI_LINEDOWN,
VK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND,
VK_UP, SCI_NORM, SCI_LINEUP,
VK_UP, SCI_SHIFT, SCI_LINEUPEXTEND,
VK_LEFT, SCI_NORM, SCI_CHARLEFT,
VK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND,
VK_LEFT, SCI_CTRL, SCI_WORDLEFT,
VK_LEFT, SCI_CSHIFT, SCI_WORDLEFTEXTEND,
VK_RIGHT, SCI_NORM, SCI_CHARRIGHT,
VK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND,
VK_RIGHT, SCI_CTRL, SCI_WORDRIGHT,
VK_RIGHT, SCI_CSHIFT, SCI_WORDRIGHTEXTEND,
VK_HOME, SCI_NORM, SCI_VCHOME,
VK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND,
VK_HOME, SCI_CTRL, SCI_DOCUMENTSTART,
VK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND,
VK_RIGHT, SCI_NORM, SCI_CHARRIGHT,
VK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND,
VK_RIGHT, SCI_CTRL, SCI_WORDRIGHT,
VK_RIGHT, SCI_CSHIFT, SCI_WORDRIGHTEXTEND,
VK_HOME, SCI_NORM, SCI_VCHOME,
VK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND,
VK_HOME, SCI_CTRL, SCI_DOCUMENTSTART,
VK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND,
VK_END, SCI_NORM, SCI_LINEEND,
VK_END, SCI_SHIFT, SCI_LINEENDEXTEND,
VK_END, SCI_CTRL, SCI_DOCUMENTEND,
VK_END, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND,
VK_PRIOR, SCI_NORM, SCI_PAGEUP,
VK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND,
VK_NEXT, SCI_NORM, SCI_PAGEDOWN,
VK_NEXT, SCI_SHIFT, SCI_PAGEDOWNEXTEND,
VK_PRIOR, SCI_NORM, SCI_PAGEUP,
VK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND,
VK_NEXT, SCI_NORM, SCI_PAGEDOWN,
VK_NEXT, SCI_SHIFT, SCI_PAGEDOWNEXTEND,
VK_DELETE, SCI_NORM, WM_CLEAR,
VK_DELETE, SCI_SHIFT, WM_CUT,
VK_DELETE, SCI_CTRL, SCI_DELWORDRIGHT,
VK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE,
VK_INSERT, SCI_SHIFT, WM_PASTE,
VK_INSERT, SCI_CTRL, WM_COPY,
VK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE,
VK_INSERT, SCI_SHIFT, WM_PASTE,
VK_INSERT, SCI_CTRL, WM_COPY,
VK_ESCAPE, SCI_NORM, SCI_CANCEL,
VK_BACK, SCI_NORM, SCI_DELETEBACK,
VK_BACK, SCI_CTRL, SCI_DELWORDLEFT,
@ -103,14 +103,9 @@ KeyToCommand KeyMap::MapDefault[] = {
VK_TAB, SCI_NORM, SCI_TAB,
VK_TAB, SCI_SHIFT, SCI_BACKTAB,
VK_RETURN, SCI_NORM, SCI_NEWLINE,
'L', SCI_CTRL, SCI_FORMFEED,
VK_ADD, SCI_CTRL, SCI_ZOOMIN,
VK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT,
//'L', SCI_CTRL, SCI_FORMFEED,
'L', SCI_CTRL, SCI_LINECUT,
'L', SCI_CSHIFT, SCI_LINEDELETE,
'T', SCI_CTRL, SCI_LINETRANSPOSE,
'U', SCI_CTRL, SCI_LOWERCASE,
'U', SCI_CSHIFT, SCI_UPPERCASE,
0,0,0,
};

View File

@ -11,7 +11,6 @@
#define SCI_CTRL LEFT_CTRL_PRESSED
#define SCI_ALT LEFT_ALT_PRESSED
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
class KeyToCommand {
public:

File diff suppressed because it is too large Load Diff

View File

@ -1,255 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexCPP.cxx - lexer for C++, C, Java, and Javascript
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
char s[100];
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
bool wordIsUUID = false;
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
}
char chAttr = SCE_C_IDENTIFIER;
if (wordIsNumber)
chAttr = SCE_C_NUMBER;
else {
if (keywords.InList(s)) {
chAttr = SCE_C_WORD;
wordIsUUID = strcmp(s, "uuid") == 0;
}
}
styler.ColourTo(end, chAttr);
return wordIsUUID;
}
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
StylingContext &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
bool fold = styler.GetPropSet().GetInt("fold");
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
int state = initStyle;
char chPrev = ' ';
char chNext = styler[startPos];
unsigned int lengthDoc = startPos + length;
int visChars = 0;
styler.StartSegment(startPos);
bool lastWordWasUUID = false;
for (unsigned int i = startPos; i <= lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((fold) && ((ch == '\r' && chNext != '\n') || (ch == '\n'))) {
int lev = levelPrev;
if (visChars == 0)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
visChars = 0;
levelPrev = levelCurrent;
}
if (!isspace(ch))
visChars++;
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_C_STRINGEOL) {
if (ch != '\r' && ch != '\n') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
}
if (state == SCE_C_DEFAULT) {
if (iswordstart(ch)) {
styler.ColourTo(i-1, state);
if (lastWordWasUUID) {
state = SCE_C_UUID;
lastWordWasUUID = false;
} else {
state = SCE_C_WORD;
}
} else if (ch == '/' && chNext == '*') {
styler.ColourTo(i-1, state);
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
styler.ColourTo(i-1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i-1, state);
state = SCE_C_STRING;
} else if (ch == '\'') {
styler.ColourTo(i-1, state);
state = SCE_C_CHARACTER;
} else if (ch == '#') {
styler.ColourTo(i-1, state);
state = SCE_C_PREPROCESSOR;
} else if (isoperator(ch)) {
styler.ColourTo(i-1, state);
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
} else if (state == SCE_C_WORD) {
if (!iswordchar(ch)) {
lastWordWasUUID = classifyWordCpp(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_C_DEFAULT;
if (ch == '/' && chNext == '*') {
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_C_STRING;
} else if (ch == '\'') {
state = SCE_C_CHARACTER;
} else if (ch == '#') {
state = SCE_C_PREPROCESSOR;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
}
} else {
if (state == SCE_C_PREPROCESSOR) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_COMMENT) {
if (ch == '/' && chPrev == '*') {
if (((i > styler.GetStartSegment() + 2) || (
(initStyle == SCE_C_COMMENT) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTDOC) {
if (ch == '/' && chPrev == '*') {
if (((i > styler.GetStartSegment() + 3) || (
(initStyle == SCE_C_COMMENTDOC) &&
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_STRING) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, state);
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;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_C_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i-1, state);
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;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_C_UUID) {
if (ch == '\r' || ch == '\n' || ch == ')') {
styler.ColourTo(i-1, state);
state = SCE_C_DEFAULT;
}
}
if (state == SCE_C_DEFAULT) { // One of the above succeeded
if (ch == '/' && chNext == '*') {
if (styler.SafeGetCharAt(i + 2) == '*')
state = SCE_C_COMMENTDOC;
else
state = SCE_C_COMMENT;
} else if (ch == '/' && chNext == '/') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_C_STRING;
} else if (ch == '\'') {
state = SCE_C_CHARACTER;
} else if (ch == '#') {
state = SCE_C_PREPROCESSOR;
} else if (iswordstart(ch)) {
state = SCE_C_WORD;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
if ((ch == '{') || (ch == '}')) {
levelCurrent += (ch == '{') ? 1 : -1;
}
}
}
}
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 lmCPP(SCLEX_CPP, ColouriseCppDoc);

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexOthers.cxx - lexers for properties files, batch files, make files and error lists
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void ColouriseBatchLine(char *lineBuffer, int endLine, StylingContext &styler) {
if (0 == strncmp(lineBuffer, "REM", 3)) {
styler.ColourTo(endLine, 1);
} else if (0 == strncmp(lineBuffer, "rem", 3)) {
styler.ColourTo(endLine, 1);
} else if (0 == strncmp(lineBuffer, "SET", 3)) {
styler.ColourTo(endLine, 2);
} else if (0 == strncmp(lineBuffer, "set", 3)) {
styler.ColourTo(endLine, 2);
} else if (lineBuffer[0] == ':') {
styler.ColourTo(endLine, 3);
} else {
styler.ColourTo(endLine, 0);
}
}
static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
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)) {
ColouriseBatchLine(lineBuffer, i, styler);
linePos = 0;
}
}
if (linePos > 0)
ColouriseBatchLine(lineBuffer, startPos + length, styler);
}
static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, StylingContext &styler) {
int i = 0;
while (isspace(lineBuffer[i]) && (i < lengthLine)) // 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 {
while (lineBuffer[i] != '=' && (i < lengthLine)) // Search the '=' character
i++;
if (lineBuffer[i] == '=') {
styler.ColourTo(startLine+i-1, 0);
styler.ColourTo(startLine+i, 3);
styler.ColourTo(endPos, 0);
} else {
styler.ColourTo(endPos, 0);
}
}
}
static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
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)) {
lineBuffer[linePos] = '\0';
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0;
startLine = i+1;
}
}
if (linePos > 0)
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
}
static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
int i = 0;
while (isspace(lineBuffer[i]) && (i < lengthLine))
i++;
if (lineBuffer[i] == '#' || lineBuffer[i] == '!') {
styler.ColourTo(endPos, 1);
} else {
styler.ColourTo(endPos, 0);
}
}
static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
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)) {
ColouriseMakeLine(lineBuffer, linePos, i, styler);
linePos = 0;
}
}
if (linePos > 0)
ColouriseMakeLine(lineBuffer, linePos, startPos + length, styler);
}
static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
if (lineBuffer[0] == '>') {
// Command or return status
styler.ColourTo(endPos, 4);
} else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
styler.ColourTo(endPos, 1);
} else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
// Borland error message
styler.ColourTo(endPos, 5);
} else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
// Borland warning message
styler.ColourTo(endPos, 5);
} else {
// Look for <filename>:<line>:message
// Look for <filename>(line)message
// Look for <filename>(line,pos)message
int state = 0;
for (int i = 0; i < lengthLine; i++) {
if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
state = 1;
} else if (state == 0 && lineBuffer[i] == '(') {
state = 10;
} else if (state == 1 && isdigit(lineBuffer[i])) {
state = 2;
} else if (state == 2 && lineBuffer[i] == ':') {
state = 3;
break;
} else if (state == 2 && !isdigit(lineBuffer[i])) {
state = 99;
} else if (state == 10 && isdigit(lineBuffer[i])) {
state = 11;
} else if (state == 11 && lineBuffer[i] == ',') {
state = 14;
} else if (state == 11 && lineBuffer[i] == ')') {
state = 12;
break;
} else if (state == 12 && lineBuffer[i] == ':') {
state = 13;
} else if (state == 14 && lineBuffer[i] == ')') {
state = 15;
break;
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
state = 99;
}
}
if (state == 3) {
styler.ColourTo(endPos, 2);
} else if ((state == 14) || (state == 15)) {
styler.ColourTo(endPos, 3);
} else {
styler.ColourTo(endPos, 0);
}
}
}
static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
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)) {
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
linePos = 0;
}
}
if (linePos > 0)
ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
}
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc);
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc);
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc);
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc);

View File

@ -1,488 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexPerl.cxx - lexer for subset of Perl
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
inline bool isPerlOperator(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 == '~')
return true;
return false;
}
static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, StylingContext &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_PL_IDENTIFIER;
if (wordIsNumber)
chAttr = SCE_PL_NUMBER;
else {
if (keywords.InList(s))
chAttr = SCE_PL_WORD;
}
styler.ColourTo(end, chAttr);
return chAttr;
}
static bool isEndVar(char ch) {
return !isalnum(ch) && ch != '#' && ch != '$' &&
ch != '_' && ch != '\'';
}
static bool isMatch(StylingContext &styler, int lengthDoc, int pos, const char *val) {
if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
return false;
}
while (*val) {
if (*val != styler[pos++]) {
return false;
}
val++;
}
return true;
}
static bool isOKQuote(char ch) {
if (isalnum(ch))
return false;
if (isspace(ch))
return false;
if (iscntrl(ch))
return false;
return true;
}
static char opposite(char ch) {
if (ch == '(')
return ')';
if (ch == '[')
return ']';
if (ch == '{')
return '}';
if (ch == '<')
return '>';
return ch;
}
static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], StylingContext &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
// start position and what the termination string is for here documents
WordList &keywords = *keywordlists[0];
char sooked[100];
int quotes = 0;
char quoteDown = 'd';
char quoteUp = 'd';
int quoteRep = 1;
int sookedpos = 0;
bool preferRE = true;
sooked[sookedpos] = '\0';
int state = initStyle;
int lengthDoc = startPos + length;
// If in a long distance lexical state, seek to the beginning to find quote characters
if (state == SCE_PL_HERE || state == SCE_PL_REGEX ||
state == SCE_PL_REGSUBST || state == SCE_PL_LONGQUOTE) {
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
startPos--;
}
state = SCE_PL_DEFAULT;
}
styler.StartAt(startPos);
char chPrev = ' ';
char chNext = styler[startPos];
styler.StartSegment(startPos);
for (int i = startPos; i <= lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2);
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
i += 1;
continue;
}
if (state == SCE_PL_DEFAULT) {
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
if (ch == 's' && !isalnum(chNext)) {
state = SCE_PL_REGSUBST;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 2;
} else if (ch == 'm' && !isalnum(chNext)) {
state = SCE_PL_REGEX;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 1;
} else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) {
state = SCE_PL_REGSUBST;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 2;
i++;
chNext = chNext2;
} else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) {
state = SCE_PL_LONGQUOTE;
i++;
chNext = chNext2;
quotes = 0;
quoteUp = '\0';
quoteDown = '\0';
quoteRep = 1;
} else {
state = SCE_PL_WORD;
preferRE = false;
}
} else if (ch == '#') {
styler.ColourTo(i - 1, state);
state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i - 1, state);
state = SCE_PL_STRING;
} else if (ch == '\'') {
if (chPrev == '&') {
// Archaic call
styler.ColourTo(i, state);
} else {
styler.ColourTo(i - 1, state);
state = SCE_PL_CHARACTER;
}
} else if (ch == '`') {
styler.ColourTo(i - 1, state);
state = SCE_PL_BACKTICKS;
} else if (ch == '$') {
preferRE = false;
styler.ColourTo(i - 1, state);
if (isalnum(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
state = SCE_PL_SCALAR;
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_SCALAR);
i++;
ch = ' ';
chNext = ' ';
} else {
styler.ColourTo(i, SCE_PL_SCALAR);
}
} else if (ch == '@') {
preferRE = false;
styler.ColourTo(i - 1, state);
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
state = SCE_PL_ARRAY;
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_ARRAY);
i++;
ch = ' ';
} else {
styler.ColourTo(i, SCE_PL_ARRAY);
}
} else if (ch == '%') {
preferRE = false;
styler.ColourTo(i - 1, state);
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
state = SCE_PL_HASH;
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_HASH);
i++;
ch = ' ';
} else {
styler.ColourTo(i, SCE_PL_HASH);
}
} else if (ch == '*') {
styler.ColourTo(i - 1, state);
state = SCE_PL_SYMBOLTABLE;
} else if (ch == '/' && preferRE) {
styler.ColourTo(i - 1, state);
state = SCE_PL_REGEX;
quoteUp = '/';
quoteDown = '/';
quotes = 1;
quoteRep = 1;
} else if (ch == '<' && chNext == '<') {
styler.ColourTo(i - 1, state);
state = SCE_PL_HERE;
i++;
ch = chNext;
chNext = chNext2;
quotes = 0;
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (ch == '=' && isalpha(chNext)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_POD;
quotes = 0;
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (isPerlOperator(ch)) {
if (ch == ')' || ch == ']')
preferRE = false;
else
preferRE = true;
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_PL_OPERATOR);
}
} else if (state == SCE_PL_WORD) {
if (!iswordchar(ch) && ch != '\'') { // Archaic Perl has quotes inside names
if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) {
styler.ColourTo(i, SCE_PL_DATASECTION);
state = SCE_PL_DATASECTION;
} else if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) {
styler.ColourTo(i, SCE_PL_DATASECTION);
state = SCE_PL_DATASECTION;
} else {
if (classifyWordPerl(styler.GetStartSegment(), i - 1, keywords, styler) == SCE_PL_WORD)
preferRE = true;
state = SCE_PL_DEFAULT;
if (ch == '#') {
state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_PL_STRING;
} else if (ch == '\'') {
state = SCE_PL_CHARACTER;
} else if (ch == '<' && chNext == '<') {
state = SCE_PL_HERE;
quotes = 0;
sookedpos = 0;
sooked[sookedpos] = '\0';
} else if (isPerlOperator(ch)) {
if (ch == ')' || ch == ']')
preferRE = false;
else
preferRE = true;
styler.ColourTo(i, SCE_PL_OPERATOR);
state = SCE_PL_DEFAULT;
}
}
}
} else {
if (state == SCE_PL_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_HERE) {
if (isalnum(ch) && quotes < 2) {
sooked[sookedpos++] = ch;
sooked[sookedpos] = '\0';
if (quotes == 0)
quotes = 1;
} else {
quotes++;
}
if (quotes > 1 && isMatch(styler, lengthDoc, i, sooked)) {
styler.ColourTo(i + sookedpos - 1, SCE_PL_HERE);
state = SCE_PL_DEFAULT;
i += sookedpos;
chNext = ' ';
}
} else if (state == SCE_PL_STRING) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_CHARACTER) {
if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_BACKTICKS) {
if (ch == '`') {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (state == SCE_PL_POD) {
if (ch == '=') {
if (isMatch(styler, lengthDoc, i, "=cut")) {
styler.ColourTo(i - 1 + 4, state);
i += 4;
state = SCE_PL_DEFAULT;
chNext = ' ';
ch = ' ';
}
}
} else if (state == SCE_PL_SCALAR) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_ARRAY) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_HASH) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_SYMBOLTABLE) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_REF) {
if (isEndVar(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_PL_DEFAULT;
}
} else if (state == SCE_PL_REGEX) {
if (!quoteUp && !isspace(ch)) {
quoteUp = ch;
quoteDown = opposite(ch);
quotes++;
} else {
if (ch == quoteDown && chPrev != '\\') {
quotes--;
if (quotes == 0) {
quoteRep--;
if (quoteUp == quoteDown) {
quotes++;
}
}
if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
} else if (ch == quoteUp && chPrev != '\\') {
quotes++;
} else if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
}
} else if (state == SCE_PL_REGSUBST) {
if (!quoteUp && !isspace(ch)) {
quoteUp = ch;
quoteDown = opposite(ch);
quotes++;
} else {
if (ch == quoteDown && chPrev != '\\') {
quotes--;
if (quotes == 0) {
quoteRep--;
}
if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
if (quoteUp == quoteDown) {
quotes++;
}
} else if (ch == quoteUp && chPrev != '\\') {
quotes++;
} else if (!isalpha(chNext)) {
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
}
}
} else if (state == SCE_PL_LONGQUOTE) {
if (!quoteDown && !isspace(ch)) {
quoteUp = ch;
quoteDown = opposite(quoteUp);
quotes++;
} else if (ch == quoteDown) {
quotes--;
if (quotes == 0) {
quoteRep--;
if (quoteRep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
}
if (quoteUp == quoteDown) {
quotes++;
}
}
} else if (ch == quoteUp) {
quotes++;
}
}
if (state == SCE_PL_DEFAULT) { // One of the above succeeded
if (ch == '#') {
state = SCE_PL_COMMENTLINE;
} else if (ch == '\"') {
state = SCE_PL_STRING;
} else if (ch == '\'') {
state = SCE_PL_CHARACTER;
} else if (iswordstart(ch)) {
state = SCE_PL_WORD;
preferRE = false;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_PL_OPERATOR);
}
}
}
chPrev = ch;
}
styler.ColourTo(lengthDoc, state);
}
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc);

View File

@ -1,254 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexPython.cxx - lexer for Python
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void classifyWordPy(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler, char *prevWord) {
char s[100];
bool wordIsNumber = isdigit(styler[start]);
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = styler[start + i];
s[i + 1] = '\0';
}
char chAttr = SCE_P_IDENTIFIER;
if (0 == strcmp(prevWord, "class"))
chAttr = SCE_P_CLASSNAME;
else if (0 == strcmp(prevWord, "def"))
chAttr = SCE_P_DEFNAME;
else if (wordIsNumber)
chAttr = SCE_P_NUMBER;
else if (keywords.InList(s))
chAttr = SCE_P_WORD;
styler.ColourTo(end, chAttr);
strcpy(prevWord, s);
}
static bool IsPyComment(StylingContext &styler, int pos, int len) {
return len>0 && styler[pos]=='#';
}
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], StylingContext &styler) {
// Python uses a different mask because bad indentation is marked by oring with 32
styler.StartAt(startPos, 127);
WordList &keywords = *keywordlists[0];
//Platform::DebugPrintf("Python coloured\n");
bool fold = styler.GetPropSet().GetInt("fold");
int whingeLevel = styler.GetPropSet().GetInt("tab.timmy.whinge.level");
char prevWord[200];
prevWord[0] = '\0';
if (length == 0)
return ;
int lineCurrent = styler.GetLine(startPos);
int spaceFlags = 0;
// TODO: Need to check previous line for indentation for both folding and bad indentation
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
int state = initStyle & 31;
char chPrev = ' ';
char chPrev2 = ' ';
char chNext = styler[startPos];
char chNext2 = styler[startPos];
styler.StartSegment(startPos);
int lengthDoc = startPos + length;
bool atStartLine = true;
for (int i = startPos; i <= lengthDoc; i++) {
if (atStartLine) {
if (whingeLevel == 1) {
styler.SetFlags((spaceFlags & wsInconsistent) ? 64 : 0, state);
} else if (whingeLevel == 2) {
styler.SetFlags((spaceFlags & wsSpaceTab) ? 64 : 0, state);
} else if (whingeLevel == 3) {
styler.SetFlags((spaceFlags & wsSpace) ? 64 : 0, state);
} else if (whingeLevel == 4) {
styler.SetFlags((spaceFlags & wsTab) ? 64 : 0, state);
}
atStartLine = false;
}
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
chNext2 = styler.SafeGetCharAt(i + 2);
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
// Perform colourisation of white space and triple quoted strings at end of each line to allow
// tab marking to work inside white space and triple quoted strings
styler.ColourTo(i, state);
}
int lev = indentCurrent;
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsPyComment);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
// Line after is blank so check the next - maybe should continue further?
int spaceFlags2 = 0;
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsPyComment);
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
}
indentCurrent = indentNext;
if (fold) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
atStartLine = true;
}
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
chPrev = ' ';
chPrev2 = ' ';
i += 1;
continue;
}
if (state == SCE_P_STRINGEOL) {
if (ch != '\r' && ch != '\n') {
styler.ColourTo(i - 1, state);
state = SCE_P_DEFAULT;
}
}
if (state == SCE_P_DEFAULT) {
if (iswordstart(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_P_WORD;
} else if (ch == '#') {
styler.ColourTo(i - 1, state);
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (ch == '\"') {
styler.ColourTo(i - 1, state);
if (chNext == '\"' && chNext2 == '\"') {
i += 2;
state = SCE_P_TRIPLEDOUBLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_STRING;
}
} else if (ch == '\'') {
styler.ColourTo(i - 1, state);
if (chNext == '\'' && chNext2 == '\'') {
i += 2;
state = SCE_P_TRIPLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_CHARACTER;
}
} else if (isoperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_P_OPERATOR);
}
} else if (state == SCE_P_WORD) {
if (!iswordchar(ch)) {
classifyWordPy(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
state = SCE_P_DEFAULT;
if (ch == '#') {
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
} else if (ch == '\"') {
if (chNext == '\"' && chNext2 == '\"') {
i += 2;
state = SCE_P_TRIPLEDOUBLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_STRING;
}
} else if (ch == '\'') {
if (chNext == '\'' && chNext2 == '\'') {
i += 2;
state = SCE_P_TRIPLE;
ch = ' ';
chPrev = ' ';
chNext = styler.SafeGetCharAt(i + 1);
} else {
state = SCE_P_CHARACTER;
}
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_P_OPERATOR);
}
}
} else {
if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_STRING) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_P_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\"') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_CHARACTER) {
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
styler.ColourTo(i - 1, state);
state = SCE_P_STRINGEOL;
} else if (ch == '\\') {
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
} else if (ch == '\'') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_TRIPLE) {
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
} else if (state == SCE_P_TRIPLEDOUBLE) {
if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
styler.ColourTo(i, state);
state = SCE_P_DEFAULT;
}
}
}
chPrev2 = chPrev;
chPrev = ch;
}
if (state == SCE_P_WORD) {
classifyWordPy(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
} else {
styler.ColourTo(lengthDoc, state);
}
}
LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc);

View File

@ -1,158 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexSQL.cxx - lexer for SQL
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keywords, StylingContext &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] = toupper(styler[start + i]);
s[i + 1] = '\0';
}
char chAttr = SCE_C_IDENTIFIER;
if (wordIsNumber)
chAttr = SCE_C_NUMBER;
else {
if (keywords.InList(s))
chAttr = SCE_C_WORD;
}
styler.ColourTo(end, chAttr);
}
static void ColouriseSQLDoc(unsigned int startPos, int length,
int initStyle, WordList *keywordlists[], StylingContext &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
bool fold = styler.GetPropSet().GetInt("fold");
int lineCurrent = styler.GetLine(startPos);
int spaceFlags = 0;
int indentCurrent = 0;
int state = initStyle;
char chPrev = ' ';
char chNext = styler[startPos];
styler.StartSegment(startPos);
unsigned int lengthDoc = startPos + length;
bool prevCr = false;
for (unsigned int i = startPos; i <= lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags);
int lev = indentCurrent;
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Only non whitespace lines can be headers
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags);
if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) {
lev |= SC_FOLDLEVELHEADERFLAG;
}
}
if (fold) {
styler.SetLevel(lineCurrent, lev);
}
}
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_WORD;
} else if (ch == '/' && chNext == '*') {
styler.ColourTo(i - 1, state);
state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') {
styler.ColourTo(i - 1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '\'') {
styler.ColourTo(i - 1, state);
state = SCE_C_STRING;
} else if (isoperator(ch)) {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_C_OPERATOR);
}
} else if (state == SCE_C_WORD) {
if (!iswordchar(ch)) {
classifyWordSQL(styler.GetStartSegment(), i - 1, keywords, styler);
state = SCE_C_DEFAULT;
if (ch == '/' && chNext == '*') {
state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\'') {
state = SCE_C_STRING;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
}
}
} else {
if (state == SCE_C_COMMENT) {
if (ch == '/' && chPrev == '*') {
if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_C_COMMENT) &&
(styler.GetStartSegment() == startPos)))) {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
}
}
} else if (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_C_DEFAULT;
}
} else if (state == SCE_C_STRING) {
if (ch == '\'') {
if ( chNext == '\'' ) {
i++;
} else {
styler.ColourTo(i, state);
state = SCE_C_DEFAULT;
i++;
}
ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
}
}
if (state == SCE_C_DEFAULT) { // One of the above succeeded
if (ch == '/' && chNext == '*') {
state = SCE_C_COMMENT;
} else if (ch == '-' && chNext == '-') {
state = SCE_C_COMMENTLINE;
} else if (ch == '\'') {
state = SCE_C_STRING;
} else if (iswordstart(ch)) {
state = SCE_C_WORD;
} else if (isoperator(ch)) {
styler.ColourTo(i, SCE_C_OPERATOR);
}
}
}
chPrev = ch;
}
styler.ColourTo(lengthDoc - 1, state);
}
LexerModule lmSQL(SCLEX_SQL, ColouriseSQLDoc);

View File

@ -1,118 +0,0 @@
// SciTE - Scintilla based Text Editor
// LexVB.cxx - lexer for Visual Basic and VBScript
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, StylingContext &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] = tolower(styler[start + i]);
s[i + 1] = '\0';
}
char chAttr = SCE_C_DEFAULT;
if (wordIsNumber)
chAttr = SCE_C_NUMBER;
else {
if (keywords.InList(s)) {
chAttr = SCE_C_WORD;
if (strcmp(s, "rem") == 0)
chAttr = SCE_C_COMMENTLINE;
}
}
styler.ColourTo(end, chAttr);
if (chAttr == SCE_C_COMMENTLINE)
return SCE_C_COMMENTLINE;
else
return SCE_C_DEFAULT;
}
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], StylingContext &styler) {
WordList &keywords = *keywordlists[0];
styler.StartAt(startPos);
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 (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 (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 (state == SCE_C_COMMENTLINE) {
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_C_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);
}
}
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;
}
}
}
}
styler.ColourTo(lengthDoc, state);
}
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc);

View File

@ -27,7 +27,6 @@ bool EqualCaseInsensitive(const char *a, const char *b) {
// Get a line of input. If end of line escaped with '\\' then continue reading.
static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
bool continuation = true;
s[0] = '\0';
while ((len > 1) && lenData > 0) {
char ch = *fpc;
fpc++;
@ -47,7 +46,6 @@ static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
} else {
continuation = false;
*s++ = ch;
*s = '\0';
len--;
}
}
@ -255,9 +253,6 @@ void PropSet::ReadFromMemory(const char *data, int len) {
if (isalpha(linebuf[0]))
Set(linebuf);
}
// If there is a final line:
if (isalpha(linebuf[0]))
Set(linebuf);
}
}

View File

@ -30,7 +30,7 @@ class SVector {
return;
}
size = newSize;
for (unsigned int i=0; i<len; i++) {
for (int i=0; i<len; i++) {
newv[i] = v[i];
}
delete []v;
@ -94,13 +94,13 @@ public:
size = 0;
len = 0;
}
void SetLength(unsigned int newLength) {
if (newLength > len) {
if (newLength >= size) {
SizeTo(newLength);
void SetLength(int newLen) {
if (newLen > len) {
if (newLen >= size) {
SizeTo(newLen);
}
}
len = newLength;
len = newLen;
}
int Length() const {
return len;

View File

@ -276,14 +276,15 @@ void ScintillaBase::Colourise(int start, int end) {
end = lengthDoc;
int len = end - start;
PropSet props;
StylingContext styler(wMain.GetID(), props);
int styleStart = 0;
if (start > 0)
styleStart = styler.StyleAt(start - 1);
styler.SetCodePage(pdoc->dbcsCodePage);
LexerModule::Colourise(start, len, styleStart, lexLanguage, keyWordLists, styler);
ColouriseDoc(pdoc->dbcsCodePage, start, len, styleStart, lexLanguage, keyWordLists, styler);
styler.Flush();
}
#endif

View File

@ -10,31 +10,23 @@
#include "Style.h"
Style::Style() {
aliasOfDefaultFont = true;
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
Platform::DefaultFontSize(), 0,
false, false, false);
Clear();
}
Style::~Style() {
if (aliasOfDefaultFont)
font.SetID(0);
else
font.Release();
aliasOfDefaultFont = false;
font.Release();
}
Style &Style::operator=(const Style &source) {
if (this == &source)
return *this;
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
0, 0,
false, false, false);
Clear();
fore.desired = source.fore.desired;
back.desired = source.back.desired;
bold = source.bold;
italic = source.italic;
size = source.size;
strcpy(fontName, source.fontName);
eolFilled = source.eolFilled;
return *this;
}
@ -46,48 +38,18 @@ void Style::Clear(Colour fore_, Colour back_, int size_, const char *fontName_,
bold = bold_;
italic = italic_;
size = size_;
fontName = fontName_;
strcpy(fontName, fontName_);
eolFilled = eolFilled_;
if (aliasOfDefaultFont)
font.SetID(0);
else
font.Release();
aliasOfDefaultFont = false;
font.Release();
}
bool Style::EquivalentFontTo(const Style *other) const {
if (bold != other->bold ||
italic != other->italic ||
size != other->size)
return false;
if (fontName == other->fontName)
return true;
if (!fontName)
return false;
if (!other->fontName)
return false;
return strcmp(fontName, other->fontName) == 0;
}
void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) {
void Style::Realise(Surface &surface, int zoomLevel) {
int sizeZoomed = size + zoomLevel;
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
sizeZoomed = 2;
if (aliasOfDefaultFont)
font.SetID(0);
else
font.Release();
int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
aliasOfDefaultFont = defaultStyle &&
(EquivalentFontTo(defaultStyle) || !fontName);
if (aliasOfDefaultFont) {
font.SetID(defaultStyle->font.GetID());
} else if (fontName) {
font.Create(fontName, deviceHeight, bold, italic);
} else {
font.SetID(0);
}
font.Create(fontName, deviceHeight, bold, italic);
ascent = surface.Ascent(font);
descent = surface.Descent(font);

View File

@ -10,11 +10,10 @@ class Style {
public:
ColourPair fore;
ColourPair back;
bool aliasOfDefaultFont;
bool bold;
bool italic;
int size;
const char *fontName;
char fontName[100];
bool eolFilled;
Font font;
@ -28,12 +27,11 @@ public:
Style();
~Style();
Style &operator=(const Style &source);
void Clear(Colour fore_, Colour back_,
int size_,
const char *fontName_,
bool bold_, bool italic_, bool eolFilled_);
bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle=0);
void Clear(Colour fore_=Colour(0,0,0), Colour back_=Colour(0xff,0xff,0xff),
int size_=Platform::DefaultFontSize(),
const char *fontName_=Platform::DefaultFont(),
bool bold_=false, bool italic_=false, bool eolFilled_=false);
void Realise(Surface &surface, int zoomLevel);
};
#endif

View File

@ -17,46 +17,14 @@ MarginStyle::MarginStyle() :
symbol(false), width(16), mask(0xffffffff), sensitive(false) {
}
// A list of the fontnames - avoids wasting space in each style
FontNames::FontNames() {
max = 0;
}
FontNames::~FontNames() {
Clear();
}
void FontNames::Clear() {
for (int i=0;i<max;i++) {
delete []names[i];
}
max = 0;
}
const char *FontNames::Save(const char *name) {
if (!name)
return 0;
for (int i=0;i<max;i++) {
if (strcmp(names[i], name) == 0) {
return names[i];
}
}
names[max] = new char[strlen(name) + 1];
strcpy(names[max], name);
max++;
return names[max-1];
}
ViewStyle::ViewStyle() {
Init();
}
ViewStyle::ViewStyle(const ViewStyle &source) {
Init();
for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
for (int sty=0;sty<=STYLE_MAX;sty++) {
styles[sty] = source.styles[sty];
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
}
for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
markers[mrk] = source.markers[mrk];
@ -91,9 +59,6 @@ ViewStyle::~ViewStyle() {
}
void ViewStyle::Init() {
fontNames.Clear();
ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE;
indicators[0].fore = Colour(0, 0x7f, 0);
indicators[1].style = INDIC_TT;
@ -171,17 +136,14 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
void ViewStyle::Refresh(Surface &surface) {
selbar.desired = Platform::Chrome();
selbarlight.desired = Platform::ChromeHighlight();
styles[STYLE_DEFAULT].Realise(surface, zoomLevel);
maxAscent = styles[STYLE_DEFAULT].ascent;
maxDescent = styles[STYLE_DEFAULT].descent;
maxAscent = 1;
maxDescent = 1;
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
if (i != STYLE_DEFAULT) {
styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]);
if (maxAscent < styles[i].ascent)
maxAscent = styles[i].ascent;
if (maxDescent < styles[i].descent)
maxDescent = styles[i].descent;
}
styles[i].Realise(surface, zoomLevel);
if (maxAscent < styles[i].ascent)
maxAscent = styles[i].ascent;
if (maxDescent < styles[i].descent)
maxDescent = styles[i].descent;
}
lineHeight = maxAscent + maxDescent;
@ -200,14 +162,12 @@ void ViewStyle::Refresh(Surface &surface) {
}
void ViewStyle::ResetDefaultStyle() {
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
false, false, false);
styles[STYLE_DEFAULT].Clear();
}
void ViewStyle::ClearStyles() {
// Reset all styles to be like the default style
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
for (int i=0; i<=STYLE_MAX; i++) {
if (i != STYLE_DEFAULT) {
styles[i].Clear(
styles[STYLE_DEFAULT].fore.desired,
@ -215,13 +175,9 @@ void ViewStyle::ClearStyles() {
styles[STYLE_DEFAULT].size,
styles[STYLE_DEFAULT].fontName,
styles[STYLE_DEFAULT].bold,
styles[STYLE_DEFAULT].italic,
styles[STYLE_DEFAULT].eolFilled);
styles[STYLE_DEFAULT].italic);
}
}
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
}
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
styles[styleIndex].fontName = fontNames.Save(name);
}

View File

@ -15,20 +15,8 @@ public:
MarginStyle();
};
class FontNames {
private:
char *names[STYLE_MAX + 1];
int max;
public:
FontNames();
~FontNames();
void Clear();
const char *Save(const char *name);
};
class ViewStyle {
public:
FontNames fontNames;
Style styles[STYLE_MAX + 1];
LineMarker markers[MARKER_MAX + 1];
Indicator indicators[INDIC_MAX + 1];
@ -66,7 +54,6 @@ public:
void Refresh(Surface &surface);
void ResetDefaultStyle();
void ClearStyles();
void SetStyleFontName(int styleIndex, const char *name);
};
#endif

View File

@ -5,7 +5,7 @@
// derive directly from the Scintilla classes, but instead
// delegates most things to the real Scintilla class.
// This allows the use of Scintilla without polluting the
// namespace with all the classes and identifiers from Scintilla.
// namespace with all the classes and itentifiers from Scintilla.
//
// Author: Robin Dunn
//
@ -15,53 +15,11 @@
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include <ctype.h>
#include "wx/stc/stc.h"
#include "ScintillaWX.h"
#include <wx/tokenzr.h>
// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// them away. (eric@sourcegear.com)
int wxForceScintillaLexers(void)
{
extern LexerModule lmCPP;
extern LexerModule lmHTML;
extern LexerModule lmXML;
extern LexerModule lmProps;
extern LexerModule lmErrorList;
extern LexerModule lmMake;
extern LexerModule lmBatch;
extern LexerModule lmPerl;
extern LexerModule lmPython;
extern LexerModule lmSQL;
extern LexerModule lmVB;
if (
&lmCPP
&& &lmHTML
&& &lmXML
&& &lmProps
&& &lmErrorList
&& &lmMake
&& &lmBatch
&& &lmPerl
&& &lmPython
&& &lmSQL
&& &lmVB
)
{
return 1;
}
else
{
return 0;
}
}
//----------------------------------------------------------------------
const wxChar* wxSTCNameStr = "stcwindow";