Update Scintilla to version 3.3.3

This commit is contained in:
Colomban Wendling 2013-06-06 16:31:26 +02:00
parent 6b406d04dc
commit 8498957cf1
33 changed files with 283 additions and 250 deletions

3
NEWS
View File

@ -6,6 +6,9 @@ Geany 1.24 (unreleased)
Interface
* Fix custom GTK styles under KDE (#3607935).
Editor
* Update Scintilla to version 3.3.3.
Filetypes
* Extend list of recognized keywords for SQL

View File

@ -1881,7 +1881,7 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) {
Clear();
int count = strlen(listText) + 1;
std::vector<char> words(listText, listText+count);
char *startword = words.data();
char *startword = &words[0];
char *numword = NULL;
int i = 0;
for (; words[i]; i++) {
@ -1890,10 +1890,10 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) {
if (numword)
*numword = '\0';
Append(startword, numword?atoi(numword + 1):-1);
startword = words.data() + i + 1;
startword = &words[0] + i + 1;
numword = NULL;
} else if (words[i] == typesep) {
numword = words.data() + i;
numword = &words[0] + i;
}
}
if (startword) {

View File

@ -14,6 +14,7 @@
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@ -172,7 +173,7 @@ private:
virtual bool DragThreshold(Point ptStart, Point ptNow);
virtual void StartDrag();
int TargetAsUTF8(char *text);
int EncodedFromUTF8(char *utf8, char *encoded);
int EncodedFromUTF8(char *utf8, char *encoded) const;
virtual bool ValidCodePage(int codePage) const;
public: // Public for scintilla_send_message
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
@ -839,7 +840,7 @@ void ScintillaGTK::StartDrag() {
reinterpret_cast<GdkEvent *>(evbtn));
}
static std::string ConvertText(char *s, size_t len, const char *charSetDest,
static std::string ConvertText(const char *s, size_t len, const char *charSetDest,
const char *charSetSource, bool transliterations, bool silent=false) {
// s is not const because of different versions of iconv disagreeing about const
std::string destForm;
@ -847,7 +848,8 @@ static std::string ConvertText(char *s, size_t len, const char *charSetDest,
if (conv) {
size_t outLeft = len*3+1;
destForm = std::string(outLeft, '\0');
char *pin = s;
// g_iconv does not actually write to its input argument so safe to cast away const
char *pin = const_cast<char *>(s);
size_t inLeft = len;
char *putf = &destForm[0];
char *pout = putf;
@ -856,10 +858,10 @@ static std::string ConvertText(char *s, size_t len, const char *charSetDest,
if (!silent) {
if (len == 1)
fprintf(stderr, "iconv %s->%s failed for %0x '%s'\n",
charSetSource, charSetDest, (unsigned char)(*s), static_cast<char *>(s));
charSetSource, charSetDest, (unsigned char)(*s), s);
else
fprintf(stderr, "iconv %s->%s failed for %s\n",
charSetSource, charSetDest, static_cast<char *>(s));
charSetSource, charSetDest, s);
}
destForm = std::string();
} else {
@ -900,7 +902,7 @@ int ScintillaGTK::TargetAsUTF8(char *text) {
// Translates a nul terminated UTF8 string into the document encoding.
// Return the length of the result in bytes.
int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) {
int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) const {
int inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8);
if (IsUnicodeMode()) {
if (encoded) {
@ -1264,7 +1266,7 @@ public:
folded[0] = mapping[static_cast<unsigned char>(mixed[0])];
return 1;
} else if (*charSet) {
std::string sUTF8 = ConvertText(const_cast<char *>(mixed), lenMixed,
std::string sUTF8 = ConvertText(mixed, lenMixed,
"UTF-8", charSet, false);
if (!sUTF8.empty()) {
gchar *mapped = g_utf8_casefold(sUTF8.c_str(), sUTF8.length());
@ -1354,7 +1356,7 @@ std::string ScintillaGTK::CaseMapString(const std::string &s, int caseMapping) {
return std::string(mapper.mapped, strlen(mapper.mapped));
} else {
// Change text to UTF-8
std::string sUTF8 = ConvertText(const_cast<char *>(s.c_str()), s.length(),
std::string sUTF8 = ConvertText(s.c_str(), s.length(),
"UTF-8", charSetBuffer, false);
CaseMapper mapper(sUTF8, caseMapping == cmUpper);
return ConvertText(mapper.mapped, strlen(mapper.mapped), charSetBuffer, "UTF-8", false);
@ -1448,14 +1450,14 @@ void ScintillaGTK::ClaimSelection() {
primarySelection = true;
gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)),
GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
primary.Free();
primary.Clear();
} else if (OwnPrimarySelection()) {
primarySelection = true;
if (primary.s == NULL)
if (primary.Empty())
gtk_selection_owner_set(NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
} else {
primarySelection = false;
primary.Free();
primary.Clear();
}
}
@ -1479,7 +1481,7 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio
// Return empty string if selection is not a string
if ((selectionTypeData != GDK_TARGET_STRING) && (selectionTypeData != atomUTF8)) {
selText.Copy("", 0, SC_CP_UTF8, 0, false, false);
selText.Clear();
return;
}
@ -1498,20 +1500,21 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio
if (IsUnicodeMode()) {
// Unknown encoding so assume in Latin1
dest = UTF8FromLatin1(dest.c_str(), dest.length());
selText.Copy(dest.c_str(), dest.length()+1, SC_CP_UTF8, 0, selText.rectangular, false);
selText.Copy(dest, SC_CP_UTF8, 0, isRectangular, false);
} else {
// Assume buffer is in same encoding as selection
selText.Copy(dest.c_str(), dest.length()+1, pdoc->dbcsCodePage,
selText.Copy(dest, pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, isRectangular, false);
}
} else { // UTF-8
selText.Copy(dest.c_str(), dest.length()+1, SC_CP_UTF8, 0, isRectangular, false);
const char *charSetBuffer = CharacterSetID();
if (!IsUnicodeMode() && *charSetBuffer) {
// Convert to locale
dest = ConvertText(selText.s, selText.len, charSetBuffer, "UTF-8", true);
selText.Copy(dest.c_str(), dest.length(), pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular, false);
dest = ConvertText(dest.c_str(), dest.length(), charSetBuffer, "UTF-8", true);
selText.Copy(dest, pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, isRectangular, false);
} else {
selText.Copy(dest, SC_CP_UTF8, 0, isRectangular, false);
}
}
}
@ -1538,9 +1541,9 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) {
sel.Range(sel.Main()).Start();
if (selText.rectangular) {
PasteRectangular(selStart, selText.s, selText.len-1);
PasteRectangular(selStart, selText.Data(), selText.Length());
} else {
InsertPaste(selStart, selText.s, selText.len-1);
InsertPaste(selStart, selText.Data(), selText.Length());
}
EnsureCaretVisible();
}
@ -1559,12 +1562,12 @@ void ScintillaGTK::ReceivedDrop(GtkSelectionData *selection_data) {
const char *data = reinterpret_cast<const char *>(DataOfGSD(selection_data));
std::vector<char> drop(data, data + LengthOfGSD(selection_data));
drop.push_back('\0');
NotifyURIDropped(drop.data());
NotifyURIDropped(&drop[0]);
} else if ((TypeOfGSD(selection_data) == GDK_TARGET_STRING) || (TypeOfGSD(selection_data) == atomUTF8)) {
if (TypeOfGSD(selection_data) > 0) {
SelectionText selText;
GetGtkSelectionText(selection_data, selText);
DropAt(posDrop, selText.s, false, selText.rectangular);
DropAt(posDrop, selText.Data(), selText.Length(), false, selText.rectangular);
}
} else if (LengthOfGSD(selection_data) > 0) {
//~ fprintf(stderr, "ReceivedDrop other %p\n", static_cast<void *>(selection_data->type));
@ -1581,9 +1584,9 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
// from code below
SelectionText *newline_normalized = NULL;
{
std::string tmpstr = Document::TransformLineEnds(text->s, text->len, SC_EOL_LF);
std::string tmpstr = Document::TransformLineEnds(text->Data(), text->Length(), SC_EOL_LF);
newline_normalized = new SelectionText();
newline_normalized->Copy(tmpstr.c_str(), tmpstr.length()+1, SC_CP_UTF8, 0, text->rectangular, false);
newline_normalized->Copy(tmpstr, SC_CP_UTF8, 0, text->rectangular, false);
text = newline_normalized;
}
#endif
@ -1593,9 +1596,9 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
if ((text->codePage != SC_CP_UTF8) && (info == TARGET_UTF8_STRING)) {
const char *charSet = ::CharacterSetID(text->characterSet);
if (*charSet) {
std::string tmputf = ConvertText(text->s, text->len, "UTF-8", charSet, false);
std::string tmputf = ConvertText(text->Data(), text->Length(), "UTF-8", charSet, false);
converted = new SelectionText();
converted->Copy(tmputf.c_str(), tmputf.length(), SC_CP_UTF8, 0, text->rectangular, false);
converted->Copy(tmputf, SC_CP_UTF8, 0, text->rectangular, false);
text = converted;
}
}
@ -1607,8 +1610,8 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
// All other tested aplications behave benignly by ignoring the \0.
// The #if is here because on Windows cfColumnSelect clip entry is used
// instead as standard indicator of rectangularness (so no need to kludge)
const char *textData = text->s ? text->s : "";
int len = strlen(textData);
const char *textData = text->Data();
int len = text->Length();
#if PLAT_GTK_WIN32 == 0
if (text->rectangular)
len++;
@ -1655,7 +1658,7 @@ void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) {
if (selection_event->selection == GDK_SELECTION_PRIMARY) {
//Platform::DebugPrintf("UnclaimPrimarySelection\n");
if (!OwnPrimarySelection()) {
primary.Free();
primary.Clear();
primarySelection = false;
FullPaint();
}
@ -1796,7 +1799,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) {
} else if (event->button == 2) {
// Grab the primary selection if it exists
SelectionPosition pos = SPositionFromLocation(pt, false, false, UserVirtualSpace());
if (OwnPrimarySelection() && primary.s == NULL)
if (OwnPrimarySelection() && primary.Empty())
CopySelectionRange(&primary);
sel.Clear();
@ -2542,7 +2545,7 @@ void ScintillaGTK::SelectionGet(GtkWidget *widget,
try {
//Platform::DebugPrintf("Selection get\n");
if (SelectionOfGSD(selection_data) == GDK_SELECTION_PRIMARY) {
if (sciThis->primary.s == NULL) {
if (sciThis->primary.Empty()) {
sciThis->CopySelectionRange(&sciThis->primary);
}
sciThis->GetSelection(selection_data, info, &sciThis->primary);
@ -2939,7 +2942,10 @@ static void scintilla_init(ScintillaObject *sci) {
}
GtkWidget* scintilla_new() {
return GTK_WIDGET(g_object_new(scintilla_get_type(), NULL));
GtkWidget *widget = GTK_WIDGET(g_object_new(scintilla_get_type(), NULL));
gtk_widget_set_direction(widget, GTK_TEXT_DIR_LTR);
return widget;
}
void scintilla_set_id(ScintillaObject *sci, uptr_t id) {

View File

@ -119,19 +119,19 @@ public:
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
bool operator==(PRectangle &rc) {
bool operator==(PRectangle &rc) const {
return (rc.left == left) && (rc.right == right) &&
(rc.top == top) && (rc.bottom == bottom);
}
bool Contains(Point pt) {
bool Contains(Point pt) const {
return (pt.x >= left) && (pt.x <= right) &&
(pt.y >= top) && (pt.y <= bottom);
}
bool Contains(PRectangle rc) {
bool Contains(PRectangle rc) const {
return (rc.left >= left) && (rc.right <= right) &&
(rc.top >= top) && (rc.bottom <= bottom);
}
bool Intersects(PRectangle other) {
bool Intersects(PRectangle other) const {
return (right > other.left) && (left < other.right) &&
(bottom > other.top) && (top < other.bottom);
}
@ -141,9 +141,9 @@ public:
right += xDelta;
bottom += yDelta;
}
XYPOSITION Width() { return right - left; }
XYPOSITION Height() { return bottom - top; }
bool Empty() {
XYPOSITION Width() const { return right - left; }
XYPOSITION Height() const { return bottom - top; }
bool Empty() const {
return (Height() <= 0) || (Width() <= 0);
}
};
@ -199,15 +199,15 @@ public:
return co;
}
unsigned int GetRed() {
unsigned int GetRed() const {
return co & 0xff;
}
unsigned int GetGreen() {
unsigned int GetGreen() const {
return (co >> 8) & 0xff;
}
unsigned int GetBlue() {
unsigned int GetBlue() const {
return (co >> 16) & 0xff;
}
};

View File

@ -121,6 +121,7 @@
#define SCLEX_OSCRIPT 106
#define SCLEX_VISUALPROLOG 107
#define SCLEX_LITERATEHASKELL 108
#define SCLEX_STTXT 109
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
@ -1627,6 +1628,25 @@
#define SCE_VISUALPROLOG_STRING_VERBATIM 20
#define SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL 21
#define SCE_VISUALPROLOG_STRING_VERBATIM_EOL 22
#define SCE_STTXT_DEFAULT 0
#define SCE_STTXT_COMMENT 1
#define SCE_STTXT_COMMENTLINE 2
#define SCE_STTXT_KEYWORD 3
#define SCE_STTXT_TYPE 4
#define SCE_STTXT_FUNCTION 5
#define SCE_STTXT_FB 6
#define SCE_STTXT_NUMBER 7
#define SCE_STTXT_HEXNUMBER 8
#define SCE_STTXT_PRAGMA 9
#define SCE_STTXT_OPERATOR 10
#define SCE_STTXT_CHARACTER 11
#define SCE_STTXT_STRING1 12
#define SCE_STTXT_STRING2 13
#define SCE_STTXT_STRINGEOL 14
#define SCE_STTXT_IDENTIFIER 15
#define SCE_STTXT_DATETIME 16
#define SCE_STTXT_VARS 17
#define SCE_STTXT_PRAGMAS 18
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif

View File

@ -2579,6 +2579,7 @@ val SCLEX_ECL=105
val SCLEX_OSCRIPT=106
val SCLEX_VISUALPROLOG=107
val SCLEX_LITERATEHASKELL=108
val SCLEX_STTXT=109
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
@ -4283,6 +4284,27 @@ val SCE_VISUALPROLOG_STRING_EOL_OPEN=19
val SCE_VISUALPROLOG_STRING_VERBATIM=20
val SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL=21
val SCE_VISUALPROLOG_STRING_VERBATIM_EOL=22
# Lexical states for SCLEX_STTXT
lex StructuredText=SCLEX_STTXT SCE_STTXT_
val SCE_STTXT_DEFAULT=0
val SCE_STTXT_COMMENT=1
val SCE_STTXT_COMMENTLINE=2
val SCE_STTXT_KEYWORD=3
val SCE_STTXT_TYPE=4
val SCE_STTXT_FUNCTION=5
val SCE_STTXT_FB=6
val SCE_STTXT_NUMBER=7
val SCE_STTXT_HEXNUMBER=8
val SCE_STTXT_PRAGMA=9
val SCE_STTXT_OPERATOR=10
val SCE_STTXT_CHARACTER=11
val SCE_STTXT_STRING1=12
val SCE_STTXT_STRING2=13
val SCE_STTXT_STRINGEOL=14
val SCE_STTXT_IDENTIFIER=15
val SCE_STTXT_DATETIME=16
val SCE_STTXT_VARS=17
val SCE_STTXT_PRAGMAS=18
# Events

View File

@ -153,7 +153,7 @@ public:
bool IsInactive() const {
return state != 0;
}
bool CurrentIfTaken() {
bool CurrentIfTaken() const {
return (ifTaken & maskLevel()) != 0;
}
void StartSection(bool on) {
@ -188,7 +188,7 @@ public:
class PPStates {
std::vector<LinePPState> vlls;
public:
LinePPState ForLine(int line) {
LinePPState ForLine(int line) const {
if ((line > 0) && (vlls.size() > static_cast<size_t>(line))) {
return vlls[line];
} else {

View File

@ -28,7 +28,7 @@ using namespace Scintilla;
Accessor::Accessor(IDocument *pAccess_, PropSetSimple *pprops_) : LexAccessor(pAccess_), pprops(pprops_) {
}
int Accessor::GetPropertyInt(const char *key, int defaultValue) {
int Accessor::GetPropertyInt(const char *key, int defaultValue) const {
return pprops->GetInt(key, defaultValue);
}

View File

@ -24,7 +24,7 @@ class Accessor : public LexAccessor {
public:
PropSetSimple *pprops;
Accessor(IDocument *pAccess_, PropSetSimple *pprops_);
int GetPropertyInt(const char *, int defaultValue=0);
int GetPropertyInt(const char *, int defaultValue=0) const;
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
};

View File

@ -90,7 +90,7 @@ public:
}
return buf[position - startPos];
}
bool IsLeadByte(char ch) {
bool IsLeadByte(char ch) const {
return pAccess->IsDBCSLeadByte(ch);
}
EncodingType Encoding() const {
@ -104,13 +104,13 @@ public:
}
return true;
}
char StyleAt(int position) {
char StyleAt(int position) const {
return static_cast<char>(pAccess->StyleAt(position) & mask);
}
int GetLine(int position) {
int GetLine(int position) const {
return pAccess->LineFromPosition(position);
}
int LineStart(int line) {
int LineStart(int line) const {
return pAccess->LineStart(line);
}
int LineEnd(int line) {
@ -126,7 +126,7 @@ public:
return startNext - 1;
}
}
int LevelAt(int line) {
int LevelAt(int line) const {
return pAccess->GetLevel(line);
}
int Length() const {
@ -140,7 +140,7 @@ public:
validLen = 0;
}
}
int GetLineState(int line) {
int GetLineState(int line) const {
return pAccess->GetLineState(line);
}
int SetLineState(int line, int state) {

View File

@ -40,7 +40,7 @@ class OptionSet {
Option(plcos ps_, std::string description_) :
opType(SC_TYPE_STRING), ps(ps_), description(description_) {
}
bool Set(T *base, const char *val) {
bool Set(T *base, const char *val) const {
switch (opType) {
case SC_TYPE_BOOLEAN: {
bool option = atoi(val) != 0;
@ -94,7 +94,7 @@ public:
nameToDef[name] = Option(ps, description);
AppendName(name);
}
const char *PropertyNames() {
const char *PropertyNames() const {
return names.c_str();
}
int PropertyType(const char *name) {
@ -130,7 +130,7 @@ public:
}
}
const char *DescribeWordListSets() {
const char *DescribeWordListSets() const {
return wordLists.c_str();
}
};

View File

@ -188,7 +188,7 @@ public:
styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
state = state_;
}
int LengthCurrent() {
int LengthCurrent() const {
return currentPos - styler.GetStartSegment();
}
int GetRelative(int n) {

View File

@ -28,10 +28,10 @@ diff -Naur scintilla_orig/gtk/scintilla-marshal.c scintilla/gtk/scintilla-marsha
{
typedef void (*GMarshalFunc_VOID__INT_POINTER) (gpointer data1,
diff --git b/scintilla/src/Catalogue.cxx a/scintilla/src/Catalogue.cxx
index 2f75247..a34f834 100644
index 84d003e..37b2a3c 100644
+++ scintilla/src/Catalogue.cxx
--- scintilla/src/Catalogue.cxx
@@ -81,109 +81,45 @@ int Scintilla_LinkLexers() {
@@ -81,110 +81,45 @@ int Scintilla_LinkLexers() {
//++Autogenerated -- run src/LexGen.py to regenerate
//**\(\tLINK_LEXER(\*);\n\)
@ -127,6 +127,7 @@ index 2f75247..a34f834 100644
- LINK_LEXER(lmSpecman);
- LINK_LEXER(lmSpice);
LINK_LEXER(lmSQL);
- LINK_LEXER(lmSTTXT);
- LINK_LEXER(lmTACL);
- LINK_LEXER(lmTADS3);
- LINK_LEXER(lmTAL);

View File

@ -69,7 +69,7 @@ bool CallTip::IsTabCharacter(char ch) const {
return (tabSize > 0) && (ch == '\t');
}
int CallTip::NextTabPos(int x) {
int CallTip::NextTabPos(int x) const {
if (tabSize > 0) { // paranoia... not called unless this is true
x -= insetX; // position relative to text
x = (x + tabSize) / tabSize; // tab "number"

View File

@ -35,7 +35,7 @@ class CallTip {
bool highlight, bool draw);
int PaintContents(Surface *surfaceWindow, bool draw);
bool IsTabCharacter(char c) const;
int NextTabPos(int x);
int NextTabPos(int x) const;
public:
Window wCallTip;

View File

@ -496,7 +496,7 @@ void CellBuffer::SetSavePoint() {
uh.SetSavePoint();
}
bool CellBuffer::IsSavePoint() {
bool CellBuffer::IsSavePoint() const {
return uh.IsSavePoint();
}
@ -728,7 +728,7 @@ void CellBuffer::DeleteUndoHistory() {
uh.DeleteUndoHistory();
}
bool CellBuffer::CanUndo() {
bool CellBuffer::CanUndo() const {
return uh.CanUndo();
}
@ -750,7 +750,7 @@ void CellBuffer::PerformUndoStep() {
uh.CompletedUndoStep();
}
bool CellBuffer::CanRedo() {
bool CellBuffer::CanRedo() const {
return uh.CanRedo();
}

View File

@ -191,7 +191,7 @@ public:
/// 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();
bool IsSavePoint() const;
bool SetUndoCollection(bool collectUndo);
bool IsCollectingUndo() const;
@ -202,11 +202,11 @@ public:
/// 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();
bool CanUndo() const;
int StartUndo();
const Action &GetUndoStep() const;
void PerformUndoStep();
bool CanRedo();
bool CanRedo() const;
int StartRedo();
const Action &GetRedoStep() const;
void PerformRedoStep();

View File

@ -29,7 +29,7 @@ Decoration::Decoration(int indicator_) : next(0), indicator(indicator_) {
Decoration::~Decoration() {
}
bool Decoration::Empty() {
bool Decoration::Empty() const {
return (rs.Runs() == 1) && (rs.AllSameAs(0));
}
@ -159,7 +159,7 @@ void DecorationList::DeleteAnyEmpty() {
}
}
int DecorationList::AllOnFor(int position) {
int DecorationList::AllOnFor(int position) const {
int mask = 0;
for (Decoration *deco=root; deco; deco = deco->next) {
if (deco->rs.ValueAt(position)) {

View File

@ -20,7 +20,7 @@ public:
Decoration(int indicator_);
~Decoration();
bool Empty();
bool Empty() const;
};
class DecorationList {
@ -51,7 +51,7 @@ public:
void InsertSpace(int position, int insertLength);
void DeleteRange(int position, int deleteLength);
int AllOnFor(int position);
int AllOnFor(int position) const;
int ValueAt(int indicator, int position);
int Start(int indicator, int position);
int End(int indicator, int position);

View File

@ -392,7 +392,7 @@ int Document::GetLastChild(int lineParent, int level, int lastLine) {
return lineMaxSubord;
}
int Document::GetFoldParent(int line) {
int Document::GetFoldParent(int line) const {
int level = GetLevel(line) & SC_FOLDLEVELNUMBERMASK;
int lineLook = line - 1;
while ((lineLook > 0) && (
@ -479,11 +479,11 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in
highlightDelimiter.firstChangeableLineAfter = firstChangeableLineAfter;
}
int Document::ClampPositionIntoDocument(int pos) {
int Document::ClampPositionIntoDocument(int pos) const {
return Platform::Clamp(pos, 0, Length());
}
bool Document::IsCrLf(int pos) {
bool Document::IsCrLf(int pos) const {
if (pos < 0)
return false;
if (pos >= (Length() - 1))
@ -688,7 +688,7 @@ int Document::NextPosition(int pos, int moveDir) const {
return pos;
}
bool Document::NextCharacter(int &pos, int moveDir) {
bool Document::NextCharacter(int &pos, int moveDir) const {
// Returns true if pos changed
int posNext = NextPosition(pos, moveDir);
if (posNext == pos) {
@ -746,7 +746,7 @@ static inline bool IsSpaceOrTab(int ch) {
// 2) Break before punctuation
// 3) Break after whole character
int Document::SafeSegment(const char *text, int length, int lengthSegment) {
int Document::SafeSegment(const char *text, int length, int lengthSegment) const {
if (length <= lengthSegment)
return length;
int lastSpaceBreak = -1;
@ -1275,7 +1275,7 @@ bool Document::IsWhiteLine(int line) const {
return true;
}
int Document::ParaUp(int pos) {
int Document::ParaUp(int pos) const {
int line = LineFromPosition(pos);
line--;
while (line >= 0 && IsWhiteLine(line)) { // skip empty lines
@ -1288,7 +1288,7 @@ int Document::ParaUp(int pos) {
return LineStart(line);
}
int Document::ParaDown(int pos) {
int Document::ParaDown(int pos) const {
int line = LineFromPosition(pos);
while (line < LinesTotal() && !IsWhiteLine(line)) { // skip non-empty lines
line++;
@ -1302,7 +1302,7 @@ int Document::ParaDown(int pos) {
return LineEnd(line-1);
}
CharClassify::cc Document::WordCharClass(unsigned char ch) {
CharClassify::cc Document::WordCharClass(unsigned char ch) const {
if ((SC_CP_UTF8 == dbcsCodePage) && (!UTF8IsAscii(ch)))
return CharClassify::ccWord;
return charClass.GetClass(ch);
@ -1393,7 +1393,7 @@ int Document::NextWordEnd(int pos, int delta) {
* Check that the character at the given position is a word or punctuation character and that
* the previous character is of a different character class.
*/
bool Document::IsWordStartAt(int pos) {
bool Document::IsWordStartAt(int pos) const {
if (pos > 0) {
CharClassify::cc ccPos = WordCharClass(CharAt(pos));
return (ccPos == CharClassify::ccWord || ccPos == CharClassify::ccPunctuation) &&
@ -1406,7 +1406,7 @@ bool Document::IsWordStartAt(int pos) {
* 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) {
bool Document::IsWordEndAt(int pos) const {
if (pos < Length()) {
CharClassify::cc ccPrev = WordCharClass(CharAt(pos-1));
return (ccPrev == CharClassify::ccWord || ccPrev == CharClassify::ccPunctuation) &&
@ -1419,7 +1419,7 @@ bool Document::IsWordEndAt(int pos) {
* 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) {
bool Document::IsWordAt(int start, int end) const {
return IsWordStartAt(start) && IsWordEndAt(end);
}
@ -1464,7 +1464,7 @@ void CaseFolderTable::StandardASCII() {
}
}
bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length) {
bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length) const {
return (!word && !wordStart) ||
(word && IsWordAt(pos, pos + length)) ||
(wordStart && IsWordStartAt(pos));
@ -1765,7 +1765,7 @@ void SCI_METHOD Document::ChangeLexerState(int start, int end) {
NotifyModified(mh);
}
StyledText Document::MarginStyledText(int line) {
StyledText Document::MarginStyledText(int line) const {
LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldMargin]);
return StyledText(pla->Length(line), pla->Text(line),
pla->MultipleStyles(line), pla->Style(line), pla->Styles(line));
@ -1795,7 +1795,7 @@ void Document::MarginClearAll() {
static_cast<LineAnnotation *>(perLineData[ldMargin])->ClearAll();
}
StyledText Document::AnnotationStyledText(int line) {
StyledText Document::AnnotationStyledText(int line) const {
LineAnnotation *pla = static_cast<LineAnnotation *>(perLineData[ldAnnotation]);
return StyledText(pla->Length(line), pla->Text(line),
pla->MultipleStyles(line), pla->Style(line), pla->Styles(line));
@ -1891,7 +1891,7 @@ void Document::NotifyModified(DocModification mh) {
}
}
bool Document::IsWordPartSeparator(char ch) {
bool Document::IsWordPartSeparator(char ch) const {
return (WordCharClass(ch) == CharClassify::ccWord) && IsPunctuation(ch);
}

View File

@ -128,23 +128,23 @@ public:
firstChangeableLineAfter = -1;
}
bool NeedsDrawing(int line) {
bool NeedsDrawing(int line) const {
return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter);
}
bool IsFoldBlockHighlighted(int line) {
bool IsFoldBlockHighlighted(int line) const {
return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock;
}
bool IsHeadOfFoldBlock(int line) {
bool IsHeadOfFoldBlock(int line) const {
return beginFoldBlock == line && line < endFoldBlock;
}
bool IsBodyOfFoldBlock(int line) {
bool IsBodyOfFoldBlock(int line) const {
return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock;
}
bool IsTailOfFoldBlock(int line) {
bool IsTailOfFoldBlock(int line) const {
return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock;
}
@ -204,7 +204,7 @@ public:
WatcherWithUserData(DocWatcher *watcher_=0, void *userData_=0) :
watcher(watcher_), userData(userData_) {
}
bool operator==(const WatcherWithUserData &other) {
bool operator==(const WatcherWithUserData &other) const {
return (watcher == other.watcher) && (userData == other.userData);
}
};
@ -259,9 +259,9 @@ public:
virtual void Init();
int LineEndTypesSupported() const;
bool SetDBCSCodePage(int dbcsCodePage_);
int GetLineEndTypesAllowed() { return cb.GetLineEndTypes(); }
int GetLineEndTypesAllowed() const { return cb.GetLineEndTypes(); }
bool SetLineEndTypesAllowed(int lineEndBitSet_);
int GetLineEndTypesActive() { return cb.GetLineEndTypes(); }
int GetLineEndTypesActive() const { return cb.GetLineEndTypes(); }
virtual void InsertLine(int line);
virtual void RemoveLine(int line);
@ -272,16 +272,16 @@ public:
void SCI_METHOD SetErrorStatus(int status);
int SCI_METHOD LineFromPosition(int pos) const;
int ClampPositionIntoDocument(int pos);
bool IsCrLf(int pos);
int ClampPositionIntoDocument(int pos) const;
bool IsCrLf(int pos) const;
int LenChar(int pos);
bool InGoodUTF8(int pos, int &start, int &end) const;
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
int NextPosition(int pos, int moveDir) const;
bool NextCharacter(int &pos, int moveDir); // Returns true if pos changed
bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed
int SCI_METHOD CodePage() const;
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
int SafeSegment(const char *text, int length, int lengthSegment);
int SafeSegment(const char *text, int length, int lengthSegment) const;
// Gateways to modifying document
void ModifiedAt(int pos);
@ -292,18 +292,18 @@ public:
void * SCI_METHOD ConvertToDocument();
int Undo();
int Redo();
bool CanUndo() { return cb.CanUndo(); }
bool CanRedo() { return cb.CanRedo(); }
bool CanUndo() const { return cb.CanUndo(); }
bool CanRedo() const { return cb.CanRedo(); }
void DeleteUndoHistory() { cb.DeleteUndoHistory(); }
bool SetUndoCollection(bool collectUndo) {
return cb.SetUndoCollection(collectUndo);
}
bool IsCollectingUndo() { return cb.IsCollectingUndo(); }
bool IsCollectingUndo() const { return cb.IsCollectingUndo(); }
void BeginUndoAction() { cb.BeginUndoAction(); }
void EndUndoAction() { cb.EndUndoAction(); }
void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
void SetSavePoint();
bool IsSavePoint() { return cb.IsSavePoint(); }
bool IsSavePoint() const { return cb.IsSavePoint(); }
const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); }
const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); }
int GapPosition() const { return cb.GapPosition(); }
@ -318,14 +318,14 @@ public:
static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
bool IsReadOnly() { return cb.IsReadOnly(); }
bool IsReadOnly() const { return cb.IsReadOnly(); }
bool InsertChar(int pos, char ch);
bool InsertCString(int position, const char *s);
void DelChar(int pos);
void DelCharBack(int pos);
char CharAt(int position) { return cb.CharAt(position); }
char CharAt(int position) const { return cb.CharAt(position); }
void SCI_METHOD GetCharRange(char *buffer, int position, int lengthRetrieve) const {
cb.GetCharRange(buffer, position, lengthRetrieve);
}
@ -352,7 +352,7 @@ public:
int SCI_METHOD GetLevel(int line) const;
void ClearLevels();
int GetLastChild(int lineParent, int level=-1, int lastLine=-1);
int GetFoldParent(int line);
int GetFoldParent(int line) const;
void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int lastLine);
void Indent(bool forwards);
@ -361,7 +361,7 @@ public:
int NextWordEnd(int pos, int delta);
int SCI_METHOD Length() const { return cb.Length(); }
void Allocate(int newSize) { cb.Allocate(newSize); }
bool MatchesWordOptions(bool word, bool wordStart, int pos, int length);
bool MatchesWordOptions(bool word, bool wordStart, int pos, int length) const;
bool HasCaseFolder(void) const;
void SetCaseFolder(CaseFolder *pcf_);
long FindText(int minPos, int maxPos, const char *search, bool caseSensitive, bool word,
@ -376,10 +376,10 @@ public:
void SCI_METHOD StartStyling(int position, char mask);
bool SCI_METHOD SetStyleFor(int length, char style);
bool SCI_METHOD SetStyles(int length, const char *styles);
int GetEndStyled() { return endStyled; }
int GetEndStyled() const { return endStyled; }
void EnsureStyledTo(int pos);
void LexerChanged();
int GetStyleClock() { return styleClock; }
int GetStyleClock() const { return styleClock; }
void IncrementStyleClock();
void SCI_METHOD DecorationSetCurrentIndicator(int indicator) {
decorations.SetCurrentIndicator(indicator);
@ -391,13 +391,13 @@ public:
int GetMaxLineState();
void SCI_METHOD ChangeLexerState(int start, int end);
StyledText MarginStyledText(int line);
StyledText MarginStyledText(int line) const;
void MarginSetStyle(int line, int style);
void MarginSetStyles(int line, const unsigned char *styles);
void MarginSetText(int line, const char *text);
void MarginClearAll();
StyledText AnnotationStyledText(int line);
StyledText AnnotationStyledText(int line) const;
void AnnotationSetText(int line, const char *text);
void AnnotationSetStyle(int line, int style);
void AnnotationSetStyles(int line, const unsigned char *styles);
@ -407,21 +407,21 @@ public:
bool AddWatcher(DocWatcher *watcher, void *userData);
bool RemoveWatcher(DocWatcher *watcher, void *userData);
CharClassify::cc WordCharClass(unsigned char ch);
bool IsWordPartSeparator(char ch);
CharClassify::cc WordCharClass(unsigned char ch) const;
bool IsWordPartSeparator(char ch) const;
int WordPartLeft(int pos);
int WordPartRight(int pos);
int ExtendStyleRange(int pos, int delta, bool singleLine = false);
bool IsWhiteLine(int line) const;
int ParaUp(int pos);
int ParaDown(int pos);
int IndentSize() { return actualIndentInChars; }
int ParaUp(int pos) const;
int ParaDown(int pos) const;
int IndentSize() const { return actualIndentInChars; }
int BraceMatch(int position, int maxReStyle);
private:
bool IsWordStartAt(int pos);
bool IsWordEndAt(int pos);
bool IsWordAt(int start, int end);
bool IsWordStartAt(int pos) const;
bool IsWordEndAt(int pos) const;
bool IsWordAt(int start, int end) const;
void NotifyModifyAttempt();
void NotifySavePoint(bool atSavePoint);

View File

@ -333,7 +333,7 @@ Point Editor::DocumentPointFromView(Point ptView) {
return ptDocument;
}
int Editor::TopLineOfMain() {
int Editor::TopLineOfMain() const {
if (wMargin.GetID())
return 0;
else
@ -489,7 +489,7 @@ int Editor::XFromPosition(SelectionPosition sp) {
return pt.x - vs.textStart + xOffset;
}
int Editor::LineFromLocation(Point pt) {
int Editor::LineFromLocation(Point pt) const {
return cs.DocFromDisplay(pt.y / vs.lineHeight + topLine);
}
@ -722,11 +722,11 @@ void Editor::InvalidateRange(int start, int end) {
RedrawRect(RectangleFromRange(start, end));
}
int Editor::CurrentPosition() {
int Editor::CurrentPosition() const {
return sel.MainCaret();
}
bool Editor::SelectionEmpty() {
bool Editor::SelectionEmpty() const {
return sel.Empty();
}
@ -1137,7 +1137,7 @@ void Editor::MoveSelectedLines(int lineDelta) {
pdoc->InsertCString(pdoc->Length(), eol);
GoToLine(currentLine + lineDelta);
pdoc->InsertCString(CurrentPosition(), selectedText.s);
pdoc->InsertCString(CurrentPosition(), selectedText.Data());
if (appendEol) {
pdoc->InsertCString(CurrentPosition() + selectionLength, eol);
selectionLength += istrlen(eol);
@ -1740,7 +1740,7 @@ void Editor::LinesSplit(int pixelWidth) {
}
}
int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) {
int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const {
if (vs.markers[markerCheck].markType == SC_MARK_EMPTY)
return markerDefault;
return markerCheck;
@ -2426,14 +2426,14 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
}
}
ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) {
ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) const {
return main ?
(primarySelection ? vsDraw.selbackground : vsDraw.selbackground2) :
vsDraw.selAdditionalBackground;
}
ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const {
if (inSelection == 1) {
if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
return SelectionBackground(vsDraw, true);
@ -5767,13 +5767,13 @@ int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
}
void Editor::Indent(bool forwards) {
UndoGroup ug(pdoc);
for (size_t r=0; r<sel.Count(); r++) {
int lineOfAnchor = pdoc->LineFromPosition(sel.Range(r).anchor.Position());
int caretPosition = sel.Range(r).caret.Position();
int lineCurrentPos = pdoc->LineFromPosition(caretPosition);
if (lineOfAnchor == lineCurrentPos) {
if (forwards) {
UndoGroup ug(pdoc);
pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
caretPosition = sel.Range(r).caret.Position();
if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
@ -5800,7 +5800,6 @@ void Editor::Indent(bool forwards) {
} else {
if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) &&
pdoc->tabIndents) {
UndoGroup ug(pdoc);
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
int indentationStep = pdoc->IndentSize();
pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
@ -5824,10 +5823,7 @@ void Editor::Indent(bool forwards) {
int lineBottomSel = Platform::Maximum(lineOfAnchor, lineCurrentPos);
if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition)
lineBottomSel--; // If not selecting any characters on a line, do not indent
{
UndoGroup ug(pdoc);
pdoc->Indent(forwards, lineBottomSel, lineTopSel);
}
if (lineOfAnchor < lineCurrentPos) {
if (currentPosPosOnLine == 0)
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor));
@ -6019,45 +6015,28 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
std::string text = RangeText(start, end);
if (pdoc->eolMode != SC_EOL_LF)
text.append("\r");
text.push_back('\r');
if (pdoc->eolMode != SC_EOL_CR)
text.append("\n");
ss->Copy(text.c_str(), static_cast<int>(text.length() + 1),
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true);
text.push_back('\n');
ss->Copy(text, pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, false, true);
}
} else {
int delimiterLength = 0;
if (sel.selType == Selection::selRectangle) {
if (pdoc->eolMode == SC_EOL_CRLF) {
delimiterLength = 2;
} else {
delimiterLength = 1;
}
}
size_t size = sel.Length() + delimiterLength * sel.Count();
std::string text(size+1, '\0');
int j = 0;
std::string text;
std::vector<SelectionRange> rangesInOrder = sel.RangesCopy();
if (sel.selType == Selection::selRectangle)
std::sort(rangesInOrder.begin(), rangesInOrder.end());
for (size_t r=0; r<rangesInOrder.size(); r++) {
SelectionRange current = rangesInOrder[r];
for (int i = current.Start().Position();
i < current.End().Position();
i++) {
text[j++] = pdoc->CharAt(i);
}
text.append(RangeText(current.Start().Position(), current.End().Position()));
if (sel.selType == Selection::selRectangle) {
if (pdoc->eolMode != SC_EOL_LF) {
text[j++] = '\r';
}
if (pdoc->eolMode != SC_EOL_CR) {
text[j++] = '\n';
if (pdoc->eolMode != SC_EOL_LF)
text.push_back('\r');
if (pdoc->eolMode != SC_EOL_CR)
text.push_back('\n');
}
}
}
text[size] = '\0';
ss->Copy(&text[0], static_cast<int>(size + 1), pdoc->dbcsCodePage,
ss->Copy(text, pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::selLines);
}
}
@ -6067,14 +6046,14 @@ void Editor::CopyRangeToClipboard(int start, int end) {
end = pdoc->ClampPositionIntoDocument(end);
SelectionText selectedText;
std::string text = RangeText(start, end);
selectedText.Copy(text.c_str(), end - start + 1,
selectedText.Copy(text,
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
CopyToClipboard(selectedText);
}
void Editor::CopyText(int length, const char *text) {
SelectionText selectedText;
selectedText.Copy(text, length + 1,
selectedText.Copy(std::string(text, length),
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
CopyToClipboard(selectedText);
}
@ -6113,7 +6092,7 @@ void Editor::StartDrag() {
//DisplayCursor(Window::cursorArrow);
}
void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) {
void Editor::DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular) {
//Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position);
if (inDragDrop == ddDragging)
dropWentOutside = false;
@ -6154,15 +6133,15 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving,
position = positionAfterDeletion;
if (rectangular) {
PasteRectangular(position, value, istrlen(value));
PasteRectangular(position, value, static_cast<int>(lengthValue));
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetEmptySelection(position);
} else {
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace()));
if (pdoc->InsertCString(position.Position(), value)) {
if (pdoc->InsertString(position.Position(), value, static_cast<int>(lengthValue))) {
SelectionPosition posAfterInsertion = position;
posAfterInsertion.Add(istrlen(value));
posAfterInsertion.Add(static_cast<int>(lengthValue));
SetSelection(posAfterInsertion, position);
}
}
@ -6171,6 +6150,10 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving,
}
}
void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) {
DropAt(position, value, strlen(value), moving, rectangular);
}
/**
* @return true if given position is inside the selection,
*/
@ -6221,7 +6204,7 @@ bool Editor::PointInSelMargin(Point pt) {
}
}
Window::Cursor Editor::GetMarginCursor(Point pt) {
Window::Cursor Editor::GetMarginCursor(Point pt) const {
int x = 0;
for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width))
@ -6487,7 +6470,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
ShowCaretAtCurrentPosition();
}
bool Editor::PositionIsHotspot(int position) {
bool Editor::PositionIsHotspot(int position) const {
return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot;
}
@ -6531,7 +6514,7 @@ void Editor::SetHotSpotRange(Point *pt) {
}
}
void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) {
void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) const {
hsStart_ = hsStart;
hsEnd_ = hsEnd;
}
@ -6676,26 +6659,26 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
SelectionPosition selStart = SelectionStart();
SelectionPosition selEnd = SelectionEnd();
if (selStart < selEnd) {
if (drag.len) {
if (drag.Length()) {
if (ctrl) {
if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) {
SetSelection(newPos.Position(), newPos.Position() + drag.len);
if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
}
} else if (newPos < selStart) {
pdoc->DeleteChars(selStart.Position(), drag.len);
if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) {
SetSelection(newPos.Position(), newPos.Position() + drag.len);
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
}
} else if (newPos > selEnd) {
pdoc->DeleteChars(selStart.Position(), drag.len);
newPos.Add(-drag.len);
if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) {
SetSelection(newPos.Position(), newPos.Position() + drag.len);
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
newPos.Add(-static_cast<int>(drag.Length()));
if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
}
} else {
SetEmptySelection(newPos.Position());
}
drag.Free();
drag.Clear();
}
selectionType = selChar;
}
@ -6791,7 +6774,7 @@ void Editor::SetFocusState(bool focusState) {
}
}
int Editor::PositionAfterArea(PRectangle rcArea) {
int Editor::PositionAfterArea(PRectangle rcArea) const {
// The start of the document line after the display line after the area
// This often means that the line after a modification is restyled which helps
// detect multiline comment additions and heals single line comments
@ -7050,7 +7033,7 @@ void Editor::FoldExpand(int line, int action, int level) {
Redraw();
}
int Editor::ContractedFoldNext(int lineStart) {
int Editor::ContractedFoldNext(int lineStart) const {
for (int line = lineStart; line<pdoc->LinesTotal();) {
if (!cs.GetExpanded(line) && (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG))
return line;
@ -7533,13 +7516,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
SelectionText selectedText;
CopySelectionRange(&selectedText);
if (lParam == 0) {
return selectedText.len ? selectedText.len : 1;
return selectedText.LengthWithTerminator();
} else {
char *ptr = CharPtrFromSPtr(lParam);
int iChar = 0;
if (selectedText.len) {
for (; iChar < selectedText.len; iChar++)
ptr[iChar] = selectedText.s[iChar];
unsigned int iChar = 0;
if (selectedText.Length()) {
for (; iChar < selectedText.LengthWithTerminator(); iChar++)
ptr[iChar] = selectedText.Data()[iChar];
} else {
ptr[0] = '\0';
}

View File

@ -75,38 +75,27 @@ public:
};
/**
* Hold a piece of text selected for copying or dragging.
* The text is expected to hold a terminating '\0' and this is counted in len.
* Hold a piece of text selected for copying or dragging, along with encoding and selection format information.
*/
class SelectionText {
std::string s;
public:
char *s;
int len;
bool rectangular;
bool lineCopy;
int codePage;
int characterSet;
SelectionText() : s(0), len(0), rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
SelectionText() : rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
~SelectionText() {
Free();
}
void Free() {
delete []s;
s = 0;
len = 0;
void Clear() {
s.clear();
rectangular = false;
lineCopy = false;
codePage = 0;
characterSet = 0;
}
void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
delete []s;
s = 0;
s = new char[len_];
len = len_;
for (int i = 0; i < len_; i++) {
s[i] = s_[i];
}
void Copy(const std::string &s_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
s = s_;
codePage = codePage_;
characterSet = characterSet_;
rectangular = rectangular_;
@ -114,18 +103,25 @@ public:
FixSelectionForClipboard();
}
void Copy(const SelectionText &other) {
Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular, other.lineCopy);
Copy(other.s, other.codePage, other.characterSet, other.rectangular, other.lineCopy);
}
const char *Data() const {
return s.c_str();
}
size_t Length() const {
return s.length();
}
size_t LengthWithTerminator() const {
return s.length() + 1;
}
bool Empty() const {
return s.empty();
}
private:
void FixSelectionForClipboard() {
// Replace null characters by spaces.
// To avoid that the content of the clipboard is truncated in the paste operation
// when the clipboard contains null characters.
for (int i = 0; i < len - 1; ++i) {
if (s[i] == '\0')
s[i] = ' ';
}
// To avoid truncating the contents of the clipboard when pasted where the
// clipboard contains NUL characters, replace NUL characters by spaces.
std::replace(s.begin(), s.end(), '\0', ' ');
}
};
@ -308,7 +304,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
// scroll views where it will be equivalent to the current scroll position.
virtual Point GetVisibleOriginInMain();
Point DocumentPointFromView(Point ptView); // Convert a point from view space to document
int TopLineOfMain(); // Return the line at Main's y coordinate 0
int TopLineOfMain() const; // Return the line at Main's y coordinate 0
virtual PRectangle GetClientRectangle();
PRectangle GetTextRectangle();
@ -324,7 +320,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
int PositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false);
SelectionPosition SPositionFromLineX(int lineDoc, int x);
int PositionFromLineX(int line, int x);
int LineFromLocation(Point pt);
int LineFromLocation(Point pt) const;
void SetTopLine(int topLineNew);
bool AbandonPaint();
@ -337,8 +333,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool UserVirtualSpace() const {
return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
}
int CurrentPosition();
bool SelectionEmpty();
int CurrentPosition() const;
bool SelectionEmpty() const;
SelectionPosition SelectionStart();
SelectionPosition SelectionEnd();
void SetRectangularRange();
@ -399,13 +395,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
void LinesJoin();
void LinesSplit(int pixelWidth);
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const;
void PaintSelMargin(Surface *surface, PRectangle &rc);
LineLayout *RetrieveLineLayout(int lineNumber);
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
int width=LineLayout::wrapWidthInfinite);
ColourDesired SelectionBackground(ViewStyle &vsDraw, bool main);
ColourDesired TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
ColourDesired SelectionBackground(ViewStyle &vsDraw, bool main) const;
ColourDesired TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const;
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
@ -524,12 +520,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void DisplayCursor(Window::Cursor c);
virtual bool DragThreshold(Point ptStart, Point ptNow);
virtual void StartDrag();
void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular);
void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular);
/** PositionInSelection returns true if position in selection. */
bool PositionInSelection(int pos);
bool PointInSelection(Point pt);
bool PointInSelMargin(Point pt);
Window::Cursor GetMarginCursor(Point pt);
Window::Cursor GetMarginCursor(Point pt) const;
void TrimAndSetSelection(int currentPos_, int anchor_);
void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine);
void WordSelection(int pos);
@ -547,7 +544,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual bool HaveMouseCapture() = 0;
void SetFocusState(bool focusState);
int PositionAfterArea(PRectangle rcArea);
int PositionAfterArea(PRectangle rcArea) const;
void StyleToPositionInView(Position pos);
virtual void IdleWork();
virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo=0);
@ -566,7 +563,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void SetFoldExpanded(int lineDoc, bool expanded);
void FoldLine(int line, int action);
void FoldExpand(int line, int action, int level);
int ContractedFoldNext(int lineStart);
int ContractedFoldNext(int lineStart) const;
void EnsureLineVisible(int lineDoc, bool enforcePolicy);
void FoldChanged(int line, int levelNow, int levelPrev);
void NeedShown(int pos, int len);
@ -575,10 +572,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
int GetTag(char *tagValue, int tagNumber);
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
bool PositionIsHotspot(int position);
bool PositionIsHotspot(int position) const;
bool PointIsHotspot(Point pt);
void SetHotSpotRange(Point *pt);
void GetHotSpotRange(int &hsStart, int &hsEnd);
void GetHotSpotRange(int &hsStart, int &hsEnd) const;
int CodePage() const;
virtual bool ValidCodePage(int /* codePage */) const { return true; }

View File

@ -49,7 +49,7 @@ void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) {
kmap.push_back(ktc);
}
unsigned int KeyMap::Find(int key, int modifiers) {
unsigned int KeyMap::Find(int key, int modifiers) const {
for (size_t i = 0; i < kmap.size(); i++) {
if ((key == kmap[i].key) && (modifiers == kmap[i].modifiers)) {
return kmap[i].msg;

View File

@ -40,7 +40,7 @@ public:
~KeyMap();
void Clear();
void AssignCmdKey(int key, int modifiers, unsigned int msg);
unsigned int Find(int key, int modifiers); // 0 returned on failure
unsigned int Find(int key, int modifiers) const; // 0 returned on failure
};
#ifdef SCI_NAMESPACE

View File

@ -282,7 +282,7 @@ int LineLevels::SetLevel(int line, int level, int lines) {
return prev;
}
int LineLevels::GetLevel(int line) {
int LineLevels::GetLevel(int line) const {
if (levels.Length() && (line >= 0) && (line < levels.Length())) {
return levels[line];
} else {
@ -325,7 +325,7 @@ int LineState::GetLineState(int line) {
return lineStates[line];
}
int LineState::GetMaxLineState() {
int LineState::GetMaxLineState() const {
return lineStates.Length();
}
@ -383,7 +383,7 @@ bool LineAnnotation::MultipleStyles(int line) const {
return 0;
}
int LineAnnotation::Style(int line) {
int LineAnnotation::Style(int line) const {
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
return reinterpret_cast<AnnotationHeader *>(annotations[line])->style;
else

View File

@ -72,7 +72,7 @@ public:
void ExpandLevels(int sizeNew=-1);
void ClearLevels();
int SetLevel(int line, int level, int lines);
int GetLevel(int line);
int GetLevel(int line) const;
};
class LineState : public PerLine {
@ -87,7 +87,7 @@ public:
int SetLineState(int line, int state);
int GetLineState(int line);
int GetMaxLineState();
int GetMaxLineState() const;
};
class LineAnnotation : public PerLine {
@ -101,7 +101,7 @@ public:
virtual void RemoveLine(int line);
bool MultipleStyles(int line) const;
int Style(int line);
int Style(int line) const;
const char *Text(int line) const;
const unsigned char *Styles(int line) const;
void SetText(int line, const char *text);

View File

@ -61,7 +61,7 @@ private:
unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
int failure;
CharClassify *charClass;
bool iswordc(unsigned char x) {
bool iswordc(unsigned char x) const {
return charClass->IsWord(x);
}
};

View File

@ -87,7 +87,7 @@ int RunStyles::ValueAt(int position) const {
return styles->ValueAt(starts->PartitionFromPosition(position));
}
int RunStyles::FindNextChange(int position, int end) {
int RunStyles::FindNextChange(int position, int end) const {
int run = starts->PartitionFromPosition(position);
if (run < starts->Partitions()) {
int runChange = starts->PositionFromPartition(run);
@ -106,11 +106,11 @@ int RunStyles::FindNextChange(int position, int end) {
}
}
int RunStyles::StartRun(int position) {
int RunStyles::StartRun(int position) const {
return starts->PositionFromPartition(starts->PartitionFromPosition(position));
}
int RunStyles::EndRun(int position) {
int RunStyles::EndRun(int position) const {
return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1);
}
@ -258,7 +258,7 @@ int RunStyles::Find(int value, int start) const {
return -1;
}
void RunStyles::Check() {
void RunStyles::Check() const {
if (Length() < 0) {
throw std::runtime_error("RunStyles: Length can not be negative.");
}

View File

@ -30,9 +30,9 @@ public:
~RunStyles();
int Length() const;
int ValueAt(int position) const;
int FindNextChange(int position, int end);
int StartRun(int position);
int EndRun(int position);
int FindNextChange(int position, int end) const;
int StartRun(int position) const;
int EndRun(int position) const;
// Returns true if some values may have changed
bool FillRange(int &position, int value, int &fillLength);
void SetValueAt(int position, int value);
@ -44,7 +44,7 @@ public:
bool AllSameAs(int value) const;
int Find(int value, int start) const;
void Check();
void Check() const;
};
#ifdef SCI_NAMESPACE

View File

@ -14,6 +14,7 @@
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include "Platform.h"
@ -367,13 +368,13 @@ void ScintillaBase::AutoCompleteCompleted() {
SetLastXChosen();
}
int ScintillaBase::AutoCompleteGetCurrent() {
int ScintillaBase::AutoCompleteGetCurrent() const {
if (!ac.Active())
return -1;
return ac.GetSelection();
}
int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) const {
if (ac.Active()) {
int item = ac.GetSelection();
if (item != -1) {

View File

@ -68,8 +68,8 @@ protected:
void AutoCompleteStart(int lenEntered, const char *list);
void AutoCompleteCancel();
void AutoCompleteMove(int delta);
int AutoCompleteGetCurrent();
int AutoCompleteGetCurrentText(char *buffer);
int AutoCompleteGetCurrent() const;
int AutoCompleteGetCurrentText(char *buffer) const;
void AutoCompleteCharacterAdded(char ch);
void AutoCompleteCharacterDeleted();
void AutoCompleteCompleted();

View File

@ -1 +1 @@
332
333