2009-04-24 23:35:41 +00:00
|
|
|
// Scintilla source code edit control
|
|
|
|
/** @file Editor.h
|
|
|
|
** Defines the main editor class.
|
|
|
|
**/
|
2011-07-17 22:30:49 +00:00
|
|
|
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
|
2009-04-24 23:35:41 +00:00
|
|
|
// The License.txt file describes the conditions under which this software may be distributed.
|
|
|
|
|
|
|
|
#ifndef EDITOR_H
|
|
|
|
#define EDITOR_H
|
|
|
|
|
|
|
|
#ifdef SCI_NAMESPACE
|
|
|
|
namespace Scintilla {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class Caret {
|
|
|
|
public:
|
|
|
|
bool active;
|
|
|
|
bool on;
|
|
|
|
int period;
|
|
|
|
|
|
|
|
Caret();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class Timer {
|
|
|
|
public:
|
|
|
|
bool ticking;
|
|
|
|
int ticksToWait;
|
|
|
|
enum {tickSize = 100};
|
|
|
|
TickerID tickerID;
|
|
|
|
|
|
|
|
Timer();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class Idler {
|
|
|
|
public:
|
|
|
|
bool state;
|
|
|
|
IdlerID idlerID;
|
|
|
|
|
|
|
|
Idler();
|
|
|
|
};
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
/**
|
|
|
|
* When platform has a way to generate an event before painting,
|
2013-08-28 00:44:27 +00:00
|
|
|
* accumulate needed styling range and other work items in
|
|
|
|
* WorkNeeded to avoid unnecessary work inside paint handler
|
2010-07-12 22:19:51 +00:00
|
|
|
*/
|
2013-08-28 00:44:27 +00:00
|
|
|
class WorkNeeded {
|
2010-07-12 22:19:51 +00:00
|
|
|
public:
|
2013-08-28 00:44:27 +00:00
|
|
|
enum workItems {
|
|
|
|
workNone=0,
|
|
|
|
workStyle=1,
|
|
|
|
workUpdateUI=2
|
|
|
|
};
|
2010-07-12 22:19:51 +00:00
|
|
|
bool active;
|
2013-08-28 00:44:27 +00:00
|
|
|
enum workItems items;
|
2010-07-12 22:19:51 +00:00
|
|
|
Position upTo;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
WorkNeeded() : active(false), items(workNone), upTo(0) {}
|
2010-07-12 22:19:51 +00:00
|
|
|
void Reset() {
|
|
|
|
active = false;
|
2013-08-28 00:44:27 +00:00
|
|
|
items = workNone;
|
2010-07-12 22:19:51 +00:00
|
|
|
upTo = 0;
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
void Need(workItems items_, Position pos) {
|
|
|
|
if ((items_ & workStyle) && (upTo < pos))
|
2010-07-12 22:19:51 +00:00
|
|
|
upTo = pos;
|
2013-08-28 00:44:27 +00:00
|
|
|
items = static_cast<workItems>(items | items_);
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
2013-08-28 00:44:27 +00:00
|
|
|
* Hold a piece of text selected for copying or dragging, along with encoding and selection format information.
|
2009-04-24 23:35:41 +00:00
|
|
|
*/
|
|
|
|
class SelectionText {
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string s;
|
2009-04-24 23:35:41 +00:00
|
|
|
public:
|
|
|
|
bool rectangular;
|
|
|
|
bool lineCopy;
|
|
|
|
int codePage;
|
|
|
|
int characterSet;
|
2013-08-28 00:44:27 +00:00
|
|
|
SelectionText() : rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
|
2009-04-24 23:35:41 +00:00
|
|
|
~SelectionText() {
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
void Clear() {
|
|
|
|
s.clear();
|
|
|
|
rectangular = false;
|
|
|
|
lineCopy = false;
|
|
|
|
codePage = 0;
|
|
|
|
characterSet = 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
void Copy(const std::string &s_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
|
2009-04-24 23:35:41 +00:00
|
|
|
s = s_;
|
|
|
|
codePage = codePage_;
|
|
|
|
characterSet = characterSet_;
|
|
|
|
rectangular = rectangular_;
|
|
|
|
lineCopy = lineCopy_;
|
2013-08-28 00:44:27 +00:00
|
|
|
FixSelectionForClipboard();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
void Copy(const SelectionText &other) {
|
2013-08-28 00:44:27 +00:00
|
|
|
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() {
|
|
|
|
// 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', ' ');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrapPending {
|
|
|
|
// The range of lines that need to be wrapped
|
|
|
|
enum { lineLarge = 0x7ffffff };
|
|
|
|
int start; // When there are wraps pending, will be in document range
|
|
|
|
int end; // May be lineLarge to indicate all of document after start
|
|
|
|
WrapPending() {
|
|
|
|
start = lineLarge;
|
|
|
|
end = lineLarge;
|
|
|
|
}
|
|
|
|
void Reset() {
|
|
|
|
start = lineLarge;
|
|
|
|
end = lineLarge;
|
|
|
|
}
|
|
|
|
void Wrapped(int line) {
|
|
|
|
if (start == line)
|
|
|
|
start++;
|
|
|
|
}
|
|
|
|
bool NeedsWrap() const {
|
|
|
|
return start < end;
|
|
|
|
}
|
|
|
|
bool AddRange(int lineStart, int lineEnd) {
|
|
|
|
const bool neededWrap = NeedsWrap();
|
|
|
|
bool changed = false;
|
|
|
|
if (start > lineStart) {
|
|
|
|
start = lineStart;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if ((end < lineEnd) || !neededWrap) {
|
|
|
|
end = lineEnd;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
return changed;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class Editor : public DocWatcher {
|
|
|
|
// Private so Editor objects can not be copied
|
2010-07-12 22:19:51 +00:00
|
|
|
Editor(const Editor &);
|
|
|
|
Editor &operator=(const Editor &);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
protected: // ScintillaBase subclass needs access to much of Editor
|
|
|
|
|
|
|
|
/** On GTK+, Scintilla is a container widget holding two scroll bars
|
|
|
|
* whereas on Windows there is just one window with both scroll bars turned on. */
|
|
|
|
Window wMain; ///< The Scintilla parent window
|
2013-08-28 00:44:27 +00:00
|
|
|
Window wMargin; ///< May be separate when using a scroll view for wMain
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
/** Style resources may be expensive to allocate so are cached between uses.
|
|
|
|
* When a style attribute is changed, this cache is flushed. */
|
|
|
|
bool stylesValid;
|
|
|
|
ViewStyle vs;
|
2013-08-28 00:44:27 +00:00
|
|
|
int technology;
|
|
|
|
Point sizeRGBAImage;
|
|
|
|
float scaleRGBAImage;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
int printMagnification;
|
|
|
|
int printColourMode;
|
|
|
|
int printWrapState;
|
|
|
|
int cursorMode;
|
|
|
|
int controlCharSymbol;
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
// Highlight current folding block
|
|
|
|
HighlightDelimiter highlightDelimiter;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
bool hasFocus;
|
|
|
|
bool hideSelection;
|
|
|
|
bool inOverstrike;
|
2013-08-28 00:44:27 +00:00
|
|
|
bool drawOverstrikeCaret;
|
2009-04-24 23:35:41 +00:00
|
|
|
bool mouseDownCaptures;
|
|
|
|
|
|
|
|
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
|
|
|
|
* the screen. This avoids flashing but is about 30% slower. */
|
|
|
|
bool bufferedDraw;
|
|
|
|
/** In twoPhaseDraw mode, drawing is performed in two phases, first the background
|
|
|
|
* and then the foreground. This avoids chopping off characters that overlap the next run. */
|
|
|
|
bool twoPhaseDraw;
|
|
|
|
|
|
|
|
int xOffset; ///< Horizontal scrolled amount in pixels
|
|
|
|
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
|
|
|
|
bool horizontalScrollBarVisible;
|
|
|
|
int scrollWidth;
|
|
|
|
bool trackLineWidth;
|
|
|
|
int lineWidthMaxSeen;
|
|
|
|
bool verticalScrollBarVisible;
|
|
|
|
bool endAtLastLine;
|
2010-08-21 23:59:56 +00:00
|
|
|
int caretSticky;
|
2011-07-17 22:30:49 +00:00
|
|
|
int marginOptions;
|
2009-08-23 02:24:48 +00:00
|
|
|
bool multipleSelection;
|
|
|
|
bool additionalSelectionTyping;
|
2010-07-12 22:19:51 +00:00
|
|
|
int multiPasteMode;
|
2009-08-23 02:24:48 +00:00
|
|
|
bool additionalCaretsBlink;
|
2010-07-12 22:19:51 +00:00
|
|
|
bool additionalCaretsVisible;
|
2009-08-23 02:24:48 +00:00
|
|
|
|
|
|
|
int virtualSpaceOptions;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
Surface *pixmapLine;
|
|
|
|
Surface *pixmapSelMargin;
|
|
|
|
Surface *pixmapSelPattern;
|
2013-08-28 00:44:27 +00:00
|
|
|
Surface *pixmapSelPatternOffset1;
|
2009-04-24 23:35:41 +00:00
|
|
|
Surface *pixmapIndentGuide;
|
|
|
|
Surface *pixmapIndentGuideHighlight;
|
|
|
|
|
|
|
|
LineLayoutCache llc;
|
|
|
|
PositionCache posCache;
|
|
|
|
|
|
|
|
KeyMap kmap;
|
|
|
|
|
|
|
|
Caret caret;
|
|
|
|
Timer timer;
|
|
|
|
Timer autoScrollTimer;
|
|
|
|
enum { autoScrollDelay = 200 };
|
|
|
|
|
|
|
|
Idler idler;
|
|
|
|
|
|
|
|
Point lastClick;
|
|
|
|
unsigned int lastClickTime;
|
|
|
|
int dwellDelay;
|
|
|
|
int ticksToDwell;
|
|
|
|
bool dwelling;
|
2011-07-17 22:30:49 +00:00
|
|
|
enum { selChar, selWord, selSubLine, selWholeLine } selectionType;
|
2009-04-24 23:35:41 +00:00
|
|
|
Point ptMouseLast;
|
|
|
|
enum { ddNone, ddInitial, ddDragging } inDragDrop;
|
|
|
|
bool dropWentOutside;
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition posDrag;
|
|
|
|
SelectionPosition posDrop;
|
2011-03-22 00:16:49 +00:00
|
|
|
int hotSpotClickPos;
|
2009-04-24 23:35:41 +00:00
|
|
|
int lastXChosen;
|
2011-07-17 22:30:49 +00:00
|
|
|
int lineAnchorPos;
|
2009-04-24 23:35:41 +00:00
|
|
|
int originalAnchorPos;
|
2011-03-22 00:16:49 +00:00
|
|
|
int wordSelectAnchorStartPos;
|
|
|
|
int wordSelectAnchorEndPos;
|
|
|
|
int wordSelectInitialCaretPos;
|
2009-04-24 23:35:41 +00:00
|
|
|
int targetStart;
|
|
|
|
int targetEnd;
|
|
|
|
int searchFlags;
|
|
|
|
int topLine;
|
|
|
|
int posTopLine;
|
|
|
|
int lengthForEncode;
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
int needUpdateUI;
|
2009-04-24 23:35:41 +00:00
|
|
|
Position braces[2];
|
|
|
|
int bracesMatchStyle;
|
|
|
|
int highlightGuideColumn;
|
|
|
|
|
|
|
|
int theEdge;
|
|
|
|
|
|
|
|
enum { notPainting, painting, paintAbandoned } paintState;
|
2013-08-28 00:44:27 +00:00
|
|
|
bool paintAbandonedByStyling;
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcPaint;
|
|
|
|
bool paintingAllText;
|
2013-08-28 00:44:27 +00:00
|
|
|
bool willRedrawAll;
|
|
|
|
WorkNeeded workNeeded;
|
2011-03-22 00:16:49 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
int modEventMask;
|
|
|
|
|
|
|
|
SelectionText drag;
|
2009-08-23 02:24:48 +00:00
|
|
|
Selection sel;
|
2009-04-24 23:35:41 +00:00
|
|
|
bool primarySelection;
|
|
|
|
|
|
|
|
int caretXPolicy;
|
|
|
|
int caretXSlop; ///< Ensure this many pixels visible on both sides of caret
|
|
|
|
|
|
|
|
int caretYPolicy;
|
|
|
|
int caretYSlop; ///< Ensure this many lines visible on both sides of caret
|
|
|
|
|
|
|
|
int visiblePolicy;
|
|
|
|
int visibleSlop;
|
|
|
|
|
|
|
|
int searchAnchor;
|
|
|
|
|
|
|
|
bool recordingMacro;
|
|
|
|
|
|
|
|
int foldFlags;
|
2013-08-28 00:44:27 +00:00
|
|
|
int foldAutomatic;
|
2009-04-24 23:35:41 +00:00
|
|
|
ContractionState cs;
|
|
|
|
|
|
|
|
// Hotspot support
|
|
|
|
int hsStart;
|
|
|
|
int hsEnd;
|
|
|
|
|
|
|
|
// Wrapping support
|
|
|
|
enum { eWrapNone, eWrapWord, eWrapChar } wrapState;
|
|
|
|
int wrapWidth;
|
2013-08-28 00:44:27 +00:00
|
|
|
WrapPending wrapPending;
|
2009-04-24 23:35:41 +00:00
|
|
|
int wrapVisualFlags;
|
|
|
|
int wrapVisualFlagsLocation;
|
|
|
|
int wrapVisualStartIndent;
|
2009-08-23 02:24:48 +00:00
|
|
|
int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
bool convertPastes;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int marginNumberPadding; // the right-side padding of the number margin
|
|
|
|
int ctrlCharPadding; // the padding around control character text blobs
|
|
|
|
int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
Document *pdoc;
|
|
|
|
|
|
|
|
Editor();
|
|
|
|
virtual ~Editor();
|
|
|
|
virtual void Initialise() = 0;
|
|
|
|
virtual void Finalise();
|
|
|
|
|
|
|
|
void InvalidateStyleData();
|
|
|
|
void InvalidateStyleRedraw();
|
|
|
|
void RefreshStyleData();
|
2013-08-28 00:44:27 +00:00
|
|
|
void DropGraphics(bool freeObjects);
|
|
|
|
void AllocateGraphics();
|
|
|
|
|
|
|
|
// The top left visible point in main window coordinates. Will be 0,0 except for
|
|
|
|
// 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() const; // Return the line at Main's y coordinate 0
|
2009-04-24 23:35:41 +00:00
|
|
|
virtual PRectangle GetClientRectangle();
|
|
|
|
PRectangle GetTextRectangle();
|
|
|
|
|
|
|
|
int LinesOnScreen();
|
|
|
|
int LinesToScroll();
|
|
|
|
int MaxScrollPos();
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const;
|
|
|
|
Point LocationFromPosition(SelectionPosition pos);
|
2009-04-24 23:35:41 +00:00
|
|
|
Point LocationFromPosition(int pos);
|
|
|
|
int XFromPosition(int pos);
|
2009-08-23 02:24:48 +00:00
|
|
|
int XFromPosition(SelectionPosition sp);
|
|
|
|
SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true);
|
|
|
|
int PositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false);
|
|
|
|
SelectionPosition SPositionFromLineX(int lineDoc, int x);
|
2009-04-24 23:35:41 +00:00
|
|
|
int PositionFromLineX(int line, int x);
|
2013-08-28 00:44:27 +00:00
|
|
|
int LineFromLocation(Point pt) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetTopLine(int topLineNew);
|
|
|
|
|
|
|
|
bool AbandonPaint();
|
|
|
|
void RedrawRect(PRectangle rc);
|
|
|
|
void Redraw();
|
2010-07-12 22:19:51 +00:00
|
|
|
void RedrawSelMargin(int line=-1, bool allAfter=false);
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle RectangleFromRange(int start, int end);
|
|
|
|
void InvalidateRange(int start, int end);
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
bool UserVirtualSpace() const {
|
|
|
|
return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
int CurrentPosition() const;
|
|
|
|
bool SelectionEmpty() const;
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition SelectionStart();
|
|
|
|
SelectionPosition SelectionEnd();
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetRectangularRange();
|
2010-07-12 22:19:51 +00:00
|
|
|
void ThinRectangularRange();
|
2009-08-23 02:24:48 +00:00
|
|
|
void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
|
|
|
|
void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetSelection(int currentPos_, int anchor_);
|
2009-08-23 02:24:48 +00:00
|
|
|
void SetSelection(SelectionPosition currentPos_);
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetSelection(int currentPos_);
|
2009-08-23 02:24:48 +00:00
|
|
|
void SetEmptySelection(SelectionPosition currentPos_);
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetEmptySelection(int currentPos_);
|
|
|
|
bool RangeContainsProtected(int start, int end) const;
|
|
|
|
bool SelectionContainsProtected();
|
2009-08-23 02:24:48 +00:00
|
|
|
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
|
|
|
|
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
|
|
|
|
int MovePositionTo(SelectionPosition newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
|
|
|
|
int MovePositionTo(int newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
|
|
|
|
SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir);
|
|
|
|
SelectionPosition MovePositionSoVisible(int pos, int moveDir);
|
|
|
|
Point PointMainCaret();
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetLastXChosen();
|
|
|
|
|
|
|
|
void ScrollTo(int line, bool moveThumb=true);
|
|
|
|
virtual void ScrollText(int linesToMove);
|
|
|
|
void HorizontalScrollTo(int xPos);
|
2011-03-22 00:16:49 +00:00
|
|
|
void VerticalCentreCaret();
|
2011-07-17 22:30:49 +00:00
|
|
|
void MoveSelectedLines(int lineDelta);
|
|
|
|
void MoveSelectedLinesUp();
|
|
|
|
void MoveSelectedLinesDown();
|
2009-04-24 23:35:41 +00:00
|
|
|
void MoveCaretInsideView(bool ensureVisible=true);
|
|
|
|
int DisplayFromPosition(int pos);
|
2010-07-12 22:19:51 +00:00
|
|
|
|
|
|
|
struct XYScrollPosition {
|
|
|
|
int xOffset;
|
|
|
|
int topLine;
|
|
|
|
XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {}
|
2013-08-28 00:44:27 +00:00
|
|
|
bool operator==(const XYScrollPosition &other) const {
|
|
|
|
return (xOffset == other.xOffset) && (topLine == other.topLine);
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
};
|
2013-08-28 00:44:27 +00:00
|
|
|
enum XYScrollOptions {
|
|
|
|
xysUseMargin=0x1,
|
|
|
|
xysVertical=0x2,
|
|
|
|
xysHorizontal=0x4,
|
|
|
|
xysDefault=xysUseMargin|xysVertical|xysHorizontal};
|
|
|
|
XYScrollPosition XYScrollToMakeVisible(const SelectionRange range, const XYScrollOptions options);
|
2010-07-12 22:19:51 +00:00
|
|
|
void SetXYScroll(XYScrollPosition newXY);
|
2009-04-24 23:35:41 +00:00
|
|
|
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
|
2013-08-28 00:44:27 +00:00
|
|
|
void ScrollRange(SelectionRange range);
|
2009-04-24 23:35:41 +00:00
|
|
|
void ShowCaretAtCurrentPosition();
|
|
|
|
void DropCaret();
|
|
|
|
void InvalidateCaret();
|
|
|
|
virtual void UpdateSystemCaret();
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge);
|
2009-04-24 23:35:41 +00:00
|
|
|
bool WrapOneLine(Surface *surface, int lineToWrap);
|
2013-08-28 00:44:27 +00:00
|
|
|
enum wrapScope {wsAll, wsVisible, wsIdle};
|
|
|
|
bool WrapLines(enum wrapScope ws);
|
2009-04-24 23:35:41 +00:00
|
|
|
void LinesJoin();
|
|
|
|
void LinesSplit(int pixelWidth);
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
void PaintSelMargin(Surface *surface, PRectangle &rc);
|
|
|
|
LineLayout *RetrieveLineLayout(int lineNumber);
|
|
|
|
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
|
|
|
|
int width=LineLayout::wrapWidthInfinite);
|
2013-08-28 00:44:27 +00:00
|
|
|
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;
|
2009-04-24 23:35:41 +00:00
|
|
|
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
|
2013-08-28 00:44:27 +00:00
|
|
|
void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
|
2009-04-24 23:35:41 +00:00
|
|
|
void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
|
2013-08-28 00:44:27 +00:00
|
|
|
int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
|
|
|
|
bool overrideBackground, ColourDesired background,
|
|
|
|
bool drawWrapMark, ColourDesired wrapColour);
|
2011-07-17 22:30:49 +00:00
|
|
|
void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw,
|
|
|
|
int xStart, PRectangle rcLine, LineLayout *ll, int subLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
|
|
|
|
PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);
|
2009-06-24 19:09:31 +00:00
|
|
|
void DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
|
|
|
|
PRectangle rcLine, LineLayout *ll, int subLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
|
2009-08-23 02:24:48 +00:00
|
|
|
PRectangle rcLine, LineLayout *ll, int subLine);
|
2010-07-12 22:19:51 +00:00
|
|
|
void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
|
2013-08-28 00:44:27 +00:00
|
|
|
int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour);
|
2009-08-23 02:24:48 +00:00
|
|
|
void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
|
|
|
|
PRectangle rcLine, LineLayout *ll, int subLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
void RefreshPixMaps(Surface *surfaceWindow);
|
|
|
|
void Paint(Surface *surfaceWindow, PRectangle rcArea);
|
2009-08-23 02:24:48 +00:00
|
|
|
long FormatRange(bool draw, Sci_RangeToFormat *pfr);
|
2009-04-24 23:35:41 +00:00
|
|
|
int TextWidth(int style, const char *text);
|
|
|
|
|
|
|
|
virtual void SetVerticalScrollPos() = 0;
|
|
|
|
virtual void SetHorizontalScrollPos() = 0;
|
|
|
|
virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
|
|
|
|
virtual void ReconfigureScrollBars();
|
|
|
|
void SetScrollBars();
|
|
|
|
void ChangeSize();
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void FilterSelections();
|
|
|
|
int InsertSpace(int position, unsigned int spaces);
|
2009-04-24 23:35:41 +00:00
|
|
|
void AddChar(char ch);
|
|
|
|
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
|
2010-07-12 22:19:51 +00:00
|
|
|
void InsertPaste(SelectionPosition selStart, const char *text, int len);
|
2011-03-22 00:16:49 +00:00
|
|
|
void ClearSelection(bool retainMultipleSelections=false);
|
2009-04-24 23:35:41 +00:00
|
|
|
void ClearAll();
|
|
|
|
void ClearDocumentStyle();
|
|
|
|
void Cut();
|
2009-08-23 02:24:48 +00:00
|
|
|
void PasteRectangular(SelectionPosition pos, const char *ptr, int len);
|
2009-04-24 23:35:41 +00:00
|
|
|
virtual void Copy() = 0;
|
|
|
|
virtual void CopyAllowLine();
|
|
|
|
virtual bool CanPaste();
|
|
|
|
virtual void Paste() = 0;
|
|
|
|
void Clear();
|
|
|
|
void SelectAll();
|
|
|
|
void Undo();
|
|
|
|
void Redo();
|
|
|
|
void DelChar();
|
|
|
|
void DelCharBack(bool allowLineStartDeletion);
|
|
|
|
virtual void ClaimSelection() = 0;
|
|
|
|
|
|
|
|
virtual void NotifyChange() = 0;
|
|
|
|
virtual void NotifyFocus(bool focus);
|
2011-07-17 22:30:49 +00:00
|
|
|
virtual void SetCtrlID(int identifier);
|
2009-04-24 23:35:41 +00:00
|
|
|
virtual int GetCtrlID() { return ctrlID; }
|
|
|
|
virtual void NotifyParent(SCNotification scn) = 0;
|
|
|
|
virtual void NotifyStyleToNeeded(int endStyleNeeded);
|
|
|
|
void NotifyChar(int ch);
|
|
|
|
void NotifySavePoint(bool isSavePoint);
|
|
|
|
void NotifyModifyAttempt();
|
|
|
|
virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
|
|
|
|
void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
|
|
|
|
void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
|
2011-03-22 00:16:49 +00:00
|
|
|
void NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt);
|
2013-08-28 00:44:27 +00:00
|
|
|
bool NotifyUpdateUI();
|
2009-04-24 23:35:41 +00:00
|
|
|
void NotifyPainted();
|
2010-07-12 22:19:51 +00:00
|
|
|
void NotifyScrolled();
|
2009-04-24 23:35:41 +00:00
|
|
|
void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
|
|
|
|
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
|
|
|
|
void NotifyNeedShown(int pos, int len);
|
|
|
|
void NotifyDwelling(Point pt, bool state);
|
|
|
|
void NotifyZoom();
|
|
|
|
|
|
|
|
void NotifyModifyAttempt(Document *document, void *userData);
|
|
|
|
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
|
|
|
void CheckModificationForWrap(DocModification mh);
|
|
|
|
void NotifyModified(Document *document, DocModification mh, void *userData);
|
|
|
|
void NotifyDeleted(Document *document, void *userData);
|
|
|
|
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
|
2010-08-21 23:59:56 +00:00
|
|
|
void NotifyLexerChanged(Document *doc, void *userData);
|
|
|
|
void NotifyErrorOccurred(Document *doc, void *userData, int status);
|
2009-04-24 23:35:41 +00:00
|
|
|
void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
void ContainerNeedsUpdate(int flags);
|
2009-08-23 02:24:48 +00:00
|
|
|
void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false);
|
2010-07-12 22:19:51 +00:00
|
|
|
enum { cmSame, cmUpper, cmLower } caseMap;
|
|
|
|
virtual std::string CaseMapString(const std::string &s, int caseMapping);
|
|
|
|
void ChangeCaseOfSelection(int caseMapping);
|
2009-04-24 23:35:41 +00:00
|
|
|
void LineTranspose();
|
|
|
|
void Duplicate(bool forLine);
|
|
|
|
virtual void CancelModes();
|
|
|
|
void NewLine();
|
2009-08-23 02:24:48 +00:00
|
|
|
void CursorUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
|
|
|
|
void ParaUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
|
2009-04-24 23:35:41 +00:00
|
|
|
int StartEndDisplayLine(int pos, bool start);
|
|
|
|
virtual int KeyCommand(unsigned int iMessage);
|
|
|
|
virtual int KeyDefault(int /* key */, int /*modifiers*/);
|
2011-07-17 22:30:49 +00:00
|
|
|
int KeyDownWithModifiers(int key, int modifiers, bool *consumed);
|
2009-04-24 23:35:41 +00:00
|
|
|
int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0);
|
|
|
|
|
|
|
|
void Indent(bool forwards);
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
virtual CaseFolder *CaseFolderForEncoding();
|
2009-04-24 23:35:41 +00:00
|
|
|
long FindText(uptr_t wParam, sptr_t lParam);
|
|
|
|
void SearchAnchor();
|
|
|
|
long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
|
|
|
long SearchInTarget(const char *text, int length);
|
|
|
|
void GoToLine(int lineNo);
|
|
|
|
|
|
|
|
virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string RangeText(int start, int end) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
|
|
|
|
void CopyRangeToClipboard(int start, int end);
|
|
|
|
void CopyText(int length, const char *text);
|
2009-08-23 02:24:48 +00:00
|
|
|
void SetDragPosition(SelectionPosition newPos);
|
2009-04-24 23:35:41 +00:00
|
|
|
virtual void DisplayCursor(Window::Cursor c);
|
|
|
|
virtual bool DragThreshold(Point ptStart, Point ptNow);
|
|
|
|
virtual void StartDrag();
|
2013-08-28 00:44:27 +00:00
|
|
|
void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular);
|
2009-08-23 02:24:48 +00:00
|
|
|
void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular);
|
|
|
|
/** PositionInSelection returns true if position in selection. */
|
|
|
|
bool PositionInSelection(int pos);
|
2009-04-24 23:35:41 +00:00
|
|
|
bool PointInSelection(Point pt);
|
|
|
|
bool PointInSelMargin(Point pt);
|
2013-08-28 00:44:27 +00:00
|
|
|
Window::Cursor GetMarginCursor(Point pt) const;
|
|
|
|
void TrimAndSetSelection(int currentPos_, int anchor_);
|
2011-07-17 22:30:49 +00:00
|
|
|
void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine);
|
2011-03-22 00:16:49 +00:00
|
|
|
void WordSelection(int pos);
|
2009-04-24 23:35:41 +00:00
|
|
|
void DwellEnd(bool mouseMoved);
|
2010-07-12 22:19:51 +00:00
|
|
|
void MouseLeave();
|
2009-04-24 23:35:41 +00:00
|
|
|
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
|
|
|
void ButtonMove(Point pt);
|
|
|
|
void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
|
|
|
|
|
|
|
void Tick();
|
|
|
|
bool Idle();
|
|
|
|
virtual void SetTicking(bool on) = 0;
|
|
|
|
virtual bool SetIdle(bool) { return false; }
|
|
|
|
virtual void SetMouseCapture(bool on) = 0;
|
|
|
|
virtual bool HaveMouseCapture() = 0;
|
|
|
|
void SetFocusState(bool focusState);
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int PositionAfterArea(PRectangle rcArea) const;
|
2010-07-12 22:19:51 +00:00
|
|
|
void StyleToPositionInView(Position pos);
|
2013-08-28 00:44:27 +00:00
|
|
|
virtual void IdleWork();
|
|
|
|
virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo=0);
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
virtual bool PaintContains(PRectangle rc);
|
|
|
|
bool PaintContainsMargin();
|
|
|
|
void CheckForChangeOutsidePaint(Range r);
|
|
|
|
void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
|
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
void SetAnnotationHeights(int start, int end);
|
2013-08-28 00:44:27 +00:00
|
|
|
virtual void SetDocPointer(Document *document);
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
void SetAnnotationVisible(int visible);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int ExpandLine(int line);
|
|
|
|
void SetFoldExpanded(int lineDoc, bool expanded);
|
|
|
|
void FoldLine(int line, int action);
|
|
|
|
void FoldExpand(int line, int action, int level);
|
|
|
|
int ContractedFoldNext(int lineStart) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
void EnsureLineVisible(int lineDoc, bool enforcePolicy);
|
2013-08-28 00:44:27 +00:00
|
|
|
void FoldChanged(int line, int levelNow, int levelPrev);
|
|
|
|
void NeedShown(int pos, int len);
|
|
|
|
void FoldAll(int action);
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
int GetTag(char *tagValue, int tagNumber);
|
2009-04-24 23:35:41 +00:00
|
|
|
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
bool PositionIsHotspot(int position) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
bool PointIsHotspot(Point pt);
|
|
|
|
void SetHotSpotRange(Point *pt);
|
2013-08-28 00:44:27 +00:00
|
|
|
void GetHotSpotRange(int &hsStart, int &hsEnd) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
int CodePage() const;
|
|
|
|
virtual bool ValidCodePage(int /* codePage */) const { return true; }
|
|
|
|
int WrapCount(int line);
|
|
|
|
void AddStyledText(char *buffer, int appendLength);
|
|
|
|
|
|
|
|
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
|
|
|
|
void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
|
|
|
sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
|
|
|
|
|
|
|
static const char *StringFromEOLMode(int eolMode);
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
static sptr_t StringResult(sptr_t lParam, const char *val);
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
public:
|
|
|
|
// Public so the COM thunks can access it.
|
|
|
|
bool IsUnicodeMode() const;
|
|
|
|
// Public so scintilla_send_message can use it.
|
|
|
|
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
|
|
|
// Public so scintilla_set_id can use it.
|
|
|
|
int ctrlID;
|
2009-08-23 02:24:48 +00:00
|
|
|
// Public so COM methods for drag and drop can set it.
|
|
|
|
int errorStatus;
|
2009-04-24 23:35:41 +00:00
|
|
|
friend class AutoSurface;
|
|
|
|
friend class SelectionLineIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A smart pointer class to ensure Surfaces are set up and deleted correctly.
|
|
|
|
*/
|
|
|
|
class AutoSurface {
|
|
|
|
private:
|
|
|
|
Surface *surf;
|
|
|
|
public:
|
2013-08-28 00:44:27 +00:00
|
|
|
AutoSurface(Editor *ed, int technology = -1) : surf(0) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (ed->wMain.GetID()) {
|
2013-08-28 00:44:27 +00:00
|
|
|
surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (surf) {
|
|
|
|
surf->Init(ed->wMain.GetID());
|
|
|
|
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
|
|
|
|
surf->SetDBCSMode(ed->CodePage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) : surf(0) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (ed->wMain.GetID()) {
|
2013-08-28 00:44:27 +00:00
|
|
|
surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (surf) {
|
|
|
|
surf->Init(sid, ed->wMain.GetID());
|
|
|
|
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
|
|
|
|
surf->SetDBCSMode(ed->CodePage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoSurface() {
|
|
|
|
delete surf;
|
|
|
|
}
|
|
|
|
Surface *operator->() const {
|
|
|
|
return surf;
|
|
|
|
}
|
|
|
|
operator Surface *() const {
|
|
|
|
return surf;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef SCI_NAMESPACE
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|