Revision: 5521 http://geany.svn.sourceforge.net/geany/?rev=5521&view=rev Author: ntrel Date: 2011-01-10 17:21:48 +0000 (Mon, 10 Jan 2011)
Log Message: ----------- Merge unstable branch: - src/utils.c: Fix detecting non-lowercase self-closing tags e.g. <BR> (#2226117). - src/notebook.c: Add 'Open in New Window' command in the notebook tab menu (based on patch by Matthew Brush, thanks - #3118059). - data/filetypes.cpp, data/filetypes.vala, data/filetypes.glsl, data/filetypes.cs, data/filetypes.c: Disable preprocessor #define tracking for the CPP lexer (enabled by default in Scintilla). - scintilla/*, wscript: Update Scintilla to version 2.22. Use Scintilla's directory structure mostly and only remove unused lexers.
Modified Paths: -------------- trunk/ChangeLog trunk/data/filetypes.c trunk/data/filetypes.cpp trunk/data/filetypes.cs trunk/data/filetypes.glsl trunk/data/filetypes.vala trunk/scintilla/Makefile.am trunk/scintilla/include/Makefile.am trunk/scintilla/include/SciLexer.h trunk/scintilla/include/Scintilla.h trunk/scintilla/include/Scintilla.iface trunk/scintilla/include/ScintillaWidget.h trunk/scintilla/makefile.win32 trunk/scintilla/scintilla_changes.patch trunk/src/notebook.c trunk/src/utils.c trunk/wscript
Added Paths: ----------- trunk/scintilla/gtk/ trunk/scintilla/gtk/Converter.h trunk/scintilla/gtk/PlatGTK.cxx trunk/scintilla/gtk/ScintillaGTK.cxx trunk/scintilla/gtk/scintilla-marshal.c trunk/scintilla/gtk/scintilla-marshal.h trunk/scintilla/gtk/scintilla-marshal.list trunk/scintilla/include/ILexer.h trunk/scintilla/lexers/ trunk/scintilla/lexers/LexAda.cxx trunk/scintilla/lexers/LexAsm.cxx trunk/scintilla/lexers/LexBash.cxx trunk/scintilla/lexers/LexBasic.cxx trunk/scintilla/lexers/LexCPP.cxx trunk/scintilla/lexers/LexCSS.cxx trunk/scintilla/lexers/LexCaml.cxx trunk/scintilla/lexers/LexCmake.cxx trunk/scintilla/lexers/LexD.cxx trunk/scintilla/lexers/LexErlang.cxx trunk/scintilla/lexers/LexForth.cxx trunk/scintilla/lexers/LexFortran.cxx trunk/scintilla/lexers/LexHTML.cxx trunk/scintilla/lexers/LexHaskell.cxx trunk/scintilla/lexers/LexLisp.cxx trunk/scintilla/lexers/LexLua.cxx trunk/scintilla/lexers/LexMarkdown.cxx trunk/scintilla/lexers/LexMatlab.cxx trunk/scintilla/lexers/LexNsis.cxx trunk/scintilla/lexers/LexOthers.cxx trunk/scintilla/lexers/LexPascal.cxx trunk/scintilla/lexers/LexPerl.cxx trunk/scintilla/lexers/LexPython.cxx trunk/scintilla/lexers/LexR.cxx trunk/scintilla/lexers/LexRuby.cxx trunk/scintilla/lexers/LexSQL.cxx trunk/scintilla/lexers/LexTCL.cxx trunk/scintilla/lexers/LexTxt2tags.cxx trunk/scintilla/lexers/LexVHDL.cxx trunk/scintilla/lexers/LexVerilog.cxx trunk/scintilla/lexers/LexYAML.cxx trunk/scintilla/lexlib/ trunk/scintilla/lexlib/Accessor.cxx trunk/scintilla/lexlib/Accessor.h trunk/scintilla/lexlib/CharacterSet.cxx trunk/scintilla/lexlib/CharacterSet.h trunk/scintilla/lexlib/LexAccessor.h trunk/scintilla/lexlib/LexerBase.cxx trunk/scintilla/lexlib/LexerBase.h trunk/scintilla/lexlib/LexerModule.cxx trunk/scintilla/lexlib/LexerModule.h trunk/scintilla/lexlib/LexerNoExceptions.cxx trunk/scintilla/lexlib/LexerNoExceptions.h trunk/scintilla/lexlib/LexerSimple.cxx trunk/scintilla/lexlib/LexerSimple.h trunk/scintilla/lexlib/OptionSet.h trunk/scintilla/lexlib/PropSetSimple.cxx trunk/scintilla/lexlib/PropSetSimple.h trunk/scintilla/lexlib/StyleContext.cxx trunk/scintilla/lexlib/StyleContext.h trunk/scintilla/lexlib/WordList.cxx trunk/scintilla/lexlib/WordList.h trunk/scintilla/src/ trunk/scintilla/src/AutoComplete.cxx trunk/scintilla/src/AutoComplete.h trunk/scintilla/src/CallTip.cxx trunk/scintilla/src/CallTip.h trunk/scintilla/src/Catalogue.cxx trunk/scintilla/src/Catalogue.h trunk/scintilla/src/CellBuffer.cxx trunk/scintilla/src/CellBuffer.h trunk/scintilla/src/CharClassify.cxx trunk/scintilla/src/CharClassify.h trunk/scintilla/src/ContractionState.cxx trunk/scintilla/src/ContractionState.h trunk/scintilla/src/Decoration.cxx trunk/scintilla/src/Decoration.h trunk/scintilla/src/Document.cxx trunk/scintilla/src/Document.h trunk/scintilla/src/Editor.cxx trunk/scintilla/src/Editor.h trunk/scintilla/src/ExternalLexer.cxx trunk/scintilla/src/ExternalLexer.h trunk/scintilla/src/FontQuality.h trunk/scintilla/src/Indicator.cxx trunk/scintilla/src/Indicator.h trunk/scintilla/src/KeyMap.cxx trunk/scintilla/src/KeyMap.h trunk/scintilla/src/LineMarker.cxx trunk/scintilla/src/LineMarker.h trunk/scintilla/src/Partitioning.h trunk/scintilla/src/PerLine.cxx trunk/scintilla/src/PerLine.h trunk/scintilla/src/PositionCache.cxx trunk/scintilla/src/PositionCache.h trunk/scintilla/src/RESearch.cxx trunk/scintilla/src/RESearch.h trunk/scintilla/src/RunStyles.cxx trunk/scintilla/src/RunStyles.h trunk/scintilla/src/SVector.h trunk/scintilla/src/ScintillaBase.cxx trunk/scintilla/src/ScintillaBase.h trunk/scintilla/src/Selection.cxx trunk/scintilla/src/Selection.h trunk/scintilla/src/SplitVector.h trunk/scintilla/src/Style.cxx trunk/scintilla/src/Style.h trunk/scintilla/src/UniConversion.cxx trunk/scintilla/src/UniConversion.h trunk/scintilla/src/ViewStyle.cxx trunk/scintilla/src/ViewStyle.h trunk/scintilla/src/XPM.cxx trunk/scintilla/src/XPM.h
Removed Paths: ------------- trunk/scintilla/AutoComplete.cxx trunk/scintilla/AutoComplete.h trunk/scintilla/CallTip.cxx trunk/scintilla/CallTip.h trunk/scintilla/CellBuffer.cxx trunk/scintilla/CellBuffer.h trunk/scintilla/CharClassify.cxx trunk/scintilla/CharClassify.h trunk/scintilla/CharacterSet.h trunk/scintilla/ContractionState.cxx trunk/scintilla/ContractionState.h trunk/scintilla/Converter.h trunk/scintilla/Decoration.cxx trunk/scintilla/Decoration.h trunk/scintilla/Document.cxx trunk/scintilla/Document.h trunk/scintilla/DocumentAccessor.cxx trunk/scintilla/DocumentAccessor.h trunk/scintilla/Editor.cxx trunk/scintilla/Editor.h trunk/scintilla/ExternalLexer.cxx trunk/scintilla/ExternalLexer.h trunk/scintilla/Indicator.cxx trunk/scintilla/Indicator.h trunk/scintilla/KeyMap.cxx trunk/scintilla/KeyMap.h trunk/scintilla/KeyWords.cxx trunk/scintilla/LexAda.cxx trunk/scintilla/LexAsm.cxx trunk/scintilla/LexBash.cxx trunk/scintilla/LexBasic.cxx trunk/scintilla/LexCPP.cxx trunk/scintilla/LexCSS.cxx trunk/scintilla/LexCaml.cxx trunk/scintilla/LexCmake.cxx trunk/scintilla/LexD.cxx trunk/scintilla/LexErlang.cxx trunk/scintilla/LexForth.cxx trunk/scintilla/LexFortran.cxx trunk/scintilla/LexHTML.cxx trunk/scintilla/LexHaskell.cxx trunk/scintilla/LexLisp.cxx trunk/scintilla/LexLua.cxx trunk/scintilla/LexMarkdown.cxx trunk/scintilla/LexMatlab.cxx trunk/scintilla/LexNsis.cxx trunk/scintilla/LexOthers.cxx trunk/scintilla/LexPascal.cxx trunk/scintilla/LexPerl.cxx trunk/scintilla/LexPython.cxx trunk/scintilla/LexR.cxx trunk/scintilla/LexRuby.cxx trunk/scintilla/LexSQL.cxx trunk/scintilla/LexTCL.cxx trunk/scintilla/LexTxt2tags.cxx trunk/scintilla/LexVHDL.cxx trunk/scintilla/LexVerilog.cxx trunk/scintilla/LexYAML.cxx trunk/scintilla/LineMarker.cxx trunk/scintilla/LineMarker.h trunk/scintilla/Partitioning.h trunk/scintilla/PerLine.cxx trunk/scintilla/PerLine.h trunk/scintilla/PlatGTK.cxx trunk/scintilla/PositionCache.cxx trunk/scintilla/PositionCache.h trunk/scintilla/PropSet.cxx trunk/scintilla/PropSetSimple.h trunk/scintilla/RESearch.cxx trunk/scintilla/RESearch.h trunk/scintilla/RunStyles.cxx trunk/scintilla/RunStyles.h trunk/scintilla/SVector.h trunk/scintilla/ScintillaBase.cxx trunk/scintilla/ScintillaBase.h trunk/scintilla/ScintillaGTK.cxx trunk/scintilla/Selection.cxx trunk/scintilla/Selection.h trunk/scintilla/SplitVector.h trunk/scintilla/Style.cxx trunk/scintilla/Style.h trunk/scintilla/StyleContext.cxx trunk/scintilla/StyleContext.h trunk/scintilla/UniConversion.cxx trunk/scintilla/UniConversion.h trunk/scintilla/ViewStyle.cxx trunk/scintilla/ViewStyle.h trunk/scintilla/WindowAccessor.cxx trunk/scintilla/XPM.cxx trunk/scintilla/XPM.h trunk/scintilla/gtk/Converter.h trunk/scintilla/gtk/PlatGTK.cxx trunk/scintilla/gtk/ScintillaGTK.cxx trunk/scintilla/gtk/scintilla-marshal.c trunk/scintilla/gtk/scintilla-marshal.h trunk/scintilla/gtk/scintilla-marshal.list trunk/scintilla/include/Accessor.h trunk/scintilla/include/KeyWords.h trunk/scintilla/include/PropSet.h trunk/scintilla/include/SString.h trunk/scintilla/include/WindowAccessor.h trunk/scintilla/lexers/LexAda.cxx trunk/scintilla/lexers/LexAsm.cxx trunk/scintilla/lexers/LexBash.cxx trunk/scintilla/lexers/LexBasic.cxx trunk/scintilla/lexers/LexCPP.cxx trunk/scintilla/lexers/LexCSS.cxx trunk/scintilla/lexers/LexCaml.cxx trunk/scintilla/lexers/LexCmake.cxx trunk/scintilla/lexers/LexD.cxx trunk/scintilla/lexers/LexErlang.cxx trunk/scintilla/lexers/LexForth.cxx trunk/scintilla/lexers/LexFortran.cxx trunk/scintilla/lexers/LexHTML.cxx trunk/scintilla/lexers/LexHaskell.cxx trunk/scintilla/lexers/LexLisp.cxx trunk/scintilla/lexers/LexLua.cxx trunk/scintilla/lexers/LexMarkdown.cxx trunk/scintilla/lexers/LexMatlab.cxx trunk/scintilla/lexers/LexNsis.cxx trunk/scintilla/lexers/LexOthers.cxx trunk/scintilla/lexers/LexPascal.cxx trunk/scintilla/lexers/LexPerl.cxx trunk/scintilla/lexers/LexPython.cxx trunk/scintilla/lexers/LexR.cxx trunk/scintilla/lexers/LexRuby.cxx trunk/scintilla/lexers/LexSQL.cxx trunk/scintilla/lexers/LexTCL.cxx trunk/scintilla/lexers/LexTxt2tags.cxx trunk/scintilla/lexers/LexVHDL.cxx trunk/scintilla/lexers/LexVerilog.cxx trunk/scintilla/lexers/LexYAML.cxx trunk/scintilla/lexlib/Accessor.cxx trunk/scintilla/lexlib/Accessor.h trunk/scintilla/lexlib/CharacterSet.cxx trunk/scintilla/lexlib/CharacterSet.h trunk/scintilla/lexlib/LexAccessor.h trunk/scintilla/lexlib/LexerBase.cxx trunk/scintilla/lexlib/LexerBase.h trunk/scintilla/lexlib/LexerModule.cxx trunk/scintilla/lexlib/LexerModule.h trunk/scintilla/lexlib/LexerNoExceptions.cxx trunk/scintilla/lexlib/LexerNoExceptions.h trunk/scintilla/lexlib/LexerSimple.cxx trunk/scintilla/lexlib/LexerSimple.h trunk/scintilla/lexlib/OptionSet.h trunk/scintilla/lexlib/PropSetSimple.cxx trunk/scintilla/lexlib/PropSetSimple.h trunk/scintilla/lexlib/StyleContext.cxx trunk/scintilla/lexlib/StyleContext.h trunk/scintilla/lexlib/WordList.cxx trunk/scintilla/lexlib/WordList.h trunk/scintilla/scintilla-marshal.c trunk/scintilla/scintilla-marshal.h trunk/scintilla/scintilla-marshal.list trunk/scintilla/src/AutoComplete.cxx trunk/scintilla/src/AutoComplete.h trunk/scintilla/src/CallTip.cxx trunk/scintilla/src/CallTip.h trunk/scintilla/src/Catalogue.cxx trunk/scintilla/src/Catalogue.h trunk/scintilla/src/CellBuffer.cxx trunk/scintilla/src/CellBuffer.h trunk/scintilla/src/CharClassify.cxx trunk/scintilla/src/CharClassify.h trunk/scintilla/src/ContractionState.cxx trunk/scintilla/src/ContractionState.h trunk/scintilla/src/Decoration.cxx trunk/scintilla/src/Decoration.h trunk/scintilla/src/Document.cxx trunk/scintilla/src/Document.h trunk/scintilla/src/Editor.cxx trunk/scintilla/src/Editor.h trunk/scintilla/src/ExternalLexer.cxx trunk/scintilla/src/ExternalLexer.h trunk/scintilla/src/FontQuality.h trunk/scintilla/src/Indicator.cxx trunk/scintilla/src/Indicator.h trunk/scintilla/src/KeyMap.cxx trunk/scintilla/src/KeyMap.h trunk/scintilla/src/LineMarker.cxx trunk/scintilla/src/LineMarker.h trunk/scintilla/src/Partitioning.h trunk/scintilla/src/PerLine.cxx trunk/scintilla/src/PerLine.h trunk/scintilla/src/PositionCache.cxx trunk/scintilla/src/PositionCache.h trunk/scintilla/src/RESearch.cxx trunk/scintilla/src/RESearch.h trunk/scintilla/src/RunStyles.cxx trunk/scintilla/src/RunStyles.h trunk/scintilla/src/SVector.h trunk/scintilla/src/ScintillaBase.cxx trunk/scintilla/src/ScintillaBase.h trunk/scintilla/src/Selection.cxx trunk/scintilla/src/Selection.h trunk/scintilla/src/SplitVector.h trunk/scintilla/src/Style.cxx trunk/scintilla/src/Style.h trunk/scintilla/src/UniConversion.cxx trunk/scintilla/src/UniConversion.h trunk/scintilla/src/ViewStyle.cxx trunk/scintilla/src/ViewStyle.h trunk/scintilla/src/XPM.cxx trunk/scintilla/src/XPM.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/ChangeLog 2011-01-10 17:21:48 UTC (rev 5521) @@ -3,6 +3,23 @@ * src/toolbar.c, src/ui_utils.c, src/about.c, THANKS: Add Save As toolbar button option (patch by Matthew Brush, thanks; #3153490). + * scintilla/*, src/utils.c, src/notebook.c, + data/filetypes.cpp, data/filetypes.vala, data/filetypes.glsl, + data/filetypes.cs, data/filetypes.c, wscript: + Merge unstable branch: + - src/utils.c: + Fix detecting non-lowercase self-closing tags e.g. <BR> (#2226117). + - src/notebook.c: + Add 'Open in New Window' command in the notebook tab menu (based on + patch by Matthew Brush, thanks - #3118059). + - data/filetypes.cpp, data/filetypes.vala, data/filetypes.glsl, + data/filetypes.cs, data/filetypes.c: + Disable preprocessor #define tracking for the CPP lexer + (enabled by default in Scintilla). + - scintilla/*, wscript: + Update Scintilla to version 2.22. + Use Scintilla's directory structure mostly and only remove + unused lexers.
2011-01-05 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/data/filetypes.c =================================================================== --- trunk/data/filetypes.c 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/data/filetypes.c 2011-01-10 17:21:48 UTC (rev 5521) @@ -33,6 +33,7 @@
[lexer_properties] styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0 preprocessor.symbol.$(file.patterns.cpp)=# preprocessor.start.$(file.patterns.cpp)=if ifdef ifndef preprocessor.middle.$(file.patterns.cpp)=else elif
Modified: trunk/data/filetypes.cpp =================================================================== --- trunk/data/filetypes.cpp 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/data/filetypes.cpp 2011-01-10 17:21:48 UTC (rev 5521) @@ -33,6 +33,7 @@
[lexer_properties] styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0 preprocessor.symbol.$(file.patterns.cpp)=# preprocessor.start.$(file.patterns.cpp)=if ifdef ifndef preprocessor.middle.$(file.patterns.cpp)=else elif
Modified: trunk/data/filetypes.cs =================================================================== --- trunk/data/filetypes.cs 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/data/filetypes.cs 2011-01-10 17:21:48 UTC (rev 5521) @@ -33,6 +33,7 @@
[lexer_properties] styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0 preprocessor.symbol.$(file.patterns.cpp)=# preprocessor.start.$(file.patterns.cpp)=if preprocessor.middle.$(file.patterns.cpp)=else elif
Modified: trunk/data/filetypes.glsl =================================================================== --- trunk/data/filetypes.glsl 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/data/filetypes.glsl 2011-01-10 17:21:48 UTC (rev 5521) @@ -36,6 +36,7 @@
[lexer_properties] styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0 preprocessor.symbol.$(file.patterns.cpp)=# preprocessor.start.$(file.patterns.cpp)=if ifdef ifndef preprocessor.middle.$(file.patterns.cpp)=else elif
Modified: trunk/data/filetypes.vala =================================================================== --- trunk/data/filetypes.vala 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/data/filetypes.vala 2011-01-10 17:21:48 UTC (rev 5521) @@ -33,6 +33,7 @@
[lexer_properties] styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0 preprocessor.symbol.$(file.patterns.cpp)=# preprocessor.start.$(file.patterns.cpp)=if preprocessor.middle.$(file.patterns.cpp)=else elif
Deleted: trunk/scintilla/AutoComplete.cxx =================================================================== --- trunk/scintilla/AutoComplete.cxx 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/AutoComplete.cxx 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,178 +0,0 @@ -// Scintilla source code edit control -/** @file AutoComplete.cxx - ** Defines the auto completion list box. - **/ -// Copyright 1998-2003 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 <stdio.h> - -#include "Platform.h" - -#include "CharClassify.h" -#include "AutoComplete.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -AutoComplete::AutoComplete() : - active(false), - separator(' '), - typesep('?'), - ignoreCase(false), - chooseSingle(false), - lb(0), - posStart(0), - startLen(0), - cancelAtStartPos(true), - autoHide(true), - dropRestOfWord(false) { - lb = ListBox::Allocate(); - stopChars[0] = '\0'; - fillUpChars[0] = '\0'; -} - -AutoComplete::~AutoComplete() { - if (lb) { - lb->Destroy(); - delete lb; - lb = 0; - } -} - -bool AutoComplete::Active() const { - return active; -} - -void AutoComplete::Start(Window &parent, int ctrlID, - int position, Point location, int startLen_, - int lineHeight, bool unicodeMode) { - if (active) { - Cancel(); - } - lb->Create(parent, ctrlID, location, lineHeight, unicodeMode); - lb->Clear(); - active = true; - startLen = startLen_; - posStart = position; -} - -void AutoComplete::SetStopChars(const char *stopChars_) { - strncpy(stopChars, stopChars_, sizeof(stopChars)); - stopChars[sizeof(stopChars) - 1] = '\0'; -} - -bool AutoComplete::IsStopChar(char ch) { - return ch && strchr(stopChars, ch); -} - -void AutoComplete::SetFillUpChars(const char *fillUpChars_) { - strncpy(fillUpChars, fillUpChars_, sizeof(fillUpChars)); - fillUpChars[sizeof(fillUpChars) - 1] = '\0'; -} - -bool AutoComplete::IsFillUpChar(char ch) { - return ch && strchr(fillUpChars, ch); -} - -void AutoComplete::SetSeparator(char separator_) { - separator = separator_; -} - -char AutoComplete::GetSeparator() const { - return separator; -} - -void AutoComplete::SetTypesep(char separator_) { - typesep = separator_; -} - -char AutoComplete::GetTypesep() const { - return typesep; -} - -void AutoComplete::SetList(const char *list) { - lb->SetList(list, separator, typesep); -} - -void AutoComplete::Show(bool show) { - lb->Show(show); - if (show) - lb->Select(0); -} - -void AutoComplete::Cancel() { - if (lb->Created()) { - lb->Clear(); - lb->Destroy(); - active = false; - } -} - - -void AutoComplete::Move(int delta) { - int count = lb->Length(); - int current = lb->GetSelection(); - current += delta; - if (current >= count) - current = count - 1; - if (current < 0) - current = 0; - lb->Select(current); -} - -void AutoComplete::Select(const char *word) { - size_t lenWord = strlen(word); - int location = -1; - const int maxItemLen=1000; - char item[maxItemLen]; - int start = 0; // lower bound of the api array block to search - int end = lb->Length() - 1; // upper bound of the api array block to search - while ((start <= end) && (location == -1)) { // Binary searching loop - int pivot = (start + end) / 2; - lb->GetValue(pivot, item, maxItemLen); - int cond; - if (ignoreCase) - cond = CompareNCaseInsensitive(word, item, lenWord); - else - cond = strncmp(word, item, lenWord); - if (!cond) { - // Find first match - while (pivot > start) { - lb->GetValue(pivot-1, item, maxItemLen); - if (ignoreCase) - cond = CompareNCaseInsensitive(word, item, lenWord); - else - cond = strncmp(word, item, lenWord); - if (0 != cond) - break; - --pivot; - } - location = pivot; - if (ignoreCase) { - // Check for exact-case match - for (; pivot <= end; pivot++) { - lb->GetValue(pivot, item, maxItemLen); - if (!strncmp(word, item, lenWord)) { - location = pivot; - break; - } - if (CompareNCaseInsensitive(word, item, lenWord)) - break; - } - } - } else if (cond < 0) { - end = pivot - 1; - } else if (cond > 0) { - start = pivot + 1; - } - } - if (location == -1 && autoHide) - Cancel(); - else - lb->Select(location); -} -
Deleted: trunk/scintilla/AutoComplete.h =================================================================== --- trunk/scintilla/AutoComplete.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/AutoComplete.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,78 +0,0 @@ -// Scintilla source code edit control -/** @file AutoComplete.h - ** Defines the auto completion list box. - **/ -// Copyright 1998-2003 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef AUTOCOMPLETE_H -#define AUTOCOMPLETE_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - */ -class AutoComplete { - bool active; - char stopChars[256]; - char fillUpChars[256]; - char separator; - char typesep; // Type seperator - -public: - bool ignoreCase; - bool chooseSingle; - ListBox *lb; - int posStart; - int startLen; - /// Should autocompletion be canceled if editor's currentPos <= startPos? - bool cancelAtStartPos; - bool autoHide; - bool dropRestOfWord; - - AutoComplete(); - ~AutoComplete(); - - /// Is the auto completion list displayed? - bool Active() const; - - /// Display the auto completion list positioned to be near a character position - void Start(Window &parent, int ctrlID, int position, Point location, - int startLen_, int lineHeight, bool unicodeMode); - - /// The stop chars are characters which, when typed, cause the auto completion list to disappear - void SetStopChars(const char *stopChars_); - bool IsStopChar(char ch); - - /// The fillup chars are characters which, when typed, fill up the selected word - void SetFillUpChars(const char *fillUpChars_); - bool IsFillUpChar(char ch); - - /// The separator character is used when interpreting the list in SetList - void SetSeparator(char separator_); - char GetSeparator() const; - - /// The typesep character is used for seperating the word from the type - void SetTypesep(char separator_); - char GetTypesep() const; - - /// The list string contains a sequence of words separated by the separator character - void SetList(const char *list); - - void Show(bool show); - void Cancel(); - - /// Move the current list element by delta, scrolling appropriately - void Move(int delta); - - /// Select a list element that starts with word as the current element - void Select(const char *word); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif
Deleted: trunk/scintilla/CallTip.cxx =================================================================== --- trunk/scintilla/CallTip.cxx 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/CallTip.cxx 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,327 +0,0 @@ -// Scintilla source code edit control -/** @file CallTip.cxx - ** Code for displaying call tips. - **/ -// Copyright 1998-2001 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#include <stdlib.h> -#include <string.h> - -#include "Platform.h" - -#include "Scintilla.h" -#include "CallTip.h" -#include <stdio.h> - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -static const int insetX = 5; // text inset in x from calltip border -static const int widthArrow = 14; - -CallTip::CallTip() { - wCallTip = 0; - inCallTipMode = false; - posStartCallTip = 0; - val = 0; - rectUp = PRectangle(0,0,0,0); - rectDown = PRectangle(0,0,0,0); - lineHeight = 1; - startHighlight = 0; - endHighlight = 0; - tabSize = 0; - useStyleCallTip = false; // for backwards compatibility - -#ifdef __APPLE__ - // proper apple colours for the default - colourBG.desired = ColourDesired(0xff, 0xff, 0xc6); - colourUnSel.desired = ColourDesired(0, 0, 0); -#else - colourBG.desired = ColourDesired(0xff, 0xff, 0xff); - colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80); -#endif - colourSel.desired = ColourDesired(0, 0, 0x80); - colourShade.desired = ColourDesired(0, 0, 0); - colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0); -} - -CallTip::~CallTip() { - font.Release(); - wCallTip.Destroy(); - delete []val; - val = 0; -} - -void CallTip::RefreshColourPalette(Palette &pal, bool want) { - pal.WantFind(colourBG, want); - pal.WantFind(colourUnSel, want); - pal.WantFind(colourSel, want); - pal.WantFind(colourShade, want); - pal.WantFind(colourLight, want); -} - -// Although this test includes 0, we should never see a \0 character. -static bool IsArrowCharacter(char ch) { - return (ch == 0) || (ch == '\001') || (ch == '\002'); -} - -// We ignore tabs unless a tab width has been set. -bool CallTip::IsTabCharacter(char ch) const { - return (tabSize > 0) && (ch == '\t'); -} - -int CallTip::NextTabPos(int x) { - if (tabSize > 0) { // paranoia... not called unless this is true - x -= insetX; // position relative to text - x = (x + tabSize) / tabSize; // tab "number" - return tabSize*x + insetX; // position of next tab - } else { - return x + 1; // arbitrary - } -} - -// Draw a section of the call tip that does not include \n in one colour. -// The text may include up to numEnds tabs or arrow characters. -void CallTip::DrawChunk(Surface *surface, int &x, const char *s, - int posStart, int posEnd, int ytext, PRectangle rcClient, - bool highlight, bool draw) { - s += posStart; - int len = posEnd - posStart; - - // Divide the text into sections that are all text, or that are - // single arrows or single tab characters (if tabSize > 0). - int maxEnd = 0; - const int numEnds = 10; - int ends[numEnds + 2]; - for (int i=0; i<len; i++) { - if ((maxEnd < numEnds) && - (IsArrowCharacter(s[i]) || IsTabCharacter(s[i])) ) { - if (i > 0) - ends[maxEnd++] = i; - ends[maxEnd++] = i+1; - } - } - ends[maxEnd++] = len; - int startSeg = 0; - int xEnd; - for (int seg = 0; seg<maxEnd; seg++) { - int endSeg = ends[seg]; - if (endSeg > startSeg) { - if (IsArrowCharacter(s[startSeg])) { - bool upArrow = s[startSeg] == '\001'; - rcClient.left = x; - rcClient.right = rcClient.left + widthArrow; - if (draw) { - const int halfWidth = widthArrow / 2 - 3; - const int centreX = rcClient.left + widthArrow / 2 - 1; - const int centreY = (rcClient.top + rcClient.bottom) / 2; - surface->FillRectangle(rcClient, colourBG.allocated); - PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1, - rcClient.right - 2, rcClient.bottom - 1); - surface->FillRectangle(rcClientInner, colourUnSel.allocated); - - if (upArrow) { // Up arrow - Point pts[] = { - Point(centreX - halfWidth, centreY + halfWidth / 2), - Point(centreX + halfWidth, centreY + halfWidth / 2), - Point(centreX, centreY - halfWidth + halfWidth / 2), - }; - surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), - colourBG.allocated, colourBG.allocated); - } else { // Down arrow - Point pts[] = { - Point(centreX - halfWidth, centreY - halfWidth / 2), - Point(centreX + halfWidth, centreY - halfWidth / 2), - Point(centreX, centreY + halfWidth - halfWidth / 2), - }; - surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), - colourBG.allocated, colourBG.allocated); - } - } - xEnd = rcClient.right; - offsetMain = xEnd; - if (upArrow) { - rectUp = rcClient; - } else { - rectDown = rcClient; - } - } else if (IsTabCharacter(s[startSeg])) { - xEnd = NextTabPos(x); - } else { - xEnd = x + surface->WidthText(font, s + startSeg, endSeg - startSeg); - if (draw) { - rcClient.left = x; - rcClient.right = xEnd; - surface->DrawTextTransparent(rcClient, font, ytext, - s+startSeg, endSeg - startSeg, - highlight ? colourSel.allocated : colourUnSel.allocated); - } - } - x = xEnd; - startSeg = endSeg; - } - } -} - -int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { - PRectangle rcClientPos = wCallTip.GetClientPosition(); - PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left, - rcClientPos.bottom - rcClientPos.top); - PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1); - - // To make a nice small call tip window, it is only sized to fit most normal characters without accents - int ascent = surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font); - - // For each line... - // Draw the definition in three parts: before highlight, highlighted, after highlight - int ytext = rcClient.top + ascent + 1; - rcClient.bottom = ytext + surfaceWindow->Descent(font) + 1; - char *chunkVal = val; - bool moreChunks = true; - int maxWidth = 0; - - while (moreChunks) { - char *chunkEnd = strchr(chunkVal, '\n'); - if (chunkEnd == NULL) { - chunkEnd = chunkVal + strlen(chunkVal); - moreChunks = false; - } - int chunkOffset = chunkVal - val; - int chunkLength = chunkEnd - chunkVal; - int chunkEndOffset = chunkOffset + chunkLength; - int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset); - thisStartHighlight = Platform::Minimum(thisStartHighlight, chunkEndOffset); - thisStartHighlight -= chunkOffset; - int thisEndHighlight = Platform::Maximum(endHighlight, chunkOffset); - thisEndHighlight = Platform::Minimum(thisEndHighlight, chunkEndOffset); - thisEndHighlight -= chunkOffset; - rcClient.top = ytext - ascent - 1; - - int x = insetX; // start each line at this inset - - DrawChunk(surfaceWindow, x, chunkVal, 0, thisStartHighlight, - ytext, rcClient, false, draw); - DrawChunk(surfaceWindow, x, chunkVal, thisStartHighlight, thisEndHighlight, - ytext, rcClient, true, draw); - DrawChunk(surfaceWindow, x, chunkVal, thisEndHighlight, chunkLength, - ytext, rcClient, false, draw); - - chunkVal = chunkEnd + 1; - ytext += lineHeight; - rcClient.bottom += lineHeight; - maxWidth = Platform::Maximum(maxWidth, x); - } - return maxWidth; -} - -void CallTip::PaintCT(Surface *surfaceWindow) { - if (!val) - return; - PRectangle rcClientPos = wCallTip.GetClientPosition(); - PRectangle rcClientSize(0, 0, rcClientPos.right - rcClientPos.left, - rcClientPos.bottom - rcClientPos.top); - PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1); - - surfaceWindow->FillRectangle(rcClient, colourBG.allocated); - - offsetMain = insetX; // initial alignment assuming no arrows - PaintContents(surfaceWindow, true); - -#ifndef __APPLE__ - // OSX doesn't put borders on "help tags" - // Draw a raised border around the edges of the window - surfaceWindow->MoveTo(0, rcClientSize.bottom - 1); - surfaceWindow->PenColour(colourShade.allocated); - surfaceWindow->LineTo(rcClientSize.right - 1, rcClientSize.bottom - 1); - surfaceWindow->LineTo(rcClientSize.right - 1, 0); - surfaceWindow->PenColour(colourLight.allocated); - surfaceWindow->LineTo(0, 0); - surfaceWindow->LineTo(0, rcClientSize.bottom - 1); -#endif -} - -void CallTip::MouseClick(Point pt) { - clickPlace = 0; - if (rectUp.Contains(pt)) - clickPlace = 1; - if (rectDown.Contains(pt)) - clickPlace = 2; -} - -PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, - const char *faceName, int size, - int codePage_, int characterSet, Window &wParent) { - clickPlace = 0; - delete []val; - val = 0; - val = new char[strlen(defn) + 1]; - strcpy(val, defn); - codePage = codePage_; - Surface *surfaceMeasure = Surface::Allocate(); - if (!surfaceMeasure) - return PRectangle(); - surfaceMeasure->Init(wParent.GetID()); - surfaceMeasure->SetUnicodeMode(SC_CP_UTF8 == codePage); - surfaceMeasure->SetDBCSMode(codePage); - startHighlight = 0; - endHighlight = 0; - inCallTipMode = true; - posStartCallTip = pos; - int deviceHeight = surfaceMeasure->DeviceHeightFont(size); - font.Create(faceName, characterSet, deviceHeight, false, false); - // Look for multiple lines in the text - // Only support \n here - simply means container must avoid \r! - int numLines = 1; - const char *newline; - const char *look = val; - rectUp = PRectangle(0,0,0,0); - rectDown = PRectangle(0,0,0,0); - offsetMain = insetX; // changed to right edge of any arrows - int width = PaintContents(surfaceMeasure, false) + insetX; - while ((newline = strchr(look, '\n')) != NULL) { - look = newline + 1; - numLines++; - } - lineHeight = surfaceMeasure->Height(font); - - // Extra line for border and an empty line at top and bottom. The returned - // rectangle is aligned to the right edge of the last arrow encountered in - // the tip text, else to the tip text left edge. - int height = lineHeight * numLines - surfaceMeasure->InternalLeading(font) + 2 + 2; - delete surfaceMeasure; - return PRectangle(pt.x - offsetMain, pt.y + 1, pt.x + width - offsetMain, pt.y + 1 + height); -} - -void CallTip::CallTipCancel() { - inCallTipMode = false; - if (wCallTip.Created()) { - wCallTip.Destroy(); - } -} - -void CallTip::SetHighlight(int start, int end) { - // Avoid flashing by checking something has really changed - if ((start != startHighlight) || (end != endHighlight)) { - startHighlight = start; - endHighlight = end; - if (wCallTip.Created()) { - wCallTip.InvalidateAll(); - } - } -} - -// Set the tab size (sizes > 0 enable the use of tabs). This also enables the -// use of the STYLE_CALLTIP. -void CallTip::SetTabSize(int tabSz) { - tabSize = tabSz; - useStyleCallTip = true; -} - -// It might be better to have two access functions for this and to use -// them for all settings of colours. -void CallTip::SetForeBack(const ColourPair &fore, const ColourPair &back) { - colourBG = back; - colourUnSel = fore; -}
Deleted: trunk/scintilla/CallTip.h =================================================================== --- trunk/scintilla/CallTip.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/CallTip.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,87 +0,0 @@ -// Scintilla source code edit control -/** @file CallTip.h - ** Interface to the call tip control. - **/ -// Copyright 1998-2001 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CALLTIP_H -#define CALLTIP_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - */ -class CallTip { - int startHighlight; // character offset to start and... - int endHighlight; // ...end of highlighted text - char *val; - Font font; - PRectangle rectUp; // rectangle of last up angle in the tip - PRectangle rectDown; // rectangle of last down arrow in the tip - int lineHeight; // vertical line spacing - int offsetMain; // The alignment point of the call tip - int tabSize; // Tab size in pixels, <=0 no TAB expand - bool useStyleCallTip; // if true, STYLE_CALLTIP should be used - - // Private so CallTip objects can not be copied - CallTip(const CallTip &); - CallTip &operator=(const CallTip &); - void DrawChunk(Surface *surface, int &x, const char *s, - int posStart, int posEnd, int ytext, PRectangle rcClient, - bool highlight, bool draw); - int PaintContents(Surface *surfaceWindow, bool draw); - bool IsTabCharacter(char c) const; - int NextTabPos(int x); - -public: - Window wCallTip; - Window wDraw; - bool inCallTipMode; - int posStartCallTip; - ColourPair colourBG; - ColourPair colourUnSel; - ColourPair colourSel; - ColourPair colourShade; - ColourPair colourLight; - int codePage; - int clickPlace; - - CallTip(); - ~CallTip(); - - /// Claim or accept palette entries for the colours required to paint a calltip. - void RefreshColourPalette(Palette &pal, bool want); - - void PaintCT(Surface *surfaceWindow); - - void MouseClick(Point pt); - - /// Setup the calltip and return a rectangle of the area required. - PRectangle CallTipStart(int pos, Point pt, const char *defn, - const char *faceName, int size, int codePage_, - int characterSet, Window &wParent); - - void CallTipCancel(); - - /// Set a range of characters to be displayed in a highlight style. - /// Commonly used to highlight the current parameter. - void SetHighlight(int start, int end); - - /// Set the tab size in pixels for the call tip. 0 or -ve means no tab expand. - void SetTabSize(int tabSz); - - /// Used to determine which STYLE_xxxx to use for call tip information - bool UseStyleCallTip() const { return useStyleCallTip;} - - // Modify foreground and background colours - void SetForeBack(const ColourPair &fore, const ColourPair &back); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif
Deleted: trunk/scintilla/CellBuffer.cxx =================================================================== --- trunk/scintilla/CellBuffer.cxx 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/CellBuffer.cxx 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,656 +0,0 @@ -// Scintilla source code edit control -/** @file CellBuffer.cxx - ** Manages a buffer of cells. - **/ -// Copyright 1998-2001 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdarg.h> - -#include "Platform.h" - -#include "Scintilla.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "CellBuffer.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -LineVector::LineVector() : starts(256), perLine(0) { - Init(); -} - -LineVector::~LineVector() { - starts.DeleteAll(); -} - -void LineVector::Init() { - starts.DeleteAll(); - if (perLine) { - perLine->Init(); - } -} - -void LineVector::SetPerLine(PerLine *pl) { - perLine = pl; -} - -void LineVector::InsertText(int line, int delta) { - starts.InsertText(line, delta); -} - -void LineVector::InsertLine(int line, int position, bool lineStart) { - starts.InsertPartition(line, position); - if (perLine) { - if ((line > 0) && lineStart) - line--; - perLine->InsertLine(line); - } -} - -void LineVector::SetLineStart(int line, int position) { - starts.SetPartitionStartPosition(line, position); -} - -void LineVector::RemoveLine(int line) { - starts.RemovePartition(line); - if (perLine) { - perLine->RemoveLine(line); - } -} - -int LineVector::LineFromPosition(int pos) const { - return starts.PartitionFromPosition(pos); -} - -Action::Action() { - at = startAction; - position = 0; - data = 0; - lenData = 0; - mayCoalesce = false; -} - -Action::~Action() { - Destroy(); -} - -void Action::Create(actionType at_, int position_, char *data_, int lenData_, bool mayCoalesce_) { - delete []data; - position = position_; - at = at_; - data = data_; - lenData = lenData_; - mayCoalesce = mayCoalesce_; -} - -void Action::Destroy() { - delete []data; - data = 0; -} - -void Action::Grab(Action *source) { - delete []data; - - position = source->position; - at = source->at; - data = source->data; - lenData = source->lenData; - mayCoalesce = source->mayCoalesce; - - // Ownership of source data transferred to this - source->position = 0; - source->at = startAction; - source->data = 0; - source->lenData = 0; - source->mayCoalesce = true; -} - -// 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() { - // Have to test that there is room for 2 more actions in the array - // as two actions may be created by the calling function - if (currentAction >= (lenActions - 2)) { - // Run out of undo nodes so extend the array - int lenActionsNew = lenActions * 2; - Action *actionsNew = new Action[lenActionsNew]; - 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, - bool &startSequence, bool mayCoalesce) { - 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 < savePoint) { - savePoint = -1; - } - int oldCurrentAction = currentAction; - if (currentAction >= 1) { - if (0 == undoSequenceDepth) { - // Top level actions may not always be coalesced - int targetAct = -1; - const Action *actPrevious = &(actions[currentAction + targetAct]); - // Container actions may forward the coalesce state of Scintilla Actions. - while ((actPrevious->at == containerAction) && actPrevious->mayCoalesce) { - targetAct--; - actPrevious = &(actions[currentAction + targetAct]); - } - // See if current action can be coalesced into previous action - // Will work if both are inserts or deletes and position is same - if (currentAction == savePoint) { - currentAction++; - } else if (!actions[currentAction].mayCoalesce) { - // Not allowed to coalesce if this set - currentAction++; - } else if (!mayCoalesce || !actPrevious->mayCoalesce) { - currentAction++; - } else if (at == containerAction || actions[currentAction].at == containerAction) { - ; // A coalescible containerAction - } else if ((at != actPrevious->at) && (actPrevious->at != startAction)) { - currentAction++; - } else if ((at == insertAction) && - (position != (actPrevious->position + actPrevious->lenData))) { - // Insertions must be immediately after to coalesce - currentAction++; - } else if (at == removeAction) { - if ((lengthData == 1) || (lengthData == 2)) { - if ((position + lengthData) == actPrevious->position) { - ; // Backspace -> OK - } else if (position == actPrevious->position) { - ; // Delete -> OK - } else { - // Removals must be at same position to coalesce - currentAction++; - } - } else { - // Removals must be of one character to coalesce - currentAction++; - } - } else { - // Action coalesced. - } - - } else { - // Actions not at top level are always coalesced unless this is after return to top level - if (!actions[currentAction].mayCoalesce) - currentAction++; - } - } else { - currentAction++; - } - startSequence = oldCurrentAction != currentAction; - actions[currentAction].Create(at, position, data, lengthData, mayCoalesce); - 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; - } - actions[currentAction].mayCoalesce = false; - } - undoSequenceDepth++; -} - -void UndoHistory::EndUndoAction() { - PLATFORM_ASSERT(undoSequenceDepth > 0); - EnsureUndoRoom(); - undoSequenceDepth--; - if (0 == undoSequenceDepth) { - if (actions[currentAction].at != startAction) { - currentAction++; - actions[currentAction].Create(startAction); - maxAction = currentAction; - } - actions[currentAction].mayCoalesce = false; - } -} - -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::GetUndoStep() const { - return actions[currentAction]; -} - -void UndoHistory::CompletedUndoStep() { - 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::GetRedoStep() const { - return actions[currentAction]; -} - -void UndoHistory::CompletedRedoStep() { - currentAction++; -} - -CellBuffer::CellBuffer() { - readOnly = false; - collectingUndo = true; -} - -CellBuffer::~CellBuffer() { -} - -char CellBuffer::CharAt(int position) const { - return substance.ValueAt(position); -} - -void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) const { - if (lengthRetrieve < 0) - return; - if (position < 0) - return; - if ((position + lengthRetrieve) > substance.Length()) { - Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", position, - lengthRetrieve, substance.Length()); - return; - } - - for (int i=0; i<lengthRetrieve; i++) { - *buffer++ = substance.ValueAt(position + i); - } -} - -char CellBuffer::StyleAt(int position) const { - return style.ValueAt(position); -} - -const char *CellBuffer::BufferPointer() { - return substance.BufferPointer(); -} - -// The char* returned is to an allocation owned by the undo history -const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) { - char *data = 0; - // InsertString and DeleteChars are the bottleneck though which all changes occur - if (!readOnly) { - if (collectingUndo) { - // Save into the undo/redo stack, but only the characters - not the formatting - // This takes up about half load time - data = new char[insertLength]; - for (int i = 0; i < insertLength; i++) { - data[i] = s[i]; - } - uh.AppendAction(insertAction, position, data, insertLength, startSequence); - } - - BasicInsertString(position, s, insertLength); - } - return data; -} - -bool CellBuffer::SetStyleAt(int position, char styleValue, char mask) { - styleValue &= mask; - char curVal = style.ValueAt(position); - if ((curVal & mask) != styleValue) { - style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue)); - return true; - } else { - return false; - } -} - -bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue, char mask) { - bool changed = false; - PLATFORM_ASSERT(lengthStyle == 0 || - (lengthStyle > 0 && lengthStyle + position <= style.Length())); - while (lengthStyle--) { - char curVal = style.ValueAt(position); - if ((curVal & mask) != styleValue) { - style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue)); - changed = true; - } - position++; - } - return changed; -} - -// The char* returned is to an allocation owned by the undo history -const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) { - // InsertString and DeleteChars are the bottleneck though which all changes occur - PLATFORM_ASSERT(deleteLength > 0); - char *data = 0; - if (!readOnly) { - if (collectingUndo) { - // Save into the undo/redo stack, but only the characters - not the formatting - data = new char[deleteLength]; - for (int i = 0; i < deleteLength; i++) { - data[i] = substance.ValueAt(position + i); - } - uh.AppendAction(removeAction, position, data, deleteLength, startSequence); - } - - BasicDeleteChars(position, deleteLength); - } - return data; -} - -int CellBuffer::Length() const { - return substance.Length(); -} - -void CellBuffer::Allocate(int newSize) { - substance.ReAllocate(newSize); - style.ReAllocate(newSize); -} - -void CellBuffer::SetPerLine(PerLine *pl) { - lv.SetPerLine(pl); -} - -int CellBuffer::Lines() const { - return lv.Lines(); -} - -int CellBuffer::LineStart(int line) const { - if (line < 0) - return 0; - else if (line >= Lines()) - return Length(); - else - return lv.LineStart(line); -} - -bool CellBuffer::IsReadOnly() const { - return readOnly; -} - -void CellBuffer::SetReadOnly(bool set) { - readOnly = set; -} - -void CellBuffer::SetSavePoint() { - uh.SetSavePoint(); -} - -bool CellBuffer::IsSavePoint() { - return uh.IsSavePoint(); -} - -// Without undo - -void CellBuffer::InsertLine(int line, int position, bool lineStart) { - lv.InsertLine(line, position, lineStart); -} - -void CellBuffer::RemoveLine(int line) { - lv.RemoveLine(line); -} - -void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) { - if (insertLength == 0) - return; - PLATFORM_ASSERT(insertLength > 0); - - substance.InsertFromArray(position, s, 0, insertLength); - style.InsertValue(position, insertLength, 0); - - int lineInsert = lv.LineFromPosition(position) + 1; - bool atLineStart = lv.LineStart(lineInsert-1) == position; - // Point all the lines after the insertion point further along in the buffer - lv.InsertText(lineInsert-1, insertLength); - char chPrev = substance.ValueAt(position - 1); - char chAfter = substance.ValueAt(position + insertLength); - if (chPrev == '\r' && chAfter == '\n') { - // Splitting up a crlf pair at position - InsertLine(lineInsert, position, false); - lineInsert++; - } - char ch = ' '; - for (int i = 0; i < insertLength; i++) { - ch = s[i]; - if (ch == '\r') { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } else if (ch == '\n') { - if (chPrev == '\r') { - // Patch up what was end of line - lv.SetLineStart(lineInsert - 1, (position + i) + 1); - } else { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } - } - chPrev = ch; - } - // Joining two lines where last insertion is cr and following substance starts with lf - if (chAfter == '\n') { - if (ch == '\r') { - // End of line already in buffer so drop the newly created one - RemoveLine(lineInsert - 1); - } - } -} - -void CellBuffer::BasicDeleteChars(int position, int deleteLength) { - if (deleteLength == 0) - return; - - if ((position == 0) && (deleteLength == substance.Length())) { - // If whole buffer is being deleted, faster to reinitialise lines data - // than to delete each line. - lv.Init(); - } else { - // Have to fix up line positions before doing deletion as looking at text in buffer - // to work out which lines have been removed - - int lineRemove = lv.LineFromPosition(position) + 1; - lv.InsertText(lineRemove-1, - (deleteLength)); - char chPrev = substance.ValueAt(position - 1); - char chBefore = chPrev; - char chNext = substance.ValueAt(position); - bool ignoreNL = false; - if (chPrev == '\r' && chNext == '\n') { - // Move back one - lv.SetLineStart(lineRemove, position); - lineRemove++; - ignoreNL = true; // First \n is not real deletion - } - - char ch = chNext; - for (int i = 0; i < deleteLength; i++) { - chNext = substance.ValueAt(position + i + 1); - if (ch == '\r') { - if (chNext != '\n') { - RemoveLine(lineRemove); - } - } else if (ch == '\n') { - if (ignoreNL) { - ignoreNL = false; // Further \n are real deletions - } else { - RemoveLine(lineRemove); - } - } - - ch = chNext; - } - // May have to fix up end if last deletion causes cr to be next to lf - // or removes one of a crlf pair - char chAfter = substance.ValueAt(position + deleteLength); - if (chBefore == '\r' && chAfter == '\n') { - // Using lineRemove-1 as cr ended line before start of deletion - RemoveLine(lineRemove - 1); - lv.SetLineStart(lineRemove - 1, position + 1); - } - } - substance.DeleteRange(position, deleteLength); - style.DeleteRange(position, deleteLength); -} - -bool CellBuffer::SetUndoCollection(bool collectUndo) { - collectingUndo = collectUndo; - uh.DropUndoSequence(); - return collectingUndo; -} - -bool CellBuffer::IsCollectingUndo() const { - return collectingUndo; -} - -void CellBuffer::BeginUndoAction() { - uh.BeginUndoAction(); -} - -void CellBuffer::EndUndoAction() { - uh.EndUndoAction(); -} - -void CellBuffer::AddUndoAction(int token, bool mayCoalesce) { - bool startSequence; - uh.AppendAction(containerAction, token, 0, 0, startSequence, mayCoalesce); -} - -void CellBuffer::DeleteUndoHistory() { - uh.DeleteUndoHistory(); -} - -bool CellBuffer::CanUndo() { - return uh.CanUndo(); -} - -int CellBuffer::StartUndo() { - return uh.StartUndo(); -} - -const Action &CellBuffer::GetUndoStep() const { - return uh.GetUndoStep(); -} - -void CellBuffer::PerformUndoStep() { - const Action &actionStep = uh.GetUndoStep(); - if (actionStep.at == insertAction) { - BasicDeleteChars(actionStep.position, actionStep.lenData); - } else if (actionStep.at == removeAction) { - BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); - } - uh.CompletedUndoStep(); -} - -bool CellBuffer::CanRedo() { - return uh.CanRedo(); -} - -int CellBuffer::StartRedo() { - return uh.StartRedo(); -} - -const Action &CellBuffer::GetRedoStep() const { - return uh.GetRedoStep(); -} - -void CellBuffer::PerformRedoStep() { - const Action &actionStep = uh.GetRedoStep(); - if (actionStep.at == insertAction) { - BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); - } else if (actionStep.at == removeAction) { - BasicDeleteChars(actionStep.position, actionStep.lenData); - } - uh.CompletedRedoStep(); -} -
Deleted: trunk/scintilla/CellBuffer.h =================================================================== --- trunk/scintilla/CellBuffer.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/CellBuffer.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,208 +0,0 @@ -// Scintilla source code edit control -/** @file CellBuffer.h - ** Manages the text of the document. - **/ -// Copyright 1998-2004 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CELLBUFFER_H -#define CELLBUFFER_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -// Interface to per-line data that wants to see each line insertion and deletion -class PerLine { -public: - virtual ~PerLine() {} - virtual void Init()=0; - virtual void InsertLine(int)=0; - virtual void RemoveLine(int)=0; -}; - -/** - * The line vector contains information about each of the lines in a cell buffer. - */ -class LineVector { - - Partitioning starts; - PerLine *perLine; - -public: - - LineVector(); - ~LineVector(); - void Init(); - void SetPerLine(PerLine *pl); - - void InsertText(int line, int delta); - void InsertLine(int line, int position, bool lineStart); - void SetLineStart(int line, int position); - void RemoveLine(int line); - int Lines() const { - return starts.Partitions(); - } - int LineFromPosition(int pos) const; - int LineStart(int line) const { - return starts.PositionFromPartition(line); - } - - int MarkValue(int line); - int AddMark(int line, int marker); - void MergeMarkers(int pos); - void DeleteMark(int line, int markerNum, bool all); - void DeleteMarkFromHandle(int markerHandle); - int LineFromHandle(int markerHandle); - - void ClearLevels(); - int SetLevel(int line, int level); - int GetLevel(int line); - - int SetLineState(int line, int state); - int GetLineState(int line); - int GetMaxLineState(); - -}; - -enum actionType { insertAction, removeAction, startAction, containerAction }; - -/** - * Actions are used to store all the information required to perform one undo/redo step. - */ -class Action { -public: - actionType at; - int position; - char *data; - int lenData; - bool mayCoalesce; - - Action(); - ~Action(); - void Create(actionType at_, int position_=0, char *data_=0, int lenData_=0, bool mayCoalesce_=true); - void Destroy(); - void Grab(Action *source); -}; - -/** - * - */ -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, bool &startSequence, bool mayCoalesce=true); - - 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 &GetUndoStep() const; - void CompletedUndoStep(); - bool CanRedo() const; - int StartRedo(); - const Action &GetRedoStep() const; - void CompletedRedoStep(); -}; - -/** - * 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. - */ -class CellBuffer { -private: - SplitVector<char> substance; - SplitVector<char> style; - bool readOnly; - - bool collectingUndo; - UndoHistory uh; - - LineVector lv; - -public: - - CellBuffer(); - ~CellBuffer(); - - /// Retrieving positions outside the range of the buffer works and returns 0 - char CharAt(int position) const; - void GetCharRange(char *buffer, int position, int lengthRetrieve) const; - char StyleAt(int position) const; - const char *BufferPointer(); - - int Length() const; - void Allocate(int newSize); - void SetPerLine(PerLine *pl); - int Lines() const; - int LineStart(int line) const; - int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); } - void InsertLine(int line, int position, bool lineStart); - void RemoveLine(int line); - const char *InsertString(int position, const char *s, int insertLength, bool &startSequence); - - /// Setting styles for positions outside the range of the buffer is safe and has no effect. - /// @return true if the style of a character is changed. - bool SetStyleAt(int position, char styleValue, char mask='\377'); - bool SetStyleFor(int position, int length, char styleValue, char mask); - - const char *DeleteChars(int position, int deleteLength, bool &startSequence); - - bool IsReadOnly() const; - void SetReadOnly(bool set); - - /// 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(); - - /// Actions without undo - void BasicInsertString(int position, const char *s, int insertLength); - void BasicDeleteChars(int position, int deleteLength); - - bool SetUndoCollection(bool collectUndo); - bool IsCollectingUndo() const; - void BeginUndoAction(); - void EndUndoAction(); - void AddUndoAction(int token, bool mayCoalesce); - void DeleteUndoHistory(); - - /// 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(); - int StartUndo(); - const Action &GetUndoStep() const; - void PerformUndoStep(); - bool CanRedo(); - int StartRedo(); - const Action &GetRedoStep() const; - void PerformRedoStep(); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif
Deleted: trunk/scintilla/CharClassify.cxx =================================================================== --- trunk/scintilla/CharClassify.cxx 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/CharClassify.cxx 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,78 +0,0 @@ -// Scintilla source code edit control -/** @file CharClassify.cxx - ** Character classifications used by Document and RESearch. - **/ -// Copyright 2006 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#include <stdlib.h> -#include <ctype.h> - -#include "CharClassify.h" - -// Shut up annoying Visual C++ warnings: -#ifdef _MSC_VER -#pragma warning(disable: 4514) -#endif - -CharClassify::CharClassify() { - SetDefaultCharClasses(true); -} - -void CharClassify::SetDefaultCharClasses(bool includeWordClass) { - // Initialize all char classes to default values - for (int ch = 0; ch < 256; ch++) { - if (ch == '\r' || ch == '\n') - charClass[ch] = ccNewLine; - else if (ch < 0x20 || ch == ' ') - charClass[ch] = ccSpace; - else if (includeWordClass && (ch >= 0x80 || isalnum(ch) || ch == '_')) - charClass[ch] = ccWord; - else - charClass[ch] = ccPunctuation; - } -} - -void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) { - // Apply the newCharClass to the specifed chars - if (chars) { - while (*chars) { - charClass[*chars] = static_cast<unsigned char>(newCharClass); - chars++; - } - } -} - -int CompareCaseInsensitive(const char *a, const char *b) { - while (*a && *b) { - if (*a != *b) { - char upperA = MakeUpperCase(*a); - char upperB = MakeUpperCase(*b); - if (upperA != upperB) - return upperA - upperB; - } - a++; - b++; - } - // Either *a or *b is nul - return *a - *b; -} - -int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { - while (*a && *b && len) { - if (*a != *b) { - char upperA = MakeUpperCase(*a); - char upperB = MakeUpperCase(*b); - if (upperA != upperB) - return upperA - upperB; - } - a++; - b++; - len--; - } - if (len == 0) - return 0; - else - // Either *a or *b is nul - return *a - *b; -}
Deleted: trunk/scintilla/CharClassify.h =================================================================== --- trunk/scintilla/CharClassify.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/CharClassify.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,37 +0,0 @@ -// Scintilla source code edit control -/** @file CharClassify.h - ** Character classifications used by Document and RESearch. - **/ -// Copyright 2006-2009 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CHARCLASSIFY_H -#define CHARCLASSIFY_H - -class CharClassify { -public: - CharClassify(); - - enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation }; - void SetDefaultCharClasses(bool includeWordClass); - void SetCharClasses(const unsigned char *chars, cc newCharClass); - cc GetClass(unsigned char ch) const { return static_cast<cc>(charClass[ch]);} - bool IsWord(unsigned char ch) const { return static_cast<cc>(charClass[ch]) == ccWord;} - -private: - enum { maxChar=256 }; - unsigned char charClass[maxChar]; // not type cc to save space -}; - -// These functions are implemented because each platform calls them something different. -int CompareCaseInsensitive(const char *a, const char *b); -int CompareNCaseInsensitive(const char *a, const char *b, size_t len); - -inline char MakeUpperCase(char ch) { - if (ch < 'a' || ch > 'z') - return ch; - else - return static_cast<char>(ch - 'a' + 'A'); -} - -#endif
Deleted: trunk/scintilla/CharacterSet.h =================================================================== --- trunk/scintilla/CharacterSet.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/CharacterSet.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,59 +0,0 @@ -// Scintilla source code edit control -/** @file CharacterSet.h - ** Encapsulates a set of characters. Used to test if a character is within a set. - **/ -// Copyright 2007 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -class CharacterSet { - int size; - bool valueAfter; - bool *bset; -public: - enum setBase { - setNone=0, - setLower=1, - setUpper=2, - setDigits=4, - setAlpha=setLower|setUpper, - setAlphaNum=setAlpha|setDigits - }; - CharacterSet(setBase base=setNone, const char *initialSet="", int size_=0x80, bool valueAfter_=false) { - size = size_; - valueAfter = valueAfter_; - bset = new bool[size]; - for (int i=0; i < size; i++) { - bset[i] = false; - } - AddString(initialSet); - if (base & setLower) - AddString("abcdefghijklmnopqrstuvwxyz"); - if (base & setUpper) - AddString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - if (base & setDigits) - AddString("0123456789"); - } - ~CharacterSet() { - delete []bset; - bset = 0; - size = 0; - } - void Add(int val) { - PLATFORM_ASSERT(val >= 0); - PLATFORM_ASSERT(val < size); - bset[val] = true; - } - void AddString(const char *CharacterSet) { - for (const char *cp=CharacterSet; *cp; cp++) { - int val = static_cast<unsigned char>(*cp); - PLATFORM_ASSERT(val >= 0); - PLATFORM_ASSERT(val < size); - bset[val] = true; - } - } - bool Contains(int val) const { - PLATFORM_ASSERT(val >= 0); - if (val < 0) return false; - return (val < size) ? bset[val] : valueAfter; - } -};
Deleted: trunk/scintilla/ContractionState.cxx =================================================================== --- trunk/scintilla/ContractionState.cxx 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/ContractionState.cxx 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,251 +0,0 @@ -// Scintilla source code edit control -/** @file ContractionState.cxx - ** Manages visibility of lines for folding and wrapping. - **/ -// Copyright 1998-2007 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#include <string.h> - -#include "Platform.h" - -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "ContractionState.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -ContractionState::ContractionState() : visible(0), expanded(0), heights(0), displayLines(0), linesInDocument(1) { - //InsertLine(0); -} - -ContractionState::~ContractionState() { - Clear(); -} - -void ContractionState::EnsureData() { - if (OneToOne()) { - visible = new RunStyles(); - expanded = new RunStyles(); - heights = new RunStyles(); - displayLines = new Partitioning(4); - InsertLines(0, linesInDocument); - } -} - -void ContractionState::Clear() { - delete visible; - visible = 0; - delete expanded; - expanded = 0; - delete heights; - heights = 0; - delete displayLines; - displayLines = 0; - linesInDocument = 1; -} - -int ContractionState::LinesInDoc() const { - if (OneToOne()) { - return linesInDocument; - } else { - return displayLines->Partitions() - 1; - } -} - -int ContractionState::LinesDisplayed() const { - if (OneToOne()) { - return linesInDocument; - } else { - return displayLines->PositionFromPartition(LinesInDoc()); - } -} - -int ContractionState::DisplayFromDoc(int lineDoc) const { - if (OneToOne()) { - return lineDoc; - } else { - if (lineDoc > displayLines->Partitions()) - lineDoc = displayLines->Partitions(); - return displayLines->PositionFromPartition(lineDoc); - } -} - -int ContractionState::DocFromDisplay(int lineDisplay) const { - if (OneToOne()) { - return lineDisplay; - } else { - if (lineDisplay <= 0) { - return 0; - } - if (lineDisplay > LinesDisplayed()) { - return displayLines->PartitionFromPosition(LinesDisplayed()); - } - int lineDoc = displayLines->PartitionFromPosition(lineDisplay); - PLATFORM_ASSERT(GetVisible(lineDoc)); - return lineDoc; - } -} - -void ContractionState::InsertLine(int lineDoc) { - if (OneToOne()) { - linesInDocument++; - } else { - visible->InsertSpace(lineDoc, 1); - visible->SetValueAt(lineDoc, 1); - expanded->InsertSpace(lineDoc, 1); - expanded->SetValueAt(lineDoc, 1); - heights->InsertSpace(lineDoc, 1); - heights->SetValueAt(lineDoc, 1); - int lineDisplay = DisplayFromDoc(lineDoc); - displayLines->InsertPartition(lineDoc, lineDisplay); - displayLines->InsertText(lineDoc, 1); - } -} - -void ContractionState::InsertLines(int lineDoc, int lineCount) { - for (int l = 0; l < lineCount; l++) { - InsertLine(lineDoc + l); - } - Check(); -} - -void ContractionState::DeleteLine(int lineDoc) { - if (OneToOne()) { - linesInDocument--; - } else { - if (GetVisible(lineDoc)) { - displayLines->InsertText(lineDoc, -heights->ValueAt(lineDoc)); - } - displayLines->RemovePartition(lineDoc); - visible->DeleteRange(lineDoc, 1); - expanded->DeleteRange(lineDoc, 1); - heights->DeleteRange(lineDoc, 1); - } -} - -void ContractionState::DeleteLines(int lineDoc, int lineCount) { - for (int l = 0; l < lineCount; l++) { - DeleteLine(lineDoc); - } - Check(); -} - -bool ContractionState::GetVisible(int lineDoc) const { - if (OneToOne()) { - return true; - } else { - if (lineDoc >= visible->Length()) - return true; - return visible->ValueAt(lineDoc) == 1; - } -} - -bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible_) { - if (OneToOne() && visible_) { - return false; - } else { - EnsureData(); - int delta = 0; - Check(); - if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) { - for (int line = lineDocStart; line <= lineDocEnd; line++) { - if (GetVisible(line) != visible_) { - int difference = visible_ ? heights->ValueAt(line) : -heights->ValueAt(line); - visible->SetValueAt(line, visible_ ? 1 : 0); - displayLines->InsertText(line, difference); - delta += difference; - } - } - } else { - return false; - } - Check(); - return delta != 0; - } -} - -bool ContractionState::GetExpanded(int lineDoc) const { - if (OneToOne()) { - return true; - } else { - Check(); - return expanded->ValueAt(lineDoc) == 1; - } -} - -bool ContractionState::SetExpanded(int lineDoc, bool expanded_) { - if (OneToOne() && expanded_) { - return false; - } else { - EnsureData(); - if (expanded_ != (expanded->ValueAt(lineDoc) == 1)) { - expanded->SetValueAt(lineDoc, expanded_ ? 1 : 0); - Check(); - return true; - } else { - Check(); - return false; - } - } -} - -int ContractionState::GetHeight(int lineDoc) const { - if (OneToOne()) { - return 1; - } else { - return heights->ValueAt(lineDoc); - } -} - -// Set the number of display lines needed for this line. -// Return true if this is a change. -bool ContractionState::SetHeight(int lineDoc, int height) { - if (OneToOne() && (height == 1)) { - return false; - } else { - EnsureData(); - if (GetHeight(lineDoc) != height) { - if (GetVisible(lineDoc)) { - displayLines->InsertText(lineDoc, height - GetHeight(lineDoc)); - } - heights->SetValueAt(lineDoc, height); - Check(); - return true; - } else { - Check(); - return false; - } - } -} - -void ContractionState::ShowAll() { - int lines = LinesInDoc(); - Clear(); - linesInDocument = lines; -} - -// Debugging checks - -void ContractionState::Check() const { -#ifdef CHECK_CORRECTNESS - for (int vline = 0; vline < LinesDisplayed(); vline++) { - const int lineDoc = DocFromDisplay(vline); - PLATFORM_ASSERT(GetVisible(lineDoc)); - } - for (int lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) { - const int displayThis = DisplayFromDoc(lineDoc); - const int displayNext = DisplayFromDoc(lineDoc + 1); - const int height = displayNext - displayThis; - PLATFORM_ASSERT(height >= 0); - if (GetVisible(lineDoc)) { - PLATFORM_ASSERT(GetHeight(lineDoc) == height); - } else { - PLATFORM_ASSERT(0 == height); - } - } -#endif -}
Deleted: trunk/scintilla/ContractionState.h =================================================================== --- trunk/scintilla/ContractionState.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/ContractionState.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,66 +0,0 @@ -// Scintilla source code edit control -/** @file ContractionState.h - ** Manages visibility of lines for folding and wrapping. - **/ -// Copyright 1998-2007 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CONTRACTIONSTATE_H -#define CONTRACTIONSTATE_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - */ -class ContractionState { - // These contain 1 element for every document line. - RunStyles *visible; - RunStyles *expanded; - RunStyles *heights; - Partitioning *displayLines; - int linesInDocument; - - void EnsureData(); - - bool OneToOne() const { - // True when each document line is exactly one display line so need for - // complex data structures. - return visible == 0; - } - -public: - ContractionState(); - virtual ~ContractionState(); - - void Clear(); - - int LinesInDoc() const; - int LinesDisplayed() const; - int DisplayFromDoc(int lineDoc) const; - int DocFromDisplay(int lineDisplay) const; - - void InsertLine(int lineDoc); - void InsertLines(int lineDoc, int lineCount); - void DeleteLine(int lineDoc); - void DeleteLines(int lineDoc, int lineCount); - - bool GetVisible(int lineDoc) const; - bool SetVisible(int lineDocStart, int lineDocEnd, bool visible); - - bool GetExpanded(int lineDoc) const; - bool SetExpanded(int lineDoc, bool expanded); - - int GetHeight(int lineDoc) const; - bool SetHeight(int lineDoc, int height); - - void ShowAll(); - void Check() const; -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif
Deleted: trunk/scintilla/Converter.h =================================================================== --- trunk/scintilla/Converter.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/Converter.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,70 +0,0 @@ -// Scintilla source code edit control -// Converter.h - Encapsulation of iconv -// Copyright 2004 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -typedef GIConv ConverterHandle; -const ConverterHandle iconvhBad = (ConverterHandle)(-1); -// Since various versions of iconv can not agree on whether the src argument -// is char ** or const char ** provide a templatised adaptor. -template<typename T> -size_t iconv_adaptor(size_t(*f_iconv)(ConverterHandle, T, size_t *, char **, size_t *), - ConverterHandle cd, char** src, size_t *srcleft, - char **dst, size_t *dstleft) { - return f_iconv(cd, (T)src, srcleft, dst, dstleft); -} -/** - * Encapsulate iconv safely and avoid iconv_adaptor complexity in client code. - */ -class Converter { - ConverterHandle iconvh; - void OpenHandle(const char *fullDestination, const char *charSetSource) { - iconvh = g_iconv_open(fullDestination, charSetSource); - } - bool Succeeded() const { - return iconvh != iconvhBad; - } -public: - Converter() { - iconvh = iconvhBad; - } - Converter(const char *charSetDestination, const char *charSetSource, bool transliterations) { - iconvh = iconvhBad; - Open(charSetDestination, charSetSource, transliterations); - } - ~Converter() { - Close(); - } - operator bool() const { - return Succeeded(); - } - void Open(const char *charSetDestination, const char *charSetSource, bool transliterations=true) { - Close(); - if (*charSetSource) { - // Try allowing approximate transliterations - if (transliterations) { - char fullDest[200]; - strcpy(fullDest, charSetDestination); - strcat(fullDest, "//TRANSLIT"); - OpenHandle(fullDest, charSetSource); - } - if (!Succeeded()) { - // Transliterations failed so try basic name - OpenHandle(charSetDestination, charSetSource); - } - } - } - void Close() { - if (Succeeded()) { - g_iconv_close(iconvh); - iconvh = iconvhBad; - } - } - size_t Convert(char** src, size_t *srcleft, char **dst, size_t *dstleft) const { - if (!Succeeded()) { - return (size_t)(-1); - } else { - return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft); - } - } -};
Deleted: trunk/scintilla/Decoration.cxx =================================================================== --- trunk/scintilla/Decoration.cxx 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/Decoration.cxx 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,188 +0,0 @@ -/** @file Decoration.cxx - ** Visual elements added over text. - **/ -// Copyright 1998-2007 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdarg.h> - -#include "Platform.h" - -#include "Scintilla.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "Decoration.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -Decoration::Decoration(int indicator_) : next(0), indicator(indicator_) { -} - -Decoration::~Decoration() { -} - -bool Decoration::Empty() { - return rs.starts->Partitions() == 1; -} - -DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(0), - lengthDocument(0), root(0), clickNotified(false) { -} - -DecorationList::~DecorationList() { - Decoration *deco = root; - while (deco) { - Decoration *decoNext = deco->next; - delete deco; - deco = decoNext; - } - root = 0; - current = 0; -} - -Decoration *DecorationList::DecorationFromIndicator(int indicator) { - for (Decoration *deco=root; deco; deco = deco->next) { - if (deco->indicator == indicator) { - return deco; - } - } - return 0; -} - -Decoration *DecorationList::Create(int indicator, int length) { - currentIndicator = indicator; - Decoration *decoNew = new Decoration(indicator); - decoNew->rs.InsertSpace(0, length); - - Decoration *decoPrev = 0; - Decoration *deco = root; - - while (deco && (deco->indicator < indicator)) { - decoPrev = deco; - deco = deco->next; - } - if (decoPrev == 0) { - decoNew->next = root; - root = decoNew; - } else { - decoNew->next = deco; - decoPrev->next = decoNew; - } - return decoNew; -} - -void DecorationList::Delete(int indicator) { - Decoration *decoToDelete = 0; - if (root) { - if (root->indicator == indicator) { - decoToDelete = root; - root = root->next; - } else { - Decoration *deco=root; - while (deco->next && !decoToDelete) { - if (deco->next && deco->next->indicator == indicator) { - decoToDelete = deco->next; - deco->next = decoToDelete->next; - } else { - deco = deco->next; - } - } - } - } - if (decoToDelete) { - delete decoToDelete; - current = 0; - } -} - -void DecorationList::SetCurrentIndicator(int indicator) { - currentIndicator = indicator; - current = DecorationFromIndicator(indicator); - currentValue = 1; -} - -void DecorationList::SetCurrentValue(int value) { - currentValue = value ? value : 1; -} - -bool DecorationList::FillRange(int &position, int value, int &fillLength) { - if (!current) { - current = DecorationFromIndicator(currentIndicator); - if (!current) { - current = Create(currentIndicator, lengthDocument); - } - } - bool changed = current->rs.FillRange(position, value, fillLength); - if (current->Empty()) { - Delete(currentIndicator); - } - return changed; -} - -void DecorationList::InsertSpace(int position, int insertLength) { - lengthDocument += insertLength; - for (Decoration *deco=root; deco; deco = deco->next) { - deco->rs.InsertSpace(position, insertLength); - } -} - -void DecorationList::DeleteRange(int position, int deleteLength) { - lengthDocument -= deleteLength; - Decoration *deco; - for (deco=root; deco; deco = deco->next) { - deco->rs.DeleteRange(position, deleteLength); - } - DeleteAnyEmpty(); -} - -void DecorationList::DeleteAnyEmpty() { - Decoration *deco = root; - while (deco) { - if (deco->Empty()) { - Delete(deco->indicator); - deco = root; - } else { - deco = deco->next; - } - } -} - -int DecorationList::AllOnFor(int position) { - int mask = 0; - for (Decoration *deco=root; deco; deco = deco->next) { - if (deco->rs.ValueAt(position)) { - mask |= 1 << deco->indicator; - } - } - return mask; -} - -int DecorationList::ValueAt(int indicator, int position) { - Decoration *deco = DecorationFromIndicator(indicator); - if (deco) { - return deco->rs.ValueAt(position); - } - return 0; -} - -int DecorationList::Start(int indicator, int position) { - Decoration *deco = DecorationFromIndicator(indicator); - if (deco) { - return deco->rs.StartRun(position); - } - return 0; -} - -int DecorationList::End(int indicator, int position) { - Decoration *deco = DecorationFromIndicator(indicator); - if (deco) { - return deco->rs.EndRun(position); - } - return 0; -}
Deleted: trunk/scintilla/Decoration.h =================================================================== --- trunk/scintilla/Decoration.h 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/Decoration.h 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,64 +0,0 @@ -/** @file Decoration.h - ** Visual elements added over text. - **/ -// Copyright 1998-2007 by Neil Hodgson neilh@scintilla.org -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef DECORATION_H -#define DECORATION_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -class Decoration { -public: - Decoration *next; - RunStyles rs; - int indicator; - - Decoration(int indicator_); - ~Decoration(); - - bool Empty(); -}; - -class DecorationList { - int currentIndicator; - int currentValue; - Decoration *current; - int lengthDocument; - Decoration *DecorationFromIndicator(int indicator); - Decoration *Create(int indicator, int length); - void Delete(int indicator); - void DeleteAnyEmpty(); -public: - Decoration *root; - bool clickNotified; - - DecorationList(); - ~DecorationList(); - - void SetCurrentIndicator(int indicator); - int GetCurrentIndicator() const { return currentIndicator; } - - void SetCurrentValue(int value); - int GetCurrentValue() const { return currentValue; } - - // Returns true if some values may have changed - bool FillRange(int &position, int value, int &fillLength); - - void InsertSpace(int position, int insertLength); - void DeleteRange(int position, int deleteLength); - - int AllOnFor(int position); - int ValueAt(int indicator, int position); - int Start(int indicator, int position); - int End(int indicator, int position); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif
Deleted: trunk/scintilla/Document.cxx =================================================================== --- trunk/scintilla/Document.cxx 2011-01-10 13:58:12 UTC (rev 5520) +++ trunk/scintilla/Document.cxx 2011-01-10 17:21:48 UTC (rev 5521) @@ -1,1920 +0,0 @@ -// Scintilla source code edit control -/** @file Document.cxx - ** Text document that handles notifications, DBCS, styling, words and end of line. - **/ -// Copyright 1998-2003 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 <stdio.h> -#include <ctype.h> - -#include <string> -#include <vector> - -// With Borland C++ 5.5, including <string> includes Windows.h leading to defining -// FindText to FindTextA which makes calls here to Document::FindText fail. -#ifdef __BORLANDC__ -#ifdef FindText -#undef FindText -#endif -#endif - -#include "Platform.h" - -#include "Scintilla.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "CellBuffer.h" -#include "PerLine.h" -#include "CharClassify.h" -#include "Decoration.h" -#include "Document.h" -#include "RESearch.h" -#include "UniConversion.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -// This is ASCII specific but is safe with chars >= 0x80 -static inline bool isspacechar(unsigned char ch) { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - -static inline bool IsPunctuation(char ch) { - return isascii(ch) && ispunct(ch); -} - -static inline bool IsADigit(char ch) { - return isascii(ch) && isdigit(ch); -} - -static inline bool IsLowerCase(char ch) { - return isascii(ch) && islower(ch); -} - -static inline bool IsUpperCase(char ch) { - return isascii(ch) && isupper(ch); -} - -Document::Document() { - refCount = 0; -#ifdef unix - eolMode = SC_EOL_LF; -#else - eolMode = SC_EOL_CRLF; -#endif - dbcsCodePage = 0; - stylingBits = 5; - stylingBitsMask = 0x1F; - stylingMask = 0; - endStyled = 0; - styleClock = 0; - enteredModification = 0; - enteredStyling = 0; - enteredReadOnlyCount = 0; - tabInChars = 8; - indentInChars = 0; - actualIndentInChars = 8; - useTabs = true; - tabIndents = true; - backspaceUnindents = false; - watchers = 0; - lenWatchers = 0; - - matchesValid = false; - regex = 0; - - perLineData[ldMarkers] = new LineMarkers(); - perLineData[ldLevels] = new LineLevels(); - perLineData[ldState] = new LineState(); - perLineData[ldMargin] = new LineAnnotation(); - perLineData[ldAnnotation] = new LineAnnotation(); - - cb.SetPerLine(this); -} - -Document::~Document() { - for (int i = 0; i < lenWatchers; i++) { - watchers[i].watcher->NotifyDeleted(this, watchers[i].userData); - } - delete []watchers; - for (int j=0; j<ldSize; j++) { - delete perLineData[j]; - perLineData[j] = 0; - } - watchers = 0; - lenWatchers = 0; - delete regex; - regex = 0; -} - -void Document::Init() { - for (int j=0; j<ldSize; j++) { - if (perLineData[j]) - perLineData[j]->Init(); - } -} - -void Document::InsertLine(int line) { - for (int j=0; j<ldSize; j++) { - if (perLineData[j]) - perLineData[j]->InsertLine(line); - } -} - -void Document::RemoveLine(int line) { - for (int j=0; j<ldSize; j++) { - if (perLineData[j]) - perLineData[j]->RemoveLine(line); - } -} - -// Increase reference count and return its previous value. -int Document::AddRef() { - return refCount++; -} - -// Decrease reference count and return its previous value. -// Delete the document if reference count reaches zero. -int Document::Release() { - int curRefCount = --refCount; - if (curRefCount == 0) - delete this; - return curRefCount; -} - -void Document::SetSavePoint() { - cb.SetSavePoint(); - NotifySavePoint(true); -} - -int Document::GetMark(int line) { - return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkValue(line); -} - -int Document::AddMark(int line, int markerNum) { - if (line <= LinesTotal()) { - int prev = static_cast<LineMarkers *>(perLineData[ldMarkers])-> - AddMark(line, markerNum, LinesTotal()); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); - NotifyModified(mh); - return prev; - } else { - return 0; - } -} - -void Document::AddMarkSet(int line, int valueSet) { - unsigned int m = valueSet; - for (int i = 0; m; i++, m >>= 1) - if (m & 1) - static_cast<LineMarkers *>(perLineData[ldMarkers])-> - AddMark(line, i, LinesTotal()); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); - NotifyModified(mh); -} - -void Document::DeleteMark(int line, int markerNum) { - static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMark(line, markerNum, false); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); - NotifyModified(mh); -} - -void Document::DeleteMarkFromHandle(int markerHandle) { - static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMarkFromHandle(markerHandle); - DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); - mh.line = -1; - NotifyModified(mh); -} - -void Document::DeleteAllMarks(int markerNum) { - for (int line = 0; line < LinesTotal(); line++) { - static_cast<LineMarkers *>(perLineData[ldMarkers])->DeleteMark(line, markerNum, true); - } - DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); - mh.line = -1; - NotifyModified(mh); -} - -int Document::LineFromHandle(int markerHandle) { - return static_cast<LineMarkers *>(perLineData[ldMarkers])->LineFromHandle(markerHandle); -} - -int Document::LineStart(int line) const { - return cb.LineStart(line); -} - -int Document::LineEnd(int line) const { - 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) const { - return cb.LineFromPosition(pos); -} - -int Document::LineEndPosition(int position) const { - return LineEnd(LineFromPosition(position)); -} - -bool Document::IsLineEndPosition(int position) const { - return LineEnd(LineFromPosition(position)) == position; -} - -int Document::VCHomePosition(int position) const { - int line = LineFromPosition(position); - int startPosition = LineStart(line); - int endLine = LineEnd(line); - int startText = startPosition; - while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t')) - startText++; - if (position == startText) - return startPosition; - else - return startText; -} - -int Document::SetLevel(int line, int level) { - int prev = static_cast<LineLevels *>(perLineData[ldLevels])->SetLevel(line, level, LinesTotal()); - if (prev != level) { - DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER, - LineStart(line), 0, 0, 0, line); - mh.foldLevelNow = level; - mh.foldLevelPrev = prev; - NotifyModified(mh); - } - return prev; -} - -int Document::GetLevel(int line) const { - return static_cast<LineLevels *>(perLineData[ldLevels])->GetLevel(line); -} - -void Document::ClearLevels() { - static_cast<LineLevels *>(perLineData[ldLevels])->ClearLevels(); -} - -static bool IsSubordinate(int levelStart, int levelTry) { - if (levelTry & SC_FOLDLEVELWHITEFLAG) - return true; - else - return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK); -} - -int Document::GetLastChild(int lineParent, int level) { - if (level == -1) - 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; - lineMaxSubord++; - } - if (lineMaxSubord > lineParent) { - if (level > (GetLevel(lineMaxSubord + 1) & SC_FOLDLEVELNUMBERMASK)) { - // Have chewed up some whitespace that belongs to a parent so seek back - if (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG) { - lineMaxSubord--; - } - } - } - return lineMaxSubord; -} - -int Document::GetFoldParent(int line) { - int level = GetLevel(line) & SC_FOLDLEVELNUMBERMASK; - int lineLook = line - 1; - while ((lineLook > 0) && ( - (!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) || - ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level)) - ) { - lineLook--; - } - if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) && - ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) { - return lineLook; - } else { - return -1; - } -} - -int Document::ClampPositionIntoDocument(int pos) { - return Platform::Clamp(pos, 0, Length()); -} - -bool Document::IsCrLf(int pos) { - if (pos < 0) - return false; - if (pos >= (Length() - 1)) - return false; - return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n'); -} - -static const int maxBytesInDBCSCharacter=5; - -int Document::LenChar(int pos) { - if (pos < 0) { - return 1; - } else if (IsCrLf(pos)) { - return 2; - } else if (SC_CP_UTF8 == dbcsCodePage) { - unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos)); - if (ch < 0x80) - return 1; - int len = 2; - if (ch >= (0x80 + 0x40 + 0x20 + 0x10)) - len = 4; - else if (ch >= (0x80 + 0x40 + 0x20)) - len = 3; - int lengthDoc = Length(); - if ((pos + len) > lengthDoc) - return lengthDoc -pos; - else - return len; - } else if (dbcsCodePage) { - char mbstr[maxBytesInDBCSCharacter+1]; - int i; - for (i=0; i<Platform::DBCSCharMaxLength(); i++) { - mbstr[i] = cb.CharAt(pos+i); - } - mbstr[i] = '\0'; - return Platform::DBCSCharLength(dbcsCodePage, mbstr); - } else { - return 1; - } -} - -static bool IsTrailByte(int ch) { - return (ch >= 0x80) && (ch < (0x80 + 0x40)); -} - -static int BytesFromLead(int leadByte) { - if (leadByte > 0xF4) { - // Characters longer than 4 bytes not possible in current UTF-8 - return 0; - } else if (leadByte >= 0xF0) { - return 4; - } else if (leadByte >= 0xE0) { - return 3; - } else if (leadByte >= 0xC2) { - return 2; - } - return 0; -} - -bool Document::InGoodUTF8(int pos, int &start, int &end) { - int lead = pos; - while ((lead>0) && (pos-lead < 4) && IsTrailByte(static_cast<unsigned char>(cb.CharAt(lead-1)))) - lead--; - start = 0; - if (lead > 0) { - start = lead-1; - } - int leadByte = static_cast<unsigned char>(cb.CharAt(start)); - int bytes = BytesFromLead(leadByte); - if (bytes == 0) { - return false; - } else { - int trailBytes = bytes - 1; - int len = pos - lead + 1; - if (len > trailBytes) - // pos too far from lead - return false; - // Check that there are enough trails for this lead - int trail = pos + 1; - while ((trail-lead<trailBytes) && (trail < Length())) { - if (!IsTrailByte(static_cast<unsigned char>(cb.CharAt(trail)))) { - return false; - } - trail++; - } - end = start + bytes; - return true; - } -} - -// Normalise a position so that it is not halfway through a two byte character. -// This can occur in two situations - -// When lines are terminated with \r\n pairs which should be treated as one character. -// When displaying DBCS text such as Japanese. -// If moving, move the position in the indicated direction. -int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) { - //Platform::DebugPrintf("NoCRLF %d %d\n", pos, moveDir); - // If out of range, just return minimum/maximum value. - if (pos <= 0) - return 0; - if (pos >= Length()) - return Length(); - - // PLATFORM_ASSERT(pos > 0 && pos < Length()); - if (checkLineEnd && IsCrLf(pos - 1)) { - if (moveDir > 0) - return pos + 1; - else - return pos - 1; - } - - // Not between CR and LF - - if (dbcsCodePage) { - if (SC_CP_UTF8 == dbcsCodePage) { - unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos)); - int startUTF = pos; - int endUTF = pos; - if (IsTrailByte(ch) && InGoodUTF8(pos, startUTF, endUTF)) { - // ch is a trail byte within a UTF-8 character - if (moveDir > 0) - pos = endUTF; - else - pos = startUTF; - } - } else { - // Anchor DBCS calculations at start of line because start of line can - // not be a DBCS trail byte. - int posCheck = LineStart(LineFromPosition(pos)); - while (posCheck < pos) { - char mbstr[maxBytesInDBCSCharacter+1]; - int i; - for (i=0; i<Platform::DBCSCharMaxLength(); i++) { - mbstr[i] = cb.CharAt(posCheck+i); - } - mbstr[i] = '\0'; - - int mbsize = Platform::DBCSCharLength(dbcsCodePage, mbstr); - if (posCheck + mbsize == pos) { - return pos; - } else if (posCheck + mbsize > pos) { - if (moveDir > 0) { - return posCheck + mbsize; - } else { - return posCheck; - } - } - posCheck += mbsize; - } - } - } - - return pos; -} - -void Document::ModifiedAt(int pos) { - if (endStyled > pos) - endStyled = pos; -} - -void Document::CheckReadOnly() { - if (cb.IsReadOnly() && enteredReadOnlyCount == 0) { - enteredReadOnlyCount++; - NotifyModifyAttempt(); - enteredReadOnlyCount--; - } -} - -// Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt. -// SetStyleAt does not change the persistent state of a document - -bool Document::DeleteChars(int pos, int len) { - if (len == 0) - return false; - if ((pos + len) > Length()) - return false; - CheckReadOnly(); - if (enteredModification != 0) { - return false; - } else { - enteredModification++; - if (!cb.IsReadOnly()) { - NotifyModified( - DocModification( - SC_MOD_BEFOREDELETE | SC_PERFORMED_USER, - pos, len, - 0, 0)); - int prevLinesTotal = LinesTotal(); - bool startSavePoint = cb.IsSavePoint(); - bool startSequence = false; - const char *text = cb.DeleteChars(pos, len, startSequence); - if (startSavePoint && cb.IsCollectingUndo()) - NotifySavePoint(!startSavePoint); - if ((pos < Length()) || (pos == 0)) - ModifiedAt(pos); - else - ModifiedAt(pos-1); - NotifyModified( - DocModification( - SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0), - pos, len, - LinesTotal() - prevLinesTotal, text)); - } - enteredModification--; - } - return !cb.IsReadOnly(); -} - -/** - * Insert a string with a length. - */ -bool Document::InsertString(int position, const char *s, int insertLength) { - if (insertLength <= 0) { - return false; - } - CheckReadOnly(); - if (enteredModification != 0) { - return false; - } else { - enteredModification++; - if (!cb.IsReadOnly()) { - NotifyModified( - DocModification( - SC_MOD_BEFOREINSERT | SC_PERFORMED_USER, - position, insertLength, - 0, s)); - int prevLinesTotal = LinesTotal(); - bool startSavePoint = cb.IsSavePoint(); - bool startSequence = false; - const char *text = cb.InsertString(position, s, insertLength, startSequence); - if (startSavePoint && cb.IsCollectingUndo()) - NotifySavePoint(!startSavePoint); - ModifiedAt(position); - NotifyModified( - DocModification( - SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0), - position, insertLength, - LinesTotal() - prevLinesTotal, text)); - } - enteredModification--; - } - return !cb.IsReadOnly(); -} - -int Document::Undo() { - int newPos = -1; - CheckReadOnly(); - if (enteredModification == 0) { - enteredModification++; - if (!cb.IsReadOnly()) { - bool startSavePoint = cb.IsSavePoint(); - bool multiLine = false; - int steps = cb.StartUndo(); - //Platform::DebugPrintf("Steps=%d\n", steps); - for (int step = 0; step < steps; step++) { - const int prevLinesTotal = LinesTotal(); - const Action &action = cb.GetUndoStep(); - if (action.at == removeAction) { - NotifyModified(DocModification( - SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action)); - } else if (action.at == containerAction) { - DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_UNDO); - dm.token = action.position; - NotifyModified(dm); - } else { - NotifyModified(DocModification( - SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); - } - cb.PerformUndoStep(); - int cellPosition = action.position; - if (action.at != containerAction) { - ModifiedAt(cellPosition); - newPos = cellPosition; - } - - int modFlags = SC_PERFORMED_UNDO; - // With undo, an insertion action becomes a deletion notification - if (action.at == removeAction) { - newPos += action.lenData; - modFlags |= SC_MOD_INSERTTEXT; - } else if (action.at == insertAction) { - modFlags |= SC_MOD_DELETETEXT; - } - if (steps > 1) - modFlags |= SC_MULTISTEPUNDOREDO; - const int linesAdded = LinesTotal() - prevLinesTotal; - if (linesAdded != 0) - multiLine = true; - if (step == steps - 1) { - modFlags |= SC_LASTSTEPINUNDOREDO; - if (multiLine) - modFlags |= SC_MULTILINEUNDOREDO; - } - NotifyModified(DocModification(modFlags, cellPosition, action.lenData, - linesAdded, action.data)); - } - - bool endSavePoint = cb.IsSavePoint(); - if (startSavePoint != endSavePoint) - NotifySavePoint(endSavePoint); - } - enteredModification--; - } - return newPos; -} - -int Document::Redo() { - int newPos = -1; - CheckReadOnly(); - if (enteredModification == 0) { - enteredModification++; - if (!cb.IsReadOnly()) { - bool startSavePoint = cb.IsSavePoint(); - bool multiLine = false; - int steps = cb.StartRedo(); - for (int step = 0; step < steps; step++) { - const int prevLinesTotal = LinesTotal(); - const Action &action = cb.GetRedoStep(); - if (action.at == insertAction) { - NotifyModified(DocModification( - SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); - } else if (action.at == containerAction) { - DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_REDO); - dm.token = action.position; - NotifyModified(dm); - } else { - NotifyModified(DocModification( - SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); - } - cb.PerformRedoStep(); - if (action.at != containerAction) { - ModifiedAt(action.position); - newPos = action.position; - } - - int modFlags = SC_PERFORMED_REDO; - if (action.at == insertAction) { - newPos += action.lenData; - modFlags |= SC_MOD_INSERTTEXT; - } else if (action.at == removeAction) { - modFlags |= SC_MOD_DELETETEXT; - } - if (steps > 1) - modFlags |= SC_MULTISTEPUNDOREDO; - const int linesAdded = LinesTotal() - prevLinesTotal; - if (linesAdded != 0) - multiLine = true; - if (step == steps - 1) { - modFlags |= SC_LASTSTEPINUNDOREDO; - if (multiLine) - modFlags |= SC_MULTILINEUNDOREDO; - } - NotifyModified( - DocModification(modFlags, action.position, action.lenData, - linesAdded, action.data)); - } - - bool endSavePoint = cb.IsSavePoint(); - if (startSavePoint != endSavePoint) - NotifySavePoint(endSavePoint); - } - enteredModification--; - } - return newPos; -} - -/** - * Insert a single character. - */ -bool Document::InsertChar(int pos, char ch) { - char chs[1]; - chs[0] = ch; - return InsertString(pos, chs, 1); -} - -/** - * Insert a null terminated string. - */ -bool Document::InsertCString(int position, const char *s) { - return InsertString(position, s, strlen(s)); -} - -void Document::ChangeChar(int pos, char ch) { - DeleteChars(pos, 1); - InsertChar(pos, ch); -} - -void Document::DelChar(int pos) { - DeleteChars(pos, LenChar(pos)); -} - -void Document::DelCharBack(int pos) { - if (pos <= 0) { - return; - } else if (IsCrLf(pos - 2)) { - DeleteChars(pos - 2, 2); - } else if (dbcsCodePage) { - int startChar = MovePositionOutsideChar(pos - 1, -1, false); - DeleteChars(startChar, pos - startChar); - } else { - DeleteChars(pos - 1, 1); - } -} - -static bool isindentchar(char ch) { - return (ch == ' ') || (ch == '\t'); -} - -static int NextTab(int pos, int tabSize) { - return ((pos / tabSize) + 1) * tabSize; -} - -static void CreateIndentation(char *linebuf, int length, int indent, int tabSize, bool insertSpaces) { - length--; // ensure space for \0 - if (!insertSpaces) { - while ((indent >= tabSize) && (length > 0)) { - *linebuf++ = '\t'; - indent -= tabSize; - length--; - } - } - while ((indent > 0) && (length > 0)) { - *linebuf++ = ' '; - indent--; - length--; - } - *linebuf = '\0'; -} - -int Document::GetLineIndentation(int line) { - int indent = 0; - if ((line >= 0) && (line < LinesTotal())) { - int lineStart = LineStart(line); - int length = Length(); - for (int i = lineStart; i < length; i++) { - char ch = cb.CharAt(i); - if (ch == ' ') - indent++; - else if (ch == '\t') - indent = NextTab(indent, tabInChars); - else - return indent; - } - } - return indent; -} - -void Document::SetLineIndentation(int line, int indent) { - int indentOfLine = GetLineIndentation(line); - if (indent < 0) - indent = 0; - if (indent != indentOfLine) { - char linebuf[1000]; - CreateIndentation(linebuf, sizeof(linebuf), indent, tabInChars, !useTabs); - int thisLineStart = LineStart(line); - int indentPos = GetLineIndentPosition(line); - UndoGroup ug(this); - DeleteChars(thisLineStart, indentPos - thisLineStart); - InsertCString(thisLineStart, linebuf); - } -} - -int Document::GetLineIndentPosition(int line) const { - if (line < 0) - return 0; - int pos = LineStart(line); - int length = Length(); - while ((pos < length) && isindentchar(cb.CharAt(pos))) { - pos++; - } - return pos; -} - -int Document::GetColumn(int pos) { - int column = 0; - int line = LineFromPosition(pos); - if ((line >= 0) && (line < LinesTotal())) { - for (int i = LineStart(line); i < pos;) { - char ch = cb.CharAt(i); - if (ch == '\t') { - column = NextTab(column, tabInChars); - i++; - } else if (ch == '\r') { - return column; - } else if (ch == '\n') { - return column; - } else if (i >= Length()) { - return column; - } else { - column++; - i = MovePositionOutsideChar(i + 1, 1, false); - } - } - } - return column; -} - -int Document::FindColumn(int line, int column) { - int position = LineStart(line); - if ((line >= 0) && (line < LinesTotal())) { - int columnCurrent = 0; - while ((columnCurrent < column) && (position < Length())) { - char ch = cb.CharAt(position); - if (ch == '\t') { - columnCurrent = NextTab(columnCurrent, tabInChars); - position++; - } else if (ch == '\r') { - return position; - } else if (ch == '\n') { - return position; - } else { - columnCurrent++; - position = MovePositionOutsideChar(position + 1, 1, false); - } - } - } - return position; -} - -void Document::Indent(bool forwards, int lineBottom, int lineTop) { - // Dedent - suck white space off the front of the line to dedent by equivalent of a tab - for (int line = lineBottom; line >= lineTop; line--) { - int indentOfLine = GetLineIndentation(line); - if (forwards) { - if (LineStart(line) < LineEnd(line)) { - SetLineIndentation(line, indentOfLine + IndentSize()); - } - } else { - SetLineIndentation(line, indentOfLine - IndentSize()); - } - } -} - -// Convert line endings for a piece of text to a particular mode. -// Stop at len or when a NUL is found. -// Caller must delete the returned pointer. -char *Document::TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolMode) { - char *dest = new char[2 * len + 1]; - const char *sptr = s; - char *dptr = dest; - for (size_t i = 0; (i < len) && (*sptr != '\0'); i++) { - if (*sptr == '\n' || *sptr == '\r') { - if (eolMode == SC_EOL_CR) { - *dptr++ = '\r'; - } else if (eolMode == SC_EOL_LF) { - *dptr++ = '\n'; - } else { // eolMode == SC_EOL_CRLF - *dptr++ = '\r'; - *dptr++ = '\n'; - } - if ((*sptr == '\r') && (i+1 < len) && (*(sptr+1) == '\n')) { - i++; - sptr++; - } - sptr++; - } else { - *dptr++ = *sptr++; - } - } - *dptr++ = '\0'; - *pLenOut = (dptr - dest) - 1; - return dest; -} - -void Document::ConvertLineEnds(int eolModeSet) { - UndoGroup ug(this); - - for (int pos = 0; pos < Length(); pos++) { - if (cb.CharAt(pos) == '\r') { - if (cb.CharAt(pos + 1) == '\n') { - // CRLF - if (eolModeSet == SC_EOL_CR) { - DeleteChars(pos + 1, 1); // Delete the LF - } else if (eolModeSet == SC_EOL_LF) { - DeleteChars(pos, 1); // Delete the CR - } else { - pos++; - } - } else { - // CR - if (eolModeSet == SC_EOL_CRLF) { - InsertString(pos + 1, "\n", 1); // Insert LF - pos++; - } else if (eolModeSet == SC_EOL_LF) { - InsertString(pos, "\n", 1); // Insert LF - DeleteChars(pos + 1, 1); // Delete CR - } - } - } else if (cb.CharAt(pos) == '\n') { - // LF - if (eolModeSet == SC_EOL_CRLF) { - InsertString(pos, "\r", 1); // Insert CR - pos++; - } else if (eolModeSet == SC_EOL_CR) { - InsertString(pos, "\r", 1); // Insert CR - DeleteChars(pos + 1, 1); // Delete LF - } - } - } - -} - -bool Document::IsWhiteLine(int line) const { - int currentChar = LineStart(line); - int endLine = LineEnd(line); - while (currentChar < endLine) { - if (cb.CharAt(currentChar) != ' ' && cb.CharAt(currentChar) != '\t') { - return false; - } - ++currentChar; - } - return true; -} - -int Document::ParaUp(int pos) { - int line = LineFromPosition(pos); - line--; - while (line >= 0 && IsWhiteLine(line)) { // skip empty lines - line--; - } - while (line >= 0 && !IsWhiteLine(line)) { // skip non-empty lines - line--; - } - line++; - return LineStart(line); -} - -int Document::ParaDown(int pos) { - int line = LineFromPosition(pos); - while (line < LinesTotal() && !IsWhiteLine(line)) { // skip non-empty lines - line++; - } - while (line < LinesTotal() && IsWhiteLine(line)) { // skip empty lines - line++; - } - if (line < LinesTotal()) - return LineStart(line); - else // end of a document - return LineEnd(line-1); -} - -CharClassify::cc Document::WordCharClass(unsigned char ch) { - if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80)) - return CharClassify::ccWord; - return charClass.GetClass(ch); -} - -/** - * Used by commmands that want to select whole words. - * Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0. - */ -int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) { - CharClassify::cc ccStart = CharClassify::ccWord; - if (delta < 0) { - if (!onlyWordCharacters) - ccStart = WordCharClass(cb.CharAt(pos-1)); - while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) - pos--; - } else { - if (!onlyWordCharacters && pos < Length()) - ccStart = WordCharClass(cb.CharAt(pos)); - while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart)) - pos++; - } - return MovePositionOutsideChar(pos, delta, true); -} - -/** - * Find the start of the next word in either a forward (delta >= 0) or backwards direction - * (delta < 0). - * This is looking for a transition between character classes although there is also some - * additional movement to transit white space. - * Used by cursor movement by word commands. - */ -int Document::NextWordStart(int pos, int delta) { - if (delta < 0) { - while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == CharClassify::ccSpace)) - pos--; - if (pos > 0) { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos-1)); - while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) { - pos--; - } - } - } else { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos)); - while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart)) - pos++; - while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == CharClassify::ccSpace)) - pos++; - } - return pos; -} - -/** - * Find the end of the next word in either a forward (delta >= 0) or backwards direction - * (delta < 0). - * This is looking for a transition between character classes although there is also some - * additional movement to transit white space. - * Used by cursor movement by word commands. - */ -int Document::NextWordEnd(int pos, int delta) { - if (delta < 0) { - if (pos > 0) { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos-1)); - if (ccStart != CharClassify::ccSpace) { - while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccStart) { - pos--; - } - } - while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == CharClassify::ccSpace) { - pos--; - } - } - } else { - while (pos < Length() && WordCharClass(cb.CharAt(pos)) == CharClassify::ccSpace) { - pos++; - } - if (pos < Length()) { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos)); - while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccStart) { - pos++; - } - } - } - return pos; -} - -/** - * Check that the character at the given position is a word or punctuation character and that - * the previous character is of a different character class. - */ -bool Document::IsWordStartAt(int pos) { - if (pos > 0) { - CharClassify::cc ccPos = WordCharClass(CharAt(pos)); - return (ccPos == CharClassify::ccWord || ccPos == CharClassify::ccPunctuation) && - (ccPos != WordCharClass(CharAt(pos - 1))); - } - return true; -} - -/** - * Check that the character at the given position is a word or punctuation character and that - * the next character is of a different character class. - */ -bool Document::IsWordEndAt(int pos) { - if (pos < Length()) { - CharClassify::cc ccPrev = WordCharClass(CharAt(pos-1)); - return (ccPrev == CharClassify::ccWord || ccPrev == CharClassify::ccPunctuation) && - (ccPrev != WordCharClass(CharAt(pos))); - } - return true; -} - -/** - * Check that the given range is has transitions between character classes at both - * ends and where the characters on the inside are word or punctuation characters. - */ -bool Document::IsWordAt(int start, int end) { - return IsWordStartAt(start) && IsWordEndAt(end); -} - -static inline char MakeLowerCase(char ch) { - if (ch < 'A' || ch > 'Z') - return ch; - else - return static_cast<char>(ch - 'A' + 'a'); -} - -static bool GoodTrailByte(int v) { - return (v >= 0x80) && (v < 0xc0); -} - -size_t Document::ExtractChar(int pos, char *bytes) { - unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos)); - size_t widthChar = UTF8CharLength(ch); - bytes[0] = ch; - for (size_t i=1; i<widthChar; i++) { - bytes[i] = cb.CharAt(pos+i); - if (!GoodTrailByte(static_cast<unsigned char>(bytes[i]))) { // Bad byte - widthChar = 1; - } - } - return widthChar; -} - -CaseFolderTable::CaseFolderTable() { - for (size_t iChar=0; iChar<sizeof(mapping); iChar++) { - mapping[iChar] = static_cast<char>(iChar); - } -} - -CaseFolderTable::~CaseFolderTable() { -} - -size_t CaseFolderTable::Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { - if (lenMixed > sizeFolded) { - return 0; - } else { - for (size_t i=0; i<lenMixed; i++) { - folded[i] = mapping[static_cast<unsigned char>(mixed[i])]; - } - return lenMixed; - } -} - -void CaseFolderTable::SetTranslation(char ch, char chTranslation) { - mapping[static_cast<unsigned char>(ch)] = chTranslation; -} - -void CaseFolderTable::StandardASCII() { - for (size_t iChar=0; iChar<sizeof(mapping); iChar++) { - if (iChar >= 'A' && iChar <= 'Z') { - mapping[iChar] = static_cast<char>(iChar - 'A' + 'a'); - } else { - mapping[iChar] = static_cast<char>(iChar); - } - } -} - -bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length) { - return (!word && !wordStart) || - (word && IsWordAt(pos, pos + length)) || - (wordStart && IsWordStartAt(pos)); -} - -/** - * Find text in document, supporting both forward and backward - * searches (just pass minPos > maxPos to do a backward search) - * Has not been tested with backwards DBCS searches yet. - */ -long Document::FindText(int minPos, int maxPos, const char *search, - bool caseSensitive, bool word, bool wordStart, bool regExp, int flags,
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.