2009-04-24 23:35:41 +00:00
|
|
|
// Scintilla source code edit control
|
|
|
|
/** @file Editor.cxx
|
|
|
|
** Main code for the edit control.
|
|
|
|
**/
|
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.
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2010-08-21 23:59:56 +00:00
|
|
|
#include <assert.h>
|
2015-06-07 21:19:26 +00:00
|
|
|
#include <ctype.h>
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <stdexcept>
|
2009-08-23 02:24:48 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2013-08-28 00:44:27 +00:00
|
|
|
#include <map>
|
2009-08-23 02:24:48 +00:00
|
|
|
#include <algorithm>
|
2010-07-12 22:19:51 +00:00
|
|
|
#include <memory>
|
2009-08-23 02:24:48 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
#include "Platform.h"
|
|
|
|
|
2010-08-21 23:59:56 +00:00
|
|
|
#include "ILexer.h"
|
2009-04-24 23:35:41 +00:00
|
|
|
#include "Scintilla.h"
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
#include "StringCopy.h"
|
2009-04-24 23:35:41 +00:00
|
|
|
#include "SplitVector.h"
|
|
|
|
#include "Partitioning.h"
|
|
|
|
#include "RunStyles.h"
|
|
|
|
#include "ContractionState.h"
|
|
|
|
#include "CellBuffer.h"
|
2015-06-07 21:19:26 +00:00
|
|
|
#include "PerLine.h"
|
2009-04-24 23:35:41 +00:00
|
|
|
#include "KeyMap.h"
|
|
|
|
#include "Indicator.h"
|
|
|
|
#include "XPM.h"
|
|
|
|
#include "LineMarker.h"
|
|
|
|
#include "Style.h"
|
|
|
|
#include "ViewStyle.h"
|
|
|
|
#include "CharClassify.h"
|
|
|
|
#include "Decoration.h"
|
2013-08-28 00:44:27 +00:00
|
|
|
#include "CaseFolder.h"
|
2009-04-24 23:35:41 +00:00
|
|
|
#include "Document.h"
|
2013-08-28 00:44:27 +00:00
|
|
|
#include "UniConversion.h"
|
2009-08-23 02:24:48 +00:00
|
|
|
#include "Selection.h"
|
2009-04-24 23:35:41 +00:00
|
|
|
#include "PositionCache.h"
|
2015-06-07 21:19:26 +00:00
|
|
|
#include "EditModel.h"
|
|
|
|
#include "MarginView.h"
|
|
|
|
#include "EditView.h"
|
2009-04-24 23:35:41 +00:00
|
|
|
#include "Editor.h"
|
|
|
|
|
|
|
|
#ifdef SCI_NAMESPACE
|
|
|
|
using namespace Scintilla;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
return whether this modification represents an operation that
|
|
|
|
may reasonably be deferred (not done now OR [possibly] at all)
|
|
|
|
*/
|
2010-07-12 22:19:51 +00:00
|
|
|
static bool CanDeferToLastStep(const DocModification &mh) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE))
|
|
|
|
return true; // CAN skip
|
|
|
|
if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)))
|
|
|
|
return false; // MUST do
|
|
|
|
if (mh.modificationType & SC_MULTISTEPUNDOREDO)
|
|
|
|
return true; // CAN skip
|
|
|
|
return false; // PRESUMABLY must do
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
static bool CanEliminate(const DocModification &mh) {
|
2009-04-24 23:35:41 +00:00
|
|
|
return
|
|
|
|
(mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
return whether this modification represents the FINAL step
|
|
|
|
in a [possibly lengthy] multi-step Undo/Redo sequence
|
|
|
|
*/
|
2010-07-12 22:19:51 +00:00
|
|
|
static bool IsLastStep(const DocModification &mh) {
|
2009-04-24 23:35:41 +00:00
|
|
|
return
|
|
|
|
(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0
|
|
|
|
&& (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0
|
|
|
|
&& (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0
|
|
|
|
&& (mh.modificationType & SC_MULTILINEUNDOREDO) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer::Timer() :
|
|
|
|
ticking(false), ticksToWait(0), tickerID(0) {}
|
|
|
|
|
|
|
|
Idler::Idler() :
|
|
|
|
state(false), idlerID(0) {}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
static inline bool IsAllSpacesOrTabs(const char *s, unsigned int len) {
|
2010-08-21 23:59:56 +00:00
|
|
|
for (unsigned int i = 0; i < len; i++) {
|
|
|
|
// This is safe because IsSpaceOrTab() will return false for null terminators
|
|
|
|
if (!IsSpaceOrTab(s[i]))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
Editor::Editor() {
|
|
|
|
ctrlID = 0;
|
|
|
|
|
|
|
|
stylesValid = false;
|
2013-08-28 00:44:27 +00:00
|
|
|
technology = SC_TECHNOLOGY_DEFAULT;
|
2015-06-07 21:19:26 +00:00
|
|
|
scaleRGBAImage = 100.0f;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
cursorMode = SC_CURSORNORMAL;
|
|
|
|
|
|
|
|
hasFocus = false;
|
|
|
|
errorStatus = 0;
|
|
|
|
mouseDownCaptures = true;
|
|
|
|
|
|
|
|
lastClickTime = 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
doubleClickCloseThreshold = Point(3, 3);
|
2009-04-24 23:35:41 +00:00
|
|
|
dwellDelay = SC_TIME_FOREVER;
|
|
|
|
ticksToDwell = SC_TIME_FOREVER;
|
|
|
|
dwelling = false;
|
|
|
|
ptMouseLast.x = 0;
|
|
|
|
ptMouseLast.y = 0;
|
|
|
|
inDragDrop = ddNone;
|
|
|
|
dropWentOutside = false;
|
2009-08-23 02:24:48 +00:00
|
|
|
posDrop = SelectionPosition(invalidPosition);
|
2011-03-22 00:16:49 +00:00
|
|
|
hotSpotClickPos = INVALID_POSITION;
|
2009-04-24 23:35:41 +00:00
|
|
|
selectionType = selChar;
|
|
|
|
|
|
|
|
lastXChosen = 0;
|
2011-07-17 22:30:49 +00:00
|
|
|
lineAnchorPos = 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
originalAnchorPos = 0;
|
2011-03-22 00:16:49 +00:00
|
|
|
wordSelectAnchorStartPos = 0;
|
|
|
|
wordSelectAnchorEndPos = 0;
|
|
|
|
wordSelectInitialCaretPos = -1;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
caretXPolicy = CARET_SLOP | CARET_EVEN;
|
|
|
|
caretXSlop = 50;
|
|
|
|
|
|
|
|
caretYPolicy = CARET_EVEN;
|
|
|
|
caretYSlop = 0;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
visiblePolicy = 0;
|
|
|
|
visibleSlop = 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
searchAnchor = 0;
|
|
|
|
|
|
|
|
xCaretMargin = 50;
|
|
|
|
horizontalScrollBarVisible = true;
|
|
|
|
scrollWidth = 2000;
|
|
|
|
verticalScrollBarVisible = true;
|
|
|
|
endAtLastLine = true;
|
2010-08-21 23:59:56 +00:00
|
|
|
caretSticky = SC_CARETSTICKY_OFF;
|
2011-07-17 22:30:49 +00:00
|
|
|
marginOptions = SC_MARGINOPTION_NONE;
|
2015-06-07 21:19:26 +00:00
|
|
|
mouseSelectionRectangularSwitch = false;
|
2009-08-23 02:24:48 +00:00
|
|
|
multipleSelection = false;
|
|
|
|
additionalSelectionTyping = false;
|
2010-07-12 22:19:51 +00:00
|
|
|
multiPasteMode = SC_MULTIPASTE_ONCE;
|
2009-08-23 02:24:48 +00:00
|
|
|
virtualSpaceOptions = SCVS_NONE;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
targetStart = 0;
|
|
|
|
targetEnd = 0;
|
|
|
|
searchFlags = 0;
|
|
|
|
|
|
|
|
topLine = 0;
|
|
|
|
posTopLine = 0;
|
|
|
|
|
|
|
|
lengthForEncode = -1;
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
needUpdateUI = 0;
|
|
|
|
ContainerNeedsUpdate(SC_UPDATE_CONTENT);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
paintState = notPainting;
|
2015-06-07 21:19:26 +00:00
|
|
|
paintAbandonedByStyling = false;
|
|
|
|
paintingAllText = false;
|
2013-08-28 00:44:27 +00:00
|
|
|
willRedrawAll = false;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
modEventMask = SC_MODEVENTMASKALL;
|
|
|
|
|
|
|
|
pdoc->AddWatcher(this, 0);
|
|
|
|
|
|
|
|
recordingMacro = false;
|
2013-08-28 00:44:27 +00:00
|
|
|
foldAutomatic = 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
convertPastes = true;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
SetRepresentations();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Editor::~Editor() {
|
|
|
|
pdoc->RemoveWatcher(this, 0);
|
2013-08-28 00:44:27 +00:00
|
|
|
DropGraphics(true);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::Finalise() {
|
|
|
|
SetIdle(false);
|
|
|
|
CancelModes();
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::SetRepresentations() {
|
|
|
|
reprs.Clear();
|
|
|
|
|
|
|
|
// C0 control set
|
|
|
|
const char *reps[] = {
|
|
|
|
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
|
|
|
|
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
|
|
|
|
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
|
|
|
|
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
|
|
|
|
};
|
|
|
|
for (size_t j=0; j < ELEMENTS(reps); j++) {
|
|
|
|
char c[2] = { static_cast<char>(j), 0 };
|
|
|
|
reprs.SetRepresentation(c, reps[j]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// C1 control set
|
|
|
|
// As well as Unicode mode, ISO-8859-1 should use these
|
|
|
|
if (IsUnicodeMode()) {
|
|
|
|
const char *repsC1[] = {
|
|
|
|
"PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA",
|
|
|
|
"HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3",
|
|
|
|
"DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA",
|
|
|
|
"SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC"
|
|
|
|
};
|
|
|
|
for (size_t j=0; j < ELEMENTS(repsC1); j++) {
|
|
|
|
char c1[3] = { '\xc2', static_cast<char>(0x80+j), 0 };
|
|
|
|
reprs.SetRepresentation(c1, repsC1[j]);
|
|
|
|
}
|
|
|
|
reprs.SetRepresentation("\xe2\x80\xa8", "LS");
|
|
|
|
reprs.SetRepresentation("\xe2\x80\xa9", "PS");
|
|
|
|
}
|
|
|
|
|
|
|
|
// UTF-8 invalid bytes
|
|
|
|
if (IsUnicodeMode()) {
|
|
|
|
for (int k=0x80; k < 0x100; k++) {
|
|
|
|
char hiByte[2] = { static_cast<char>(k), 0 };
|
|
|
|
char hexits[4];
|
|
|
|
sprintf(hexits, "x%2X", k);
|
|
|
|
reprs.SetRepresentation(hiByte, hexits);
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::DropGraphics(bool freeObjects) {
|
|
|
|
marginView.DropGraphics(freeObjects);
|
|
|
|
view.DropGraphics(freeObjects);
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::AllocateGraphics() {
|
2015-06-07 21:19:26 +00:00
|
|
|
marginView.AllocateGraphics(vs);
|
|
|
|
view.AllocateGraphics(vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::InvalidateStyleData() {
|
|
|
|
stylesValid = false;
|
2013-08-28 00:44:27 +00:00
|
|
|
vs.technology = technology;
|
|
|
|
DropGraphics(false);
|
|
|
|
AllocateGraphics();
|
2015-06-07 21:19:26 +00:00
|
|
|
view.llc.Invalidate(LineLayout::llInvalid);
|
|
|
|
view.posCache.Clear();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::InvalidateStyleRedraw() {
|
|
|
|
NeedWrapping();
|
|
|
|
InvalidateStyleData();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::RefreshStyleData() {
|
|
|
|
if (!stylesValid) {
|
|
|
|
stylesValid = true;
|
|
|
|
AutoSurface surface(this);
|
|
|
|
if (surface) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.Refresh(*surface, pdoc->tabInChars);
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
2009-08-23 02:24:48 +00:00
|
|
|
SetRectangularRange();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
Point Editor::GetVisibleOriginInMain() const {
|
2013-08-28 00:44:27 +00:00
|
|
|
return Point(0,0);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
Point Editor::DocumentPointFromView(Point ptView) const {
|
2013-08-28 00:44:27 +00:00
|
|
|
Point ptDocument = ptView;
|
|
|
|
if (wMargin.GetID()) {
|
|
|
|
Point ptOrigin = GetVisibleOriginInMain();
|
|
|
|
ptDocument.x += ptOrigin.x;
|
|
|
|
ptDocument.y += ptOrigin.y;
|
|
|
|
} else {
|
|
|
|
ptDocument.x += xOffset;
|
|
|
|
ptDocument.y += topLine * vs.lineHeight;
|
|
|
|
}
|
|
|
|
return ptDocument;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::TopLineOfMain() const {
|
|
|
|
if (wMargin.GetID())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return topLine;
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
PRectangle Editor::GetClientRectangle() const {
|
|
|
|
Window &win = const_cast<Window &>(wMain);
|
|
|
|
return win.GetClientPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
PRectangle Editor::GetClientDrawingRectangle() {
|
|
|
|
return GetClientRectangle();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
PRectangle Editor::GetTextRectangle() const {
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rc = GetClientRectangle();
|
2013-08-28 00:44:27 +00:00
|
|
|
rc.left += vs.textStart;
|
2009-04-24 23:35:41 +00:00
|
|
|
rc.right -= vs.rightMarginWidth;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
int Editor::LinesOnScreen() const {
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcClient = GetClientRectangle();
|
2015-06-07 21:19:26 +00:00
|
|
|
int htClient = static_cast<int>(rcClient.bottom - rcClient.top);
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1);
|
|
|
|
return htClient / vs.lineHeight;
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
int Editor::LinesToScroll() const {
|
2009-04-24 23:35:41 +00:00
|
|
|
int retVal = LinesOnScreen() - 1;
|
|
|
|
if (retVal < 1)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
int Editor::MaxScrollPos() const {
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("Lines %d screen = %d maxScroll = %d\n",
|
|
|
|
//LinesTotal(), LinesOnScreen(), LinesTotal() - LinesOnScreen() + 1);
|
|
|
|
int retVal = cs.LinesDisplayed();
|
|
|
|
if (endAtLastLine) {
|
|
|
|
retVal -= LinesOnScreen();
|
|
|
|
} else {
|
|
|
|
retVal--;
|
|
|
|
}
|
|
|
|
if (retVal < 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const {
|
|
|
|
if (sp.Position() < 0) {
|
|
|
|
return SelectionPosition(0);
|
|
|
|
} else if (sp.Position() > pdoc->Length()) {
|
|
|
|
return SelectionPosition(pdoc->Length());
|
|
|
|
} else {
|
|
|
|
// If not at end of line then set offset to 0
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!pdoc->IsLineEndPosition(sp.Position()))
|
2009-08-23 02:24:48 +00:00
|
|
|
sp.SetVirtualSpace(0);
|
|
|
|
return sp;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
Point Editor::LocationFromPosition(SelectionPosition pos) {
|
2009-04-24 23:35:41 +00:00
|
|
|
RefreshStyleData();
|
|
|
|
AutoSurface surface(this);
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.LocationFromPosition(surface, *this, pos, topLine, vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
Point Editor::LocationFromPosition(int pos) {
|
|
|
|
return LocationFromPosition(SelectionPosition(pos));
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
int Editor::XFromPosition(int pos) {
|
|
|
|
Point pt = LocationFromPosition(pos);
|
2015-06-07 21:19:26 +00:00
|
|
|
return static_cast<int>(pt.x) - vs.textStart + xOffset;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int Editor::XFromPosition(SelectionPosition sp) {
|
|
|
|
Point pt = LocationFromPosition(sp);
|
2015-06-07 21:19:26 +00:00
|
|
|
return static_cast<int>(pt.x) - vs.textStart + xOffset;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace) {
|
2009-04-24 23:35:41 +00:00
|
|
|
RefreshStyleData();
|
2015-06-07 21:19:26 +00:00
|
|
|
AutoSurface surface(this);
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
if (canReturnInvalid) {
|
|
|
|
PRectangle rcClient = GetTextRectangle();
|
2015-06-07 21:19:26 +00:00
|
|
|
// May be in scroll view coordinates so translate back to main view
|
|
|
|
Point ptOrigin = GetVisibleOriginInMain();
|
|
|
|
rcClient.Move(-ptOrigin.x, -ptOrigin.y);
|
2009-08-23 02:24:48 +00:00
|
|
|
if (!rcClient.Contains(pt))
|
|
|
|
return SelectionPosition(INVALID_POSITION);
|
2013-08-28 00:44:27 +00:00
|
|
|
if (pt.x < vs.textStart)
|
2009-08-23 02:24:48 +00:00
|
|
|
return SelectionPosition(INVALID_POSITION);
|
|
|
|
if (pt.y < 0)
|
|
|
|
return SelectionPosition(INVALID_POSITION);
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
pt = DocumentPointFromView(pt);
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.SPositionFromLocation(surface, *this, pt, canReturnInvalid, charPosition, virtualSpace, vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) {
|
|
|
|
return SPositionFromLocation(pt, canReturnInvalid, charPosition, false).Position();
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
2015-06-07 21:19:26 +00:00
|
|
|
* Find the document position corresponding to an x coordinate on a particular document line.
|
|
|
|
* Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
|
|
|
|
* This method is used for rectangular selections and does not work on wrapped lines.
|
|
|
|
*/
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) {
|
2009-04-24 23:35:41 +00:00
|
|
|
RefreshStyleData();
|
|
|
|
if (lineDoc >= pdoc->LinesTotal())
|
2009-08-23 02:24:48 +00:00
|
|
|
return SelectionPosition(pdoc->Length());
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine);
|
|
|
|
AutoSurface surface(this);
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.SPositionFromLineX(surface, *this, lineDoc, x, vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int Editor::PositionFromLineX(int lineDoc, int x) {
|
|
|
|
return SPositionFromLineX(lineDoc, x).Position();
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
int Editor::LineFromLocation(Point pt) const {
|
|
|
|
return cs.DocFromDisplay(static_cast<int>(pt.y) / vs.lineHeight + topLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetTopLine(int topLineNew) {
|
|
|
|
if ((topLine != topLineNew) && (topLineNew >= 0)) {
|
|
|
|
topLine = topLineNew;
|
|
|
|
ContainerNeedsUpdate(SC_UPDATE_V_SCROLL);
|
|
|
|
}
|
|
|
|
posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine));
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* If painting then abandon the painting because a wider redraw is needed.
|
|
|
|
* @return true if calling code should stop drawing.
|
|
|
|
*/
|
|
|
|
bool Editor::AbandonPaint() {
|
|
|
|
if ((paintState == painting) && !paintingAllText) {
|
|
|
|
paintState = paintAbandoned;
|
|
|
|
}
|
|
|
|
return paintState == paintAbandoned;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::RedrawRect(PRectangle rc) {
|
|
|
|
//Platform::DebugPrintf("Redraw %0d,%0d - %0d,%0d\n", rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
|
|
|
|
// Clip the redraw rectangle into the client area
|
|
|
|
PRectangle rcClient = GetClientRectangle();
|
|
|
|
if (rc.top < rcClient.top)
|
|
|
|
rc.top = rcClient.top;
|
|
|
|
if (rc.bottom > rcClient.bottom)
|
|
|
|
rc.bottom = rcClient.bottom;
|
|
|
|
if (rc.left < rcClient.left)
|
|
|
|
rc.left = rcClient.left;
|
|
|
|
if (rc.right > rcClient.right)
|
|
|
|
rc.right = rcClient.right;
|
|
|
|
|
|
|
|
if ((rc.bottom > rc.top) && (rc.right > rc.left)) {
|
|
|
|
wMain.InvalidateRectangle(rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::DiscardOverdraw() {
|
|
|
|
// Overridden on platforms that may draw outside visible area.
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::Redraw() {
|
|
|
|
//Platform::DebugPrintf("Redraw all\n");
|
|
|
|
PRectangle rcClient = GetClientRectangle();
|
|
|
|
wMain.InvalidateRectangle(rcClient);
|
2013-08-28 00:44:27 +00:00
|
|
|
if (wMargin.GetID())
|
|
|
|
wMargin.InvalidateAll();
|
2009-04-24 23:35:41 +00:00
|
|
|
//wMain.InvalidateAll();
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::RedrawSelMargin(int line, bool allAfter) {
|
2015-06-07 21:19:26 +00:00
|
|
|
bool abandonDraw = false;
|
|
|
|
if (!wMargin.GetID()) // Margin in main window so may need to abandon and retry
|
|
|
|
abandonDraw = AbandonPaint();
|
|
|
|
if (!abandonDraw) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (vs.maskInLine) {
|
|
|
|
Redraw();
|
|
|
|
} else {
|
|
|
|
PRectangle rcSelMargin = GetClientRectangle();
|
2013-08-28 00:44:27 +00:00
|
|
|
rcSelMargin.right = rcSelMargin.left + vs.fixedColumnWidth;
|
2009-04-24 23:35:41 +00:00
|
|
|
if (line != -1) {
|
2015-06-07 21:19:26 +00:00
|
|
|
PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)), 0);
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
// Inflate line rectangle if there are image markers with height larger than line height
|
|
|
|
if (vs.largestMarkerHeight > vs.lineHeight) {
|
|
|
|
int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2;
|
|
|
|
rcLine.top -= delta;
|
|
|
|
rcLine.bottom += delta;
|
|
|
|
if (rcLine.top < rcSelMargin.top)
|
|
|
|
rcLine.top = rcSelMargin.top;
|
|
|
|
if (rcLine.bottom > rcSelMargin.bottom)
|
|
|
|
rcLine.bottom = rcSelMargin.bottom;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
rcSelMargin.top = rcLine.top;
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!allAfter)
|
|
|
|
rcSelMargin.bottom = rcLine.bottom;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (rcSelMargin.Empty())
|
|
|
|
return;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
if (wMargin.GetID()) {
|
|
|
|
Point ptOrigin = GetVisibleOriginInMain();
|
|
|
|
rcSelMargin.Move(-ptOrigin.x, -ptOrigin.y);
|
|
|
|
wMargin.InvalidateRectangle(rcSelMargin);
|
|
|
|
} else {
|
|
|
|
wMain.InvalidateRectangle(rcSelMargin);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
PRectangle Editor::RectangleFromRange(Range r, int overlap) {
|
|
|
|
const int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(r.First()));
|
|
|
|
const int maxLine = cs.DisplayLastFromDoc(pdoc->LineFromPosition(r.Last()));
|
|
|
|
const PRectangle rcClientDrawing = GetClientDrawingRectangle();
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rc;
|
2013-08-28 00:44:27 +00:00
|
|
|
const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
rc.left = static_cast<XYPOSITION>(vs.textStart - leftTextOverlap);
|
|
|
|
rc.top = static_cast<XYPOSITION>((minLine - TopLineOfMain()) * vs.lineHeight - overlap);
|
|
|
|
if (rc.top < rcClientDrawing.top)
|
|
|
|
rc.top = rcClientDrawing.top;
|
|
|
|
// Extend to right of prepared area if any to prevent artifacts from caret line highlight
|
|
|
|
rc.right = rcClientDrawing.right;
|
|
|
|
rc.bottom = static_cast<XYPOSITION>((maxLine - TopLineOfMain() + 1) * vs.lineHeight + overlap);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::InvalidateRange(int start, int end) {
|
2015-06-07 21:19:26 +00:00
|
|
|
RedrawRect(RectangleFromRange(Range(start, end), view.LinesOverlap() ? vs.lineOverlap : 0));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int Editor::CurrentPosition() const {
|
2009-08-23 02:24:48 +00:00
|
|
|
return sel.MainCaret();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
bool Editor::SelectionEmpty() const {
|
2009-08-23 02:24:48 +00:00
|
|
|
return sel.Empty();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition Editor::SelectionStart() {
|
|
|
|
return sel.RangeMain().Start();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition Editor::SelectionEnd() {
|
|
|
|
return sel.RangeMain().End();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetRectangularRange() {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.IsRectangular()) {
|
|
|
|
int xAnchor = XFromPosition(sel.Rectangular().anchor);
|
|
|
|
int xCaret = XFromPosition(sel.Rectangular().caret);
|
|
|
|
if (sel.selType == Selection::selThin) {
|
|
|
|
xCaret = xAnchor;
|
|
|
|
}
|
2011-03-22 00:16:49 +00:00
|
|
|
int lineAnchorRect = pdoc->LineFromPosition(sel.Rectangular().anchor.Position());
|
2009-08-23 02:24:48 +00:00
|
|
|
int lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position());
|
2011-03-22 00:16:49 +00:00
|
|
|
int increment = (lineCaret > lineAnchorRect) ? 1 : -1;
|
|
|
|
for (int line=lineAnchorRect; line != lineCaret+increment; line += increment) {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionRange range(SPositionFromLineX(line, xCaret), SPositionFromLineX(line, xAnchor));
|
|
|
|
if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0)
|
|
|
|
range.ClearVirtualSpace();
|
2011-03-22 00:16:49 +00:00
|
|
|
if (line == lineAnchorRect)
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.SetSelection(range);
|
|
|
|
else
|
2011-03-22 00:16:49 +00:00
|
|
|
sel.AddSelectionWithoutTrim(range);
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::ThinRectangularRange() {
|
|
|
|
if (sel.IsRectangular()) {
|
|
|
|
sel.selType = Selection::selThin;
|
|
|
|
if (sel.Rectangular().caret < sel.Rectangular().anchor) {
|
|
|
|
sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).caret, sel.Range(0).anchor);
|
|
|
|
} else {
|
|
|
|
sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).anchor, sel.Range(0).caret);
|
|
|
|
}
|
|
|
|
SetRectangularRange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection) {
|
|
|
|
if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
invalidateWholeSelection = true;
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
int firstAffected = Platform::Minimum(sel.RangeMain().Start().Position(), newMain.Start().Position());
|
|
|
|
// +1 for lastAffected ensures caret repainted
|
|
|
|
int lastAffected = Platform::Maximum(newMain.caret.Position()+1, newMain.anchor.Position());
|
|
|
|
lastAffected = Platform::Maximum(lastAffected, sel.RangeMain().End().Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (invalidateWholeSelection) {
|
2009-08-23 02:24:48 +00:00
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
firstAffected = Platform::Minimum(firstAffected, sel.Range(r).caret.Position());
|
|
|
|
firstAffected = Platform::Minimum(firstAffected, sel.Range(r).anchor.Position());
|
|
|
|
lastAffected = Platform::Maximum(lastAffected, sel.Range(r).caret.Position()+1);
|
|
|
|
lastAffected = Platform::Maximum(lastAffected, sel.Range(r).anchor.Position());
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2011-03-22 00:16:49 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateRange(firstAffected, lastAffected);
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
|
2010-08-21 23:59:56 +00:00
|
|
|
currentPos_ = ClampPositionIntoDocument(currentPos_);
|
|
|
|
anchor_ = ClampPositionIntoDocument(anchor_);
|
2011-07-17 22:30:49 +00:00
|
|
|
int currentLine = pdoc->LineFromPosition(currentPos_.Position());
|
2010-08-21 23:59:56 +00:00
|
|
|
/* For Line selection - ensure the anchor and caret are always
|
|
|
|
at the beginning and end of the region lines. */
|
|
|
|
if (sel.selType == Selection::selLines) {
|
|
|
|
if (currentPos_ > anchor_) {
|
|
|
|
anchor_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(anchor_.Position())));
|
|
|
|
currentPos_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(currentPos_.Position())));
|
|
|
|
} else {
|
|
|
|
currentPos_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(currentPos_.Position())));
|
|
|
|
anchor_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(anchor_.Position())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SelectionRange rangeNew(currentPos_, anchor_);
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
|
|
|
|
InvalidateSelection(rangeNew);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.RangeMain() = rangeNew;
|
2009-04-24 23:35:41 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
ClaimSelection();
|
2015-06-07 21:19:26 +00:00
|
|
|
SetHoverIndicatorPosition(sel.MainCaret());
|
2011-07-17 22:30:49 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
|
2011-07-17 22:30:49 +00:00
|
|
|
RedrawSelMargin();
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
QueueIdleWork(WorkNeeded::workUpdateUI);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::SetSelection(int currentPos_, int anchor_) {
|
|
|
|
SetSelection(SelectionPosition(currentPos_), SelectionPosition(anchor_));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Just move the caret on the main selection
|
|
|
|
void Editor::SetSelection(SelectionPosition currentPos_) {
|
|
|
|
currentPos_ = ClampPositionIntoDocument(currentPos_);
|
2011-07-17 22:30:49 +00:00
|
|
|
int currentLine = pdoc->LineFromPosition(currentPos_.Position());
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) {
|
|
|
|
InvalidateSelection(SelectionRange(currentPos_));
|
|
|
|
}
|
|
|
|
if (sel.IsRectangular()) {
|
|
|
|
sel.Rectangular() =
|
|
|
|
SelectionRange(SelectionPosition(currentPos_), sel.Rectangular().anchor);
|
|
|
|
SetRectangularRange();
|
|
|
|
} else {
|
|
|
|
sel.RangeMain() =
|
|
|
|
SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor);
|
|
|
|
}
|
|
|
|
ClaimSelection();
|
2015-06-07 21:19:26 +00:00
|
|
|
SetHoverIndicatorPosition(sel.MainCaret());
|
2011-07-17 22:30:49 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
|
2011-07-17 22:30:49 +00:00
|
|
|
RedrawSelMargin();
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
QueueIdleWork(WorkNeeded::workUpdateUI);
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::SetSelection(int currentPos_) {
|
2009-08-23 02:24:48 +00:00
|
|
|
SetSelection(SelectionPosition(currentPos_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetEmptySelection(SelectionPosition currentPos_) {
|
2011-07-17 22:30:49 +00:00
|
|
|
int currentLine = pdoc->LineFromPosition(currentPos_.Position());
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_));
|
|
|
|
if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
|
|
|
|
InvalidateSelection(rangeNew);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
|
|
|
sel.RangeMain() = rangeNew;
|
2009-04-24 23:35:41 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
ClaimSelection();
|
2015-06-07 21:19:26 +00:00
|
|
|
SetHoverIndicatorPosition(sel.MainCaret());
|
2009-08-23 02:24:48 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
|
2011-07-17 22:30:49 +00:00
|
|
|
RedrawSelMargin();
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
QueueIdleWork(WorkNeeded::workUpdateUI);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetEmptySelection(int currentPos_) {
|
2009-08-23 02:24:48 +00:00
|
|
|
SetEmptySelection(SelectionPosition(currentPos_));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::RangeContainsProtected(int start, int end) const {
|
|
|
|
if (vs.ProtectionActive()) {
|
|
|
|
if (start > end) {
|
|
|
|
int t = start;
|
|
|
|
start = end;
|
|
|
|
end = t;
|
|
|
|
}
|
|
|
|
for (int pos = start; pos < end; pos++) {
|
2015-06-07 21:19:26 +00:00
|
|
|
if (vs.styles[pdoc->StyleAt(pos)].IsProtected())
|
2009-04-24 23:35:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::SelectionContainsProtected() {
|
2009-08-23 02:24:48 +00:00
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
2010-07-12 22:19:51 +00:00
|
|
|
if (RangeContainsProtected(sel.Range(r).Start().Position(),
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Range(r).End().Position())) {
|
|
|
|
return true;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
return false;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asks document to find a good position and then moves out of any invisible positions.
|
|
|
|
*/
|
2009-08-23 02:24:48 +00:00
|
|
|
int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) const {
|
|
|
|
return MovePositionOutsideChar(SelectionPosition(pos), moveDir, checkLineEnd).Position();
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd) const {
|
|
|
|
int posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd);
|
|
|
|
if (posMoved != pos.Position())
|
|
|
|
pos.SetPosition(posMoved);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (vs.ProtectionActive()) {
|
|
|
|
if (moveDir > 0) {
|
2015-06-07 21:19:26 +00:00
|
|
|
if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected()) {
|
2009-08-23 02:24:48 +00:00
|
|
|
while ((pos.Position() < pdoc->Length()) &&
|
2015-06-07 21:19:26 +00:00
|
|
|
(vs.styles[pdoc->StyleAt(pos.Position())].IsProtected()))
|
2009-08-23 02:24:48 +00:00
|
|
|
pos.Add(1);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else if (moveDir < 0) {
|
2015-06-07 21:19:26 +00:00
|
|
|
if (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected()) {
|
2009-08-23 02:24:48 +00:00
|
|
|
while ((pos.Position() > 0) &&
|
2015-06-07 21:19:26 +00:00
|
|
|
(vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected()))
|
2009-08-23 02:24:48 +00:00
|
|
|
pos.Add(-1);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) {
|
2010-07-12 22:19:51 +00:00
|
|
|
bool simpleCaret = (sel.Count() == 1) && sel.Empty();
|
|
|
|
SelectionPosition spCaret = sel.Last();
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int delta = newPos.Position() - sel.MainCaret();
|
|
|
|
newPos = ClampPositionIntoDocument(newPos);
|
2009-04-24 23:35:41 +00:00
|
|
|
newPos = MovePositionOutsideChar(newPos, delta);
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) {
|
|
|
|
// Can't turn into multiple selection so clear additional selections
|
|
|
|
InvalidateSelection(SelectionRange(newPos), true);
|
|
|
|
SelectionRange rangeMain = sel.RangeMain();
|
|
|
|
sel.SetSelection(rangeMain);
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
if (!sel.IsRectangular() && (selt == Selection::selRectangle)) {
|
|
|
|
// Switching to rectangular
|
2015-06-07 21:19:26 +00:00
|
|
|
InvalidateSelection(sel.RangeMain(), false);
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionRange rangeMain = sel.RangeMain();
|
|
|
|
sel.Clear();
|
|
|
|
sel.Rectangular() = rangeMain;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
if (selt != Selection::noSel) {
|
|
|
|
sel.selType = selt;
|
|
|
|
}
|
|
|
|
if (selt != Selection::noSel || sel.MoveExtends()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetSelection(newPos);
|
|
|
|
} else {
|
|
|
|
SetEmptySelection(newPos);
|
|
|
|
}
|
|
|
|
ShowCaretAtCurrentPosition();
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
int currentLine = pdoc->LineFromPosition(newPos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (ensureVisible) {
|
2013-08-28 00:44:27 +00:00
|
|
|
// In case in need of wrapping to ensure DisplayFromDoc works.
|
|
|
|
if (currentLine >= wrapPending.start)
|
|
|
|
WrapLines(wsAll);
|
|
|
|
XYScrollPosition newXY = XYScrollToMakeVisible(
|
|
|
|
SelectionRange(posDrag.IsValid() ? posDrag : sel.RangeMain().caret), xysDefault);
|
2010-07-12 22:19:51 +00:00
|
|
|
if (simpleCaret && (newXY.xOffset == xOffset)) {
|
|
|
|
// simple vertical scroll then invalidate
|
|
|
|
ScrollTo(newXY.topLine);
|
|
|
|
InvalidateSelection(SelectionRange(spCaret), true);
|
|
|
|
} else {
|
|
|
|
SetXYScroll(newXY);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2011-07-17 22:30:49 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
|
2011-07-17 22:30:49 +00:00
|
|
|
RedrawSelMargin();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) {
|
|
|
|
return MovePositionTo(SelectionPosition(newPos), selt, ensureVisible);
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) {
|
|
|
|
pos = ClampPositionIntoDocument(pos);
|
2009-04-24 23:35:41 +00:00
|
|
|
pos = MovePositionOutsideChar(pos, moveDir);
|
2009-08-23 02:24:48 +00:00
|
|
|
int lineDoc = pdoc->LineFromPosition(pos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (cs.GetVisible(lineDoc)) {
|
|
|
|
return pos;
|
|
|
|
} else {
|
|
|
|
int lineDisplay = cs.DisplayFromDoc(lineDoc);
|
|
|
|
if (moveDir > 0) {
|
|
|
|
// lineDisplay is already line before fold as lines in fold use display line of line after fold
|
|
|
|
lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
|
2009-08-23 02:24:48 +00:00
|
|
|
return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay)));
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed());
|
2009-08-23 02:24:48 +00:00
|
|
|
return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay)));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition Editor::MovePositionSoVisible(int pos, int moveDir) {
|
|
|
|
return MovePositionSoVisible(SelectionPosition(pos), moveDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
Point Editor::PointMainCaret() {
|
|
|
|
return LocationFromPosition(sel.Range(sel.Main()).caret);
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* Choose the x position that the caret will try to stick to
|
|
|
|
* as it moves up and down.
|
|
|
|
*/
|
|
|
|
void Editor::SetLastXChosen() {
|
2009-08-23 02:24:48 +00:00
|
|
|
Point pt = PointMainCaret();
|
2015-06-07 21:19:26 +00:00
|
|
|
lastXChosen = static_cast<int>(pt.x) + xOffset;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::ScrollTo(int line, bool moveThumb) {
|
|
|
|
int topLineNew = Platform::Clamp(line, 0, MaxScrollPos());
|
|
|
|
if (topLineNew != topLine) {
|
|
|
|
// Try to optimise small scrolls
|
2011-07-17 22:30:49 +00:00
|
|
|
#ifndef UNDER_CE
|
2009-04-24 23:35:41 +00:00
|
|
|
int linesToMove = topLine - topLineNew;
|
2013-08-28 00:44:27 +00:00
|
|
|
bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting);
|
|
|
|
willRedrawAll = !performBlit;
|
2011-07-17 22:30:49 +00:00
|
|
|
#endif
|
2009-04-24 23:35:41 +00:00
|
|
|
SetTopLine(topLineNew);
|
2010-07-12 22:19:51 +00:00
|
|
|
// Optimize by styling the view as this will invalidate any needed area
|
|
|
|
// which could abort the initial paint if discovered later.
|
|
|
|
StyleToPositionInView(PositionAfterArea(GetClientRectangle()));
|
2009-04-24 23:35:41 +00:00
|
|
|
#ifndef UNDER_CE
|
2010-07-12 22:19:51 +00:00
|
|
|
// Perform redraw rather than scroll if many lines would be redrawn anyway.
|
2013-08-28 00:44:27 +00:00
|
|
|
if (performBlit) {
|
2009-04-24 23:35:41 +00:00
|
|
|
ScrollText(linesToMove);
|
|
|
|
} else {
|
|
|
|
Redraw();
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
willRedrawAll = false;
|
2009-04-24 23:35:41 +00:00
|
|
|
#else
|
|
|
|
Redraw();
|
|
|
|
#endif
|
|
|
|
if (moveThumb) {
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::ScrollText(int /* linesToMove */) {
|
|
|
|
//Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove);
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::HorizontalScrollTo(int xPos) {
|
|
|
|
//Platform::DebugPrintf("HorizontalScroll %d\n", xPos);
|
|
|
|
if (xPos < 0)
|
|
|
|
xPos = 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (!Wrapping() && (xOffset != xPos)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
xOffset = xPos;
|
2011-03-22 00:16:49 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetHorizontalScrollPos();
|
|
|
|
RedrawRect(GetClientRectangle());
|
|
|
|
}
|
2011-03-22 00:16:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::VerticalCentreCaret() {
|
|
|
|
int lineDoc = pdoc->LineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret());
|
|
|
|
int lineDisplay = cs.DisplayFromDoc(lineDoc);
|
|
|
|
int newTop = lineDisplay - (LinesOnScreen() / 2);
|
|
|
|
if (topLine != newTop) {
|
|
|
|
SetTopLine(newTop > 0 ? newTop : 0);
|
|
|
|
RedrawRect(GetClientRectangle());
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
// Avoid 64 bit compiler warnings.
|
|
|
|
// Scintilla does not support text buffers larger than 2**31
|
|
|
|
static int istrlen(const char *s) {
|
2015-06-07 21:19:26 +00:00
|
|
|
return static_cast<int>(s ? strlen(s) : 0);
|
2013-08-28 00:44:27 +00:00
|
|
|
}
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
void Editor::MoveSelectedLines(int lineDelta) {
|
|
|
|
|
|
|
|
// if selection doesn't start at the beginning of the line, set the new start
|
|
|
|
int selectionStart = SelectionStart().Position();
|
|
|
|
int startLine = pdoc->LineFromPosition(selectionStart);
|
|
|
|
int beginningOfStartLine = pdoc->LineStart(startLine);
|
|
|
|
selectionStart = beginningOfStartLine;
|
|
|
|
|
|
|
|
// if selection doesn't end at the beginning of a line greater than that of the start,
|
|
|
|
// then set it at the beginning of the next one
|
|
|
|
int selectionEnd = SelectionEnd().Position();
|
|
|
|
int endLine = pdoc->LineFromPosition(selectionEnd);
|
|
|
|
int beginningOfEndLine = pdoc->LineStart(endLine);
|
2013-08-28 00:44:27 +00:00
|
|
|
bool appendEol = false;
|
2011-07-17 22:30:49 +00:00
|
|
|
if (selectionEnd > beginningOfEndLine
|
|
|
|
|| selectionStart == selectionEnd) {
|
|
|
|
selectionEnd = pdoc->LineStart(endLine + 1);
|
2013-08-28 00:44:27 +00:00
|
|
|
appendEol = (selectionEnd == pdoc->Length() && pdoc->LineFromPosition(selectionEnd) == endLine);
|
2011-07-17 22:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if there's nowhere for the selection to move
|
|
|
|
// (i.e. at the beginning going up or at the end going down),
|
|
|
|
// stop it right there!
|
|
|
|
if ((selectionStart == 0 && lineDelta < 0)
|
|
|
|
|| (selectionEnd == pdoc->Length() && lineDelta > 0)
|
|
|
|
|| selectionStart == selectionEnd) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
UndoGroup ug(pdoc);
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
if (lineDelta > 0 && selectionEnd == pdoc->LineStart(pdoc->LinesTotal() - 1)) {
|
|
|
|
SetSelection(pdoc->MovePositionOutsideChar(selectionEnd - 1, -1), selectionEnd);
|
|
|
|
ClearSelection();
|
|
|
|
selectionEnd = CurrentPosition();
|
|
|
|
}
|
2011-07-17 22:30:49 +00:00
|
|
|
SetSelection(selectionStart, selectionEnd);
|
|
|
|
|
|
|
|
SelectionText selectedText;
|
|
|
|
CopySelectionRange(&selectedText);
|
|
|
|
|
|
|
|
int selectionLength = SelectionRange(selectionStart, selectionEnd).Length();
|
|
|
|
Point currentLocation = LocationFromPosition(CurrentPosition());
|
|
|
|
int currentLine = LineFromLocation(currentLocation);
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
if (appendEol)
|
|
|
|
SetSelection(pdoc->MovePositionOutsideChar(selectionStart - 1, -1), selectionEnd);
|
|
|
|
ClearSelection();
|
|
|
|
|
|
|
|
const char *eol = StringFromEOLMode(pdoc->eolMode);
|
|
|
|
if (currentLine + lineDelta >= pdoc->LinesTotal())
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->InsertString(pdoc->Length(), eol, istrlen(eol));
|
2011-07-17 22:30:49 +00:00
|
|
|
GoToLine(currentLine + lineDelta);
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectionLength);
|
2013-08-28 00:44:27 +00:00
|
|
|
if (appendEol) {
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, istrlen(eol));
|
|
|
|
selectionLength += lengthInserted;
|
2013-08-28 00:44:27 +00:00
|
|
|
}
|
2011-07-17 22:30:49 +00:00
|
|
|
SetSelection(CurrentPosition(), CurrentPosition() + selectionLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::MoveSelectedLinesUp() {
|
|
|
|
MoveSelectedLines(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::MoveSelectedLinesDown() {
|
|
|
|
MoveSelectedLines(1);
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::MoveCaretInsideView(bool ensureVisible) {
|
|
|
|
PRectangle rcClient = GetTextRectangle();
|
2009-08-23 02:24:48 +00:00
|
|
|
Point pt = PointMainCaret();
|
2009-04-24 23:35:41 +00:00
|
|
|
if (pt.y < rcClient.top) {
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(SPositionFromLocation(
|
2015-06-07 21:19:26 +00:00
|
|
|
Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top)),
|
2013-08-28 00:44:27 +00:00
|
|
|
false, false, UserVirtualSpace()),
|
2009-08-23 02:24:48 +00:00
|
|
|
Selection::noSel, ensureVisible);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
|
2015-06-07 21:19:26 +00:00
|
|
|
int yOfLastLineFullyDisplayed = static_cast<int>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight;
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(SPositionFromLocation(
|
2015-06-07 21:19:26 +00:00
|
|
|
Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed),
|
2013-08-28 00:44:27 +00:00
|
|
|
false, false, UserVirtualSpace()),
|
2009-08-23 02:24:48 +00:00
|
|
|
Selection::noSel, ensureVisible);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::DisplayFromPosition(int pos) {
|
|
|
|
AutoSurface surface(this);
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.DisplayFromPosition(surface, *this, pos, vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure the caret is reasonably visible in context.
|
|
|
|
*
|
|
|
|
Caret policy in SciTE
|
|
|
|
|
|
|
|
If slop is set, we can define a slop value.
|
|
|
|
This value defines an unwanted zone (UZ) where the caret is... unwanted.
|
|
|
|
This zone is defined as a number of pixels near the vertical margins,
|
|
|
|
and as a number of lines near the horizontal margins.
|
|
|
|
By keeping the caret away from the edges, it is seen within its context,
|
|
|
|
so it is likely that the identifier that the caret is on can be completely seen,
|
|
|
|
and that the current line is seen with some of the lines following it which are
|
|
|
|
often dependent on that line.
|
|
|
|
|
|
|
|
If strict is set, the policy is enforced... strictly.
|
|
|
|
The caret is centred on the display if slop is not set,
|
|
|
|
and cannot go in the UZ if slop is set.
|
|
|
|
|
|
|
|
If jumps is set, the display is moved more energetically
|
|
|
|
so the caret can move in the same direction longer before the policy is applied again.
|
|
|
|
'3UZ' notation is used to indicate three time the size of the UZ as a distance to the margin.
|
|
|
|
|
|
|
|
If even is not set, instead of having symmetrical UZs,
|
|
|
|
the left and bottom UZs are extended up to right and top UZs respectively.
|
2015-06-07 21:19:26 +00:00
|
|
|
This way, we favour the displaying of useful information: the beginning of lines,
|
2009-04-24 23:35:41 +00:00
|
|
|
where most code reside, and the lines after the caret, eg. the body of a function.
|
|
|
|
|
|
|
|
| | | | |
|
2009-08-23 02:24:48 +00:00
|
|
|
slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of
|
2009-04-24 23:35:41 +00:00
|
|
|
| | | | | visibility or going into the UZ) display is...
|
|
|
|
-----+--------+-------+------+--------------------------------------------+--------------------------------------------------------------
|
|
|
|
0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right
|
|
|
|
0 | 0 | 0 | 1 | Yes | moved by one position
|
|
|
|
0 | 0 | 1 | 0 | Yes | moved to put caret on top/on right
|
|
|
|
0 | 0 | 1 | 1 | Yes | centred on the caret
|
|
|
|
0 | 1 | - | 0 | Caret is always on top/on right of display | -
|
|
|
|
0 | 1 | - | 1 | No, caret is always centred | -
|
|
|
|
1 | 0 | 0 | 0 | Yes | moved to put caret out of the asymmetrical UZ
|
|
|
|
1 | 0 | 0 | 1 | Yes | moved to put caret out of the UZ
|
|
|
|
1 | 0 | 1 | 0 | Yes | moved to put caret at 3UZ of the top or right margin
|
|
|
|
1 | 0 | 1 | 1 | Yes | moved to put caret at 3UZ of the margin
|
|
|
|
1 | 1 | - | 0 | Caret is always at UZ of top/right margin | -
|
|
|
|
1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position
|
|
|
|
1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin
|
|
|
|
*/
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &range, const XYScrollOptions options) {
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcClient = GetTextRectangle();
|
2013-08-28 00:44:27 +00:00
|
|
|
Point pt = LocationFromPosition(range.caret);
|
|
|
|
Point ptAnchor = LocationFromPosition(range.anchor);
|
|
|
|
const Point ptOrigin = GetVisibleOriginInMain();
|
|
|
|
pt.x += ptOrigin.x;
|
|
|
|
pt.y += ptOrigin.y;
|
|
|
|
ptAnchor.x += ptOrigin.x;
|
|
|
|
ptAnchor.y += ptOrigin.y;
|
2010-07-12 22:19:51 +00:00
|
|
|
const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1);
|
|
|
|
|
|
|
|
XYScrollPosition newXY(xOffset, topLine);
|
2013-08-28 00:44:27 +00:00
|
|
|
if (rcClient.Empty()) {
|
|
|
|
return newXY;
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// Vertical positioning
|
2013-08-28 00:44:27 +00:00
|
|
|
if ((options & xysVertical) && (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) {
|
|
|
|
const int lineCaret = DisplayFromPosition(range.caret.Position());
|
2010-07-12 22:19:51 +00:00
|
|
|
const int linesOnScreen = LinesOnScreen();
|
|
|
|
const int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2;
|
|
|
|
const bool bSlop = (caretYPolicy & CARET_SLOP) != 0;
|
|
|
|
const bool bStrict = (caretYPolicy & CARET_STRICT) != 0;
|
|
|
|
const bool bJump = (caretYPolicy & CARET_JUMPS) != 0;
|
|
|
|
const bool bEven = (caretYPolicy & CARET_EVEN) != 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// It should be possible to scroll the window to show the caret,
|
|
|
|
// but this fails to remove the caret on GTK+
|
|
|
|
if (bSlop) { // A margin is defined
|
|
|
|
int yMoveT, yMoveB;
|
|
|
|
if (bStrict) {
|
|
|
|
int yMarginT, yMarginB;
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!(options & xysUseMargin)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
// In drag mode, avoid moves
|
|
|
|
// otherwise, a double click will select several lines.
|
|
|
|
yMarginT = yMarginB = 0;
|
|
|
|
} else {
|
|
|
|
// yMarginT must equal to caretYSlop, with a minimum of 1 and
|
|
|
|
// a maximum of slightly less than half the heigth of the text area.
|
|
|
|
yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen);
|
|
|
|
if (bEven) {
|
|
|
|
yMarginB = yMarginT;
|
|
|
|
} else {
|
|
|
|
yMarginB = linesOnScreen - yMarginT - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
yMoveT = yMarginT;
|
|
|
|
if (bEven) {
|
|
|
|
if (bJump) {
|
|
|
|
yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen);
|
|
|
|
}
|
|
|
|
yMoveB = yMoveT;
|
|
|
|
} else {
|
|
|
|
yMoveB = linesOnScreen - yMoveT - 1;
|
|
|
|
}
|
|
|
|
if (lineCaret < topLine + yMarginT) {
|
|
|
|
// Caret goes too high
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret - yMoveT;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) {
|
|
|
|
// Caret goes too low
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else { // Not strict
|
|
|
|
yMoveT = bJump ? caretYSlop * 3 : caretYSlop;
|
|
|
|
yMoveT = Platform::Clamp(yMoveT, 1, halfScreen);
|
|
|
|
if (bEven) {
|
|
|
|
yMoveB = yMoveT;
|
|
|
|
} else {
|
|
|
|
yMoveB = linesOnScreen - yMoveT - 1;
|
|
|
|
}
|
|
|
|
if (lineCaret < topLine) {
|
|
|
|
// Caret goes too high
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret - yMoveT;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else if (lineCaret > topLine + linesOnScreen - 1) {
|
|
|
|
// Caret goes too low
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { // No slop
|
|
|
|
if (!bStrict && !bJump) {
|
|
|
|
// Minimal move
|
|
|
|
if (lineCaret < topLine) {
|
|
|
|
// Caret goes too high
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else if (lineCaret > topLine + linesOnScreen - 1) {
|
|
|
|
// Caret goes too low
|
|
|
|
if (bEven) {
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret - linesOnScreen + 1;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { // Strict or going out of display
|
|
|
|
if (bEven) {
|
|
|
|
// Always center caret
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret - halfScreen;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
// Always put caret on top of display
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = lineCaret;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!(range.caret == range.anchor)) {
|
|
|
|
const int lineAnchor = DisplayFromPosition(range.anchor.Position());
|
|
|
|
if (lineAnchor < lineCaret) {
|
|
|
|
// Shift up to show anchor or as much of range as possible
|
|
|
|
newXY.topLine = std::min(newXY.topLine, lineAnchor);
|
|
|
|
newXY.topLine = std::max(newXY.topLine, lineCaret - LinesOnScreen());
|
|
|
|
} else {
|
|
|
|
// Shift down to show anchor or as much of range as possible
|
|
|
|
newXY.topLine = std::max(newXY.topLine, lineAnchor - LinesOnScreen());
|
|
|
|
newXY.topLine = std::min(newXY.topLine, lineCaret);
|
|
|
|
}
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Horizontal positioning
|
2015-06-07 21:19:26 +00:00
|
|
|
if ((options & xysHorizontal) && !Wrapping()) {
|
|
|
|
const int halfScreen = Platform::Maximum(static_cast<int>(rcClient.Width()) - 4, 4) / 2;
|
2010-07-12 22:19:51 +00:00
|
|
|
const bool bSlop = (caretXPolicy & CARET_SLOP) != 0;
|
|
|
|
const bool bStrict = (caretXPolicy & CARET_STRICT) != 0;
|
|
|
|
const bool bJump = (caretXPolicy & CARET_JUMPS) != 0;
|
|
|
|
const bool bEven = (caretXPolicy & CARET_EVEN) != 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
if (bSlop) { // A margin is defined
|
|
|
|
int xMoveL, xMoveR;
|
|
|
|
if (bStrict) {
|
|
|
|
int xMarginL, xMarginR;
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!(options & xysUseMargin)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
// In drag mode, avoid moves unless very near of the margin
|
|
|
|
// otherwise, a simple click will select text.
|
|
|
|
xMarginL = xMarginR = 2;
|
|
|
|
} else {
|
|
|
|
// xMargin must equal to caretXSlop, with a minimum of 2 and
|
|
|
|
// a maximum of slightly less than half the width of the text area.
|
|
|
|
xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen);
|
|
|
|
if (bEven) {
|
|
|
|
xMarginL = xMarginR;
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
xMarginL = static_cast<int>(rcClient.Width()) - xMarginR - 4;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bJump && bEven) {
|
|
|
|
// Jump is used only in even mode
|
|
|
|
xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen);
|
|
|
|
} else {
|
|
|
|
xMoveL = xMoveR = 0; // Not used, avoid a warning
|
|
|
|
}
|
|
|
|
if (pt.x < rcClient.left + xMarginL) {
|
|
|
|
// Caret is on the left of the display
|
|
|
|
if (bJump && bEven) {
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.xOffset -= xMoveL;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
// Move just enough to allow to display the caret
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset -= static_cast<int>((rcClient.left + xMarginL) - pt.x);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else if (pt.x >= rcClient.right - xMarginR) {
|
|
|
|
// Caret is on the right of the display
|
|
|
|
if (bJump && bEven) {
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.xOffset += xMoveR;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
// Move just enough to allow to display the caret
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset += static_cast<int>(pt.x - (rcClient.right - xMarginR) + 1);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { // Not strict
|
|
|
|
xMoveR = bJump ? caretXSlop * 3 : caretXSlop;
|
|
|
|
xMoveR = Platform::Clamp(xMoveR, 1, halfScreen);
|
|
|
|
if (bEven) {
|
|
|
|
xMoveL = xMoveR;
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
xMoveL = static_cast<int>(rcClient.Width()) - xMoveR - 4;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
if (pt.x < rcClient.left) {
|
|
|
|
// Caret is on the left of the display
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.xOffset -= xMoveL;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else if (pt.x >= rcClient.right) {
|
|
|
|
// Caret is on the right of the display
|
2010-07-12 22:19:51 +00:00
|
|
|
newXY.xOffset += xMoveR;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { // No slop
|
|
|
|
if (bStrict ||
|
|
|
|
(bJump && (pt.x < rcClient.left || pt.x >= rcClient.right))) {
|
|
|
|
// Strict or going out of display
|
|
|
|
if (bEven) {
|
|
|
|
// Center caret
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset += static_cast<int>(pt.x - rcClient.left - halfScreen);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
// Put caret on right
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset += static_cast<int>(pt.x - rcClient.right + 1);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Move just enough to allow to display the caret
|
|
|
|
if (pt.x < rcClient.left) {
|
|
|
|
// Caret is on the left of the display
|
|
|
|
if (bEven) {
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset -= static_cast<int>(rcClient.left - pt.x);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else if (pt.x >= rcClient.right) {
|
|
|
|
// Caret is on the right of the display
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// In case of a jump (find result) largely out of display, adjust the offset to display the caret
|
2010-07-12 22:19:51 +00:00
|
|
|
if (pt.x + xOffset < rcClient.left + newXY.xOffset) {
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 2;
|
2010-07-12 22:19:51 +00:00
|
|
|
} else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) {
|
2015-06-07 21:19:26 +00:00
|
|
|
newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 2;
|
|
|
|
if ((vs.caretStyle == CARETSTYLE_BLOCK) || view.imeCaretBlockOverride) {
|
2009-04-24 23:35:41 +00:00
|
|
|
// Ensure we can see a good portion of the block caret
|
2013-08-28 00:44:27 +00:00
|
|
|
newXY.xOffset += static_cast<int>(vs.aveCharWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(range.caret == range.anchor)) {
|
|
|
|
if (ptAnchor.x < pt.x) {
|
|
|
|
// Shift to left to show anchor or as much of range as possible
|
2015-06-07 21:19:26 +00:00
|
|
|
int maxOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.left) - 1;
|
|
|
|
int minOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 1;
|
2013-08-28 00:44:27 +00:00
|
|
|
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
|
|
|
|
newXY.xOffset = std::max(newXY.xOffset, minOffset);
|
|
|
|
} else {
|
|
|
|
// Shift to right to show anchor or as much of range as possible
|
2015-06-07 21:19:26 +00:00
|
|
|
int minOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.right) + 1;
|
|
|
|
int maxOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 1;
|
2013-08-28 00:44:27 +00:00
|
|
|
newXY.xOffset = std::max(newXY.xOffset, minOffset);
|
|
|
|
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
if (newXY.xOffset < 0) {
|
|
|
|
newXY.xOffset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return newXY;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetXYScroll(XYScrollPosition newXY) {
|
|
|
|
if ((newXY.topLine != topLine) || (newXY.xOffset != xOffset)) {
|
|
|
|
if (newXY.topLine != topLine) {
|
|
|
|
SetTopLine(newXY.topLine);
|
|
|
|
SetVerticalScrollPos();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
if (newXY.xOffset != xOffset) {
|
|
|
|
xOffset = newXY.xOffset;
|
2011-03-22 00:16:49 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
|
2010-07-12 22:19:51 +00:00
|
|
|
if (newXY.xOffset > 0) {
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcText = GetTextRectangle();
|
|
|
|
if (horizontalScrollBarVisible &&
|
2010-07-12 22:19:51 +00:00
|
|
|
rcText.Width() + xOffset > scrollWidth) {
|
2015-06-07 21:19:26 +00:00
|
|
|
scrollWidth = xOffset + static_cast<int>(rcText.Width());
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetHorizontalScrollPos();
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
Redraw();
|
|
|
|
UpdateSystemCaret();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::ScrollRange(SelectionRange range) {
|
|
|
|
SetXYScroll(XYScrollToMakeVisible(range, xysDefault));
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
|
2013-08-28 00:44:27 +00:00
|
|
|
SetXYScroll(XYScrollToMakeVisible(SelectionRange(posDrag.IsValid() ? posDrag : sel.RangeMain().caret),
|
|
|
|
static_cast<XYScrollOptions>((useMargin?xysUseMargin:0)|(vert?xysVertical:0)|(horiz?xysHorizontal:0))));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::ShowCaretAtCurrentPosition() {
|
|
|
|
if (hasFocus) {
|
|
|
|
caret.active = true;
|
|
|
|
caret.on = true;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickCaret);
|
|
|
|
if (caret.period > 0)
|
|
|
|
FineTickerStart(tickCaret, caret.period, caret.period/10);
|
|
|
|
} else {
|
|
|
|
SetTicking(true);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
caret.active = false;
|
|
|
|
caret.on = false;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickCaret);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
InvalidateCaret();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::DropCaret() {
|
|
|
|
caret.active = false;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickCaret);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateCaret();
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::CaretSetPeriod(int period) {
|
|
|
|
if (caret.period != period) {
|
|
|
|
caret.period = period;
|
|
|
|
caret.on = true;
|
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickCaret);
|
|
|
|
if ((caret.active) && (caret.period > 0))
|
|
|
|
FineTickerStart(tickCaret, caret.period, caret.period/10);
|
|
|
|
}
|
|
|
|
InvalidateCaret();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::InvalidateCaret() {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (posDrag.IsValid()) {
|
|
|
|
InvalidateRange(posDrag.Position(), posDrag.Position() + 1);
|
|
|
|
} else {
|
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
InvalidateRange(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1);
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
UpdateSystemCaret();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::UpdateSystemCaret() {
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
bool Editor::Wrapping() const {
|
|
|
|
return vs.wrapState != eWrapNone;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::NeedWrapping(int docLineStart, int docLineEnd) {
|
2013-08-28 00:44:27 +00:00
|
|
|
//Platform::DebugPrintf("\nNeedWrapping: %0d..%0d\n", docLineStart, docLineEnd);
|
|
|
|
if (wrapPending.AddRange(docLineStart, docLineEnd)) {
|
2015-06-07 21:19:26 +00:00
|
|
|
view.llc.Invalidate(LineLayout::llPositions);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
// Wrap lines during idle.
|
2015-06-07 21:19:26 +00:00
|
|
|
if (Wrapping() && wrapPending.NeedsWrap()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetIdle(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
|
2015-06-07 21:19:26 +00:00
|
|
|
AutoLineLayout ll(view.llc, view.RetrieveLineLayout(lineToWrap, *this));
|
2009-04-24 23:35:41 +00:00
|
|
|
int linesWrapped = 1;
|
|
|
|
if (ll) {
|
2015-06-07 21:19:26 +00:00
|
|
|
view.LayoutLine(*this, lineToWrap, surface, vs, ll, wrapWidth);
|
2009-04-24 23:35:41 +00:00
|
|
|
linesWrapped = ll->lines;
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
return cs.SetHeight(lineToWrap, linesWrapped +
|
2009-06-24 19:09:31 +00:00
|
|
|
(vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
// Perform wrapping for a subset of the lines needing wrapping.
|
|
|
|
// wsAll: wrap all lines which need wrapping in this single call
|
|
|
|
// wsVisible: wrap currently visible lines
|
|
|
|
// wsIdle: wrap one page + 100 lines
|
2009-04-24 23:35:41 +00:00
|
|
|
// Return true if wrapping occurred.
|
2013-08-28 00:44:27 +00:00
|
|
|
bool Editor::WrapLines(enum wrapScope ws) {
|
2009-04-24 23:35:41 +00:00
|
|
|
int goodTopLine = topLine;
|
|
|
|
bool wrapOccurred = false;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (!Wrapping()) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (wrapWidth != LineLayout::wrapWidthInfinite) {
|
|
|
|
wrapWidth = LineLayout::wrapWidthInfinite;
|
|
|
|
for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) {
|
|
|
|
cs.SetHeight(lineDoc, 1 +
|
|
|
|
(vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0));
|
|
|
|
}
|
|
|
|
wrapOccurred = true;
|
|
|
|
}
|
|
|
|
wrapPending.Reset();
|
|
|
|
|
|
|
|
} else if (wrapPending.NeedsWrap()) {
|
|
|
|
wrapPending.start = std::min(wrapPending.start, pdoc->LinesTotal());
|
|
|
|
if (!SetIdle(true)) {
|
|
|
|
// Idle processing not supported so full wrap required.
|
|
|
|
ws = wsAll;
|
|
|
|
}
|
|
|
|
// Decide where to start wrapping
|
|
|
|
int lineToWrap = wrapPending.start;
|
|
|
|
int lineToWrapEnd = std::min(wrapPending.end, pdoc->LinesTotal());
|
|
|
|
const int lineDocTop = cs.DocFromDisplay(topLine);
|
|
|
|
const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);
|
|
|
|
if (ws == wsVisible) {
|
|
|
|
lineToWrap = Platform::Clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());
|
|
|
|
// Priority wrap to just after visible area.
|
|
|
|
// Since wrapping could reduce display lines, treat each
|
|
|
|
// as taking only one display line.
|
|
|
|
lineToWrapEnd = lineDocTop;
|
|
|
|
int lines = LinesOnScreen() + 1;
|
|
|
|
while ((lineToWrapEnd < cs.LinesInDoc()) && (lines>0)) {
|
|
|
|
if (cs.GetVisible(lineToWrapEnd))
|
|
|
|
lines--;
|
|
|
|
lineToWrapEnd++;
|
|
|
|
}
|
|
|
|
// .. and if the paint window is outside pending wraps
|
|
|
|
if ((lineToWrap > wrapPending.end) || (lineToWrapEnd < wrapPending.start)) {
|
|
|
|
// Currently visible text does not need wrapping
|
|
|
|
return false;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
} else if (ws == wsIdle) {
|
|
|
|
lineToWrapEnd = lineToWrap + LinesOnScreen() + 100;
|
|
|
|
}
|
|
|
|
const int lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal());
|
|
|
|
lineToWrapEnd = std::min(lineToWrapEnd, lineEndNeedWrap);
|
|
|
|
|
|
|
|
// Ensure all lines being wrapped are styled.
|
|
|
|
pdoc->EnsureStyledTo(pdoc->LineStart(lineToWrapEnd));
|
|
|
|
|
|
|
|
if (lineToWrap < lineToWrapEnd) {
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcTextArea = GetClientRectangle();
|
2015-06-07 21:19:26 +00:00
|
|
|
rcTextArea.left = static_cast<XYPOSITION>(vs.textStart);
|
2009-04-24 23:35:41 +00:00
|
|
|
rcTextArea.right -= vs.rightMarginWidth;
|
2015-06-07 21:19:26 +00:00
|
|
|
wrapWidth = static_cast<int>(rcTextArea.Width());
|
2009-04-24 23:35:41 +00:00
|
|
|
RefreshStyleData();
|
|
|
|
AutoSurface surface(this);
|
|
|
|
if (surface) {
|
2013-08-28 00:44:27 +00:00
|
|
|
//Platform::DebugPrintf("Wraplines: scope=%0d need=%0d..%0d perform=%0d..%0d\n", ws, wrapPending.start, wrapPending.end, lineToWrap, lineToWrapEnd);
|
2010-08-21 23:59:56 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
while (lineToWrap < lineToWrapEnd) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (WrapOneLine(surface, lineToWrap)) {
|
|
|
|
wrapOccurred = true;
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
wrapPending.Wrapped(lineToWrap);
|
2009-04-24 23:35:41 +00:00
|
|
|
lineToWrap++;
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
goodTopLine = cs.DisplayFromDoc(lineDocTop) + std::min(subLineTop, cs.GetHeight(lineDocTop)-1);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If wrapping is done, bring it to resting position
|
|
|
|
if (wrapPending.start >= lineEndNeedWrap) {
|
|
|
|
wrapPending.Reset();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
if (wrapOccurred) {
|
|
|
|
SetScrollBars();
|
|
|
|
SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos()));
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
return wrapOccurred;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::LinesJoin() {
|
|
|
|
if (!RangeContainsProtected(targetStart, targetEnd)) {
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2009-04-24 23:35:41 +00:00
|
|
|
bool prevNonWS = true;
|
|
|
|
for (int pos = targetStart; pos < targetEnd; pos++) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (pdoc->IsPositionInLineEnd(pos)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
targetEnd -= pdoc->LenChar(pos);
|
|
|
|
pdoc->DelChar(pos);
|
|
|
|
if (prevNonWS) {
|
|
|
|
// Ensure at least one space separating previous lines
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(pos, " ", 1);
|
|
|
|
targetEnd += lengthInserted;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
prevNonWS = pdoc->CharAt(pos) != ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Editor::StringFromEOLMode(int eolMode) {
|
|
|
|
if (eolMode == SC_EOL_CRLF) {
|
|
|
|
return "\r\n";
|
|
|
|
} else if (eolMode == SC_EOL_CR) {
|
|
|
|
return "\r";
|
|
|
|
} else {
|
|
|
|
return "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::LinesSplit(int pixelWidth) {
|
|
|
|
if (!RangeContainsProtected(targetStart, targetEnd)) {
|
|
|
|
if (pixelWidth == 0) {
|
|
|
|
PRectangle rcText = GetTextRectangle();
|
2015-06-07 21:19:26 +00:00
|
|
|
pixelWidth = static_cast<int>(rcText.Width());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
int lineStart = pdoc->LineFromPosition(targetStart);
|
|
|
|
int lineEnd = pdoc->LineFromPosition(targetEnd);
|
|
|
|
const char *eol = StringFromEOLMode(pdoc->eolMode);
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2009-04-24 23:35:41 +00:00
|
|
|
for (int line = lineStart; line <= lineEnd; line++) {
|
|
|
|
AutoSurface surface(this);
|
2015-06-07 21:19:26 +00:00
|
|
|
AutoLineLayout ll(view.llc, view.RetrieveLineLayout(line, *this));
|
2009-04-24 23:35:41 +00:00
|
|
|
if (surface && ll) {
|
|
|
|
unsigned int posLineStart = pdoc->LineStart(line);
|
2015-06-07 21:19:26 +00:00
|
|
|
view.LayoutLine(*this, line, surface, vs, ll, pixelWidth);
|
|
|
|
int lengthInsertedTotal = 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
for (int subLine = 1; subLine < ll->lines; subLine++) {
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(
|
|
|
|
static_cast<int>(posLineStart + lengthInsertedTotal +
|
2013-08-28 00:44:27 +00:00
|
|
|
ll->LineStart(subLine)),
|
2015-06-07 21:19:26 +00:00
|
|
|
eol, istrlen(eol));
|
|
|
|
targetEnd += lengthInserted;
|
|
|
|
lengthInsertedTotal += lengthInserted;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lineEnd = pdoc->LineFromPosition(targetEnd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
|
|
|
|
if (vs.fixedColumnWidth == 0)
|
|
|
|
return;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
AllocateGraphics();
|
|
|
|
RefreshStyleData();
|
|
|
|
RefreshPixMaps(surfWindow);
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
// On GTK+ with Ubuntu overlay scroll bars, the surface may have been finished
|
|
|
|
// at this point. The Initialised call checks for this case and sets the status
|
|
|
|
// to be bad which avoids crashes in following calls.
|
|
|
|
if (!surfWindow->Initialised()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcMargin = GetClientRectangle();
|
2013-08-28 00:44:27 +00:00
|
|
|
Point ptOrigin = GetVisibleOriginInMain();
|
|
|
|
rcMargin.Move(0, -ptOrigin.y);
|
|
|
|
rcMargin.left = 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
rcMargin.right = static_cast<XYPOSITION>(vs.fixedColumnWidth);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
if (!rc.Intersects(rcMargin))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Surface *surface;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (view.bufferedDraw) {
|
|
|
|
surface = marginView.pixmapSelMargin;
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
surface = surfWindow;
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
// Clip vertically to paint area to avoid drawing line numbers
|
|
|
|
if (rcMargin.bottom > rc.bottom)
|
|
|
|
rcMargin.bottom = rc.bottom;
|
|
|
|
if (rcMargin.top < rc.top)
|
|
|
|
rcMargin.top = rc.top;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
marginView.PaintMargin(surface, topLine, rc, rcMargin, *this, vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (view.bufferedDraw) {
|
|
|
|
surfWindow->Copy(rcMargin, Point(rcMargin.left, rcMargin.top), *marginView.pixmapSelMargin);
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::RefreshPixMaps(Surface *surfaceWindow) {
|
|
|
|
view.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs);
|
|
|
|
marginView.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs);
|
|
|
|
if (view.bufferedDraw) {
|
|
|
|
PRectangle rcClient = GetClientRectangle();
|
|
|
|
if (!view.pixmapLine->Initialised()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
view.pixmapLine->InitPixMap(static_cast<int>(rcClient.Width()), vs.lineHeight,
|
|
|
|
surfaceWindow, wMain.GetID());
|
|
|
|
}
|
|
|
|
if (!marginView.pixmapSelMargin->Initialised()) {
|
|
|
|
marginView.pixmapSelMargin->InitPixMap(vs.fixedColumnWidth,
|
|
|
|
static_cast<int>(rcClient.Height()), surfaceWindow, wMain.GetID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
|
|
|
//Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n",
|
|
|
|
// paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
|
|
|
|
AllocateGraphics();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
RefreshStyleData();
|
|
|
|
if (paintState == paintAbandoned)
|
|
|
|
return; // Scroll bars may have changed so need redraw
|
|
|
|
RefreshPixMaps(surfaceWindow);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
paintAbandonedByStyling = false;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
StyleToPositionInView(PositionAfterArea(rcArea));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
PRectangle rcClient = GetClientRectangle();
|
|
|
|
//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n",
|
|
|
|
// rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (NotifyUpdateUI()) {
|
|
|
|
RefreshStyleData();
|
|
|
|
RefreshPixMaps(surfaceWindow);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
// Wrap the visible lines if needed.
|
|
|
|
if (WrapLines(wsVisible)) {
|
|
|
|
// The wrapping process has changed the height of some lines so
|
|
|
|
// abandon this paint for a complete repaint.
|
|
|
|
if (AbandonPaint()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
RefreshPixMaps(surfaceWindow); // In case pixmaps invalidated by scrollbar change
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
PLATFORM_ASSERT(marginView.pixmapSelPattern->Initialised());
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (!view.bufferedDraw)
|
|
|
|
surfaceWindow->SetClip(rcArea);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (paintState != paintAbandoned) {
|
|
|
|
if (vs.marginInside) {
|
|
|
|
PaintSelMargin(surfaceWindow, rcArea);
|
|
|
|
PRectangle rcRightMargin = rcClient;
|
|
|
|
rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
|
|
|
|
if (rcArea.Intersects(rcRightMargin)) {
|
|
|
|
surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
} else { // Else separate view so separate paint event but leftMargin included to allow overlap
|
|
|
|
PRectangle rcLeftMargin = rcArea;
|
|
|
|
rcLeftMargin.left = 0;
|
|
|
|
rcLeftMargin.right = rcLeftMargin.left + vs.leftMarginWidth;
|
|
|
|
if (rcArea.Intersects(rcLeftMargin)) {
|
|
|
|
surfaceWindow->FillRectangle(rcLeftMargin, vs.styles[STYLE_DEFAULT].back);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
if (paintState == paintAbandoned) {
|
|
|
|
// Either styling or NotifyUpdateUI noticed that painting is needed
|
|
|
|
// outside the current painting rectangle
|
|
|
|
//Platform::DebugPrintf("Abandoning paint\n");
|
|
|
|
if (Wrapping()) {
|
|
|
|
if (paintAbandonedByStyling) {
|
|
|
|
// Styling has spilled over a line end, such as occurs by starting a multiline
|
|
|
|
// comment. The width of subsequent text may have changed, so rewrap.
|
|
|
|
NeedWrapping(cs.DocFromDisplay(topLine));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
view.PaintText(surfaceWindow, *this, rcArea, rcClient, vs);
|
|
|
|
|
|
|
|
if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) {
|
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
scrollWidth = view.lineWidthMaxSeen;
|
|
|
|
if (!FineTickerRunning(tickWiden)) {
|
|
|
|
FineTickerStart(tickWiden, 50, 5);
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
NotifyPainted();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is mostly copied from the Paint method but with some things omitted
|
|
|
|
// such as the margin markers, line numbers, selection and caret
|
|
|
|
// Should be merged back into a combined Draw method.
|
2009-08-23 02:24:48 +00:00
|
|
|
long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (!pfr)
|
|
|
|
return 0;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
AutoSurface surface(pfr->hdc, this, SC_TECHNOLOGY_DEFAULT);
|
|
|
|
if (!surface)
|
|
|
|
return 0;
|
|
|
|
AutoSurface surfaceMeasure(pfr->hdcTarget, this, SC_TECHNOLOGY_DEFAULT);
|
|
|
|
if (!surfaceMeasure) {
|
|
|
|
return 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.FormatRange(draw, pfr, surface, surfaceMeasure, *this, vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::TextWidth(int style, const char *text) {
|
|
|
|
RefreshStyleData();
|
|
|
|
AutoSurface surface(this);
|
|
|
|
if (surface) {
|
2015-06-07 21:19:26 +00:00
|
|
|
return static_cast<int>(surface->WidthText(vs.styles[style].font, text, istrlen(text)));
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Empty method is overridden on GTK+ to show / hide scrollbars
|
|
|
|
void Editor::ReconfigureScrollBars() {}
|
|
|
|
|
|
|
|
void Editor::SetScrollBars() {
|
|
|
|
RefreshStyleData();
|
|
|
|
|
|
|
|
int nMax = MaxScrollPos();
|
|
|
|
int nPage = LinesOnScreen();
|
|
|
|
bool modified = ModifyScrollBars(nMax + nPage - 1, nPage);
|
|
|
|
if (modified) {
|
|
|
|
DwellEnd(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: ensure always showing as many lines as possible
|
|
|
|
// May not be, if, for example, window made larger
|
|
|
|
if (topLine > MaxScrollPos()) {
|
|
|
|
SetTopLine(Platform::Clamp(topLine, 0, MaxScrollPos()));
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
if (modified) {
|
|
|
|
if (!AbandonPaint())
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
//Platform::DebugPrintf("end max = %d page = %d\n", nMax, nPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::ChangeSize() {
|
2013-08-28 00:44:27 +00:00
|
|
|
DropGraphics(false);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
2015-06-07 21:19:26 +00:00
|
|
|
if (Wrapping()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcTextArea = GetClientRectangle();
|
2015-06-07 21:19:26 +00:00
|
|
|
rcTextArea.left = static_cast<XYPOSITION>(vs.textStart);
|
2009-04-24 23:35:41 +00:00
|
|
|
rcTextArea.right -= vs.rightMarginWidth;
|
|
|
|
if (wrapWidth != rcTextArea.Width()) {
|
|
|
|
NeedWrapping();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int Editor::InsertSpace(int position, unsigned int spaces) {
|
|
|
|
if (spaces > 0) {
|
|
|
|
std::string spaceText(spaces, ' ');
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(position, spaceText.c_str(), spaces);
|
|
|
|
position += lengthInserted;
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::AddChar(char ch) {
|
|
|
|
char s[2];
|
|
|
|
s[0] = ch;
|
|
|
|
s[1] = '\0';
|
|
|
|
AddCharUTF(s, 1);
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::FilterSelections() {
|
|
|
|
if (!additionalSelectionTyping && (sel.Count() > 1)) {
|
|
|
|
SelectionRange rangeOnly = sel.RangeMain();
|
|
|
|
InvalidateSelection(rangeOnly, true);
|
|
|
|
sel.SetSelection(rangeOnly);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
static bool cmpSelPtrs(const SelectionRange *a, const SelectionRange *b) {
|
|
|
|
return *a < *b;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
// AddCharUTF inserts an array of bytes which may or may not be in UTF-8.
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
|
2009-08-23 02:24:48 +00:00
|
|
|
FilterSelections();
|
|
|
|
{
|
|
|
|
UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike);
|
2011-07-17 22:30:49 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
// Vector elements point into selection in order to change selection.
|
2011-07-17 22:30:49 +00:00
|
|
|
std::vector<SelectionRange *> selPtrs;
|
|
|
|
for (size_t r = 0; r < sel.Count(); r++) {
|
|
|
|
selPtrs.push_back(&sel.Range(r));
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
// Order selections by position in document.
|
2011-07-17 22:30:49 +00:00
|
|
|
std::sort(selPtrs.begin(), selPtrs.end(), cmpSelPtrs);
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
// Loop in reverse to avoid disturbing positions of selections yet to be processed.
|
2011-07-17 22:30:49 +00:00
|
|
|
for (std::vector<SelectionRange *>::reverse_iterator rit = selPtrs.rbegin();
|
|
|
|
rit != selPtrs.rend(); ++rit) {
|
|
|
|
SelectionRange *currentSel = *rit;
|
|
|
|
if (!RangeContainsProtected(currentSel->Start().Position(),
|
|
|
|
currentSel->End().Position())) {
|
|
|
|
int positionInsert = currentSel->Start().Position();
|
|
|
|
if (!currentSel->Empty()) {
|
|
|
|
if (currentSel->Length()) {
|
|
|
|
pdoc->DeleteChars(positionInsert, currentSel->Length());
|
|
|
|
currentSel->ClearVirtualSpace();
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
|
|
|
// Range is all virtual so collapse to start of virtual space
|
2011-07-17 22:30:49 +00:00
|
|
|
currentSel->MinimizeVirtualSpace();
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
|
|
|
} else if (inOverstrike) {
|
|
|
|
if (positionInsert < pdoc->Length()) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!pdoc->IsPositionInLineEnd(positionInsert)) {
|
2009-08-23 02:24:48 +00:00
|
|
|
pdoc->DelChar(positionInsert);
|
2011-07-17 22:30:49 +00:00
|
|
|
currentSel->ClearVirtualSpace();
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-17 22:30:49 +00:00
|
|
|
positionInsert = InsertSpace(positionInsert, currentSel->caret.VirtualSpace());
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(positionInsert, s, len);
|
|
|
|
if (lengthInserted > 0) {
|
|
|
|
currentSel->caret.SetPosition(positionInsert + lengthInserted);
|
|
|
|
currentSel->anchor.SetPosition(positionInsert + lengthInserted);
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2011-07-17 22:30:49 +00:00
|
|
|
currentSel->ClearVirtualSpace();
|
2009-08-23 02:24:48 +00:00
|
|
|
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
|
2015-06-07 21:19:26 +00:00
|
|
|
if (Wrapping()) {
|
2009-08-23 02:24:48 +00:00
|
|
|
AutoSurface surface(this);
|
|
|
|
if (surface) {
|
2010-07-12 22:19:51 +00:00
|
|
|
if (WrapOneLine(surface, pdoc->LineFromPosition(positionInsert))) {
|
|
|
|
SetScrollBars();
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
Redraw();
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
if (Wrapping()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
ThinRectangularRange();
|
2009-08-23 02:24:48 +00:00
|
|
|
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
|
2009-04-24 23:35:41 +00:00
|
|
|
EnsureCaretVisible();
|
|
|
|
// Avoid blinking during rapid typing:
|
|
|
|
ShowCaretAtCurrentPosition();
|
2010-08-21 23:59:56 +00:00
|
|
|
if ((caretSticky == SC_CARETSTICKY_OFF) ||
|
|
|
|
((caretSticky == SC_CARETSTICKY_WHITESPACE) && !IsAllSpacesOrTabs(s, len))) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (treatAsDBCS) {
|
|
|
|
NotifyChar((static_cast<unsigned char>(s[0]) << 8) |
|
|
|
|
static_cast<unsigned char>(s[1]));
|
2013-08-28 00:44:27 +00:00
|
|
|
} else if (len > 0) {
|
2009-04-24 23:35:41 +00:00
|
|
|
int byte = static_cast<unsigned char>(s[0]);
|
|
|
|
if ((byte < 0xC0) || (1 == len)) {
|
|
|
|
// Handles UTF-8 characters between 0x01 and 0x7F and single byte
|
|
|
|
// characters when not in UTF-8 mode.
|
|
|
|
// Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
|
|
|
|
// characters representing themselves.
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
unsigned int utf32[1] = { 0 };
|
|
|
|
UTF32FromUTF8(s, len, utf32, ELEMENTS(utf32));
|
|
|
|
byte = utf32[0];
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
NotifyChar(byte);
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
|
|
|
|
if (recordingMacro) {
|
|
|
|
NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(s));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::FillVirtualSpace() {
|
|
|
|
const bool tmpOverstrike = inOverstrike;
|
|
|
|
inOverstrike = false; // not allow to be deleted twice.
|
|
|
|
AddCharUTF("", 0);
|
|
|
|
inOverstrike = tmpOverstrike;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::InsertPaste(const char *text, int len) {
|
2010-07-12 22:19:51 +00:00
|
|
|
if (multiPasteMode == SC_MULTIPASTE_ONCE) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SelectionPosition selStart = sel.Start();
|
2010-07-12 22:19:51 +00:00
|
|
|
selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace()));
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
|
|
|
|
if (lengthInserted > 0) {
|
|
|
|
SetEmptySelection(selStart.Position() + lengthInserted);
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// SC_MULTIPASTE_EACH
|
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
|
|
|
|
sel.Range(r).End().Position())) {
|
|
|
|
int positionInsert = sel.Range(r).Start().Position();
|
|
|
|
if (!sel.Range(r).Empty()) {
|
|
|
|
if (sel.Range(r).Length()) {
|
|
|
|
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
|
|
|
|
sel.Range(r).ClearVirtualSpace();
|
|
|
|
} else {
|
|
|
|
// Range is all virtual so collapse to start of virtual space
|
|
|
|
sel.Range(r).MinimizeVirtualSpace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(positionInsert, text, len);
|
|
|
|
if (lengthInserted > 0) {
|
|
|
|
sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
|
|
|
|
sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted);
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
sel.Range(r).ClearVirtualSpace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::InsertPasteShape(const char *text, int len, PasteShape shape) {
|
|
|
|
std::string convertedText;
|
|
|
|
if (convertPastes) {
|
|
|
|
// Convert line endings of the paste into our local line-endings mode
|
|
|
|
convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode);
|
|
|
|
len = static_cast<int>(convertedText.length());
|
|
|
|
text = convertedText.c_str();
|
|
|
|
}
|
|
|
|
if (shape == pasteRectangular) {
|
|
|
|
PasteRectangular(sel.Start(), text, len);
|
|
|
|
} else {
|
|
|
|
if (shape == pasteLine) {
|
|
|
|
int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()));
|
|
|
|
int lengthInserted = pdoc->InsertString(insertPos, text, len);
|
|
|
|
// add the newline if necessary
|
|
|
|
if ((len > 0) && (text[len - 1] != '\n' && text[len - 1] != '\r')) {
|
|
|
|
const char *endline = StringFromEOLMode(pdoc->eolMode);
|
|
|
|
int length = static_cast<int>(strlen(endline));
|
|
|
|
lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline, length);
|
|
|
|
}
|
|
|
|
if (sel.MainCaret() == insertPos) {
|
|
|
|
SetEmptySelection(sel.MainCaret() + lengthInserted);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
InsertPaste(text, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
void Editor::ClearSelection(bool retainMultipleSelections) {
|
|
|
|
if (!sel.IsRectangular() && !retainMultipleSelections)
|
2009-08-23 02:24:48 +00:00
|
|
|
FilterSelections();
|
|
|
|
UndoGroup ug(pdoc);
|
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
if (!sel.Range(r).Empty()) {
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Range(r).End().Position())) {
|
2010-07-12 22:19:51 +00:00
|
|
|
pdoc->DeleteChars(sel.Range(r).Start().Position(),
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Range(r).Length());
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(r) = SelectionRange(sel.Range(r).Start());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
ThinRectangularRange();
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.RemoveDuplicates();
|
|
|
|
ClaimSelection();
|
2015-06-07 21:19:26 +00:00
|
|
|
SetHoverIndicatorPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::ClearAll() {
|
2009-08-23 02:24:48 +00:00
|
|
|
{
|
|
|
|
UndoGroup ug(pdoc);
|
|
|
|
if (0 != pdoc->Length()) {
|
|
|
|
pdoc->DeleteChars(0, pdoc->Length());
|
|
|
|
}
|
|
|
|
if (!pdoc->IsReadOnly()) {
|
|
|
|
cs.Clear();
|
|
|
|
pdoc->AnnotationClearAll();
|
|
|
|
pdoc->MarginClearAll();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
view.ClearAllTabstops();
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
2009-04-24 23:35:41 +00:00
|
|
|
SetTopLine(0);
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::ClearDocumentStyle() {
|
|
|
|
Decoration *deco = pdoc->decorations.root;
|
|
|
|
while (deco) {
|
|
|
|
// Save next in case deco deleted
|
|
|
|
Decoration *decoNext = deco->next;
|
|
|
|
if (deco->indicator < INDIC_CONTAINER) {
|
|
|
|
pdoc->decorations.SetCurrentIndicator(deco->indicator);
|
|
|
|
pdoc->DecorationFillRange(0, 0, pdoc->Length());
|
|
|
|
}
|
|
|
|
deco = decoNext;
|
|
|
|
}
|
|
|
|
pdoc->StartStyling(0, '\377');
|
|
|
|
pdoc->SetStyleFor(pdoc->Length(), 0);
|
|
|
|
cs.ShowAll();
|
2015-06-07 21:19:26 +00:00
|
|
|
SetAnnotationHeights(0, pdoc->LinesTotal());
|
2009-04-24 23:35:41 +00:00
|
|
|
pdoc->ClearLevels();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::CopyAllowLine() {
|
|
|
|
SelectionText selectedText;
|
|
|
|
CopySelectionRange(&selectedText, true);
|
|
|
|
CopyToClipboard(selectedText);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::Cut() {
|
|
|
|
pdoc->CheckReadOnly();
|
|
|
|
if (!pdoc->IsReadOnly() && !SelectionContainsProtected()) {
|
|
|
|
Copy();
|
|
|
|
ClearSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (pdoc->IsReadOnly() || SelectionContainsProtected()) {
|
|
|
|
return;
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
|
|
|
sel.RangeMain() = SelectionRange(pos);
|
|
|
|
int line = pdoc->LineFromPosition(sel.MainCaret());
|
|
|
|
UndoGroup ug(pdoc);
|
|
|
|
sel.RangeMain().caret = SelectionPosition(
|
|
|
|
InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
|
|
|
|
int xInsert = XFromPosition(sel.RangeMain().caret);
|
2009-04-24 23:35:41 +00:00
|
|
|
bool prevCr = false;
|
2009-08-23 02:24:48 +00:00
|
|
|
while ((len > 0) && IsEOLChar(ptr[len-1]))
|
|
|
|
len--;
|
2009-04-24 23:35:41 +00:00
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if (IsEOLChar(ptr[i])) {
|
|
|
|
if ((ptr[i] == '\r') || (!prevCr))
|
|
|
|
line++;
|
|
|
|
if (line >= pdoc->LinesTotal()) {
|
|
|
|
if (pdoc->eolMode != SC_EOL_LF)
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->InsertString(pdoc->Length(), "\r", 1);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (pdoc->eolMode != SC_EOL_CR)
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->InsertString(pdoc->Length(), "\n", 1);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
// Pad the end of lines with spaces if required
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert));
|
|
|
|
if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) {
|
|
|
|
while (XFromPosition(sel.MainCaret()) < xInsert) {
|
2015-06-07 21:19:26 +00:00
|
|
|
assert(pdoc);
|
|
|
|
const int lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1);
|
|
|
|
sel.RangeMain().caret.Add(lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
prevCr = ptr[i] == '\r';
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
|
|
|
|
sel.RangeMain().caret.Add(lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
prevCr = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetEmptySelection(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::CanPaste() {
|
|
|
|
return !pdoc->IsReadOnly() && !SelectionContainsProtected();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::Clear() {
|
2009-08-23 02:24:48 +00:00
|
|
|
// If multiple selections, don't delete EOLS
|
|
|
|
if (sel.Empty()) {
|
2011-07-17 22:30:49 +00:00
|
|
|
bool singleVirtual = false;
|
|
|
|
if ((sel.Count() == 1) &&
|
|
|
|
!RangeContainsProtected(sel.MainCaret(), sel.MainCaret() + 1) &&
|
|
|
|
sel.RangeMain().Start().VirtualSpace()) {
|
|
|
|
singleVirtual = true;
|
|
|
|
}
|
|
|
|
UndoGroup ug(pdoc, (sel.Count() > 1) || singleVirtual);
|
2009-08-23 02:24:48 +00:00
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) {
|
2010-07-12 22:19:51 +00:00
|
|
|
if (sel.Range(r).Start().VirtualSpace()) {
|
|
|
|
if (sel.Range(r).anchor < sel.Range(r).caret)
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(r) = SelectionRange(InsertSpace(sel.Range(r).anchor.Position(), sel.Range(r).anchor.VirtualSpace()));
|
2010-07-12 22:19:51 +00:00
|
|
|
else
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(r) = SelectionRange(InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace()));
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
if ((sel.Count() == 1) || !pdoc->IsPositionInLineEnd(sel.Range(r).caret.Position())) {
|
2009-08-23 02:24:48 +00:00
|
|
|
pdoc->DelChar(sel.Range(r).caret.Position());
|
|
|
|
sel.Range(r).ClearVirtualSpace();
|
|
|
|
} // else multiple selection so don't eat line ends
|
|
|
|
} else {
|
|
|
|
sel.Range(r).ClearVirtualSpace();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ClearSelection();
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.RemoveDuplicates();
|
2015-06-07 21:19:26 +00:00
|
|
|
ShowCaretAtCurrentPosition(); // Avoid blinking
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SelectAll() {
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.Clear();
|
2009-04-24 23:35:41 +00:00
|
|
|
SetSelection(0, pdoc->Length());
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::Undo() {
|
|
|
|
if (pdoc->CanUndo()) {
|
|
|
|
InvalidateCaret();
|
|
|
|
int newPos = pdoc->Undo();
|
|
|
|
if (newPos >= 0)
|
|
|
|
SetEmptySelection(newPos);
|
|
|
|
EnsureCaretVisible();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::Redo() {
|
|
|
|
if (pdoc->CanRedo()) {
|
|
|
|
int newPos = pdoc->Redo();
|
|
|
|
if (newPos >= 0)
|
|
|
|
SetEmptySelection(newPos);
|
|
|
|
EnsureCaretVisible();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::DelCharBack(bool allowLineStartDeletion) {
|
2015-06-07 21:19:26 +00:00
|
|
|
RefreshStyleData();
|
2009-08-23 02:24:48 +00:00
|
|
|
if (!sel.IsRectangular())
|
|
|
|
FilterSelections();
|
|
|
|
if (sel.IsRectangular())
|
|
|
|
allowLineStartDeletion = false;
|
|
|
|
UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty());
|
|
|
|
if (sel.Empty()) {
|
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!RangeContainsProtected(sel.Range(r).caret.Position() - 1, sel.Range(r).caret.Position())) {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.Range(r).caret.VirtualSpace()) {
|
|
|
|
sel.Range(r).caret.SetVirtualSpace(sel.Range(r).caret.VirtualSpace() - 1);
|
|
|
|
sel.Range(r).anchor.SetVirtualSpace(sel.Range(r).caret.VirtualSpace());
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
int lineCurrentPos = pdoc->LineFromPosition(sel.Range(r).caret.Position());
|
|
|
|
if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != sel.Range(r).caret.Position())) {
|
|
|
|
if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) &&
|
|
|
|
pdoc->GetColumn(sel.Range(r).caret.Position()) > 0 && pdoc->backspaceUnindents) {
|
|
|
|
UndoGroup ugInner(pdoc, !ug.Needed());
|
|
|
|
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
|
|
|
|
int indentationStep = pdoc->IndentSize();
|
2015-06-07 21:19:26 +00:00
|
|
|
int indentationChange = indentation % indentationStep;
|
|
|
|
if (indentationChange == 0)
|
|
|
|
indentationChange = indentationStep;
|
|
|
|
const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange);
|
2009-08-23 02:24:48 +00:00
|
|
|
// SetEmptySelection
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(r) = SelectionRange(posSelect);
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
|
|
|
pdoc->DelCharBack(sel.Range(r).caret.Position());
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
|
|
|
sel.Range(r).ClearVirtualSpace();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
ThinRectangularRange();
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
ClearSelection();
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.RemoveDuplicates();
|
2013-08-28 00:44:27 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
|
2009-04-24 23:35:41 +00:00
|
|
|
// Avoid blinking during rapid typing:
|
|
|
|
ShowCaretAtCurrentPosition();
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
int Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta) {
|
|
|
|
return
|
|
|
|
(shift ? SCI_SHIFT : 0) |
|
|
|
|
(ctrl ? SCI_CTRL : 0) |
|
|
|
|
(alt ? SCI_ALT : 0) |
|
|
|
|
(meta ? SCI_META : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyFocus(bool focus) {
|
|
|
|
SCNotification scn = {};
|
|
|
|
scn.nmhdr.code = focus ? SCN_FOCUSIN : SCN_FOCUSOUT;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
void Editor::SetCtrlID(int identifier) {
|
2013-08-28 00:44:27 +00:00
|
|
|
ctrlID = identifier;
|
2011-07-17 22:30:49 +00:00
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::NotifyStyleToNeeded(int endStyleNeeded) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_STYLENEEDED;
|
|
|
|
scn.position = endStyleNeeded;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::NotifyStyleNeeded(Document *, void *, int endStyleNeeded) {
|
2009-04-24 23:35:41 +00:00
|
|
|
NotifyStyleToNeeded(endStyleNeeded);
|
|
|
|
}
|
|
|
|
|
2010-08-21 23:59:56 +00:00
|
|
|
void Editor::NotifyLexerChanged(Document *, void *) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyErrorOccurred(Document *, void *, int status) {
|
|
|
|
errorStatus = status;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::NotifyChar(int ch) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_CHARADDED;
|
|
|
|
scn.ch = ch;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifySavePoint(bool isSavePoint) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
if (isSavePoint) {
|
|
|
|
scn.nmhdr.code = SCN_SAVEPOINTREACHED;
|
|
|
|
} else {
|
|
|
|
scn.nmhdr.code = SCN_SAVEPOINTLEFT;
|
|
|
|
}
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyModifyAttempt() {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_MODIFYATTEMPTRO;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::NotifyDoubleClick(Point pt, int modifiers) {
|
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_DOUBLECLICK;
|
|
|
|
scn.line = LineFromLocation(pt);
|
2009-08-23 02:24:48 +00:00
|
|
|
scn.position = PositionFromLocation(pt, true);
|
2015-06-07 21:19:26 +00:00
|
|
|
scn.modifiers = modifiers;
|
2009-04-24 23:35:41 +00:00
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) {
|
|
|
|
NotifyDoubleClick(pt, ModifierFlags(shift, ctrl, alt));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyHotSpotDoubleClicked(int position, int modifiers) {
|
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK;
|
|
|
|
scn.position = position;
|
2015-06-07 21:19:26 +00:00
|
|
|
scn.modifiers = modifiers;
|
2009-04-24 23:35:41 +00:00
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) {
|
|
|
|
NotifyHotSpotDoubleClicked(position, ModifierFlags(shift, ctrl, alt));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyHotSpotClicked(int position, int modifiers) {
|
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_HOTSPOTCLICK;
|
|
|
|
scn.position = position;
|
2015-06-07 21:19:26 +00:00
|
|
|
scn.modifiers = modifiers;
|
2009-04-24 23:35:41 +00:00
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) {
|
|
|
|
NotifyHotSpotClicked(position, ModifierFlags(shift, ctrl, alt));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyHotSpotReleaseClick(int position, int modifiers) {
|
|
|
|
SCNotification scn = {};
|
2011-03-22 00:16:49 +00:00
|
|
|
scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK;
|
|
|
|
scn.position = position;
|
2015-06-07 21:19:26 +00:00
|
|
|
scn.modifiers = modifiers;
|
2011-03-22 00:16:49 +00:00
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt) {
|
|
|
|
NotifyHotSpotReleaseClick(position, ModifierFlags(shift, ctrl, alt));
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
bool Editor::NotifyUpdateUI() {
|
|
|
|
if (needUpdateUI) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2013-08-28 00:44:27 +00:00
|
|
|
scn.nmhdr.code = SCN_UPDATEUI;
|
|
|
|
scn.updated = needUpdateUI;
|
|
|
|
NotifyParent(scn);
|
|
|
|
needUpdateUI = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyPainted() {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_PAINTED;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::NotifyIndicatorClick(bool click, int position, int modifiers) {
|
2009-04-24 23:35:41 +00:00
|
|
|
int mask = pdoc->decorations.AllOnFor(position);
|
|
|
|
if ((click && mask) || pdoc->decorations.clickNotified) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
pdoc->decorations.clickNotified = click;
|
|
|
|
scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE;
|
2015-06-07 21:19:26 +00:00
|
|
|
scn.modifiers = modifiers;
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.position = position;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) {
|
|
|
|
NotifyIndicatorClick(click, position, ModifierFlags(shift, ctrl, alt));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::NotifyMarginClick(Point pt, int modifiers) {
|
2009-04-24 23:35:41 +00:00
|
|
|
int marginClicked = -1;
|
2013-08-28 00:44:27 +00:00
|
|
|
int x = vs.textStart - vs.fixedColumnWidth;
|
|
|
|
for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
|
|
|
|
if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width))
|
2009-04-24 23:35:41 +00:00
|
|
|
marginClicked = margin;
|
|
|
|
x += vs.ms[margin].width;
|
|
|
|
}
|
|
|
|
if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) {
|
2013-08-28 00:44:27 +00:00
|
|
|
int position = pdoc->LineStart(LineFromLocation(pt));
|
|
|
|
if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) {
|
2015-06-07 21:19:26 +00:00
|
|
|
const bool ctrl = (modifiers & SCI_CTRL) != 0;
|
|
|
|
const bool shift = (modifiers & SCI_SHIFT) != 0;
|
2013-08-28 00:44:27 +00:00
|
|
|
int lineClick = pdoc->LineFromPosition(position);
|
|
|
|
if (shift && ctrl) {
|
|
|
|
FoldAll(SC_FOLDACTION_TOGGLE);
|
|
|
|
} else {
|
|
|
|
int levelClick = pdoc->GetLevel(lineClick);
|
|
|
|
if (levelClick & SC_FOLDLEVELHEADERFLAG) {
|
|
|
|
if (shift) {
|
|
|
|
// Ensure all children visible
|
|
|
|
FoldExpand(lineClick, SC_FOLDACTION_EXPAND, levelClick);
|
|
|
|
} else if (ctrl) {
|
|
|
|
FoldExpand(lineClick, SC_FOLDACTION_TOGGLE, levelClick);
|
|
|
|
} else {
|
|
|
|
// Toggle this line
|
|
|
|
FoldLine(lineClick, SC_FOLDACTION_TOGGLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_MARGINCLICK;
|
2015-06-07 21:19:26 +00:00
|
|
|
scn.modifiers = modifiers;
|
2013-08-28 00:44:27 +00:00
|
|
|
scn.position = position;
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.margin = marginClicked;
|
|
|
|
NotifyParent(scn);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) {
|
|
|
|
return NotifyMarginClick(pt, ModifierFlags(shift, ctrl, alt));
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::NotifyNeedShown(int pos, int len) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_NEEDSHOWN;
|
|
|
|
scn.position = pos;
|
|
|
|
scn.length = len;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyDwelling(Point pt, bool state) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND;
|
2009-08-23 02:24:48 +00:00
|
|
|
scn.position = PositionFromLocation(pt, true);
|
2015-06-07 21:19:26 +00:00
|
|
|
scn.x = static_cast<int>(pt.x + vs.ExternalMarginWidth());
|
|
|
|
scn.y = static_cast<int>(pt.y);
|
2009-04-24 23:35:41 +00:00
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyZoom() {
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_ZOOM;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notifications from document
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::NotifyModifyAttempt(Document *, void *) {
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("** Modify Attempt\n");
|
|
|
|
NotifyModifyAttempt();
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) {
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("** Save Point %s\n", atSavePoint ? "On" : "Off");
|
|
|
|
NotifySavePoint(atSavePoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::CheckModificationForWrap(DocModification mh) {
|
|
|
|
if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
|
2015-06-07 21:19:26 +00:00
|
|
|
view.llc.Invalidate(LineLayout::llCheckTextAndStyle);
|
2013-08-28 00:44:27 +00:00
|
|
|
int lineDoc = pdoc->LineFromPosition(mh.position);
|
|
|
|
int lines = Platform::Maximum(0, mh.linesAdded);
|
2015-06-07 21:19:26 +00:00
|
|
|
if (Wrapping()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
NeedWrapping(lineDoc, lineDoc + lines + 1);
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
RefreshStyleData();
|
2009-06-24 19:09:31 +00:00
|
|
|
// Fix up annotation heights
|
|
|
|
SetAnnotationHeights(lineDoc, lineDoc + lines + 2);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move a position so it is still after the same character as before the insertion.
|
|
|
|
static inline int MovePositionForInsertion(int position, int startInsertion, int length) {
|
|
|
|
if (position > startInsertion) {
|
|
|
|
return position + length;
|
|
|
|
}
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move a position so it is still after the same character as before the deletion if that
|
|
|
|
// character is still present else after the previous surviving character.
|
|
|
|
static inline int MovePositionForDeletion(int position, int startDeletion, int length) {
|
|
|
|
if (position > startDeletion) {
|
|
|
|
int endDeletion = startDeletion + length;
|
|
|
|
if (position > endDeletion) {
|
|
|
|
return position - length;
|
|
|
|
} else {
|
|
|
|
return startDeletion;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::NotifyModified(Document *, DocModification mh, void *) {
|
2011-03-22 00:16:49 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_CONTENT);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (paintState == painting) {
|
|
|
|
CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
|
|
|
|
}
|
|
|
|
if (mh.modificationType & SC_MOD_CHANGELINESTATE) {
|
|
|
|
if (paintState == painting) {
|
|
|
|
CheckForChangeOutsidePaint(
|
|
|
|
Range(pdoc->LineStart(mh.line), pdoc->LineStart(mh.line + 1)));
|
|
|
|
} else {
|
|
|
|
// Could check that change is before last visible line.
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
if (mh.modificationType & SC_MOD_CHANGETABSTOPS) {
|
|
|
|
Redraw();
|
|
|
|
}
|
2010-08-21 23:59:56 +00:00
|
|
|
if (mh.modificationType & SC_MOD_LEXERSTATE) {
|
|
|
|
if (paintState == painting) {
|
|
|
|
CheckForChangeOutsidePaint(
|
|
|
|
Range(mh.position, mh.position + mh.length));
|
|
|
|
} else {
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
if (mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) {
|
|
|
|
if (mh.modificationType & SC_MOD_CHANGESTYLE) {
|
|
|
|
pdoc->IncrementStyleClock();
|
|
|
|
}
|
|
|
|
if (paintState == notPainting) {
|
|
|
|
if (mh.position < pdoc->LineStart(topLine)) {
|
|
|
|
// Styling performed before this view
|
|
|
|
Redraw();
|
|
|
|
} else {
|
|
|
|
InvalidateRange(mh.position, mh.position + mh.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mh.modificationType & SC_MOD_CHANGESTYLE) {
|
2015-06-07 21:19:26 +00:00
|
|
|
view.llc.Invalidate(LineLayout::llCheckTextAndStyle);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Move selection and brace highlights
|
|
|
|
if (mh.modificationType & SC_MOD_INSERTTEXT) {
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.MovePositions(true, mh.position, mh.length);
|
2009-04-24 23:35:41 +00:00
|
|
|
braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length);
|
|
|
|
braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length);
|
|
|
|
} else if (mh.modificationType & SC_MOD_DELETETEXT) {
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.MovePositions(false, mh.position, mh.length);
|
2009-04-24 23:35:41 +00:00
|
|
|
braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length);
|
|
|
|
braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length);
|
|
|
|
}
|
2011-07-17 22:30:49 +00:00
|
|
|
if ((mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) && cs.HiddenLines()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
// Some lines are hidden so may need shown.
|
|
|
|
// TODO: check if the modified area is hidden.
|
|
|
|
if (mh.modificationType & SC_MOD_BEFOREINSERT) {
|
2010-09-05 22:56:27 +00:00
|
|
|
int lineOfPos = pdoc->LineFromPosition(mh.position);
|
|
|
|
bool insertingNewLine = false;
|
|
|
|
for (int i=0; i < mh.length; i++) {
|
|
|
|
if ((mh.text[i] == '\n') || (mh.text[i] == '\r'))
|
|
|
|
insertingNewLine = true;
|
|
|
|
}
|
|
|
|
if (insertingNewLine && (mh.position != pdoc->LineStart(lineOfPos)))
|
2013-08-28 00:44:27 +00:00
|
|
|
NeedShown(mh.position, pdoc->LineStart(lineOfPos+1) - mh.position);
|
2010-09-05 22:56:27 +00:00
|
|
|
else
|
2013-08-28 00:44:27 +00:00
|
|
|
NeedShown(mh.position, 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else if (mh.modificationType & SC_MOD_BEFOREDELETE) {
|
2013-08-28 00:44:27 +00:00
|
|
|
NeedShown(mh.position, mh.length);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mh.linesAdded != 0) {
|
|
|
|
// Update contraction state for inserted and removed lines
|
|
|
|
// lineOfPos should be calculated in context of state before modification, shouldn't it
|
|
|
|
int lineOfPos = pdoc->LineFromPosition(mh.position);
|
2013-08-28 00:44:27 +00:00
|
|
|
if (mh.position > pdoc->LineStart(lineOfPos))
|
|
|
|
lineOfPos++; // Affecting subsequent lines
|
2009-04-24 23:35:41 +00:00
|
|
|
if (mh.linesAdded > 0) {
|
|
|
|
cs.InsertLines(lineOfPos, mh.linesAdded);
|
|
|
|
} else {
|
|
|
|
cs.DeleteLines(lineOfPos, -mh.linesAdded);
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
view.LinesAddedOrRemoved(lineOfPos, mh.linesAdded);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-06-24 19:09:31 +00:00
|
|
|
if (mh.modificationType & SC_MOD_CHANGEANNOTATION) {
|
|
|
|
int lineDoc = pdoc->LineFromPosition(mh.position);
|
|
|
|
if (vs.annotationVisible) {
|
|
|
|
cs.SetHeight(lineDoc, cs.GetHeight(lineDoc) + mh.annotationLinesAdded);
|
2010-08-21 23:59:56 +00:00
|
|
|
Redraw();
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
CheckModificationForWrap(mh);
|
|
|
|
if (mh.linesAdded != 0) {
|
|
|
|
// Avoid scrolling of display if change before current display
|
|
|
|
if (mh.position < posTopLine && !CanDeferToLastStep(mh)) {
|
|
|
|
int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos());
|
|
|
|
if (newTop != topLine) {
|
|
|
|
SetTopLine(newTop);
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (paintState == notPainting && !CanDeferToLastStep(mh)) {
|
2013-08-28 00:44:27 +00:00
|
|
|
QueueIdleWork(WorkNeeded::workStyle, pdoc->Length());
|
2009-04-24 23:35:41 +00:00
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (paintState == notPainting && mh.length && !CanEliminate(mh)) {
|
2013-08-28 00:44:27 +00:00
|
|
|
QueueIdleWork(WorkNeeded::workStyle, mh.position + mh.length);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateRange(mh.position, mh.position + mh.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mh.linesAdded != 0 && !CanDeferToLastStep(mh)) {
|
|
|
|
SetScrollBars();
|
|
|
|
}
|
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
if ((mh.modificationType & SC_MOD_CHANGEMARKER) || (mh.modificationType & SC_MOD_CHANGEMARGIN)) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if ((!willRedrawAll) && ((paintState == notPainting) || !PaintContainsMargin())) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (mh.modificationType & SC_MOD_CHANGEFOLD) {
|
|
|
|
// Fold changes can affect the drawing of following lines so redraw whole margin
|
2015-06-07 21:19:26 +00:00
|
|
|
RedrawSelMargin(marginView.highlightDelimiter.isEnabled ? -1 : mh.line - 1, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
RedrawSelMargin(mh.line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
if ((mh.modificationType & SC_MOD_CHANGEFOLD) && (foldAutomatic & SC_AUTOMATICFOLD_CHANGE)) {
|
|
|
|
FoldChanged(mh.line, mh.foldLevelNow, mh.foldLevelPrev);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// NOW pay the piper WRT "deferred" visual updates
|
|
|
|
if (IsLastStep(mh)) {
|
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If client wants to see this modification
|
|
|
|
if (mh.modificationType & modEventMask) {
|
|
|
|
if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
|
|
|
|
// Real modification made to text of document.
|
|
|
|
NotifyChange(); // Send EN_CHANGE
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_MODIFIED;
|
|
|
|
scn.position = mh.position;
|
|
|
|
scn.modificationType = mh.modificationType;
|
|
|
|
scn.text = mh.text;
|
|
|
|
scn.length = mh.length;
|
|
|
|
scn.linesAdded = mh.linesAdded;
|
|
|
|
scn.line = mh.line;
|
|
|
|
scn.foldLevelNow = mh.foldLevelNow;
|
|
|
|
scn.foldLevelPrev = mh.foldLevelPrev;
|
2009-06-24 19:09:31 +00:00
|
|
|
scn.token = mh.token;
|
|
|
|
scn.annotationLinesAdded = mh.annotationLinesAdded;
|
2009-04-24 23:35:41 +00:00
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyDeleted(Document *, void *) {
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
|
|
|
|
|
|
|
// Enumerates all macroable messages
|
|
|
|
switch (iMessage) {
|
|
|
|
case SCI_CUT:
|
|
|
|
case SCI_COPY:
|
|
|
|
case SCI_PASTE:
|
|
|
|
case SCI_CLEAR:
|
|
|
|
case SCI_REPLACESEL:
|
|
|
|
case SCI_ADDTEXT:
|
|
|
|
case SCI_INSERTTEXT:
|
|
|
|
case SCI_APPENDTEXT:
|
|
|
|
case SCI_CLEARALL:
|
|
|
|
case SCI_SELECTALL:
|
|
|
|
case SCI_GOTOLINE:
|
|
|
|
case SCI_GOTOPOS:
|
|
|
|
case SCI_SEARCHANCHOR:
|
|
|
|
case SCI_SEARCHNEXT:
|
|
|
|
case SCI_SEARCHPREV:
|
|
|
|
case SCI_LINEDOWN:
|
|
|
|
case SCI_LINEDOWNEXTEND:
|
|
|
|
case SCI_PARADOWN:
|
|
|
|
case SCI_PARADOWNEXTEND:
|
|
|
|
case SCI_LINEUP:
|
|
|
|
case SCI_LINEUPEXTEND:
|
|
|
|
case SCI_PARAUP:
|
|
|
|
case SCI_PARAUPEXTEND:
|
|
|
|
case SCI_CHARLEFT:
|
|
|
|
case SCI_CHARLEFTEXTEND:
|
|
|
|
case SCI_CHARRIGHT:
|
|
|
|
case SCI_CHARRIGHTEXTEND:
|
|
|
|
case SCI_WORDLEFT:
|
|
|
|
case SCI_WORDLEFTEXTEND:
|
|
|
|
case SCI_WORDRIGHT:
|
|
|
|
case SCI_WORDRIGHTEXTEND:
|
|
|
|
case SCI_WORDPARTLEFT:
|
|
|
|
case SCI_WORDPARTLEFTEXTEND:
|
|
|
|
case SCI_WORDPARTRIGHT:
|
|
|
|
case SCI_WORDPARTRIGHTEXTEND:
|
|
|
|
case SCI_WORDLEFTEND:
|
|
|
|
case SCI_WORDLEFTENDEXTEND:
|
|
|
|
case SCI_WORDRIGHTEND:
|
|
|
|
case SCI_WORDRIGHTENDEXTEND:
|
|
|
|
case SCI_HOME:
|
|
|
|
case SCI_HOMEEXTEND:
|
|
|
|
case SCI_LINEEND:
|
|
|
|
case SCI_LINEENDEXTEND:
|
|
|
|
case SCI_HOMEWRAP:
|
|
|
|
case SCI_HOMEWRAPEXTEND:
|
|
|
|
case SCI_LINEENDWRAP:
|
|
|
|
case SCI_LINEENDWRAPEXTEND:
|
|
|
|
case SCI_DOCUMENTSTART:
|
|
|
|
case SCI_DOCUMENTSTARTEXTEND:
|
|
|
|
case SCI_DOCUMENTEND:
|
|
|
|
case SCI_DOCUMENTENDEXTEND:
|
|
|
|
case SCI_STUTTEREDPAGEUP:
|
|
|
|
case SCI_STUTTEREDPAGEUPEXTEND:
|
|
|
|
case SCI_STUTTEREDPAGEDOWN:
|
|
|
|
case SCI_STUTTEREDPAGEDOWNEXTEND:
|
|
|
|
case SCI_PAGEUP:
|
|
|
|
case SCI_PAGEUPEXTEND:
|
|
|
|
case SCI_PAGEDOWN:
|
|
|
|
case SCI_PAGEDOWNEXTEND:
|
|
|
|
case SCI_EDITTOGGLEOVERTYPE:
|
|
|
|
case SCI_CANCEL:
|
|
|
|
case SCI_DELETEBACK:
|
|
|
|
case SCI_TAB:
|
|
|
|
case SCI_BACKTAB:
|
|
|
|
case SCI_FORMFEED:
|
|
|
|
case SCI_VCHOME:
|
|
|
|
case SCI_VCHOMEEXTEND:
|
|
|
|
case SCI_VCHOMEWRAP:
|
|
|
|
case SCI_VCHOMEWRAPEXTEND:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_VCHOMEDISPLAY:
|
|
|
|
case SCI_VCHOMEDISPLAYEXTEND:
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_DELWORDLEFT:
|
|
|
|
case SCI_DELWORDRIGHT:
|
|
|
|
case SCI_DELWORDRIGHTEND:
|
|
|
|
case SCI_DELLINELEFT:
|
|
|
|
case SCI_DELLINERIGHT:
|
|
|
|
case SCI_LINECOPY:
|
|
|
|
case SCI_LINECUT:
|
|
|
|
case SCI_LINEDELETE:
|
|
|
|
case SCI_LINETRANSPOSE:
|
|
|
|
case SCI_LINEDUPLICATE:
|
|
|
|
case SCI_LOWERCASE:
|
|
|
|
case SCI_UPPERCASE:
|
|
|
|
case SCI_LINESCROLLDOWN:
|
|
|
|
case SCI_LINESCROLLUP:
|
|
|
|
case SCI_DELETEBACKNOTLINE:
|
|
|
|
case SCI_HOMEDISPLAY:
|
|
|
|
case SCI_HOMEDISPLAYEXTEND:
|
|
|
|
case SCI_LINEENDDISPLAY:
|
|
|
|
case SCI_LINEENDDISPLAYEXTEND:
|
|
|
|
case SCI_SETSELECTIONMODE:
|
|
|
|
case SCI_LINEDOWNRECTEXTEND:
|
|
|
|
case SCI_LINEUPRECTEXTEND:
|
|
|
|
case SCI_CHARLEFTRECTEXTEND:
|
|
|
|
case SCI_CHARRIGHTRECTEXTEND:
|
|
|
|
case SCI_HOMERECTEXTEND:
|
|
|
|
case SCI_VCHOMERECTEXTEND:
|
|
|
|
case SCI_LINEENDRECTEXTEND:
|
|
|
|
case SCI_PAGEUPRECTEXTEND:
|
|
|
|
case SCI_PAGEDOWNRECTEXTEND:
|
|
|
|
case SCI_SELECTIONDUPLICATE:
|
|
|
|
case SCI_COPYALLOWLINE:
|
2011-03-22 00:16:49 +00:00
|
|
|
case SCI_VERTICALCENTRECARET:
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_MOVESELECTEDLINESUP:
|
|
|
|
case SCI_MOVESELECTEDLINESDOWN:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_SCROLLTOSTART:
|
|
|
|
case SCI_SCROLLTOEND:
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Filter out all others like display changes. Also, newlines are redundant
|
|
|
|
// with char insert messages.
|
|
|
|
case SCI_NEWLINE:
|
|
|
|
default:
|
|
|
|
// printf("Filtered out %ld of macro recording\n", iMessage);
|
2015-06-07 21:19:26 +00:00
|
|
|
return;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Send notification
|
2015-06-07 21:19:26 +00:00
|
|
|
SCNotification scn = {};
|
2009-04-24 23:35:41 +00:00
|
|
|
scn.nmhdr.code = SCN_MACRORECORD;
|
|
|
|
scn.message = iMessage;
|
|
|
|
scn.wParam = wParam;
|
|
|
|
scn.lParam = lParam;
|
|
|
|
NotifyParent(scn);
|
|
|
|
}
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
// Something has changed that the container should know about
|
|
|
|
void Editor::ContainerNeedsUpdate(int flags) {
|
|
|
|
needUpdateUI |= flags;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* Force scroll and keep position relative to top of window.
|
|
|
|
*
|
|
|
|
* If stuttered = true and not already at first/last row, move to first/last row of window.
|
|
|
|
* If stuttered = true and already at first/last row, scroll as normal.
|
|
|
|
*/
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
|
2011-03-22 00:16:49 +00:00
|
|
|
int topLineNew;
|
|
|
|
SelectionPosition newPos;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int currentLine = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
int topStutterLine = topLine + caretYSlop;
|
|
|
|
int bottomStutterLine =
|
|
|
|
pdoc->LineFromPosition(PositionFromLocation(
|
2015-06-07 21:19:26 +00:00
|
|
|
Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll())))
|
2009-04-24 23:35:41 +00:00
|
|
|
- caretYSlop - 1;
|
|
|
|
|
|
|
|
if (stuttered && (direction < 0 && currentLine > topStutterLine)) {
|
|
|
|
topLineNew = topLine;
|
2015-06-07 21:19:26 +00:00
|
|
|
newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * caretYSlop),
|
2011-03-22 00:16:49 +00:00
|
|
|
false, false, UserVirtualSpace());
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
} else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) {
|
|
|
|
topLineNew = topLine;
|
2015-06-07 21:19:26 +00:00
|
|
|
newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)),
|
2011-03-22 00:16:49 +00:00
|
|
|
false, false, UserVirtualSpace());
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
Point pt = LocationFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
topLineNew = Platform::Clamp(
|
|
|
|
topLine + direction * LinesToScroll(), 0, MaxScrollPos());
|
2011-03-22 00:16:49 +00:00
|
|
|
newPos = SPositionFromLocation(
|
2015-06-07 21:19:26 +00:00
|
|
|
Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())),
|
2011-03-22 00:16:49 +00:00
|
|
|
false, false, UserVirtualSpace());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (topLineNew != topLine) {
|
|
|
|
SetTopLine(topLineNew);
|
2011-03-22 00:16:49 +00:00
|
|
|
MovePositionTo(newPos, selt);
|
2009-04-24 23:35:41 +00:00
|
|
|
Redraw();
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
} else {
|
2011-03-22 00:16:49 +00:00
|
|
|
MovePositionTo(newPos, selt);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::ChangeCaseOfSelection(int caseMapping) {
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
SelectionRange current = sel.Range(r);
|
2010-07-12 22:19:51 +00:00
|
|
|
SelectionRange currentNoVS = current;
|
|
|
|
currentNoVS.ClearVirtualSpace();
|
|
|
|
size_t rangeBytes = currentNoVS.Length();
|
|
|
|
if (rangeBytes > 0) {
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string sText = RangeText(currentNoVS.Start().Position(), currentNoVS.End().Position());
|
2010-07-12 22:19:51 +00:00
|
|
|
|
|
|
|
std::string sMapped = CaseMapString(sText, caseMapping);
|
|
|
|
|
|
|
|
if (sMapped != sText) {
|
|
|
|
size_t firstDifference = 0;
|
|
|
|
while (sMapped[firstDifference] == sText[firstDifference])
|
|
|
|
firstDifference++;
|
2013-08-28 00:44:27 +00:00
|
|
|
size_t lastDifferenceText = sText.size() - 1;
|
|
|
|
size_t lastDifferenceMapped = sMapped.size() - 1;
|
|
|
|
while (sMapped[lastDifferenceMapped] == sText[lastDifferenceText]) {
|
|
|
|
lastDifferenceText--;
|
|
|
|
lastDifferenceMapped--;
|
|
|
|
}
|
|
|
|
size_t endDifferenceText = sText.size() - 1 - lastDifferenceText;
|
|
|
|
pdoc->DeleteChars(
|
|
|
|
static_cast<int>(currentNoVS.Start().Position() + firstDifference),
|
|
|
|
static_cast<int>(rangeBytes - firstDifference - endDifferenceText));
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthChange = static_cast<int>(lastDifferenceMapped - firstDifference + 1);
|
|
|
|
const int lengthInserted = pdoc->InsertString(
|
2013-08-28 00:44:27 +00:00
|
|
|
static_cast<int>(currentNoVS.Start().Position() + firstDifference),
|
|
|
|
sMapped.c_str() + firstDifference,
|
2015-06-07 21:19:26 +00:00
|
|
|
lengthChange);
|
2010-07-12 22:19:51 +00:00
|
|
|
// Automatic movement changes selection so reset to exactly the same as it was.
|
2015-06-07 21:19:26 +00:00
|
|
|
int diffSizes = static_cast<int>(sMapped.size() - sText.size()) + lengthInserted - lengthChange;
|
2013-08-28 00:44:27 +00:00
|
|
|
if (diffSizes != 0) {
|
|
|
|
if (current.anchor > current.caret)
|
|
|
|
current.anchor.Add(diffSizes);
|
|
|
|
else
|
|
|
|
current.caret.Add(diffSizes);
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.Range(r) = current;
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::LineTranspose() {
|
2009-08-23 02:24:48 +00:00
|
|
|
int line = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (line > 0) {
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
const int startPrevious = pdoc->LineStart(line - 1);
|
|
|
|
const std::string linePrevious = RangeText(startPrevious, pdoc->LineEnd(line - 1));
|
|
|
|
|
|
|
|
int startCurrent = pdoc->LineStart(line);
|
|
|
|
const std::string lineCurrent = RangeText(startCurrent, pdoc->LineEnd(line));
|
|
|
|
|
|
|
|
pdoc->DeleteChars(startCurrent, static_cast<int>(lineCurrent.length()));
|
|
|
|
pdoc->DeleteChars(startPrevious, static_cast<int>(linePrevious.length()));
|
|
|
|
startCurrent -= static_cast<int>(linePrevious.length());
|
|
|
|
|
|
|
|
startCurrent += pdoc->InsertString(startPrevious, lineCurrent.c_str(),
|
|
|
|
static_cast<int>(lineCurrent.length()));
|
|
|
|
pdoc->InsertString(startCurrent, linePrevious.c_str(),
|
|
|
|
static_cast<int>(linePrevious.length()));
|
|
|
|
// Move caret to start of current line
|
|
|
|
MovePositionTo(SelectionPosition(startCurrent));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::Duplicate(bool forLine) {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.Empty()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
forLine = true;
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2010-07-12 22:19:51 +00:00
|
|
|
const char *eol = "";
|
|
|
|
int eolLen = 0;
|
|
|
|
if (forLine) {
|
|
|
|
eol = StringFromEOLMode(pdoc->eolMode);
|
|
|
|
eolLen = istrlen(eol);
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
SelectionPosition start = sel.Range(r).Start();
|
|
|
|
SelectionPosition end = sel.Range(r).End();
|
|
|
|
if (forLine) {
|
|
|
|
int line = pdoc->LineFromPosition(sel.Range(r).caret.Position());
|
|
|
|
start = SelectionPosition(pdoc->LineStart(line));
|
|
|
|
end = SelectionPosition(pdoc->LineEnd(line));
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string text = RangeText(start.Position(), end.Position());
|
2015-06-07 21:19:26 +00:00
|
|
|
int lengthInserted = eolLen;
|
2010-07-12 22:19:51 +00:00
|
|
|
if (forLine)
|
2015-06-07 21:19:26 +00:00
|
|
|
lengthInserted = pdoc->InsertString(end.Position(), eol, eolLen);
|
|
|
|
pdoc->InsertString(end.Position() + lengthInserted, text.c_str(), static_cast<int>(text.length()));
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
if (sel.Count() && sel.IsRectangular()) {
|
|
|
|
SelectionPosition last = sel.Last();
|
2009-08-23 02:24:48 +00:00
|
|
|
if (forLine) {
|
2010-07-12 22:19:51 +00:00
|
|
|
int line = pdoc->LineFromPosition(last.Position());
|
|
|
|
last = SelectionPosition(last.Position() + pdoc->LineStart(line+1) - pdoc->LineStart(line));
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
if (sel.Rectangular().anchor > sel.Rectangular().caret)
|
|
|
|
sel.Rectangular().anchor = last;
|
|
|
|
else
|
|
|
|
sel.Rectangular().caret = last;
|
|
|
|
SetRectangularRange();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::CancelModes() {
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.SetMoveExtends(false);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NewLine() {
|
2013-08-28 00:44:27 +00:00
|
|
|
// Remove non-main ranges
|
|
|
|
InvalidateSelection(sel.RangeMain(), true);
|
|
|
|
sel.SetSelection(sel.RangeMain());
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.RangeMain().ClearVirtualSpace();
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
// Clear main range and insert line end
|
|
|
|
bool needGroupUndo = !sel.Empty();
|
|
|
|
if (needGroupUndo)
|
|
|
|
pdoc->BeginUndoAction();
|
|
|
|
|
|
|
|
if (!sel.Empty())
|
|
|
|
ClearSelection();
|
2009-04-24 23:35:41 +00:00
|
|
|
const char *eol = "\n";
|
|
|
|
if (pdoc->eolMode == SC_EOL_CRLF) {
|
|
|
|
eol = "\r\n";
|
|
|
|
} else if (pdoc->eolMode == SC_EOL_CR) {
|
|
|
|
eol = "\r";
|
|
|
|
} // else SC_EOL_LF -> "\n" already set
|
2015-06-07 21:19:26 +00:00
|
|
|
const int insertLength = pdoc->InsertString(sel.MainCaret(), eol, istrlen(eol));
|
2013-08-28 00:44:27 +00:00
|
|
|
// Want to end undo group before NotifyChar as applications often modify text here
|
|
|
|
if (needGroupUndo)
|
|
|
|
pdoc->EndUndoAction();
|
2015-06-07 21:19:26 +00:00
|
|
|
if (insertLength > 0) {
|
|
|
|
SetEmptySelection(sel.MainCaret() + insertLength);
|
2009-04-24 23:35:41 +00:00
|
|
|
while (*eol) {
|
|
|
|
NotifyChar(*eol);
|
2010-07-12 22:19:51 +00:00
|
|
|
if (recordingMacro) {
|
|
|
|
char txt[2];
|
|
|
|
txt[0] = *eol;
|
|
|
|
txt[1] = '\0';
|
|
|
|
NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(txt));
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
eol++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastXChosen();
|
|
|
|
SetScrollBars();
|
|
|
|
EnsureCaretVisible();
|
|
|
|
// Avoid blinking during rapid typing:
|
|
|
|
ShowCaretAtCurrentPosition();
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
|
2010-07-12 22:19:51 +00:00
|
|
|
SelectionPosition caretToUse = sel.Range(sel.Main()).caret;
|
|
|
|
if (sel.IsRectangular()) {
|
|
|
|
if (selt == Selection::noSel) {
|
|
|
|
caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start;
|
|
|
|
} else {
|
|
|
|
caretToUse = sel.Rectangular().caret;
|
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
Point pt = LocationFromPosition(caretToUse);
|
2013-08-28 00:44:27 +00:00
|
|
|
int skipLines = 0;
|
|
|
|
|
|
|
|
if (vs.annotationVisible) {
|
|
|
|
int lineDoc = pdoc->LineFromPosition(caretToUse.Position());
|
|
|
|
Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
|
2015-06-07 21:19:26 +00:00
|
|
|
int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
if (direction < 0 && subLine == 0) {
|
|
|
|
int lineDisplay = cs.DisplayFromDoc(lineDoc);
|
|
|
|
if (lineDisplay > 0) {
|
|
|
|
skipLines = pdoc->AnnotationLines(cs.DocFromDisplay(lineDisplay - 1));
|
|
|
|
}
|
|
|
|
} else if (direction > 0 && subLine >= (cs.GetHeight(lineDoc) - 1 - pdoc->AnnotationLines(lineDoc))) {
|
|
|
|
skipLines = pdoc->AnnotationLines(lineDoc);
|
|
|
|
}
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight;
|
2013-08-28 00:44:27 +00:00
|
|
|
SelectionPosition posNew = SPositionFromLocation(
|
2015-06-07 21:19:26 +00:00
|
|
|
Point::FromInts(lastXChosen - xOffset, newY), false, false, UserVirtualSpace());
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
if (direction < 0) {
|
|
|
|
// Line wrapping may lead to a location on the same line, so
|
|
|
|
// seek back if that is the case.
|
2009-08-23 02:24:48 +00:00
|
|
|
Point ptNew = LocationFromPosition(posNew.Position());
|
|
|
|
while ((posNew.Position() > 0) && (pt.y == ptNew.y)) {
|
2013-08-28 00:44:27 +00:00
|
|
|
posNew.Add(-1);
|
|
|
|
posNew.SetVirtualSpace(0);
|
|
|
|
ptNew = LocationFromPosition(posNew.Position());
|
|
|
|
}
|
|
|
|
} else if (direction > 0 && posNew.Position() != pdoc->Length()) {
|
|
|
|
// There is an equivalent case when moving down which skips
|
|
|
|
// over a line.
|
|
|
|
Point ptNew = LocationFromPosition(posNew.Position());
|
|
|
|
while ((posNew.Position() > caretToUse.Position()) && (ptNew.y > newY)) {
|
|
|
|
posNew.Add(-1);
|
2009-08-23 02:24:48 +00:00
|
|
|
posNew.SetVirtualSpace(0);
|
|
|
|
ptNew = LocationFromPosition(posNew.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
MovePositionTo(MovePositionSoVisible(posNew, direction), selt);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) {
|
|
|
|
int lineDoc, savedPos = sel.MainCaret();
|
2009-04-24 23:35:41 +00:00
|
|
|
do {
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt);
|
|
|
|
lineDoc = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (direction > 0) {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.MainCaret() >= pdoc->Length() && !cs.GetVisible(lineDoc)) {
|
|
|
|
if (selt == Selection::noSel) {
|
|
|
|
MovePositionTo(SelectionPosition(pdoc->LineEndPosition(savedPos)));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!cs.GetVisible(lineDoc));
|
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::StartEndDisplayLine(int pos, bool start) {
|
|
|
|
RefreshStyleData();
|
|
|
|
AutoSurface surface(this);
|
2015-06-07 21:19:26 +00:00
|
|
|
int posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (posRet == INVALID_POSITION) {
|
|
|
|
return pos;
|
|
|
|
} else {
|
|
|
|
return posRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::KeyCommand(unsigned int iMessage) {
|
|
|
|
switch (iMessage) {
|
|
|
|
case SCI_LINEDOWN:
|
|
|
|
CursorUpOrDown(1);
|
|
|
|
break;
|
|
|
|
case SCI_LINEDOWNEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
CursorUpOrDown(1, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_LINEDOWNRECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
CursorUpOrDown(1, Selection::selRectangle);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_PARADOWN:
|
|
|
|
ParaUpOrDown(1);
|
|
|
|
break;
|
|
|
|
case SCI_PARADOWNEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
ParaUpOrDown(1, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_LINESCROLLDOWN:
|
|
|
|
ScrollTo(topLine + 1);
|
|
|
|
MoveCaretInsideView(false);
|
|
|
|
break;
|
|
|
|
case SCI_LINEUP:
|
|
|
|
CursorUpOrDown(-1);
|
|
|
|
break;
|
|
|
|
case SCI_LINEUPEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
CursorUpOrDown(-1, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_LINEUPRECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
CursorUpOrDown(-1, Selection::selRectangle);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_PARAUP:
|
|
|
|
ParaUpOrDown(-1);
|
|
|
|
break;
|
|
|
|
case SCI_PARAUPEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
ParaUpOrDown(-1, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_LINESCROLLUP:
|
|
|
|
ScrollTo(topLine - 1);
|
|
|
|
MoveCaretInsideView(false);
|
|
|
|
break;
|
|
|
|
case SCI_CHARLEFT:
|
2009-08-23 02:24:48 +00:00
|
|
|
if (SelectionEmpty() || sel.MoveExtends()) {
|
2010-07-12 22:19:51 +00:00
|
|
|
if ((sel.Count() == 1) && pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition spCaret = sel.RangeMain().caret;
|
|
|
|
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
|
|
|
|
MovePositionTo(spCaret);
|
2013-08-28 00:44:27 +00:00
|
|
|
} else if (sel.MoveExtends() && sel.selType == Selection::selStream) {
|
|
|
|
MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1));
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
2010-07-12 22:19:51 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(
|
|
|
|
SelectionPosition((sel.LimitsForRectangularElseMain().start).Position() - 1), -1));
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2010-07-12 22:19:51 +00:00
|
|
|
MovePositionTo(sel.LimitsForRectangularElseMain().start);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_CHARLEFTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
|
|
|
|
SelectionPosition spCaret = sel.RangeMain().caret;
|
|
|
|
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
|
|
|
|
MovePositionTo(spCaret, Selection::selStream);
|
|
|
|
} else {
|
|
|
|
MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selStream);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_CHARLEFTRECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
|
|
|
|
SelectionPosition spCaret = sel.RangeMain().caret;
|
|
|
|
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
|
|
|
|
MovePositionTo(spCaret, Selection::selRectangle);
|
|
|
|
} else {
|
|
|
|
MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selRectangle);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_CHARRIGHT:
|
2009-08-23 02:24:48 +00:00
|
|
|
if (SelectionEmpty() || sel.MoveExtends()) {
|
|
|
|
if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) {
|
|
|
|
SelectionPosition spCaret = sel.RangeMain().caret;
|
|
|
|
spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
|
|
|
|
MovePositionTo(spCaret);
|
2013-08-28 00:44:27 +00:00
|
|
|
} else if (sel.MoveExtends() && sel.selType == Selection::selStream) {
|
|
|
|
MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1));
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
2010-07-12 22:19:51 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(
|
|
|
|
SelectionPosition((sel.LimitsForRectangularElseMain().end).Position() + 1), 1));
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2010-07-12 22:19:51 +00:00
|
|
|
MovePositionTo(sel.LimitsForRectangularElseMain().end);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_CHARRIGHTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) {
|
|
|
|
SelectionPosition spCaret = sel.RangeMain().caret;
|
|
|
|
spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
|
|
|
|
MovePositionTo(spCaret, Selection::selStream);
|
|
|
|
} else {
|
|
|
|
MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selStream);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_CHARRIGHTRECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) {
|
|
|
|
SelectionPosition spCaret = sel.RangeMain().caret;
|
|
|
|
spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
|
|
|
|
MovePositionTo(spCaret, Selection::selRectangle);
|
|
|
|
} else {
|
|
|
|
MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selRectangle);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDLEFT:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDLEFTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDRIGHT:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDRIGHTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_WORDLEFTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDLEFTENDEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDRIGHTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDRIGHTENDEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_HOME:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_HOMEEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_HOMERECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selRectangle);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_LINEEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_LINEENDEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_LINEENDRECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selRectangle);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_HOMEWRAP: {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
|
|
|
|
if (sel.RangeMain().caret <= homePos)
|
|
|
|
homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())));
|
2009-04-24 23:35:41 +00:00
|
|
|
MovePositionTo(homePos);
|
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_HOMEWRAPEXTEND: {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
|
|
|
|
if (sel.RangeMain().caret <= homePos)
|
|
|
|
homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())));
|
|
|
|
MovePositionTo(homePos, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_LINEENDWRAP: {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1);
|
|
|
|
SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret()));
|
2009-04-24 23:35:41 +00:00
|
|
|
if (endPos > realEndPos // if moved past visible EOLs
|
2009-08-23 02:24:48 +00:00
|
|
|
|| sel.RangeMain().caret >= endPos) // if at end of display line already
|
2009-04-24 23:35:41 +00:00
|
|
|
endPos = realEndPos;
|
|
|
|
MovePositionTo(endPos);
|
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_LINEENDWRAPEXTEND: {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1);
|
|
|
|
SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret()));
|
2009-04-24 23:35:41 +00:00
|
|
|
if (endPos > realEndPos // if moved past visible EOLs
|
2009-08-23 02:24:48 +00:00
|
|
|
|| sel.RangeMain().caret >= endPos) // if at end of display line already
|
2009-04-24 23:35:41 +00:00
|
|
|
endPos = realEndPos;
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(endPos, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_DOCUMENTSTART:
|
|
|
|
MovePositionTo(0);
|
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_DOCUMENTSTARTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(0, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_DOCUMENTEND:
|
|
|
|
MovePositionTo(pdoc->Length());
|
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_DOCUMENTENDEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->Length(), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_STUTTEREDPAGEUP:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(-1, Selection::noSel, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STUTTEREDPAGEUPEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(-1, Selection::selStream, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STUTTEREDPAGEDOWN:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(1, Selection::noSel, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STUTTEREDPAGEDOWNEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(1, Selection::selStream, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_PAGEUP:
|
|
|
|
PageMove(-1);
|
|
|
|
break;
|
|
|
|
case SCI_PAGEUPEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(-1, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_PAGEUPRECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(-1, Selection::selRectangle);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_PAGEDOWN:
|
|
|
|
PageMove(1);
|
|
|
|
break;
|
|
|
|
case SCI_PAGEDOWNEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(1, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_PAGEDOWNRECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
PageMove(1, Selection::selRectangle);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_EDITTOGGLEOVERTYPE:
|
|
|
|
inOverstrike = !inOverstrike;
|
|
|
|
ShowCaretAtCurrentPosition();
|
2011-03-22 00:16:49 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_CONTENT);
|
2009-04-24 23:35:41 +00:00
|
|
|
NotifyUpdateUI();
|
|
|
|
break;
|
|
|
|
case SCI_CANCEL: // Cancel any modes - handled in subclass
|
|
|
|
// Also unselect text
|
|
|
|
CancelModes();
|
|
|
|
break;
|
|
|
|
case SCI_DELETEBACK:
|
|
|
|
DelCharBack(true);
|
2010-08-21 23:59:56 +00:00
|
|
|
if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
EnsureCaretVisible();
|
|
|
|
break;
|
|
|
|
case SCI_DELETEBACKNOTLINE:
|
|
|
|
DelCharBack(false);
|
2010-08-21 23:59:56 +00:00
|
|
|
if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
EnsureCaretVisible();
|
|
|
|
break;
|
|
|
|
case SCI_TAB:
|
|
|
|
Indent(true);
|
2010-08-21 23:59:56 +00:00
|
|
|
if (caretSticky == SC_CARETSTICKY_OFF) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
EnsureCaretVisible();
|
2009-06-24 19:09:31 +00:00
|
|
|
ShowCaretAtCurrentPosition(); // Avoid blinking
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_BACKTAB:
|
|
|
|
Indent(false);
|
2010-08-21 23:59:56 +00:00
|
|
|
if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
EnsureCaretVisible();
|
2009-06-24 19:09:31 +00:00
|
|
|
ShowCaretAtCurrentPosition(); // Avoid blinking
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_NEWLINE:
|
|
|
|
NewLine();
|
|
|
|
break;
|
|
|
|
case SCI_FORMFEED:
|
|
|
|
AddChar('\f');
|
|
|
|
break;
|
|
|
|
case SCI_VCHOME:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_VCHOMEEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_VCHOMERECTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selRectangle);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_VCHOMEWRAP: {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
|
|
|
|
SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
|
|
|
|
if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos))
|
2009-04-24 23:35:41 +00:00
|
|
|
homePos = viewLineStart;
|
|
|
|
|
|
|
|
MovePositionTo(homePos);
|
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_VCHOMEWRAPEXTEND: {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
|
|
|
|
SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
|
|
|
|
if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos))
|
2009-04-24 23:35:41 +00:00
|
|
|
homePos = viewLineStart;
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(homePos, Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_ZOOMIN:
|
|
|
|
if (vs.zoomLevel < 20) {
|
|
|
|
vs.zoomLevel++;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
NotifyZoom();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_ZOOMOUT:
|
|
|
|
if (vs.zoomLevel > -10) {
|
|
|
|
vs.zoomLevel--;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
NotifyZoom();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_DELWORDLEFT: {
|
2009-08-23 02:24:48 +00:00
|
|
|
int startWord = pdoc->NextWordStart(sel.MainCaret(), -1);
|
|
|
|
pdoc->DeleteChars(startWord, sel.MainCaret() - startWord);
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.RangeMain().ClearVirtualSpace();
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_DELWORDRIGHT: {
|
2010-07-12 22:19:51 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2015-06-07 21:19:26 +00:00
|
|
|
InvalidateSelection(sel.RangeMain(), true);
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.RangeMain().caret = SelectionPosition(
|
|
|
|
InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
|
2011-03-22 00:16:49 +00:00
|
|
|
sel.RangeMain().anchor = sel.RangeMain().caret;
|
2009-08-23 02:24:48 +00:00
|
|
|
int endWord = pdoc->NextWordStart(sel.MainCaret(), 1);
|
|
|
|
pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_DELWORDRIGHTEND: {
|
2010-07-12 22:19:51 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2015-06-07 21:19:26 +00:00
|
|
|
InvalidateSelection(sel.RangeMain(), true);
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.RangeMain().caret = SelectionPosition(
|
|
|
|
InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
|
2009-08-23 02:24:48 +00:00
|
|
|
int endWord = pdoc->NextWordEnd(sel.MainCaret(), 1);
|
|
|
|
pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_DELLINELEFT: {
|
2009-08-23 02:24:48 +00:00
|
|
|
int line = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
int start = pdoc->LineStart(line);
|
2009-08-23 02:24:48 +00:00
|
|
|
pdoc->DeleteChars(start, sel.MainCaret() - start);
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.RangeMain().ClearVirtualSpace();
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_DELLINERIGHT: {
|
2009-08-23 02:24:48 +00:00
|
|
|
int line = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
int end = pdoc->LineEnd(line);
|
2009-08-23 02:24:48 +00:00
|
|
|
pdoc->DeleteChars(sel.MainCaret(), end - sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_LINECOPY: {
|
2009-08-23 02:24:48 +00:00
|
|
|
int lineStart = pdoc->LineFromPosition(SelectionStart().Position());
|
|
|
|
int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
CopyRangeToClipboard(pdoc->LineStart(lineStart),
|
|
|
|
pdoc->LineStart(lineEnd + 1));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_LINECUT: {
|
2009-08-23 02:24:48 +00:00
|
|
|
int lineStart = pdoc->LineFromPosition(SelectionStart().Position());
|
|
|
|
int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
int start = pdoc->LineStart(lineStart);
|
|
|
|
int end = pdoc->LineStart(lineEnd + 1);
|
|
|
|
SetSelection(start, end);
|
|
|
|
Cut();
|
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_LINEDELETE: {
|
2009-08-23 02:24:48 +00:00
|
|
|
int line = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
int start = pdoc->LineStart(line);
|
|
|
|
int end = pdoc->LineStart(line + 1);
|
|
|
|
pdoc->DeleteChars(start, end - start);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_LINETRANSPOSE:
|
|
|
|
LineTranspose();
|
|
|
|
break;
|
|
|
|
case SCI_LINEDUPLICATE:
|
|
|
|
Duplicate(true);
|
|
|
|
break;
|
|
|
|
case SCI_SELECTIONDUPLICATE:
|
|
|
|
Duplicate(false);
|
|
|
|
break;
|
|
|
|
case SCI_LOWERCASE:
|
2010-07-12 22:19:51 +00:00
|
|
|
ChangeCaseOfSelection(cmLower);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_UPPERCASE:
|
2010-07-12 22:19:51 +00:00
|
|
|
ChangeCaseOfSelection(cmUpper);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_WORDPARTLEFT:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDPARTLEFTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDPARTRIGHT:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_WORDPARTRIGHTEXTEND:
|
2009-08-23 02:24:48 +00:00
|
|
|
MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_HOMEDISPLAY:
|
|
|
|
MovePositionTo(MovePositionSoVisible(
|
2009-08-23 02:24:48 +00:00
|
|
|
StartEndDisplayLine(sel.MainCaret(), true), -1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_VCHOMEDISPLAY: {
|
|
|
|
SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
|
|
|
|
SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
|
|
|
|
if (viewLineStart > homePos)
|
|
|
|
homePos = viewLineStart;
|
|
|
|
|
|
|
|
MovePositionTo(homePos);
|
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_HOMEDISPLAYEXTEND:
|
|
|
|
MovePositionTo(MovePositionSoVisible(
|
2009-08-23 02:24:48 +00:00
|
|
|
StartEndDisplayLine(sel.MainCaret(), true), -1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_VCHOMEDISPLAYEXTEND: {
|
|
|
|
SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret()));
|
|
|
|
SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1);
|
|
|
|
if (viewLineStart > homePos)
|
|
|
|
homePos = viewLineStart;
|
|
|
|
|
|
|
|
MovePositionTo(homePos, Selection::selStream);
|
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
break;
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_LINEENDDISPLAY:
|
|
|
|
MovePositionTo(MovePositionSoVisible(
|
2009-08-23 02:24:48 +00:00
|
|
|
StartEndDisplayLine(sel.MainCaret(), false), 1));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
case SCI_LINEENDDISPLAYEXTEND:
|
|
|
|
MovePositionTo(MovePositionSoVisible(
|
2009-08-23 02:24:48 +00:00
|
|
|
StartEndDisplayLine(sel.MainCaret(), false), 1), Selection::selStream);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_SCROLLTOSTART:
|
|
|
|
ScrollTo(0);
|
|
|
|
break;
|
|
|
|
case SCI_SCROLLTOEND:
|
|
|
|
ScrollTo(MaxScrollPos());
|
|
|
|
break;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::KeyDefault(int, int) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) {
|
2009-04-24 23:35:41 +00:00
|
|
|
DwellEnd(false);
|
|
|
|
int msg = kmap.Find(key, modifiers);
|
|
|
|
if (msg) {
|
|
|
|
if (consumed)
|
|
|
|
*consumed = true;
|
2015-06-07 21:19:26 +00:00
|
|
|
return static_cast<int>(WndProc(msg, 0, 0));
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
if (consumed)
|
|
|
|
*consumed = false;
|
|
|
|
return KeyDefault(key, modifiers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
|
2015-06-07 21:19:26 +00:00
|
|
|
return KeyDownWithModifiers(key, ModifierFlags(shift, ctrl, alt), consumed);
|
2011-07-17 22:30:49 +00:00
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::Indent(bool forwards) {
|
2013-08-28 00:44:27 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2009-08-23 02:24:48 +00:00
|
|
|
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) {
|
2010-07-12 22:19:51 +00:00
|
|
|
pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
|
2009-08-23 02:24:48 +00:00
|
|
|
caretPosition = sel.Range(r).caret.Position();
|
|
|
|
if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
|
|
|
|
pdoc->tabIndents) {
|
|
|
|
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
|
|
|
|
int indentationStep = pdoc->IndentSize();
|
2015-06-07 21:19:26 +00:00
|
|
|
const int posSelect = pdoc->SetLineIndentation(
|
|
|
|
lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
|
|
|
|
sel.Range(r) = SelectionRange(posSelect);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (pdoc->useTabs) {
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(caretPosition, "\t", 1);
|
|
|
|
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
|
|
|
int numSpaces = (pdoc->tabInChars) -
|
|
|
|
(pdoc->GetColumn(caretPosition) % (pdoc->tabInChars));
|
|
|
|
if (numSpaces < 1)
|
|
|
|
numSpaces = pdoc->tabInChars;
|
2015-06-07 21:19:26 +00:00
|
|
|
const std::string spaceText(numSpaces, ' ');
|
|
|
|
const int lengthInserted = pdoc->InsertString(caretPosition, spaceText.c_str(),
|
|
|
|
static_cast<int>(spaceText.length()));
|
|
|
|
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) &&
|
|
|
|
pdoc->tabIndents) {
|
|
|
|
int indentation = pdoc->GetLineIndentation(lineCurrentPos);
|
|
|
|
int indentationStep = pdoc->IndentSize();
|
2015-06-07 21:19:26 +00:00
|
|
|
const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
|
|
|
|
sel.Range(r) = SelectionRange(posSelect);
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
|
|
|
int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) *
|
|
|
|
pdoc->tabInChars;
|
|
|
|
if (newColumn < 0)
|
|
|
|
newColumn = 0;
|
|
|
|
int newPos = caretPosition;
|
|
|
|
while (pdoc->GetColumn(newPos) > newColumn)
|
|
|
|
newPos--;
|
|
|
|
sel.Range(r) = SelectionRange(newPos);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
} else { // Multiline
|
|
|
|
int anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor);
|
|
|
|
int currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos);
|
|
|
|
// Multiple lines selected so indent / dedent
|
|
|
|
int lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos);
|
|
|
|
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
|
2013-08-28 00:44:27 +00:00
|
|
|
pdoc->Indent(forwards, lineBottomSel, lineTopSel);
|
2009-08-23 02:24:48 +00:00
|
|
|
if (lineOfAnchor < lineCurrentPos) {
|
|
|
|
if (currentPosPosOnLine == 0)
|
|
|
|
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor));
|
|
|
|
else
|
|
|
|
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos + 1), pdoc->LineStart(lineOfAnchor));
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (anchorPosOnLine == 0)
|
|
|
|
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor));
|
|
|
|
else
|
|
|
|
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor + 1));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_SELECTION);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
class CaseFolderASCII : public CaseFolderTable {
|
|
|
|
public:
|
|
|
|
CaseFolderASCII() {
|
|
|
|
StandardASCII();
|
|
|
|
}
|
|
|
|
~CaseFolderASCII() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CaseFolder *Editor::CaseFolderForEncoding() {
|
|
|
|
// Simple default that only maps ASCII upper case to lower case.
|
|
|
|
return new CaseFolderASCII();
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* Search of a text in the document, in the given range.
|
|
|
|
* @return The position of the found text, -1 if not found.
|
|
|
|
*/
|
|
|
|
long Editor::FindText(
|
|
|
|
uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
|
|
|
|
///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
|
|
|
|
sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range.
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
Sci_TextToFind *ft = reinterpret_cast<Sci_TextToFind *>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
int lengthFound = istrlen(ft->lpstrText);
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!pdoc->HasCaseFolder())
|
|
|
|
pdoc->SetCaseFolder(CaseFolderForEncoding());
|
2015-06-07 21:19:26 +00:00
|
|
|
try {
|
|
|
|
long pos = pdoc->FindText(
|
|
|
|
static_cast<int>(ft->chrg.cpMin),
|
|
|
|
static_cast<int>(ft->chrg.cpMax),
|
|
|
|
ft->lpstrText,
|
|
|
|
(wParam & SCFIND_MATCHCASE) != 0,
|
|
|
|
(wParam & SCFIND_WHOLEWORD) != 0,
|
|
|
|
(wParam & SCFIND_WORDSTART) != 0,
|
|
|
|
(wParam & SCFIND_REGEXP) != 0,
|
|
|
|
static_cast<int>(wParam),
|
|
|
|
&lengthFound);
|
|
|
|
if (pos != -1) {
|
|
|
|
ft->chrgText.cpMin = pos;
|
|
|
|
ft->chrgText.cpMax = pos + lengthFound;
|
|
|
|
}
|
|
|
|
return static_cast<int>(pos);
|
|
|
|
} catch (RegexError &) {
|
|
|
|
errorStatus = SC_STATUS_WARN_REGEX;
|
|
|
|
return -1;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Relocatable search support : Searches relative to current selection
|
|
|
|
* point and sets the selection to the found text range with
|
|
|
|
* each search.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Anchor following searches at current selection start: This allows
|
|
|
|
* multiple incremental interactive searches to be macro recorded
|
|
|
|
* while still setting the selection to found text so the find/select
|
|
|
|
* operation is self-contained.
|
|
|
|
*/
|
|
|
|
void Editor::SearchAnchor() {
|
2009-08-23 02:24:48 +00:00
|
|
|
searchAnchor = SelectionStart().Position();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find text from current search anchor: Must call @c SearchAnchor first.
|
|
|
|
* Used for next text and previous text requests.
|
|
|
|
* @return The position of the found text, -1 if not found.
|
|
|
|
*/
|
|
|
|
long Editor::SearchText(
|
|
|
|
unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV.
|
|
|
|
uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
|
|
|
|
///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
|
|
|
|
sptr_t lParam) { ///< The text to search for.
|
|
|
|
|
|
|
|
const char *txt = reinterpret_cast<char *>(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
long pos;
|
2009-04-24 23:35:41 +00:00
|
|
|
int lengthFound = istrlen(txt);
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!pdoc->HasCaseFolder())
|
|
|
|
pdoc->SetCaseFolder(CaseFolderForEncoding());
|
2015-06-07 21:19:26 +00:00
|
|
|
try {
|
|
|
|
if (iMessage == SCI_SEARCHNEXT) {
|
|
|
|
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
|
|
|
|
(wParam & SCFIND_MATCHCASE) != 0,
|
|
|
|
(wParam & SCFIND_WHOLEWORD) != 0,
|
|
|
|
(wParam & SCFIND_WORDSTART) != 0,
|
|
|
|
(wParam & SCFIND_REGEXP) != 0,
|
|
|
|
static_cast<int>(wParam),
|
|
|
|
&lengthFound);
|
|
|
|
} else {
|
|
|
|
pos = pdoc->FindText(searchAnchor, 0, txt,
|
|
|
|
(wParam & SCFIND_MATCHCASE) != 0,
|
|
|
|
(wParam & SCFIND_WHOLEWORD) != 0,
|
|
|
|
(wParam & SCFIND_WORDSTART) != 0,
|
|
|
|
(wParam & SCFIND_REGEXP) != 0,
|
|
|
|
static_cast<int>(wParam),
|
|
|
|
&lengthFound);
|
|
|
|
}
|
|
|
|
} catch (RegexError &) {
|
|
|
|
errorStatus = SC_STATUS_WARN_REGEX;
|
|
|
|
return -1;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
if (pos != -1) {
|
2015-06-07 21:19:26 +00:00
|
|
|
SetSelection(static_cast<int>(pos), static_cast<int>(pos + lengthFound));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
std::string Editor::CaseMapString(const std::string &s, int caseMapping) {
|
|
|
|
std::string ret(s);
|
|
|
|
for (size_t i=0; i<ret.size(); i++) {
|
|
|
|
switch (caseMapping) {
|
|
|
|
case cmUpper:
|
|
|
|
if (ret[i] >= 'a' && ret[i] <= 'z')
|
|
|
|
ret[i] = static_cast<char>(ret[i] - 'a' + 'A');
|
|
|
|
break;
|
|
|
|
case cmLower:
|
|
|
|
if (ret[i] >= 'A' && ret[i] <= 'Z')
|
|
|
|
ret[i] = static_cast<char>(ret[i] - 'A' + 'a');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* Search for text in the target range of the document.
|
|
|
|
* @return The position of the found text, -1 if not found.
|
|
|
|
*/
|
|
|
|
long Editor::SearchInTarget(const char *text, int length) {
|
|
|
|
int lengthFound = length;
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!pdoc->HasCaseFolder())
|
|
|
|
pdoc->SetCaseFolder(CaseFolderForEncoding());
|
2015-06-07 21:19:26 +00:00
|
|
|
try {
|
|
|
|
long pos = pdoc->FindText(targetStart, targetEnd, text,
|
|
|
|
(searchFlags & SCFIND_MATCHCASE) != 0,
|
|
|
|
(searchFlags & SCFIND_WHOLEWORD) != 0,
|
|
|
|
(searchFlags & SCFIND_WORDSTART) != 0,
|
|
|
|
(searchFlags & SCFIND_REGEXP) != 0,
|
|
|
|
searchFlags,
|
|
|
|
&lengthFound);
|
|
|
|
if (pos != -1) {
|
|
|
|
targetStart = static_cast<int>(pos);
|
|
|
|
targetEnd = static_cast<int>(pos + lengthFound);
|
|
|
|
}
|
|
|
|
return pos;
|
|
|
|
} catch (RegexError &) {
|
|
|
|
errorStatus = SC_STATUS_WARN_REGEX;
|
|
|
|
return -1;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::GoToLine(int lineNo) {
|
|
|
|
if (lineNo > pdoc->LinesTotal())
|
|
|
|
lineNo = pdoc->LinesTotal();
|
|
|
|
if (lineNo < 0)
|
|
|
|
lineNo = 0;
|
|
|
|
SetEmptySelection(pdoc->LineStart(lineNo));
|
|
|
|
ShowCaretAtCurrentPosition();
|
|
|
|
EnsureCaretVisible();
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
static bool Close(Point pt1, Point pt2, Point threshold) {
|
|
|
|
if (std::abs(pt1.x - pt2.x) > threshold.x)
|
2009-04-24 23:35:41 +00:00
|
|
|
return false;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (std::abs(pt1.y - pt2.y) > threshold.y)
|
2009-04-24 23:35:41 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string Editor::RangeText(int start, int end) const {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (start < end) {
|
|
|
|
int len = end - start;
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string ret(len, '\0');
|
2009-08-23 02:24:48 +00:00
|
|
|
for (int i = 0; i < len; i++) {
|
2013-08-28 00:44:27 +00:00
|
|
|
ret[i] = pdoc->CharAt(start + i);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
return ret;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
return std::string();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.Empty()) {
|
|
|
|
if (allowLineCopy) {
|
|
|
|
int currentLine = pdoc->LineFromPosition(sel.MainCaret());
|
|
|
|
int start = pdoc->LineStart(currentLine);
|
|
|
|
int end = pdoc->LineEnd(currentLine);
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string text = RangeText(start, end);
|
2009-08-23 02:24:48 +00:00
|
|
|
if (pdoc->eolMode != SC_EOL_LF)
|
2013-08-28 00:44:27 +00:00
|
|
|
text.push_back('\r');
|
2009-08-23 02:24:48 +00:00
|
|
|
if (pdoc->eolMode != SC_EOL_CR)
|
2013-08-28 00:44:27 +00:00
|
|
|
text.push_back('\n');
|
|
|
|
ss->Copy(text, pdoc->dbcsCodePage,
|
|
|
|
vs.styles[STYLE_DEFAULT].characterSet, false, true);
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string text;
|
2009-08-23 02:24:48 +00:00
|
|
|
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];
|
2013-08-28 00:44:27 +00:00
|
|
|
text.append(RangeText(current.Start().Position(), current.End().Position()));
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.selType == Selection::selRectangle) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (pdoc->eolMode != SC_EOL_LF)
|
|
|
|
text.push_back('\r');
|
|
|
|
if (pdoc->eolMode != SC_EOL_CR)
|
|
|
|
text.push_back('\n');
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
ss->Copy(text, pdoc->dbcsCodePage,
|
2009-08-23 02:24:48 +00:00
|
|
|
vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::selLines);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::CopyRangeToClipboard(int start, int end) {
|
|
|
|
start = pdoc->ClampPositionIntoDocument(start);
|
|
|
|
end = pdoc->ClampPositionIntoDocument(end);
|
|
|
|
SelectionText selectedText;
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string text = RangeText(start, end);
|
|
|
|
selectedText.Copy(text,
|
2009-04-24 23:35:41 +00:00
|
|
|
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
|
|
|
|
CopyToClipboard(selectedText);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::CopyText(int length, const char *text) {
|
|
|
|
SelectionText selectedText;
|
2013-08-28 00:44:27 +00:00
|
|
|
selectedText.Copy(std::string(text, length),
|
2009-04-24 23:35:41 +00:00
|
|
|
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
|
|
|
|
CopyToClipboard(selectedText);
|
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
void Editor::SetDragPosition(SelectionPosition newPos) {
|
|
|
|
if (newPos.Position() >= 0) {
|
2009-04-24 23:35:41 +00:00
|
|
|
newPos = MovePositionOutsideChar(newPos, 1);
|
|
|
|
posDrop = newPos;
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
if (!(posDrag == newPos)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
caret.on = true;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickCaret);
|
|
|
|
if ((caret.active) && (caret.period > 0) && (newPos.Position() < 0))
|
|
|
|
FineTickerStart(tickCaret, caret.period, caret.period/10);
|
|
|
|
} else {
|
|
|
|
SetTicking(true);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateCaret();
|
|
|
|
posDrag = newPos;
|
|
|
|
InvalidateCaret();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::DisplayCursor(Window::Cursor c) {
|
|
|
|
if (cursorMode == SC_CURSORNORMAL)
|
|
|
|
wMain.SetCursor(c);
|
|
|
|
else
|
|
|
|
wMain.SetCursor(static_cast<Window::Cursor>(cursorMode));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::DragThreshold(Point ptStart, Point ptNow) {
|
2015-06-07 21:19:26 +00:00
|
|
|
int xMove = static_cast<int>(ptStart.x - ptNow.x);
|
|
|
|
int yMove = static_cast<int>(ptStart.y - ptNow.y);
|
2009-04-24 23:35:41 +00:00
|
|
|
int distanceSquared = xMove * xMove + yMove * yMove;
|
|
|
|
return distanceSquared > 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::StartDrag() {
|
|
|
|
// Always handled by subclasses
|
|
|
|
//SetMouseCapture(true);
|
|
|
|
//DisplayCursor(Window::cursorArrow);
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular) {
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position);
|
|
|
|
if (inDragDrop == ddDragging)
|
|
|
|
dropWentOutside = false;
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
bool positionWasInSelection = PositionInSelection(position.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
bool positionOnEdgeOfSelection =
|
|
|
|
(position == SelectionStart()) || (position == SelectionEnd());
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
if ((inDragDrop != ddDragging) || !(positionWasInSelection) ||
|
2009-04-24 23:35:41 +00:00
|
|
|
(positionOnEdgeOfSelection && !moving)) {
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition selStart = SelectionStart();
|
|
|
|
SelectionPosition selEnd = SelectionEnd();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition positionAfterDeletion = position;
|
2009-04-24 23:35:41 +00:00
|
|
|
if ((inDragDrop == ddDragging) && moving) {
|
|
|
|
// Remove dragged out text
|
2009-08-23 02:24:48 +00:00
|
|
|
if (rectangular || sel.selType == Selection::selLines) {
|
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
if (position >= sel.Range(r).Start()) {
|
|
|
|
if (position > sel.Range(r).End()) {
|
|
|
|
positionAfterDeletion.Add(-sel.Range(r).Length());
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
positionAfterDeletion.Add(-SelectionRange(position, sel.Range(r).Start()).Length());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (position > selStart) {
|
2009-08-23 02:24:48 +00:00
|
|
|
positionAfterDeletion.Add(-SelectionRange(selEnd, selStart).Length());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ClearSelection();
|
|
|
|
}
|
|
|
|
position = positionAfterDeletion;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
std::string convertedText = Document::TransformLineEnds(value, lengthValue, pdoc->eolMode);
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
if (rectangular) {
|
2015-06-07 21:19:26 +00:00
|
|
|
PasteRectangular(position, convertedText.c_str(), static_cast<int>(convertedText.length()));
|
2009-04-24 23:35:41 +00:00
|
|
|
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
|
|
|
|
SetEmptySelection(position);
|
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
|
|
|
|
position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace()));
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(
|
|
|
|
position.Position(), convertedText.c_str(), static_cast<int>(convertedText.length()));
|
|
|
|
if (lengthInserted > 0) {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition posAfterInsertion = position;
|
2015-06-07 21:19:26 +00:00
|
|
|
posAfterInsertion.Add(lengthInserted);
|
2009-08-23 02:24:48 +00:00
|
|
|
SetSelection(posAfterInsertion, position);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (inDragDrop == ddDragging) {
|
|
|
|
SetEmptySelection(position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) {
|
|
|
|
DropAt(position, value, strlen(value), moving, rectangular);
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
2009-08-23 02:24:48 +00:00
|
|
|
* @return true if given position is inside the selection,
|
2009-04-24 23:35:41 +00:00
|
|
|
*/
|
2009-08-23 02:24:48 +00:00
|
|
|
bool Editor::PositionInSelection(int pos) {
|
|
|
|
pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos);
|
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
2010-07-12 22:19:51 +00:00
|
|
|
if (sel.Range(r).Contains(pos))
|
2009-08-23 02:24:48 +00:00
|
|
|
return true;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
return false;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::PointInSelection(Point pt) {
|
2013-08-28 00:44:27 +00:00
|
|
|
SelectionPosition pos = SPositionFromLocation(pt, false, true);
|
|
|
|
Point ptPos = LocationFromPosition(pos);
|
2009-08-23 02:24:48 +00:00
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
SelectionRange range = sel.Range(r);
|
|
|
|
if (range.Contains(pos)) {
|
|
|
|
bool hit = true;
|
|
|
|
if (pos == range.Start()) {
|
|
|
|
// see if just before selection
|
2013-08-28 00:44:27 +00:00
|
|
|
if (pt.x < ptPos.x) {
|
2009-08-23 02:24:48 +00:00
|
|
|
hit = false;
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
if (pos == range.End()) {
|
|
|
|
// see if just after selection
|
2013-08-28 00:44:27 +00:00
|
|
|
if (pt.x > ptPos.x) {
|
2009-08-23 02:24:48 +00:00
|
|
|
hit = false;
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
if (hit)
|
|
|
|
return true;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
bool Editor::PointInSelMargin(Point pt) const {
|
2009-04-24 23:35:41 +00:00
|
|
|
// Really means: "Point in a margin"
|
|
|
|
if (vs.fixedColumnWidth > 0) { // There is a margin
|
|
|
|
PRectangle rcSelMargin = GetClientRectangle();
|
2015-06-07 21:19:26 +00:00
|
|
|
rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart - vs.leftMarginWidth);
|
|
|
|
rcSelMargin.left = static_cast<XYPOSITION>(vs.textStart - vs.fixedColumnWidth);
|
|
|
|
return rcSelMargin.ContainsWholePixel(pt);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
Window::Cursor Editor::GetMarginCursor(Point pt) const {
|
2011-03-22 00:16:49 +00:00
|
|
|
int x = 0;
|
2013-08-28 00:44:27 +00:00
|
|
|
for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
|
2011-03-22 00:16:49 +00:00
|
|
|
if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width))
|
|
|
|
return static_cast<Window::Cursor>(vs.ms[margin].cursor);
|
|
|
|
x += vs.ms[margin].width;
|
|
|
|
}
|
|
|
|
return Window::cursorReverseArrow;
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::TrimAndSetSelection(int currentPos_, int anchor_) {
|
|
|
|
sel.TrimSelection(SelectionRange(currentPos_, anchor_));
|
|
|
|
SetSelection(currentPos_, anchor_);
|
|
|
|
}
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine) {
|
|
|
|
int selCurrentPos, selAnchorPos;
|
|
|
|
if (wholeLine) {
|
|
|
|
int lineCurrent_ = pdoc->LineFromPosition(lineCurrentPos_);
|
|
|
|
int lineAnchor_ = pdoc->LineFromPosition(lineAnchorPos_);
|
|
|
|
if (lineAnchorPos_ < lineCurrentPos_) {
|
|
|
|
selCurrentPos = pdoc->LineStart(lineCurrent_ + 1);
|
|
|
|
selAnchorPos = pdoc->LineStart(lineAnchor_);
|
|
|
|
} else if (lineAnchorPos_ > lineCurrentPos_) {
|
|
|
|
selCurrentPos = pdoc->LineStart(lineCurrent_);
|
|
|
|
selAnchorPos = pdoc->LineStart(lineAnchor_ + 1);
|
|
|
|
} else { // Same line, select it
|
|
|
|
selCurrentPos = pdoc->LineStart(lineAnchor_ + 1);
|
|
|
|
selAnchorPos = pdoc->LineStart(lineAnchor_);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (lineAnchorPos_ < lineCurrentPos_) {
|
|
|
|
selCurrentPos = StartEndDisplayLine(lineCurrentPos_, false) + 1;
|
|
|
|
selCurrentPos = pdoc->MovePositionOutsideChar(selCurrentPos, 1);
|
|
|
|
selAnchorPos = StartEndDisplayLine(lineAnchorPos_, true);
|
|
|
|
} else if (lineAnchorPos_ > lineCurrentPos_) {
|
|
|
|
selCurrentPos = StartEndDisplayLine(lineCurrentPos_, true);
|
|
|
|
selAnchorPos = StartEndDisplayLine(lineAnchorPos_, false) + 1;
|
|
|
|
selAnchorPos = pdoc->MovePositionOutsideChar(selAnchorPos, 1);
|
|
|
|
} else { // Same line, select it
|
|
|
|
selCurrentPos = StartEndDisplayLine(lineAnchorPos_, false) + 1;
|
|
|
|
selCurrentPos = pdoc->MovePositionOutsideChar(selCurrentPos, 1);
|
|
|
|
selAnchorPos = StartEndDisplayLine(lineAnchorPos_, true);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
TrimAndSetSelection(selCurrentPos, selAnchorPos);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
void Editor::WordSelection(int pos) {
|
|
|
|
if (pos < wordSelectAnchorStartPos) {
|
|
|
|
// Extend backward to the word containing pos.
|
|
|
|
// Skip ExtendWordSelect if the line is empty or if pos is after the last character.
|
|
|
|
// This ensures that a series of empty lines isn't counted as a single "word".
|
|
|
|
if (!pdoc->IsLineEndPosition(pos))
|
|
|
|
pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos + 1, 1), -1);
|
2013-08-28 00:44:27 +00:00
|
|
|
TrimAndSetSelection(pos, wordSelectAnchorEndPos);
|
2011-03-22 00:16:49 +00:00
|
|
|
} else if (pos > wordSelectAnchorEndPos) {
|
|
|
|
// Extend forward to the word containing the character to the left of pos.
|
|
|
|
// Skip ExtendWordSelect if the line is empty or if pos is the first position on the line.
|
|
|
|
// This ensures that a series of empty lines isn't counted as a single "word".
|
|
|
|
if (pos > pdoc->LineStart(pdoc->LineFromPosition(pos)))
|
|
|
|
pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos - 1, -1), 1);
|
2013-08-28 00:44:27 +00:00
|
|
|
TrimAndSetSelection(pos, wordSelectAnchorStartPos);
|
2011-03-22 00:16:49 +00:00
|
|
|
} else {
|
|
|
|
// Select only the anchored word
|
|
|
|
if (pos >= originalAnchorPos)
|
2013-08-28 00:44:27 +00:00
|
|
|
TrimAndSetSelection(wordSelectAnchorEndPos, wordSelectAnchorStartPos);
|
2011-03-22 00:16:49 +00:00
|
|
|
else
|
2013-08-28 00:44:27 +00:00
|
|
|
TrimAndSetSelection(wordSelectAnchorStartPos, wordSelectAnchorEndPos);
|
2011-03-22 00:16:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::DwellEnd(bool mouseMoved) {
|
|
|
|
if (mouseMoved)
|
|
|
|
ticksToDwell = dwellDelay;
|
|
|
|
else
|
|
|
|
ticksToDwell = SC_TIME_FOREVER;
|
|
|
|
if (dwelling && (dwellDelay < SC_TIME_FOREVER)) {
|
|
|
|
dwelling = false;
|
|
|
|
NotifyDwelling(ptMouseLast, dwelling);
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickDwell);
|
|
|
|
if (mouseMoved && (dwellDelay < SC_TIME_FOREVER)) {
|
|
|
|
//FineTickerStart(tickDwell, dwellDelay, dwellDelay/10);
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
void Editor::MouseLeave() {
|
|
|
|
SetHotSpotRange(NULL);
|
2011-03-22 00:16:49 +00:00
|
|
|
if (!HaveMouseCapture()) {
|
|
|
|
ptMouseLast = Point(-1,-1);
|
|
|
|
DwellEnd(true);
|
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) {
|
2013-08-28 00:44:27 +00:00
|
|
|
return (!rectangular && ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0))
|
2009-08-23 02:24:48 +00:00
|
|
|
|| (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0));
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) {
|
|
|
|
SetHoverIndicatorPoint(pt);
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop);
|
|
|
|
ptMouseLast = pt;
|
2015-06-07 21:19:26 +00:00
|
|
|
const bool ctrl = (modifiers & SCI_CTRL) != 0;
|
|
|
|
const bool shift = (modifiers & SCI_SHIFT) != 0;
|
|
|
|
const bool alt = (modifiers & SCI_ALT) != 0;
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt));
|
|
|
|
newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
|
2015-06-07 21:19:26 +00:00
|
|
|
SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false);
|
|
|
|
newCharPos = MovePositionOutsideChar(newCharPos, -1);
|
2009-04-24 23:35:41 +00:00
|
|
|
inDragDrop = ddNone;
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.SetMoveExtends(false);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (NotifyMarginClick(pt, modifiers))
|
2009-04-24 23:35:41 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
NotifyIndicatorClick(true, newPos.Position(), modifiers);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
bool inSelMargin = PointInSelMargin(pt);
|
2013-08-28 00:44:27 +00:00
|
|
|
// In margin ctrl+(double)click should always select everything
|
|
|
|
if (ctrl && inSelMargin) {
|
|
|
|
SelectAll();
|
|
|
|
lastClickTime = curTime;
|
|
|
|
lastClick = pt;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (shift && !inSelMargin) {
|
|
|
|
SetSelection(newPos);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick, doubleClickCloseThreshold)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime);
|
|
|
|
SetMouseCapture(true);
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerStart(tickScroll, 100, 10);
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!ctrl || !multipleSelection || (selectionType != selChar && selectionType != selWord))
|
|
|
|
SetEmptySelection(newPos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
bool doubleClick = false;
|
|
|
|
// Stop mouse button bounce changing selection type
|
|
|
|
if (!Platform::MouseButtonBounce() || curTime != lastClickTime) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (inSelMargin) {
|
|
|
|
// Inside margin selection type should be either selSubLine or selWholeLine.
|
|
|
|
if (selectionType == selSubLine) {
|
|
|
|
// If it is selSubLine, we're inside a *double* click and word wrap is enabled,
|
2011-07-17 22:30:49 +00:00
|
|
|
// so we switch to selWholeLine in order to select whole line.
|
2013-08-28 00:44:27 +00:00
|
|
|
selectionType = selWholeLine;
|
|
|
|
} else if (selectionType != selSubLine && selectionType != selWholeLine) {
|
|
|
|
// If it is neither, reset selection type to line selection.
|
2015-06-07 21:19:26 +00:00
|
|
|
selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
|
2013-08-28 00:44:27 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (selectionType == selChar) {
|
|
|
|
selectionType = selWord;
|
|
|
|
doubleClick = true;
|
|
|
|
} else if (selectionType == selWord) {
|
|
|
|
// Since we ended up here, we're inside a *triple* click, which should always select
|
2015-06-07 21:19:26 +00:00
|
|
|
// whole line regardless of word wrap being enabled or not.
|
2013-08-28 00:44:27 +00:00
|
|
|
selectionType = selWholeLine;
|
2011-07-17 22:30:49 +00:00
|
|
|
} else {
|
|
|
|
selectionType = selChar;
|
|
|
|
originalAnchorPos = sel.MainCaret();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectionType == selWord) {
|
2011-03-22 00:16:49 +00:00
|
|
|
int charPos = originalAnchorPos;
|
|
|
|
if (sel.MainCaret() == originalAnchorPos) {
|
|
|
|
charPos = PositionFromLocation(pt, false, true);
|
|
|
|
charPos = MovePositionOutsideChar(charPos, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int startWord, endWord;
|
|
|
|
if ((sel.MainCaret() >= originalAnchorPos) && !pdoc->IsLineEndPosition(charPos)) {
|
|
|
|
startWord = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(charPos + 1, 1), -1);
|
|
|
|
endWord = pdoc->ExtendWordSelect(charPos, 1);
|
|
|
|
} else {
|
|
|
|
// Selecting backwards, or anchor beyond last character on line. In these cases,
|
|
|
|
// we select the word containing the character to the *left* of the anchor.
|
|
|
|
if (charPos > pdoc->LineStart(pdoc->LineFromPosition(charPos))) {
|
|
|
|
startWord = pdoc->ExtendWordSelect(charPos, -1);
|
|
|
|
endWord = pdoc->ExtendWordSelect(startWord, 1);
|
|
|
|
} else {
|
|
|
|
// Anchor at start of line; select nothing to begin with.
|
|
|
|
startWord = charPos;
|
|
|
|
endWord = charPos;
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2011-03-22 00:16:49 +00:00
|
|
|
|
|
|
|
wordSelectAnchorStartPos = startWord;
|
|
|
|
wordSelectAnchorEndPos = endWord;
|
|
|
|
wordSelectInitialCaretPos = sel.MainCaret();
|
|
|
|
WordSelection(wordSelectInitialCaretPos);
|
2011-07-17 22:30:49 +00:00
|
|
|
} else if (selectionType == selSubLine || selectionType == selWholeLine) {
|
|
|
|
lineAnchorPos = newPos.Position();
|
|
|
|
LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("Triple click: %d - %d\n", anchor, currentPos);
|
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
SetEmptySelection(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
//Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos);
|
|
|
|
if (doubleClick) {
|
2015-06-07 21:19:26 +00:00
|
|
|
NotifyDoubleClick(pt, modifiers);
|
|
|
|
if (PositionIsHotspot(newCharPos.Position()))
|
|
|
|
NotifyHotSpotDoubleClicked(newCharPos.Position(), modifiers);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else { // Single click
|
|
|
|
if (inSelMargin) {
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.selType = Selection::selStream;
|
2009-04-24 23:35:41 +00:00
|
|
|
if (!shift) {
|
2011-07-17 22:30:49 +00:00
|
|
|
// Single click in margin: select whole line or only subline if word wrap is enabled
|
|
|
|
lineAnchorPos = newPos.Position();
|
2015-06-07 21:19:26 +00:00
|
|
|
selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
|
2011-07-17 22:30:49 +00:00
|
|
|
LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
// Single shift+click in margin: select from line anchor to clicked line
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.MainAnchor() > sel.MainCaret())
|
2011-07-17 22:30:49 +00:00
|
|
|
lineAnchorPos = sel.MainAnchor() - 1;
|
2009-04-24 23:35:41 +00:00
|
|
|
else
|
2011-07-17 22:30:49 +00:00
|
|
|
lineAnchorPos = sel.MainAnchor();
|
2013-08-28 00:44:27 +00:00
|
|
|
// Reset selection type if there is an empty selection.
|
2011-07-17 22:30:49 +00:00
|
|
|
// This ensures that we don't end up stuck in previous selection mode, which is no longer valid.
|
|
|
|
// Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine.
|
|
|
|
// This ensures that we continue selecting in the same selection mode.
|
2013-08-28 00:44:27 +00:00
|
|
|
if (sel.Empty() || (selectionType != selSubLine && selectionType != selWholeLine))
|
2015-06-07 21:19:26 +00:00
|
|
|
selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
|
2011-07-17 22:30:49 +00:00
|
|
|
LineSelection(newPos.Position(), lineAnchorPos, selectionType == selWholeLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
SetDragPosition(SelectionPosition(invalidPosition));
|
2009-04-24 23:35:41 +00:00
|
|
|
SetMouseCapture(true);
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerStart(tickScroll, 100, 10);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
if (PointIsHotspot(pt)) {
|
2015-06-07 21:19:26 +00:00
|
|
|
NotifyHotSpotClicked(newCharPos.Position(), modifiers);
|
|
|
|
hotSpotClickPos = newCharPos.Position();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
if (!shift) {
|
|
|
|
if (PointInSelection(pt) && !SelectionEmpty())
|
|
|
|
inDragDrop = ddInitial;
|
|
|
|
else
|
|
|
|
inDragDrop = ddNone;
|
|
|
|
}
|
|
|
|
SetMouseCapture(true);
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerStart(tickScroll, 100, 10);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
if (inDragDrop != ddInitial) {
|
2009-08-23 02:24:48 +00:00
|
|
|
SetDragPosition(SelectionPosition(invalidPosition));
|
2009-04-24 23:35:41 +00:00
|
|
|
if (!shift) {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (ctrl && multipleSelection) {
|
|
|
|
SelectionRange range(newPos);
|
|
|
|
sel.TentativeSelection(range);
|
|
|
|
InvalidateSelection(range, true);
|
|
|
|
} else {
|
|
|
|
InvalidateSelection(SelectionRange(newPos), true);
|
2010-07-12 22:19:51 +00:00
|
|
|
if (sel.Count() > 1)
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
2011-03-22 00:16:49 +00:00
|
|
|
if ((sel.Count() > 1) || (sel.selType != Selection::selStream))
|
|
|
|
sel.Clear();
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.selType = alt ? Selection::selRectangle : Selection::selStream;
|
|
|
|
SetSelection(newPos, newPos);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2010-07-12 22:19:51 +00:00
|
|
|
SelectionPosition anchorCurrent = newPos;
|
|
|
|
if (shift)
|
|
|
|
anchorCurrent = sel.IsRectangular() ?
|
|
|
|
sel.Rectangular().anchor : sel.RangeMain().anchor;
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.selType = alt ? Selection::selRectangle : Selection::selStream;
|
2009-04-24 23:35:41 +00:00
|
|
|
selectionType = selChar;
|
2009-08-23 02:24:48 +00:00
|
|
|
originalAnchorPos = sel.MainCaret();
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.Rectangular() = SelectionRange(newPos, anchorCurrent);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastClickTime = curTime;
|
2013-08-28 00:44:27 +00:00
|
|
|
lastClick = pt;
|
2015-06-07 21:19:26 +00:00
|
|
|
lastXChosen = static_cast<int>(pt.x) + xOffset;
|
2009-04-24 23:35:41 +00:00
|
|
|
ShowCaretAtCurrentPosition();
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
|
|
|
|
return ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt));
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
bool Editor::PositionIsHotspot(int position) const {
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.styles[static_cast<unsigned char>(pdoc->StyleAt(position))].hotspot;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::PointIsHotspot(Point pt) {
|
2015-06-07 21:19:26 +00:00
|
|
|
int pos = PositionFromLocation(pt, true, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (pos == INVALID_POSITION)
|
|
|
|
return false;
|
|
|
|
return PositionIsHotspot(pos);
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::SetHoverIndicatorPosition(int position) {
|
|
|
|
int hoverIndicatorPosPrev = hoverIndicatorPos;
|
|
|
|
hoverIndicatorPos = INVALID_POSITION;
|
|
|
|
if (vs.indicatorsDynamic == 0)
|
|
|
|
return;
|
|
|
|
if (position != INVALID_POSITION) {
|
|
|
|
for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
|
|
|
|
if (vs.indicators[deco->indicator].IsDynamic()) {
|
|
|
|
if (pdoc->decorations.ValueAt(deco->indicator, position)) {
|
|
|
|
hoverIndicatorPos = position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hoverIndicatorPosPrev != hoverIndicatorPos) {
|
|
|
|
if (hoverIndicatorPosPrev != INVALID_POSITION)
|
|
|
|
InvalidateRange(hoverIndicatorPosPrev, hoverIndicatorPosPrev + 1);
|
|
|
|
if (hoverIndicatorPos != INVALID_POSITION)
|
|
|
|
InvalidateRange(hoverIndicatorPos, hoverIndicatorPos + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetHoverIndicatorPoint(Point pt) {
|
|
|
|
if (vs.indicatorsDynamic == 0) {
|
|
|
|
SetHoverIndicatorPosition(INVALID_POSITION);
|
|
|
|
} else {
|
|
|
|
SetHoverIndicatorPosition(PositionFromLocation(pt, true, true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::SetHotSpotRange(Point *pt) {
|
|
|
|
if (pt) {
|
2015-06-07 21:19:26 +00:00
|
|
|
int pos = PositionFromLocation(*pt, false, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// If we don't limit this to word characters then the
|
|
|
|
// range can encompass more than the run range and then
|
|
|
|
// the underline will not be drawn properly.
|
2015-06-07 21:19:26 +00:00
|
|
|
Range hsNew;
|
|
|
|
hsNew.start = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine);
|
|
|
|
hsNew.end = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// Only invalidate the range if the hotspot range has changed...
|
2015-06-07 21:19:26 +00:00
|
|
|
if (!(hsNew == hotspot)) {
|
|
|
|
if (hotspot.Valid()) {
|
|
|
|
InvalidateRange(hotspot.start, hotspot.end);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
hotspot = hsNew;
|
|
|
|
InvalidateRange(hotspot.start, hotspot.end);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
if (hotspot.Valid()) {
|
|
|
|
InvalidateRange(hotspot.start, hotspot.end);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
hotspot = Range(invalidPosition);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
Range Editor::GetHotSpotRange() const {
|
|
|
|
return hotspot;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) {
|
|
|
|
DwellEnd(true);
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
SelectionPosition movePos = SPositionFromLocation(pt, false, false,
|
2009-08-23 02:24:48 +00:00
|
|
|
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
|
|
|
|
movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
if (inDragDrop == ddInitial) {
|
|
|
|
if (DragThreshold(ptMouseLast, pt)) {
|
|
|
|
SetMouseCapture(false);
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickScroll);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
SetDragPosition(movePos);
|
|
|
|
CopySelectionRange(&drag);
|
|
|
|
StartDrag();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptMouseLast = pt;
|
2015-06-07 21:19:26 +00:00
|
|
|
PRectangle rcClient = GetClientRectangle();
|
|
|
|
Point ptOrigin = GetVisibleOriginInMain();
|
|
|
|
rcClient.Move(0, -ptOrigin.y);
|
|
|
|
if (FineTickerAvailable() && (dwellDelay < SC_TIME_FOREVER) && rcClient.Contains(pt)) {
|
|
|
|
FineTickerStart(tickDwell, dwellDelay, dwellDelay/10);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
//Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y);
|
|
|
|
if (HaveMouseCapture()) {
|
|
|
|
|
|
|
|
// Slow down autoscrolling/selection
|
|
|
|
autoScrollTimer.ticksToWait -= timer.tickSize;
|
|
|
|
if (autoScrollTimer.ticksToWait > 0)
|
|
|
|
return;
|
|
|
|
autoScrollTimer.ticksToWait = autoScrollDelay;
|
|
|
|
|
|
|
|
// Adjust selection
|
2009-08-23 02:24:48 +00:00
|
|
|
if (posDrag.IsValid()) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetDragPosition(movePos);
|
|
|
|
} else {
|
|
|
|
if (selectionType == selChar) {
|
2015-06-07 21:19:26 +00:00
|
|
|
if (sel.selType == Selection::selStream && (modifiers & SCI_ALT) && mouseSelectionRectangularSwitch) {
|
|
|
|
sel.selType = Selection::selRectangle;
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.IsRectangular()) {
|
|
|
|
sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor);
|
|
|
|
SetSelection(movePos, sel.RangeMain().anchor);
|
|
|
|
} else if (sel.Count() > 1) {
|
2015-06-07 21:19:26 +00:00
|
|
|
InvalidateSelection(sel.RangeMain(), false);
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionRange range(movePos, sel.RangeMain().anchor);
|
|
|
|
sel.TentativeSelection(range);
|
|
|
|
InvalidateSelection(range, true);
|
|
|
|
} else {
|
|
|
|
SetSelection(movePos, sel.RangeMain().anchor);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
} else if (selectionType == selWord) {
|
|
|
|
// Continue selecting by word
|
2011-03-22 00:16:49 +00:00
|
|
|
if (movePos.Position() == wordSelectInitialCaretPos) { // Didn't move
|
2009-04-24 23:35:41 +00:00
|
|
|
// No need to do anything. Previously this case was lumped
|
|
|
|
// in with "Moved forward", but that can be harmful in this
|
|
|
|
// case: a handler for the NotifyDoubleClick re-adjusts
|
|
|
|
// the selection for a fancier definition of "word" (for
|
|
|
|
// example, in Perl it is useful to include the leading
|
|
|
|
// '$', '%' or '@' on variables for word selection). In this
|
|
|
|
// the ButtonMove() called via Tick() for auto-scrolling
|
|
|
|
// could result in the fancier word selection adjustment
|
|
|
|
// being unmade.
|
2011-03-22 00:16:49 +00:00
|
|
|
} else {
|
|
|
|
wordSelectInitialCaretPos = -1;
|
|
|
|
WordSelection(movePos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Continue selecting by line
|
2011-07-17 22:30:49 +00:00
|
|
|
LineSelection(movePos.Position(), lineAnchorPos, selectionType == selWholeLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Autoscroll
|
2011-07-17 22:30:49 +00:00
|
|
|
int lineMove = DisplayFromPosition(movePos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (pt.y > rcClient.bottom) {
|
2011-07-17 22:30:49 +00:00
|
|
|
ScrollTo(lineMove - LinesOnScreen() + 1);
|
2009-04-24 23:35:41 +00:00
|
|
|
Redraw();
|
|
|
|
} else if (pt.y < rcClient.top) {
|
2011-07-17 22:30:49 +00:00
|
|
|
ScrollTo(lineMove);
|
2009-04-24 23:35:41 +00:00
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
EnsureCaretVisible(false, false, true);
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (hotspot.Valid() && !PointIsHotspot(pt))
|
2009-04-24 23:35:41 +00:00
|
|
|
SetHotSpotRange(NULL);
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
if (hotSpotClickPos != INVALID_POSITION && PositionFromLocation(pt,true,true) != hotSpotClickPos) {
|
2011-03-22 00:16:49 +00:00
|
|
|
if (inDragDrop == ddNone) {
|
|
|
|
DisplayCursor(Window::cursorText);
|
|
|
|
}
|
|
|
|
hotSpotClickPos = INVALID_POSITION;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
if (vs.fixedColumnWidth > 0) { // There is a margin
|
|
|
|
if (PointInSelMargin(pt)) {
|
2011-03-22 00:16:49 +00:00
|
|
|
DisplayCursor(GetMarginCursor(pt));
|
2010-07-12 22:19:51 +00:00
|
|
|
SetHotSpotRange(NULL);
|
2009-04-24 23:35:41 +00:00
|
|
|
return; // No need to test for selection
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Display regular (drag) cursor over selection
|
|
|
|
if (PointInSelection(pt) && !SelectionEmpty()) {
|
|
|
|
DisplayCursor(Window::cursorArrow);
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
SetHoverIndicatorPoint(pt);
|
|
|
|
if (PointIsHotspot(pt)) {
|
|
|
|
DisplayCursor(Window::cursorHand);
|
|
|
|
SetHotSpotRange(&pt);
|
|
|
|
} else {
|
|
|
|
if (hoverIndicatorPos != invalidPosition)
|
|
|
|
DisplayCursor(Window::cursorHand);
|
|
|
|
else
|
|
|
|
DisplayCursor(Window::cursorText);
|
|
|
|
SetHotSpotRange(NULL);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::ButtonMove(Point pt) {
|
|
|
|
ButtonMoveWithModifiers(pt, 0);
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
|
|
|
|
//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
|
2010-07-12 22:19:51 +00:00
|
|
|
SelectionPosition newPos = SPositionFromLocation(pt, false, false,
|
2009-08-23 02:24:48 +00:00
|
|
|
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
|
2015-06-07 21:19:26 +00:00
|
|
|
if (hoverIndicatorPos != INVALID_POSITION)
|
|
|
|
InvalidateRange(newPos.Position(), newPos.Position() + 1);
|
2009-08-23 02:24:48 +00:00
|
|
|
newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (inDragDrop == ddInitial) {
|
|
|
|
inDragDrop = ddNone;
|
2013-08-28 00:44:27 +00:00
|
|
|
SetEmptySelection(newPos);
|
2011-03-22 00:16:49 +00:00
|
|
|
selectionType = selChar;
|
|
|
|
originalAnchorPos = sel.MainCaret();
|
|
|
|
}
|
|
|
|
if (hotSpotClickPos != INVALID_POSITION && PointIsHotspot(pt)) {
|
|
|
|
hotSpotClickPos = INVALID_POSITION;
|
2015-06-07 21:19:26 +00:00
|
|
|
SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false);
|
|
|
|
newCharPos = MovePositionOutsideChar(newCharPos, -1);
|
|
|
|
NotifyHotSpotReleaseClick(newCharPos.Position(), ctrl ? SCI_CTRL : 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
if (HaveMouseCapture()) {
|
|
|
|
if (PointInSelMargin(pt)) {
|
2011-03-22 00:16:49 +00:00
|
|
|
DisplayCursor(GetMarginCursor(pt));
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
|
|
|
DisplayCursor(Window::cursorText);
|
|
|
|
SetHotSpotRange(NULL);
|
|
|
|
}
|
|
|
|
ptMouseLast = pt;
|
|
|
|
SetMouseCapture(false);
|
2015-06-07 21:19:26 +00:00
|
|
|
if (FineTickerAvailable()) {
|
|
|
|
FineTickerCancel(tickScroll);
|
|
|
|
}
|
|
|
|
NotifyIndicatorClick(false, newPos.Position(), 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (inDragDrop == ddDragging) {
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionPosition selStart = SelectionStart();
|
|
|
|
SelectionPosition selEnd = SelectionEnd();
|
2009-04-24 23:35:41 +00:00
|
|
|
if (selStart < selEnd) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (drag.Length()) {
|
2015-06-07 21:19:26 +00:00
|
|
|
const int length = static_cast<int>(drag.Length());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (ctrl) {
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(
|
|
|
|
newPos.Position(), drag.Data(), length);
|
|
|
|
if (lengthInserted > 0) {
|
|
|
|
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else if (newPos < selStart) {
|
2013-08-28 00:44:27 +00:00
|
|
|
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(
|
|
|
|
newPos.Position(), drag.Data(), length);
|
|
|
|
if (lengthInserted > 0) {
|
|
|
|
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else if (newPos > selEnd) {
|
2013-08-28 00:44:27 +00:00
|
|
|
pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
|
|
|
|
newPos.Add(-static_cast<int>(drag.Length()));
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(
|
|
|
|
newPos.Position(), drag.Data(), length);
|
|
|
|
if (lengthInserted > 0) {
|
|
|
|
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
SetEmptySelection(newPos.Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
drag.Clear();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
selectionType = selChar;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (selectionType == selChar) {
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.Count() > 1) {
|
2010-07-12 22:19:51 +00:00
|
|
|
sel.RangeMain() =
|
2009-08-23 02:24:48 +00:00
|
|
|
SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor);
|
|
|
|
InvalidateSelection(sel.RangeMain(), true);
|
|
|
|
} else {
|
|
|
|
SetSelection(newPos, sel.RangeMain().anchor);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.CommitTentative();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
SetRectangularRange();
|
|
|
|
lastClickTime = curTime;
|
|
|
|
lastClick = pt;
|
2015-06-07 21:19:26 +00:00
|
|
|
lastXChosen = static_cast<int>(pt.x) + xOffset;
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.selType == Selection::selStream) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
inDragDrop = ddNone;
|
|
|
|
EnsureCaretVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called frequently to perform background UI including
|
|
|
|
// caret blinking and automatic scrolling.
|
|
|
|
void Editor::Tick() {
|
|
|
|
if (HaveMouseCapture()) {
|
|
|
|
// Auto scroll
|
|
|
|
ButtonMove(ptMouseLast);
|
|
|
|
}
|
|
|
|
if (caret.period > 0) {
|
|
|
|
timer.ticksToWait -= timer.tickSize;
|
|
|
|
if (timer.ticksToWait <= 0) {
|
|
|
|
caret.on = !caret.on;
|
|
|
|
timer.ticksToWait = caret.period;
|
|
|
|
if (caret.active) {
|
|
|
|
InvalidateCaret();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) {
|
|
|
|
scrollWidth = view.lineWidthMaxSeen;
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
|
|
|
}
|
|
|
|
if ((dwellDelay < SC_TIME_FOREVER) &&
|
|
|
|
(ticksToDwell > 0) &&
|
2011-03-22 00:16:49 +00:00
|
|
|
(!HaveMouseCapture()) &&
|
|
|
|
(ptMouseLast.y >= 0)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
ticksToDwell -= timer.tickSize;
|
|
|
|
if (ticksToDwell <= 0) {
|
|
|
|
dwelling = true;
|
|
|
|
NotifyDwelling(ptMouseLast, dwelling);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::Idle() {
|
|
|
|
|
|
|
|
bool idleDone;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
bool wrappingDone = !Wrapping();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
if (!wrappingDone) {
|
|
|
|
// Wrap lines during idle.
|
2013-08-28 00:44:27 +00:00
|
|
|
WrapLines(wsIdle);
|
2009-04-24 23:35:41 +00:00
|
|
|
// No more wrapping
|
2013-08-28 00:44:27 +00:00
|
|
|
if (!wrapPending.NeedsWrap())
|
2009-04-24 23:35:41 +00:00
|
|
|
wrappingDone = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add more idle things to do here, but make sure idleDone is
|
|
|
|
// set correctly before the function returns. returning
|
2015-06-07 21:19:26 +00:00
|
|
|
// false will stop calling this idle function until SetIdle() is
|
2009-04-24 23:35:41 +00:00
|
|
|
// called again.
|
|
|
|
|
|
|
|
idleDone = wrappingDone; // && thatDone && theOtherThingDone...
|
|
|
|
|
|
|
|
return !idleDone;
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
void Editor::SetTicking(bool) {
|
|
|
|
// SetTicking is deprecated. In the past it was pure virtual and was overridden in each
|
|
|
|
// derived platform class but fine grained timers should now be implemented.
|
|
|
|
// Either way, execution should not arrive here so assert failure.
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::TickFor(TickReason reason) {
|
|
|
|
switch (reason) {
|
|
|
|
case tickCaret:
|
|
|
|
caret.on = !caret.on;
|
|
|
|
if (caret.active) {
|
|
|
|
InvalidateCaret();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tickScroll:
|
|
|
|
// Auto scroll
|
|
|
|
ButtonMove(ptMouseLast);
|
|
|
|
break;
|
|
|
|
case tickWiden:
|
|
|
|
SetScrollBars();
|
|
|
|
FineTickerCancel(tickWiden);
|
|
|
|
break;
|
|
|
|
case tickDwell:
|
|
|
|
if ((!HaveMouseCapture()) &&
|
|
|
|
(ptMouseLast.y >= 0)) {
|
|
|
|
dwelling = true;
|
|
|
|
NotifyDwelling(ptMouseLast, dwelling);
|
|
|
|
}
|
|
|
|
FineTickerCancel(tickDwell);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// tickPlatform handled by subclass
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::FineTickerAvailable() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FineTickerStart is be overridden by subclasses that support fine ticking so
|
|
|
|
// this method should never be called.
|
|
|
|
bool Editor::FineTickerRunning(TickReason) {
|
|
|
|
assert(false);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FineTickerStart is be overridden by subclasses that support fine ticking so
|
|
|
|
// this method should never be called.
|
|
|
|
void Editor::FineTickerStart(TickReason, int, int) {
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FineTickerCancel is be overridden by subclasses that support fine ticking so
|
|
|
|
// this method should never be called.
|
|
|
|
void Editor::FineTickerCancel(TickReason) {
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::SetFocusState(bool focusState) {
|
|
|
|
hasFocus = focusState;
|
|
|
|
NotifyFocus(hasFocus);
|
2015-06-07 21:19:26 +00:00
|
|
|
if (!hasFocus) {
|
2009-04-24 23:35:41 +00:00
|
|
|
CancelModes();
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
ShowCaretAtCurrentPosition();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int Editor::PositionAfterArea(PRectangle rcArea) const {
|
2010-07-12 22:19:51 +00:00
|
|
|
// 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
|
2015-06-07 21:19:26 +00:00
|
|
|
int lineAfter = TopLineOfMain() + static_cast<int>(rcArea.bottom - 1) / vs.lineHeight + 1;
|
2010-07-12 22:19:51 +00:00
|
|
|
if (lineAfter < cs.LinesDisplayed())
|
|
|
|
return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1);
|
|
|
|
else
|
|
|
|
return pdoc->Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Style to a position within the view. If this causes a change at end of last line then
|
|
|
|
// affects later lines so style all the viewed text.
|
|
|
|
void Editor::StyleToPositionInView(Position pos) {
|
2015-06-07 21:19:26 +00:00
|
|
|
int endWindow = PositionAfterArea(GetClientDrawingRectangle());
|
2010-07-12 22:19:51 +00:00
|
|
|
if (pos > endWindow)
|
|
|
|
pos = endWindow;
|
|
|
|
int styleAtEnd = pdoc->StyleAt(pos-1);
|
|
|
|
pdoc->EnsureStyledTo(pos);
|
|
|
|
if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) {
|
2011-03-22 00:16:49 +00:00
|
|
|
// Style at end of line changed so is multi-line change like starting a comment
|
2010-07-12 22:19:51 +00:00
|
|
|
// so require rest of window to be styled.
|
2015-06-07 21:19:26 +00:00
|
|
|
DiscardOverdraw(); // Prepared bitmaps may be invalid
|
|
|
|
// DiscardOverdraw may have truncated client drawing area so recalculate endWindow
|
|
|
|
endWindow = PositionAfterArea(GetClientDrawingRectangle());
|
2010-07-12 22:19:51 +00:00
|
|
|
pdoc->EnsureStyledTo(endWindow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::IdleWork() {
|
2010-07-12 22:19:51 +00:00
|
|
|
// Style the line after the modification as this allows modifications that change just the
|
|
|
|
// line of the modification to heal instead of propagating to the rest of the window.
|
2013-08-28 00:44:27 +00:00
|
|
|
if (workNeeded.items & WorkNeeded::workStyle)
|
|
|
|
StyleToPositionInView(pdoc->LineStart(pdoc->LineFromPosition(workNeeded.upTo) + 2));
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
NotifyUpdateUI();
|
|
|
|
workNeeded.Reset();
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::QueueIdleWork(WorkNeeded::workItems items, int upTo) {
|
|
|
|
workNeeded.Need(items, upTo);
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
bool Editor::PaintContains(PRectangle rc) {
|
|
|
|
if (rc.Empty()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return rcPaint.Contains(rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::PaintContainsMargin() {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (wMargin.GetID()) {
|
|
|
|
// With separate margin view, paint of text view
|
|
|
|
// never contains margin.
|
|
|
|
return false;
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcSelMargin = GetClientRectangle();
|
2015-06-07 21:19:26 +00:00
|
|
|
rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart);
|
2009-04-24 23:35:41 +00:00
|
|
|
return PaintContains(rcSelMargin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::CheckForChangeOutsidePaint(Range r) {
|
|
|
|
if (paintState == painting && !paintingAllText) {
|
|
|
|
//Platform::DebugPrintf("Checking range in paint %d-%d\n", r.start, r.end);
|
|
|
|
if (!r.Valid())
|
|
|
|
return;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
PRectangle rcRange = RectangleFromRange(r, 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
PRectangle rcText = GetTextRectangle();
|
|
|
|
if (rcRange.top < rcText.top) {
|
|
|
|
rcRange.top = rcText.top;
|
|
|
|
}
|
|
|
|
if (rcRange.bottom > rcText.bottom) {
|
|
|
|
rcRange.bottom = rcText.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!PaintContains(rcRange)) {
|
|
|
|
AbandonPaint();
|
2013-08-28 00:44:27 +00:00
|
|
|
paintAbandonedByStyling = true;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) {
|
|
|
|
if ((pos0 != braces[0]) || (pos1 != braces[1]) || (matchStyle != bracesMatchStyle)) {
|
|
|
|
if ((braces[0] != pos0) || (matchStyle != bracesMatchStyle)) {
|
|
|
|
CheckForChangeOutsidePaint(Range(braces[0]));
|
|
|
|
CheckForChangeOutsidePaint(Range(pos0));
|
|
|
|
braces[0] = pos0;
|
|
|
|
}
|
|
|
|
if ((braces[1] != pos1) || (matchStyle != bracesMatchStyle)) {
|
|
|
|
CheckForChangeOutsidePaint(Range(braces[1]));
|
|
|
|
CheckForChangeOutsidePaint(Range(pos1));
|
|
|
|
braces[1] = pos1;
|
|
|
|
}
|
|
|
|
bracesMatchStyle = matchStyle;
|
|
|
|
if (paintState == notPainting) {
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
void Editor::SetAnnotationHeights(int start, int end) {
|
|
|
|
if (vs.annotationVisible) {
|
2015-06-07 21:19:26 +00:00
|
|
|
RefreshStyleData();
|
2013-08-28 00:44:27 +00:00
|
|
|
bool changedHeight = false;
|
|
|
|
for (int line=start; line<end && line<pdoc->LinesTotal(); line++) {
|
|
|
|
int linesWrapped = 1;
|
2015-06-07 21:19:26 +00:00
|
|
|
if (Wrapping()) {
|
2013-08-28 00:44:27 +00:00
|
|
|
AutoSurface surface(this);
|
2015-06-07 21:19:26 +00:00
|
|
|
AutoLineLayout ll(view.llc, view.RetrieveLineLayout(line, *this));
|
2013-08-28 00:44:27 +00:00
|
|
|
if (surface && ll) {
|
2015-06-07 21:19:26 +00:00
|
|
|
view.LayoutLine(*this, line, surface, vs, ll, wrapWidth);
|
2013-08-28 00:44:27 +00:00
|
|
|
linesWrapped = ll->lines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cs.SetHeight(line, pdoc->AnnotationLines(line) + linesWrapped))
|
|
|
|
changedHeight = true;
|
|
|
|
}
|
|
|
|
if (changedHeight) {
|
|
|
|
Redraw();
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void Editor::SetDocPointer(Document *document) {
|
|
|
|
//Platform::DebugPrintf("** %x setdoc to %x\n", pdoc, document);
|
|
|
|
pdoc->RemoveWatcher(this, 0);
|
|
|
|
pdoc->Release();
|
|
|
|
if (document == NULL) {
|
|
|
|
pdoc = new Document();
|
|
|
|
} else {
|
|
|
|
pdoc = document;
|
|
|
|
}
|
|
|
|
pdoc->AddRef();
|
|
|
|
|
|
|
|
// Ensure all positions within document
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
2009-04-24 23:35:41 +00:00
|
|
|
targetStart = 0;
|
|
|
|
targetEnd = 0;
|
|
|
|
|
|
|
|
braces[0] = invalidPosition;
|
|
|
|
braces[1] = invalidPosition;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
vs.ReleaseAllExtendedStyles();
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
SetRepresentations();
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
// Reset the contraction state to fully shown.
|
|
|
|
cs.Clear();
|
|
|
|
cs.InsertLines(0, pdoc->LinesTotal() - 1);
|
2009-06-24 19:09:31 +00:00
|
|
|
SetAnnotationHeights(0, pdoc->LinesTotal());
|
2015-06-07 21:19:26 +00:00
|
|
|
view.llc.Deallocate();
|
2009-04-24 23:35:41 +00:00
|
|
|
NeedWrapping();
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
hotspot = Range(invalidPosition);
|
|
|
|
hoverIndicatorPos = invalidPosition;
|
|
|
|
|
|
|
|
view.ClearAllTabstops();
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
pdoc->AddWatcher(this, 0);
|
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
void Editor::SetAnnotationVisible(int visible) {
|
|
|
|
if (vs.annotationVisible != visible) {
|
|
|
|
bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0));
|
|
|
|
vs.annotationVisible = visible;
|
|
|
|
if (changedFromOrToHidden) {
|
|
|
|
int dir = vs.annotationVisible ? 1 : -1;
|
|
|
|
for (int line=0; line<pdoc->LinesTotal(); line++) {
|
|
|
|
int annotationLines = pdoc->AnnotationLines(line);
|
|
|
|
if (annotationLines > 0) {
|
|
|
|
cs.SetHeight(line, cs.GetHeight(line) + annotationLines * dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-21 23:59:56 +00:00
|
|
|
Redraw();
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* Recursively expand a fold, making lines visible except where they have an unexpanded parent.
|
|
|
|
*/
|
2013-08-28 00:44:27 +00:00
|
|
|
int Editor::ExpandLine(int line) {
|
2009-04-24 23:35:41 +00:00
|
|
|
int lineMaxSubord = pdoc->GetLastChild(line);
|
|
|
|
line++;
|
|
|
|
while (line <= lineMaxSubord) {
|
2013-08-28 00:44:27 +00:00
|
|
|
cs.SetVisible(line, line, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
int level = pdoc->GetLevel(line);
|
|
|
|
if (level & SC_FOLDLEVELHEADERFLAG) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (cs.GetExpanded(line)) {
|
|
|
|
line = ExpandLine(line);
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2013-08-28 00:44:27 +00:00
|
|
|
line = pdoc->GetLastChild(line);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
line++;
|
|
|
|
}
|
|
|
|
return lineMaxSubord;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::SetFoldExpanded(int lineDoc, bool expanded) {
|
|
|
|
if (cs.SetExpanded(lineDoc, expanded)) {
|
|
|
|
RedrawSelMargin();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::FoldLine(int line, int action) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if (line >= 0) {
|
2013-08-28 00:44:27 +00:00
|
|
|
if (action == SC_FOLDACTION_TOGGLE) {
|
2015-06-07 21:19:26 +00:00
|
|
|
if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) {
|
2013-08-28 00:44:27 +00:00
|
|
|
line = pdoc->GetFoldParent(line);
|
|
|
|
if (line < 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
action = (cs.GetExpanded(line)) ? SC_FOLDACTION_CONTRACT : SC_FOLDACTION_EXPAND;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
if (action == SC_FOLDACTION_CONTRACT) {
|
2009-04-24 23:35:41 +00:00
|
|
|
int lineMaxSubord = pdoc->GetLastChild(line);
|
|
|
|
if (lineMaxSubord > line) {
|
2011-07-17 22:30:49 +00:00
|
|
|
cs.SetExpanded(line, 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
cs.SetVisible(line + 1, lineMaxSubord, false);
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
int lineCurrent = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (lineCurrent > line && lineCurrent <= lineMaxSubord) {
|
|
|
|
// This does not re-expand the fold
|
|
|
|
EnsureCaretVisible();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (!(cs.GetVisible(line))) {
|
|
|
|
EnsureLineVisible(line, false);
|
|
|
|
GoToLine(line);
|
|
|
|
}
|
|
|
|
cs.SetExpanded(line, 1);
|
2013-08-28 00:44:27 +00:00
|
|
|
ExpandLine(line);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::FoldExpand(int line, int action, int level) {
|
|
|
|
bool expanding = action == SC_FOLDACTION_EXPAND;
|
|
|
|
if (action == SC_FOLDACTION_TOGGLE) {
|
|
|
|
expanding = !cs.GetExpanded(line);
|
|
|
|
}
|
|
|
|
SetFoldExpanded(line, expanding);
|
|
|
|
if (expanding && (cs.HiddenLines() == 0))
|
|
|
|
// Nothing to do
|
|
|
|
return;
|
|
|
|
int lineMaxSubord = pdoc->GetLastChild(line, level & SC_FOLDLEVELNUMBERMASK);
|
|
|
|
line++;
|
|
|
|
cs.SetVisible(line, lineMaxSubord, expanding);
|
|
|
|
while (line <= lineMaxSubord) {
|
|
|
|
int levelLine = pdoc->GetLevel(line);
|
|
|
|
if (levelLine & SC_FOLDLEVELHEADERFLAG) {
|
|
|
|
SetFoldExpanded(line, expanding);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
line++;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
int Editor::ContractedFoldNext(int lineStart) const {
|
2011-07-17 22:30:49 +00:00
|
|
|
for (int line = lineStart; line<pdoc->LinesTotal();) {
|
2011-03-22 00:16:49 +00:00
|
|
|
if (!cs.GetExpanded(line) && (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG))
|
|
|
|
return line;
|
|
|
|
line = cs.ContractedNext(line+1);
|
|
|
|
if (line < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* Recurse up from this line to find any folds that prevent this line from being visible
|
|
|
|
* and unfold them all.
|
|
|
|
*/
|
|
|
|
void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) {
|
|
|
|
|
|
|
|
// In case in need of wrapping to ensure DisplayFromDoc works.
|
2013-08-28 00:44:27 +00:00
|
|
|
if (lineDoc >= wrapPending.start)
|
|
|
|
WrapLines(wsAll);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
if (!cs.GetVisible(lineDoc)) {
|
2013-08-28 00:44:27 +00:00
|
|
|
// Back up to find a non-blank line
|
|
|
|
int lookLine = lineDoc;
|
|
|
|
int lookLineLevel = pdoc->GetLevel(lookLine);
|
|
|
|
while ((lookLine > 0) && (lookLineLevel & SC_FOLDLEVELWHITEFLAG)) {
|
|
|
|
lookLineLevel = pdoc->GetLevel(--lookLine);
|
|
|
|
}
|
|
|
|
int lineParent = pdoc->GetFoldParent(lookLine);
|
|
|
|
if (lineParent < 0) {
|
|
|
|
// Backed up to a top level line, so try to find parent of initial line
|
|
|
|
lineParent = pdoc->GetFoldParent(lineDoc);
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
if (lineParent >= 0) {
|
|
|
|
if (lineDoc != lineParent)
|
|
|
|
EnsureLineVisible(lineParent, enforcePolicy);
|
|
|
|
if (!cs.GetExpanded(lineParent)) {
|
|
|
|
cs.SetExpanded(lineParent, 1);
|
2013-08-28 00:44:27 +00:00
|
|
|
ExpandLine(lineParent);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
if (enforcePolicy) {
|
|
|
|
int lineDisplay = cs.DisplayFromDoc(lineDoc);
|
|
|
|
if (visiblePolicy & VISIBLE_SLOP) {
|
|
|
|
if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) {
|
|
|
|
SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos()));
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
Redraw();
|
|
|
|
} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||
|
|
|
|
((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) {
|
|
|
|
SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) {
|
|
|
|
SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
|
|
|
|
SetVerticalScrollPos();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
void Editor::FoldAll(int action) {
|
|
|
|
pdoc->EnsureStyledTo(pdoc->Length());
|
|
|
|
int maxLine = pdoc->LinesTotal();
|
|
|
|
bool expanding = action == SC_FOLDACTION_EXPAND;
|
|
|
|
if (action == SC_FOLDACTION_TOGGLE) {
|
|
|
|
// Discover current state
|
|
|
|
for (int lineSeek = 0; lineSeek < maxLine; lineSeek++) {
|
|
|
|
if (pdoc->GetLevel(lineSeek) & SC_FOLDLEVELHEADERFLAG) {
|
|
|
|
expanding = !cs.GetExpanded(lineSeek);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (expanding) {
|
|
|
|
cs.SetVisible(0, maxLine-1, true);
|
|
|
|
for (int line = 0; line < maxLine; line++) {
|
|
|
|
int levelLine = pdoc->GetLevel(line);
|
|
|
|
if (levelLine & SC_FOLDLEVELHEADERFLAG) {
|
|
|
|
SetFoldExpanded(line, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int line = 0; line < maxLine; line++) {
|
|
|
|
int level = pdoc->GetLevel(line);
|
|
|
|
if ((level & SC_FOLDLEVELHEADERFLAG) &&
|
|
|
|
(SC_FOLDLEVELBASE == (level & SC_FOLDLEVELNUMBERMASK))) {
|
|
|
|
SetFoldExpanded(line, false);
|
|
|
|
int lineMaxSubord = pdoc->GetLastChild(line, -1);
|
|
|
|
if (lineMaxSubord > line) {
|
|
|
|
cs.SetVisible(line + 1, lineMaxSubord, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::FoldChanged(int line, int levelNow, int levelPrev) {
|
|
|
|
if (levelNow & SC_FOLDLEVELHEADERFLAG) {
|
|
|
|
if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) {
|
|
|
|
// Adding a fold point.
|
|
|
|
if (cs.SetExpanded(line, true)) {
|
|
|
|
RedrawSelMargin();
|
|
|
|
}
|
|
|
|
FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
|
|
|
|
}
|
|
|
|
} else if (levelPrev & SC_FOLDLEVELHEADERFLAG) {
|
|
|
|
if (!cs.GetExpanded(line)) {
|
|
|
|
// Removing the fold from one that has been contracted so should expand
|
|
|
|
// otherwise lines are left invisible with no way to make them visible
|
|
|
|
if (cs.SetExpanded(line, true)) {
|
|
|
|
RedrawSelMargin();
|
|
|
|
}
|
|
|
|
FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(levelNow & SC_FOLDLEVELWHITEFLAG) &&
|
|
|
|
((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK))) {
|
|
|
|
if (cs.HiddenLines()) {
|
|
|
|
// See if should still be hidden
|
|
|
|
int parentLine = pdoc->GetFoldParent(line);
|
|
|
|
if ((parentLine < 0) || (cs.GetExpanded(parentLine) && cs.GetVisible(parentLine))) {
|
|
|
|
cs.SetVisible(line, line, true);
|
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::NeedShown(int pos, int len) {
|
|
|
|
if (foldAutomatic & SC_AUTOMATICFOLD_SHOW) {
|
|
|
|
int lineStart = pdoc->LineFromPosition(pos);
|
|
|
|
int lineEnd = pdoc->LineFromPosition(pos+len);
|
|
|
|
for (int line = lineStart; line <= lineEnd; line++) {
|
|
|
|
EnsureLineVisible(line, false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NotifyNeedShown(pos, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
int Editor::GetTag(char *tagValue, int tagNumber) {
|
|
|
|
const char *text = 0;
|
|
|
|
int length = 0;
|
|
|
|
if ((tagNumber >= 1) && (tagNumber <= 9)) {
|
2013-08-28 00:44:27 +00:00
|
|
|
char name[3] = "\\?";
|
2010-07-12 22:19:51 +00:00
|
|
|
name[1] = static_cast<char>(tagNumber + '0');
|
|
|
|
length = 2;
|
|
|
|
text = pdoc->SubstituteByPosition(name, &length);
|
|
|
|
}
|
|
|
|
if (tagValue) {
|
|
|
|
if (text)
|
|
|
|
memcpy(tagValue, text, length + 1);
|
|
|
|
else
|
|
|
|
*tagValue = '\0';
|
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) {
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (length == -1)
|
|
|
|
length = istrlen(text);
|
|
|
|
if (replacePatterns) {
|
|
|
|
text = pdoc->SubstituteByPosition(text, &length);
|
|
|
|
if (!text) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (targetStart != targetEnd)
|
|
|
|
pdoc->DeleteChars(targetStart, targetEnd - targetStart);
|
|
|
|
targetEnd = targetStart;
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(targetStart, text, length);
|
|
|
|
targetEnd = targetStart + lengthInserted;
|
2009-04-24 23:35:41 +00:00
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::IsUnicodeMode() const {
|
|
|
|
return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::CodePage() const {
|
|
|
|
if (pdoc)
|
|
|
|
return pdoc->dbcsCodePage;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Editor::WrapCount(int line) {
|
|
|
|
AutoSurface surface(this);
|
2015-06-07 21:19:26 +00:00
|
|
|
AutoLineLayout ll(view.llc, view.RetrieveLineLayout(line, *this));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
if (surface && ll) {
|
2015-06-07 21:19:26 +00:00
|
|
|
view.LayoutLine(*this, line, surface, vs, ll, wrapWidth);
|
2009-04-24 23:35:41 +00:00
|
|
|
return ll->lines;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::AddStyledText(char *buffer, int appendLength) {
|
|
|
|
// The buffer consists of alternating character bytes and style bytes
|
2013-08-28 00:44:27 +00:00
|
|
|
int textLength = appendLength / 2;
|
|
|
|
std::string text(textLength, '\0');
|
|
|
|
int i;
|
2010-07-12 22:19:51 +00:00
|
|
|
for (i = 0; i < textLength; i++) {
|
2009-08-23 02:24:48 +00:00
|
|
|
text[i] = buffer[i*2];
|
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(CurrentPosition(), text.c_str(), textLength);
|
2010-07-12 22:19:51 +00:00
|
|
|
for (i = 0; i < textLength; i++) {
|
2009-08-23 02:24:48 +00:00
|
|
|
text[i] = buffer[i*2+1];
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->StartStyling(CurrentPosition(), static_cast<unsigned char>(0xff));
|
2013-08-28 00:44:27 +00:00
|
|
|
pdoc->SetStyles(textLength, text.c_str());
|
2015-06-07 21:19:26 +00:00
|
|
|
SetEmptySelection(sel.MainCaret() + lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
static bool ValidMargin(uptr_t wParam) {
|
2013-08-28 00:44:27 +00:00
|
|
|
return wParam <= SC_MAX_MARGIN;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *CharPtrFromSPtr(sptr_t lParam) {
|
|
|
|
return reinterpret_cast<char *>(lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
|
|
|
vs.EnsureStyle(wParam);
|
|
|
|
switch (iMessage) {
|
|
|
|
case SCI_STYLESETFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.styles[wParam].fore = ColourDesired(static_cast<long>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STYLESETBACK:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.styles[wParam].back = ColourDesired(static_cast<long>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STYLESETBOLD:
|
2013-08-28 00:44:27 +00:00
|
|
|
vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL;
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETWEIGHT:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.styles[wParam].weight = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STYLESETITALIC:
|
|
|
|
vs.styles[wParam].italic = lParam != 0;
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETEOLFILLED:
|
|
|
|
vs.styles[wParam].eolFilled = lParam != 0;
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETSIZE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.styles[wParam].size = static_cast<int>(lParam * SC_FONT_SIZE_MULTIPLIER);
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
case SCI_STYLESETSIZEFRACTIONAL:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.styles[wParam].size = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STYLESETFONT:
|
|
|
|
if (lParam != 0) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.SetStyleFontName(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETUNDERLINE:
|
|
|
|
vs.styles[wParam].underline = lParam != 0;
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETCASE:
|
|
|
|
vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam);
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETCHARACTERSET:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.styles[wParam].characterSet = static_cast<int>(lParam);
|
2013-08-28 00:44:27 +00:00
|
|
|
pdoc->SetCaseFolder(NULL);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_STYLESETVISIBLE:
|
|
|
|
vs.styles[wParam].visible = lParam != 0;
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETCHANGEABLE:
|
|
|
|
vs.styles[wParam].changeable = lParam != 0;
|
|
|
|
break;
|
|
|
|
case SCI_STYLESETHOTSPOT:
|
|
|
|
vs.styles[wParam].hotspot = lParam != 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
|
|
|
vs.EnsureStyle(wParam);
|
|
|
|
switch (iMessage) {
|
|
|
|
case SCI_STYLEGETFORE:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.styles[wParam].fore.AsLong();
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLEGETBACK:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.styles[wParam].back.AsLong();
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLEGETBOLD:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.styles[wParam].weight > SC_WEIGHT_NORMAL;
|
|
|
|
case SCI_STYLEGETWEIGHT:
|
|
|
|
return vs.styles[wParam].weight;
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLEGETITALIC:
|
|
|
|
return vs.styles[wParam].italic ? 1 : 0;
|
|
|
|
case SCI_STYLEGETEOLFILLED:
|
|
|
|
return vs.styles[wParam].eolFilled ? 1 : 0;
|
|
|
|
case SCI_STYLEGETSIZE:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.styles[wParam].size / SC_FONT_SIZE_MULTIPLIER;
|
|
|
|
case SCI_STYLEGETSIZEFRACTIONAL:
|
2009-04-24 23:35:41 +00:00
|
|
|
return vs.styles[wParam].size;
|
|
|
|
case SCI_STYLEGETFONT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return StringResult(lParam, vs.styles[wParam].fontName);
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLEGETUNDERLINE:
|
|
|
|
return vs.styles[wParam].underline ? 1 : 0;
|
|
|
|
case SCI_STYLEGETCASE:
|
|
|
|
return static_cast<int>(vs.styles[wParam].caseForce);
|
|
|
|
case SCI_STYLEGETCHARACTERSET:
|
|
|
|
return vs.styles[wParam].characterSet;
|
|
|
|
case SCI_STYLEGETVISIBLE:
|
|
|
|
return vs.styles[wParam].visible ? 1 : 0;
|
|
|
|
case SCI_STYLEGETCHANGEABLE:
|
|
|
|
return vs.styles[wParam].changeable ? 1 : 0;
|
|
|
|
case SCI_STYLEGETHOTSPOT:
|
|
|
|
return vs.styles[wParam].hotspot ? 1 : 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
sptr_t Editor::StringResult(sptr_t lParam, const char *val) {
|
2015-06-07 21:19:26 +00:00
|
|
|
const size_t len = val ? strlen(val) : 0;
|
|
|
|
if (lParam) {
|
|
|
|
char *ptr = CharPtrFromSPtr(lParam);
|
|
|
|
if (val)
|
|
|
|
memcpy(ptr, val, len+1);
|
|
|
|
else
|
|
|
|
*ptr = 0;
|
|
|
|
}
|
|
|
|
return len; // Not including NUL
|
|
|
|
}
|
|
|
|
|
|
|
|
sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len) {
|
|
|
|
// No NUL termination: len is number of valid/displayed bytes
|
|
|
|
if ((lParam) && (len > 0)) {
|
|
|
|
char *ptr = CharPtrFromSPtr(lParam);
|
|
|
|
if (val)
|
|
|
|
memcpy(ptr, val, len);
|
|
|
|
else
|
|
|
|
*ptr = 0;
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
2015-06-07 21:19:26 +00:00
|
|
|
return val ? len : 0;
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
|
|
|
//Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
|
|
|
|
|
|
|
|
// Optional macro recording hook
|
|
|
|
if (recordingMacro)
|
|
|
|
NotifyMacroRecord(iMessage, wParam, lParam);
|
|
|
|
|
|
|
|
switch (iMessage) {
|
|
|
|
|
|
|
|
case SCI_GETTEXT: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return pdoc->Length() + 1;
|
|
|
|
if (wParam == 0)
|
|
|
|
return 0;
|
|
|
|
char *ptr = CharPtrFromSPtr(lParam);
|
|
|
|
unsigned int iChar = 0;
|
|
|
|
for (; iChar < wParam - 1; iChar++)
|
|
|
|
ptr[iChar] = pdoc->CharAt(iChar);
|
|
|
|
ptr[iChar] = '\0';
|
|
|
|
return iChar;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_SETTEXT: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2009-04-24 23:35:41 +00:00
|
|
|
pdoc->DeleteChars(0, pdoc->Length());
|
|
|
|
SetEmptySelection(0);
|
2015-06-07 21:19:26 +00:00
|
|
|
const char *text = CharPtrFromSPtr(lParam);
|
|
|
|
pdoc->InsertString(0, text, istrlen(text));
|
2009-04-24 23:35:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_GETTEXTLENGTH:
|
|
|
|
return pdoc->Length();
|
|
|
|
|
|
|
|
case SCI_CUT:
|
|
|
|
Cut();
|
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_COPY:
|
|
|
|
Copy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_COPYALLOWLINE:
|
|
|
|
CopyAllowLine();
|
|
|
|
break;
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
case SCI_VERTICALCENTRECARET:
|
|
|
|
VerticalCentreCaret();
|
|
|
|
break;
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_MOVESELECTEDLINESUP:
|
|
|
|
MoveSelectedLinesUp();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MOVESELECTEDLINESDOWN:
|
|
|
|
MoveSelectedLinesDown();
|
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_COPYRANGE:
|
2015-06-07 21:19:26 +00:00
|
|
|
CopyRangeToClipboard(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_COPYTEXT:
|
2015-06-07 21:19:26 +00:00
|
|
|
CopyText(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_PASTE:
|
|
|
|
Paste();
|
2010-08-21 23:59:56 +00:00
|
|
|
if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
|
2009-04-24 23:35:41 +00:00
|
|
|
SetLastXChosen();
|
|
|
|
}
|
|
|
|
EnsureCaretVisible();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_CLEAR:
|
|
|
|
Clear();
|
|
|
|
SetLastXChosen();
|
|
|
|
EnsureCaretVisible();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_UNDO:
|
|
|
|
Undo();
|
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_CANUNDO:
|
|
|
|
return (pdoc->CanUndo() && !pdoc->IsReadOnly()) ? 1 : 0;
|
|
|
|
|
|
|
|
case SCI_EMPTYUNDOBUFFER:
|
|
|
|
pdoc->DeleteUndoHistory();
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_GETFIRSTVISIBLELINE:
|
|
|
|
return topLine;
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
case SCI_SETFIRSTVISIBLELINE:
|
2015-06-07 21:19:26 +00:00
|
|
|
ScrollTo(static_cast<int>(wParam));
|
2010-07-12 22:19:51 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_GETLINE: { // Risk of overwriting the end of the buffer
|
2015-06-07 21:19:26 +00:00
|
|
|
int lineStart = pdoc->LineStart(static_cast<int>(wParam));
|
|
|
|
int lineEnd = pdoc->LineStart(static_cast<int>(wParam + 1));
|
2009-04-24 23:35:41 +00:00
|
|
|
if (lParam == 0) {
|
|
|
|
return lineEnd - lineStart;
|
|
|
|
}
|
|
|
|
char *ptr = CharPtrFromSPtr(lParam);
|
|
|
|
int iPlace = 0;
|
|
|
|
for (int iChar = lineStart; iChar < lineEnd; iChar++) {
|
|
|
|
ptr[iPlace++] = pdoc->CharAt(iChar);
|
|
|
|
}
|
|
|
|
return iPlace;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_GETLINECOUNT:
|
|
|
|
if (pdoc->LinesTotal() == 0)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return pdoc->LinesTotal();
|
|
|
|
|
|
|
|
case SCI_GETMODIFY:
|
|
|
|
return !pdoc->IsSavePoint();
|
|
|
|
|
|
|
|
case SCI_SETSEL: {
|
|
|
|
int nStart = static_cast<int>(wParam);
|
|
|
|
int nEnd = static_cast<int>(lParam);
|
|
|
|
if (nEnd < 0)
|
|
|
|
nEnd = pdoc->Length();
|
|
|
|
if (nStart < 0)
|
|
|
|
nStart = nEnd; // Remove selection
|
2010-07-12 22:19:51 +00:00
|
|
|
InvalidateSelection(SelectionRange(nStart, nEnd));
|
|
|
|
sel.Clear();
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.selType = Selection::selStream;
|
2009-04-24 23:35:41 +00:00
|
|
|
SetSelection(nEnd, nStart);
|
|
|
|
EnsureCaretVisible();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELTEXT: {
|
|
|
|
SelectionText selectedText;
|
|
|
|
CopySelectionRange(&selectedText);
|
2009-08-23 02:24:48 +00:00
|
|
|
if (lParam == 0) {
|
2013-08-28 00:44:27 +00:00
|
|
|
return selectedText.LengthWithTerminator();
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
char *ptr = CharPtrFromSPtr(lParam);
|
2013-08-28 00:44:27 +00:00
|
|
|
unsigned int iChar = 0;
|
|
|
|
if (selectedText.Length()) {
|
|
|
|
for (; iChar < selectedText.LengthWithTerminator(); iChar++)
|
|
|
|
ptr[iChar] = selectedText.Data()[iChar];
|
2009-08-23 02:24:48 +00:00
|
|
|
} else {
|
|
|
|
ptr[0] = '\0';
|
|
|
|
}
|
|
|
|
return iChar;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_LINEFROMPOSITION:
|
|
|
|
if (static_cast<int>(wParam) < 0)
|
|
|
|
return 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->LineFromPosition(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_POSITIONFROMLINE:
|
|
|
|
if (static_cast<int>(wParam) < 0)
|
2009-08-23 02:24:48 +00:00
|
|
|
wParam = pdoc->LineFromPosition(SelectionStart().Position());
|
2009-04-24 23:35:41 +00:00
|
|
|
if (wParam == 0)
|
|
|
|
return 0; // Even if there is no text, there is a first line that starts at 0
|
|
|
|
if (static_cast<int>(wParam) > pdoc->LinesTotal())
|
|
|
|
return -1;
|
|
|
|
//if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway...
|
|
|
|
// return -1;
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->LineStart(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// Replacement of the old Scintilla interpretation of EM_LINELENGTH
|
|
|
|
case SCI_LINELENGTH:
|
|
|
|
if ((static_cast<int>(wParam) < 0) ||
|
|
|
|
(static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length())))
|
|
|
|
return 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->LineStart(static_cast<int>(wParam) + 1) - pdoc->LineStart(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_REPLACESEL: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
2009-08-23 02:24:48 +00:00
|
|
|
UndoGroup ug(pdoc);
|
2009-04-24 23:35:41 +00:00
|
|
|
ClearSelection();
|
|
|
|
char *replacement = CharPtrFromSPtr(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(
|
|
|
|
sel.MainCaret(), replacement, istrlen(replacement));
|
|
|
|
SetEmptySelection(sel.MainCaret() + lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
EnsureCaretVisible();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETTARGETSTART:
|
2015-06-07 21:19:26 +00:00
|
|
|
targetStart = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETTARGETSTART:
|
|
|
|
return targetStart;
|
|
|
|
|
|
|
|
case SCI_SETTARGETEND:
|
2015-06-07 21:19:26 +00:00
|
|
|
targetEnd = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETTARGETEND:
|
|
|
|
return targetEnd;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
case SCI_SETTARGETRANGE:
|
|
|
|
targetStart = static_cast<int>(wParam);
|
|
|
|
targetEnd = static_cast<int>(lParam);
|
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_TARGETFROMSELECTION:
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.MainCaret() < sel.MainAnchor()) {
|
|
|
|
targetStart = sel.MainCaret();
|
|
|
|
targetEnd = sel.MainAnchor();
|
2009-04-24 23:35:41 +00:00
|
|
|
} else {
|
2009-08-23 02:24:48 +00:00
|
|
|
targetStart = sel.MainAnchor();
|
|
|
|
targetEnd = sel.MainCaret();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
case SCI_GETTARGETTEXT: {
|
|
|
|
std::string text = RangeText(targetStart, targetEnd);
|
|
|
|
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(text.c_str()), text.length());
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_REPLACETARGET:
|
|
|
|
PLATFORM_ASSERT(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_REPLACETARGETRE:
|
|
|
|
PLATFORM_ASSERT(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SEARCHINTARGET:
|
|
|
|
PLATFORM_ASSERT(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
return SearchInTarget(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETSEARCHFLAGS:
|
2015-06-07 21:19:26 +00:00
|
|
|
searchFlags = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSEARCHFLAGS:
|
|
|
|
return searchFlags;
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
case SCI_GETTAG:
|
2015-06-07 21:19:26 +00:00
|
|
|
return GetTag(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_POSITIONBEFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) - 1, -1, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_POSITIONAFTER:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) + 1, 1, true);
|
|
|
|
|
|
|
|
case SCI_POSITIONRELATIVE:
|
|
|
|
return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_LINESCROLL:
|
2015-06-07 21:19:26 +00:00
|
|
|
ScrollTo(topLine + static_cast<int>(lParam));
|
|
|
|
HorizontalScrollTo(xOffset + static_cast<int>(wParam)* static_cast<int>(vs.spaceWidth));
|
2009-04-24 23:35:41 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
case SCI_SETXOFFSET:
|
2015-06-07 21:19:26 +00:00
|
|
|
xOffset = static_cast<int>(wParam);
|
2011-03-22 00:16:49 +00:00
|
|
|
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetHorizontalScrollPos();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETXOFFSET:
|
|
|
|
return xOffset;
|
|
|
|
|
|
|
|
case SCI_CHOOSECARETX:
|
|
|
|
SetLastXChosen();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SCROLLCARET:
|
|
|
|
EnsureCaretVisible();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETREADONLY:
|
|
|
|
pdoc->SetReadOnly(wParam != 0);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case SCI_GETREADONLY:
|
|
|
|
return pdoc->IsReadOnly();
|
|
|
|
|
|
|
|
case SCI_CANPASTE:
|
|
|
|
return CanPaste();
|
|
|
|
|
|
|
|
case SCI_POINTXFROMPOSITION:
|
|
|
|
if (lParam < 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
Point pt = LocationFromPosition(static_cast<int>(lParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
// Convert to view-relative
|
2015-06-07 21:19:26 +00:00
|
|
|
return static_cast<int>(pt.x) - vs.textStart + vs.fixedColumnWidth;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_POINTYFROMPOSITION:
|
|
|
|
if (lParam < 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
Point pt = LocationFromPosition(static_cast<int>(lParam));
|
|
|
|
return static_cast<int>(pt.y);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_FINDTEXT:
|
|
|
|
return FindText(wParam, lParam);
|
|
|
|
|
|
|
|
case SCI_GETTEXTRANGE: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
2009-08-23 02:24:48 +00:00
|
|
|
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
int cpMax = static_cast<int>(tr->chrg.cpMax);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (cpMax == -1)
|
|
|
|
cpMax = pdoc->Length();
|
|
|
|
PLATFORM_ASSERT(cpMax <= pdoc->Length());
|
2015-06-07 21:19:26 +00:00
|
|
|
int len = static_cast<int>(cpMax - tr->chrg.cpMin); // No -1 as cpMin and cpMax are referring to inter character positions
|
|
|
|
pdoc->GetCharRange(tr->lpstrText, static_cast<int>(tr->chrg.cpMin), len);
|
2009-04-24 23:35:41 +00:00
|
|
|
// Spec says copied text is terminated with a NUL
|
|
|
|
tr->lpstrText[len] = '\0';
|
|
|
|
return len; // Not including NUL
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_HIDESELECTION:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.hideSelection = wParam != 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_FORMATRANGE:
|
2009-08-23 02:24:48 +00:00
|
|
|
return FormatRange(wParam != 0, reinterpret_cast<Sci_RangeToFormat *>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETMARGINLEFT:
|
|
|
|
return vs.leftMarginWidth;
|
|
|
|
|
|
|
|
case SCI_GETMARGINRIGHT:
|
|
|
|
return vs.rightMarginWidth;
|
|
|
|
|
|
|
|
case SCI_SETMARGINLEFT:
|
2015-06-07 21:19:26 +00:00
|
|
|
lastXChosen += static_cast<int>(lParam) - vs.leftMarginWidth;
|
|
|
|
vs.leftMarginWidth = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETMARGINRIGHT:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.rightMarginWidth = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Control specific mesages
|
|
|
|
|
|
|
|
case SCI_ADDTEXT: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(
|
|
|
|
CurrentPosition(), CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
|
|
|
SetEmptySelection(sel.MainCaret() + lengthInserted);
|
2009-04-24 23:35:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_ADDSTYLEDTEXT:
|
|
|
|
if (lParam)
|
2015-06-07 21:19:26 +00:00
|
|
|
AddStyledText(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_INSERTTEXT: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
int insertPos = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (static_cast<int>(wParam) == -1)
|
|
|
|
insertPos = CurrentPosition();
|
|
|
|
int newCurrent = CurrentPosition();
|
|
|
|
char *sz = CharPtrFromSPtr(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
const int lengthInserted = pdoc->InsertString(insertPos, sz, istrlen(sz));
|
2009-04-24 23:35:41 +00:00
|
|
|
if (newCurrent > insertPos)
|
2015-06-07 21:19:26 +00:00
|
|
|
newCurrent += lengthInserted;
|
2009-04-24 23:35:41 +00:00
|
|
|
SetEmptySelection(newCurrent);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
case SCI_CHANGEINSERTION:
|
|
|
|
PLATFORM_ASSERT(lParam);
|
|
|
|
pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
|
|
|
return 0;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_APPENDTEXT:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_CLEARALL:
|
|
|
|
ClearAll();
|
|
|
|
return 0;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_DELETERANGE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->DeleteChars(static_cast<int>(wParam), static_cast<int>(lParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
return 0;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_CLEARDOCUMENTSTYLE:
|
|
|
|
ClearDocumentStyle();
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_SETUNDOCOLLECTION:
|
|
|
|
pdoc->SetUndoCollection(wParam != 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_GETUNDOCOLLECTION:
|
|
|
|
return pdoc->IsCollectingUndo();
|
|
|
|
|
|
|
|
case SCI_BEGINUNDOACTION:
|
|
|
|
pdoc->BeginUndoAction();
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_ENDUNDOACTION:
|
|
|
|
pdoc->EndUndoAction();
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_GETCARETPERIOD:
|
|
|
|
return caret.period;
|
|
|
|
|
|
|
|
case SCI_SETCARETPERIOD:
|
2015-06-07 21:19:26 +00:00
|
|
|
CaretSetPeriod(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_GETWORDCHARS:
|
|
|
|
return pdoc->GetCharsOfClass(CharClassify::ccWord, reinterpret_cast<unsigned char *>(lParam));
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETWORDCHARS: {
|
|
|
|
pdoc->SetDefaultCharClasses(false);
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
|
|
|
pdoc->SetCharClasses(reinterpret_cast<unsigned char *>(lParam), CharClassify::ccWord);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_GETWHITESPACECHARS:
|
|
|
|
return pdoc->GetCharsOfClass(CharClassify::ccSpace, reinterpret_cast<unsigned char *>(lParam));
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETWHITESPACECHARS: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
|
|
|
pdoc->SetCharClasses(reinterpret_cast<unsigned char *>(lParam), CharClassify::ccSpace);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_GETPUNCTUATIONCHARS:
|
|
|
|
return pdoc->GetCharsOfClass(CharClassify::ccPunctuation, reinterpret_cast<unsigned char *>(lParam));
|
|
|
|
|
|
|
|
case SCI_SETPUNCTUATIONCHARS: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
|
|
|
pdoc->SetCharClasses(reinterpret_cast<unsigned char *>(lParam), CharClassify::ccPunctuation);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETCHARSDEFAULT:
|
|
|
|
pdoc->SetDefaultCharClasses(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETLENGTH:
|
|
|
|
return pdoc->Length();
|
|
|
|
|
|
|
|
case SCI_ALLOCATE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->Allocate(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCHARAT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->CharAt(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETCURRENTPOS:
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.IsRectangular()) {
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Rectangular().caret.SetPosition(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
Redraw();
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
SetSelection(static_cast<int>(wParam), sel.MainAnchor());
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCURRENTPOS:
|
2009-08-23 02:24:48 +00:00
|
|
|
return sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETANCHOR:
|
2009-08-23 02:24:48 +00:00
|
|
|
if (sel.IsRectangular()) {
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
Redraw();
|
|
|
|
} else {
|
2015-06-07 21:19:26 +00:00
|
|
|
SetSelection(sel.MainCaret(), static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETANCHOR:
|
2009-08-23 02:24:48 +00:00
|
|
|
return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETSELECTIONSTART:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetSelection(Platform::Maximum(sel.MainCaret(), static_cast<int>(wParam)), static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELECTIONSTART:
|
2010-07-12 22:19:51 +00:00
|
|
|
return sel.LimitsForRectangularElseMain().start.Position();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETSELECTIONEND:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetSelection(static_cast<int>(wParam), Platform::Minimum(sel.MainAnchor(), static_cast<int>(wParam)));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELECTIONEND:
|
2010-07-12 22:19:51 +00:00
|
|
|
return sel.LimitsForRectangularElseMain().end.Position();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_SETEMPTYSELECTION:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetEmptySelection(static_cast<int>(wParam));
|
2011-07-17 22:30:49 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETPRINTMAGNIFICATION:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.printParameters.magnification = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETPRINTMAGNIFICATION:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.printParameters.magnification;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETPRINTCOLOURMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.printParameters.colourMode = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETPRINTCOLOURMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.printParameters.colourMode;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETPRINTWRAPMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.printParameters.wrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone;
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETPRINTWRAPMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.printParameters.wrapState;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETSTYLEAT:
|
|
|
|
if (static_cast<int>(wParam) >= pdoc->Length())
|
|
|
|
return 0;
|
|
|
|
else
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->StyleAt(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_REDO:
|
|
|
|
Redo();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SELECTALL:
|
|
|
|
SelectAll();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETSAVEPOINT:
|
|
|
|
pdoc->SetSavePoint();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSTYLEDTEXT: {
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
2009-08-23 02:24:48 +00:00
|
|
|
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
int iPlace = 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
for (long iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) {
|
|
|
|
tr->lpstrText[iPlace++] = pdoc->CharAt(static_cast<int>(iChar));
|
|
|
|
tr->lpstrText[iPlace++] = pdoc->StyleAt(static_cast<int>(iChar));
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
tr->lpstrText[iPlace] = '\0';
|
|
|
|
tr->lpstrText[iPlace + 1] = '\0';
|
|
|
|
return iPlace;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_CANREDO:
|
|
|
|
return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0;
|
|
|
|
|
|
|
|
case SCI_MARKERLINEFROMHANDLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->LineFromHandle(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_MARKERDELETEHANDLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->DeleteMarkFromHandle(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETVIEWWS:
|
|
|
|
return vs.viewWhitespace;
|
|
|
|
|
|
|
|
case SCI_SETVIEWWS:
|
|
|
|
vs.viewWhitespace = static_cast<WhiteSpaceVisibility>(wParam);
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
case SCI_GETWHITESPACESIZE:
|
|
|
|
return vs.whitespaceSize;
|
|
|
|
|
|
|
|
case SCI_SETWHITESPACESIZE:
|
|
|
|
vs.whitespaceSize = static_cast<int>(wParam);
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_POSITIONFROMPOINT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
|
|
|
|
false, false);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_POSITIONFROMPOINTCLOSE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
|
|
|
|
true, false);
|
2009-08-23 02:24:48 +00:00
|
|
|
|
|
|
|
case SCI_CHARPOSITIONFROMPOINT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
|
|
|
|
false, true);
|
2009-08-23 02:24:48 +00:00
|
|
|
|
|
|
|
case SCI_CHARPOSITIONFROMPOINTCLOSE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
|
|
|
|
true, true);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GOTOLINE:
|
2015-06-07 21:19:26 +00:00
|
|
|
GoToLine(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GOTOPOS:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetEmptySelection(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
EnsureCaretVisible();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCURLINE: {
|
2009-08-23 02:24:48 +00:00
|
|
|
int lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret());
|
2009-04-24 23:35:41 +00:00
|
|
|
int lineStart = pdoc->LineStart(lineCurrentPos);
|
|
|
|
unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1);
|
|
|
|
if (lParam == 0) {
|
|
|
|
return 1 + lineEnd - lineStart;
|
|
|
|
}
|
|
|
|
PLATFORM_ASSERT(wParam > 0);
|
|
|
|
char *ptr = CharPtrFromSPtr(lParam);
|
|
|
|
unsigned int iPlace = 0;
|
|
|
|
for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) {
|
|
|
|
ptr[iPlace++] = pdoc->CharAt(iChar);
|
|
|
|
}
|
|
|
|
ptr[iPlace] = '\0';
|
2009-08-23 02:24:48 +00:00
|
|
|
return sel.MainCaret() - lineStart;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_GETENDSTYLED:
|
|
|
|
return pdoc->GetEndStyled();
|
|
|
|
|
|
|
|
case SCI_GETEOLMODE:
|
|
|
|
return pdoc->eolMode;
|
|
|
|
|
|
|
|
case SCI_SETEOLMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->eolMode = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_SETLINEENDTYPESALLOWED:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (pdoc->SetLineEndTypesAllowed(static_cast<int>(wParam))) {
|
2013-08-28 00:44:27 +00:00
|
|
|
cs.Clear();
|
|
|
|
cs.InsertLines(0, pdoc->LinesTotal() - 1);
|
|
|
|
SetAnnotationHeights(0, pdoc->LinesTotal());
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETLINEENDTYPESALLOWED:
|
|
|
|
return pdoc->GetLineEndTypesAllowed();
|
|
|
|
|
|
|
|
case SCI_GETLINEENDTYPESACTIVE:
|
|
|
|
return pdoc->GetLineEndTypesActive();
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STARTSTYLING:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->StartStyling(static_cast<int>(wParam), static_cast<char>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETSTYLING:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->SetStyleFor(static_cast<int>(wParam), static_cast<char>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETSTYLINGEX: // Specify a complete styling buffer
|
|
|
|
if (lParam == 0)
|
|
|
|
return 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->SetStyles(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETBUFFEREDDRAW:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.bufferedDraw = wParam != 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETBUFFEREDDRAW:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.bufferedDraw;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETTWOPHASEDRAW:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.phasesDraw == EditView::phasesTwo;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETTWOPHASEDRAW:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (view.SetTwoPhaseDraw(wParam != 0))
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETPHASESDRAW:
|
|
|
|
return view.phasesDraw;
|
|
|
|
|
|
|
|
case SCI_SETPHASESDRAW:
|
|
|
|
if (view.SetPhasesDraw(static_cast<int>(wParam)))
|
|
|
|
InvalidateStyleRedraw();
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
case SCI_SETFONTQUALITY:
|
|
|
|
vs.extraFontFlag &= ~SC_EFF_QUALITY_MASK;
|
|
|
|
vs.extraFontFlag |= (wParam & SC_EFF_QUALITY_MASK);
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETFONTQUALITY:
|
|
|
|
return (vs.extraFontFlag & SC_EFF_QUALITY_MASK);
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETTABWIDTH:
|
|
|
|
if (wParam > 0) {
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->tabInChars = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (pdoc->indentInChars == 0)
|
|
|
|
pdoc->actualIndentInChars = pdoc->tabInChars;
|
|
|
|
}
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETTABWIDTH:
|
|
|
|
return pdoc->tabInChars;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
case SCI_CLEARTABSTOPS:
|
|
|
|
if (view.ClearTabstops(static_cast<int>(wParam))) {
|
|
|
|
DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast<int>(wParam));
|
|
|
|
NotifyModified(pdoc, mh, NULL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ADDTABSTOP:
|
|
|
|
if (view.AddTabstop(static_cast<int>(wParam), static_cast<int>(lParam))) {
|
|
|
|
DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast<int>(wParam));
|
|
|
|
NotifyModified(pdoc, mh, NULL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETNEXTTABSTOP:
|
|
|
|
return view.GetNextTabstop(static_cast<int>(wParam), static_cast<int>(lParam));
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETINDENT:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->indentInChars = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
if (pdoc->indentInChars != 0)
|
|
|
|
pdoc->actualIndentInChars = pdoc->indentInChars;
|
|
|
|
else
|
|
|
|
pdoc->actualIndentInChars = pdoc->tabInChars;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETINDENT:
|
|
|
|
return pdoc->indentInChars;
|
|
|
|
|
|
|
|
case SCI_SETUSETABS:
|
|
|
|
pdoc->useTabs = wParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETUSETABS:
|
|
|
|
return pdoc->useTabs;
|
|
|
|
|
|
|
|
case SCI_SETLINEINDENTATION:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->SetLineIndentation(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETLINEINDENTATION:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetLineIndentation(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETLINEINDENTPOSITION:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetLineIndentPosition(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETTABINDENTS:
|
|
|
|
pdoc->tabIndents = wParam != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETTABINDENTS:
|
|
|
|
return pdoc->tabIndents;
|
|
|
|
|
|
|
|
case SCI_SETBACKSPACEUNINDENTS:
|
|
|
|
pdoc->backspaceUnindents = wParam != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETBACKSPACEUNINDENTS:
|
|
|
|
return pdoc->backspaceUnindents;
|
|
|
|
|
|
|
|
case SCI_SETMOUSEDWELLTIME:
|
2015-06-07 21:19:26 +00:00
|
|
|
dwellDelay = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
ticksToDwell = dwellDelay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMOUSEDWELLTIME:
|
|
|
|
return dwellDelay;
|
|
|
|
|
|
|
|
case SCI_WORDSTARTPOSITION:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->ExtendWordSelect(static_cast<int>(wParam), -1, lParam != 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_WORDENDPOSITION:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->ExtendWordSelect(static_cast<int>(wParam), 1, lParam != 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETWRAPMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (vs.SetWrapState(static_cast<int>(wParam))) {
|
|
|
|
xOffset = 0;
|
|
|
|
ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
ReconfigureScrollBars();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETWRAPMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.wrapState;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETWRAPVISUALFLAGS:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (vs.SetWrapVisualFlags(static_cast<int>(wParam))) {
|
2010-07-12 22:19:51 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
ReconfigureScrollBars();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETWRAPVISUALFLAGS:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.wrapVisualFlags;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETWRAPVISUALFLAGSLOCATION:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (vs.SetWrapVisualFlagsLocation(static_cast<int>(wParam))) {
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETWRAPVISUALFLAGSLOCATION:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.wrapVisualFlagsLocation;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETWRAPSTARTINDENT:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (vs.SetWrapVisualStartIndent(static_cast<int>(wParam))) {
|
2010-07-12 22:19:51 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
ReconfigureScrollBars();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETWRAPSTARTINDENT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.wrapVisualStartIndent;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
case SCI_SETWRAPINDENTMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (vs.SetWrapIndentMode(static_cast<int>(wParam))) {
|
2010-07-12 22:19:51 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
ReconfigureScrollBars();
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETWRAPINDENTMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.wrapIndentMode;
|
2009-08-23 02:24:48 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETLAYOUTCACHE:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.llc.SetLevel(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETLAYOUTCACHE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.llc.GetLevel();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETPOSITIONCACHE:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.posCache.SetSize(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETPOSITIONCACHE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.posCache.GetSize();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETSCROLLWIDTH:
|
|
|
|
PLATFORM_ASSERT(wParam > 0);
|
|
|
|
if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) {
|
2015-06-07 21:19:26 +00:00
|
|
|
view.lineWidthMaxSeen = 0;
|
|
|
|
scrollWidth = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSCROLLWIDTH:
|
|
|
|
return scrollWidth;
|
|
|
|
|
|
|
|
case SCI_SETSCROLLWIDTHTRACKING:
|
|
|
|
trackLineWidth = wParam != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSCROLLWIDTHTRACKING:
|
|
|
|
return trackLineWidth;
|
|
|
|
|
|
|
|
case SCI_LINESJOIN:
|
|
|
|
LinesJoin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_LINESSPLIT:
|
2015-06-07 21:19:26 +00:00
|
|
|
LinesSplit(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_TEXTWIDTH:
|
2013-08-28 00:44:27 +00:00
|
|
|
PLATFORM_ASSERT(wParam < vs.styles.size());
|
2009-04-24 23:35:41 +00:00
|
|
|
PLATFORM_ASSERT(lParam);
|
2015-06-07 21:19:26 +00:00
|
|
|
return TextWidth(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_TEXTHEIGHT:
|
2015-06-07 21:19:26 +00:00
|
|
|
RefreshStyleData();
|
2009-04-24 23:35:41 +00:00
|
|
|
return vs.lineHeight;
|
|
|
|
|
|
|
|
case SCI_SETENDATLASTLINE:
|
|
|
|
PLATFORM_ASSERT((wParam == 0) || (wParam == 1));
|
|
|
|
if (endAtLastLine != (wParam != 0)) {
|
|
|
|
endAtLastLine = wParam != 0;
|
|
|
|
SetScrollBars();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETENDATLASTLINE:
|
|
|
|
return endAtLastLine;
|
|
|
|
|
|
|
|
case SCI_SETCARETSTICKY:
|
2013-08-28 00:44:27 +00:00
|
|
|
PLATFORM_ASSERT(wParam <= SC_CARETSTICKY_WHITESPACE);
|
|
|
|
if (wParam <= SC_CARETSTICKY_WHITESPACE) {
|
2015-06-07 21:19:26 +00:00
|
|
|
caretSticky = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCARETSTICKY:
|
|
|
|
return caretSticky;
|
|
|
|
|
|
|
|
case SCI_TOGGLECARETSTICKY:
|
|
|
|
caretSticky = !caretSticky;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCOLUMN:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetColumn(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_FINDCOLUMN:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->FindColumn(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETHSCROLLBAR :
|
|
|
|
if (horizontalScrollBarVisible != (wParam != 0)) {
|
|
|
|
horizontalScrollBarVisible = wParam != 0;
|
|
|
|
SetScrollBars();
|
|
|
|
ReconfigureScrollBars();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETHSCROLLBAR:
|
|
|
|
return horizontalScrollBarVisible;
|
|
|
|
|
|
|
|
case SCI_SETVSCROLLBAR:
|
|
|
|
if (verticalScrollBarVisible != (wParam != 0)) {
|
|
|
|
verticalScrollBarVisible = wParam != 0;
|
|
|
|
SetScrollBars();
|
|
|
|
ReconfigureScrollBars();
|
2013-08-28 00:44:27 +00:00
|
|
|
if (verticalScrollBarVisible)
|
|
|
|
SetVerticalScrollPos();
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETVSCROLLBAR:
|
|
|
|
return verticalScrollBarVisible;
|
|
|
|
|
|
|
|
case SCI_SETINDENTATIONGUIDES:
|
|
|
|
vs.viewIndentationGuides = IndentView(wParam);
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETINDENTATIONGUIDES:
|
|
|
|
return vs.viewIndentationGuides;
|
|
|
|
|
|
|
|
case SCI_SETHIGHLIGHTGUIDE:
|
|
|
|
if ((highlightGuideColumn != static_cast<int>(wParam)) || (wParam > 0)) {
|
2015-06-07 21:19:26 +00:00
|
|
|
highlightGuideColumn = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETHIGHLIGHTGUIDE:
|
|
|
|
return highlightGuideColumn;
|
|
|
|
|
|
|
|
case SCI_GETLINEENDPOSITION:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->LineEnd(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETCODEPAGE:
|
2015-06-07 21:19:26 +00:00
|
|
|
if (ValidCodePage(static_cast<int>(wParam))) {
|
|
|
|
if (pdoc->SetDBCSCodePage(static_cast<int>(wParam))) {
|
2013-08-28 00:44:27 +00:00
|
|
|
cs.Clear();
|
|
|
|
cs.InsertLines(0, pdoc->LinesTotal() - 1);
|
|
|
|
SetAnnotationHeights(0, pdoc->LinesTotal());
|
|
|
|
InvalidateStyleRedraw();
|
2015-06-07 21:19:26 +00:00
|
|
|
SetRepresentations();
|
2013-08-28 00:44:27 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCODEPAGE:
|
|
|
|
return pdoc->dbcsCodePage;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
case SCI_SETIMEINTERACTION:
|
|
|
|
imeInteraction = static_cast<EditModel::IMEInteraction>(wParam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETIMEINTERACTION:
|
|
|
|
return imeInteraction;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
#ifdef INCLUDE_DEPRECATED_FEATURES
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETUSEPALETTE:
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETUSEPALETTE:
|
2013-08-28 00:44:27 +00:00
|
|
|
return 0;
|
|
|
|
#endif
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// Marker definition and setting
|
|
|
|
case SCI_MARKERDEFINE:
|
2013-08-28 00:44:27 +00:00
|
|
|
if (wParam <= MARKER_MAX) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.markers[wParam].markType = static_cast<int>(lParam);
|
2013-08-28 00:44:27 +00:00
|
|
|
vs.CalcLargestMarkerHeight();
|
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleData();
|
|
|
|
RedrawSelMargin();
|
|
|
|
break;
|
2009-06-24 19:09:31 +00:00
|
|
|
|
|
|
|
case SCI_MARKERSYMBOLDEFINED:
|
|
|
|
if (wParam <= MARKER_MAX)
|
|
|
|
return vs.markers[wParam].markType;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_MARKERSETFORE:
|
|
|
|
if (wParam <= MARKER_MAX)
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.markers[wParam].fore = ColourDesired(static_cast<long>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleData();
|
|
|
|
RedrawSelMargin();
|
|
|
|
break;
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_MARKERSETBACKSELECTED:
|
|
|
|
if (wParam <= MARKER_MAX)
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.markers[wParam].backSelected = ColourDesired(static_cast<long>(lParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
InvalidateStyleData();
|
|
|
|
RedrawSelMargin();
|
2011-07-17 22:30:49 +00:00
|
|
|
break;
|
|
|
|
case SCI_MARKERENABLEHIGHLIGHT:
|
2015-06-07 21:19:26 +00:00
|
|
|
marginView.highlightDelimiter.isEnabled = wParam == 1;
|
2013-08-28 00:44:27 +00:00
|
|
|
RedrawSelMargin();
|
2011-07-17 22:30:49 +00:00
|
|
|
break;
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_MARKERSETBACK:
|
|
|
|
if (wParam <= MARKER_MAX)
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.markers[wParam].back = ColourDesired(static_cast<long>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleData();
|
|
|
|
RedrawSelMargin();
|
|
|
|
break;
|
|
|
|
case SCI_MARKERSETALPHA:
|
|
|
|
if (wParam <= MARKER_MAX)
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.markers[wParam].alpha = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
case SCI_MARKERADD: {
|
2015-06-07 21:19:26 +00:00
|
|
|
int markerID = pdoc->AddMark(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
return markerID;
|
|
|
|
}
|
|
|
|
case SCI_MARKERADDSET:
|
|
|
|
if (lParam != 0)
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->AddMarkSet(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARKERDELETE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->DeleteMark(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARKERDELETEALL:
|
|
|
|
pdoc->DeleteAllMarks(static_cast<int>(wParam));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARKERGET:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetMark(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_MARKERNEXT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->MarkerNext(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_MARKERPREVIOUS: {
|
2015-06-07 21:19:26 +00:00
|
|
|
for (int iLine = static_cast<int>(wParam); iLine >= 0; iLine--) {
|
2009-04-24 23:35:41 +00:00
|
|
|
if ((pdoc->GetMark(iLine) & lParam) != 0)
|
|
|
|
return iLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
case SCI_MARKERDEFINEPIXMAP:
|
|
|
|
if (wParam <= MARKER_MAX) {
|
|
|
|
vs.markers[wParam].SetXPM(CharPtrFromSPtr(lParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
vs.CalcLargestMarkerHeight();
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
2013-08-28 00:44:27 +00:00
|
|
|
InvalidateStyleData();
|
|
|
|
RedrawSelMargin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_RGBAIMAGESETWIDTH:
|
2015-06-07 21:19:26 +00:00
|
|
|
sizeRGBAImage.x = static_cast<XYPOSITION>(wParam);
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_RGBAIMAGESETHEIGHT:
|
2015-06-07 21:19:26 +00:00
|
|
|
sizeRGBAImage.y = static_cast<XYPOSITION>(wParam);
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_RGBAIMAGESETSCALE:
|
2015-06-07 21:19:26 +00:00
|
|
|
scaleRGBAImage = static_cast<float>(wParam);
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARKERDEFINERGBAIMAGE:
|
|
|
|
if (wParam <= MARKER_MAX) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, reinterpret_cast<unsigned char *>(lParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
vs.CalcLargestMarkerHeight();
|
2015-06-07 21:19:26 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleData();
|
|
|
|
RedrawSelMargin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETMARGINTYPEN:
|
|
|
|
if (ValidMargin(wParam)) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.ms[wParam].style = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMARGINTYPEN:
|
|
|
|
if (ValidMargin(wParam))
|
|
|
|
return vs.ms[wParam].style;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_SETMARGINWIDTHN:
|
|
|
|
if (ValidMargin(wParam)) {
|
|
|
|
// Short-circuit if the width is unchanged, to avoid unnecessary redraw.
|
|
|
|
if (vs.ms[wParam].width != lParam) {
|
2015-06-07 21:19:26 +00:00
|
|
|
lastXChosen += static_cast<int>(lParam) - vs.ms[wParam].width;
|
|
|
|
vs.ms[wParam].width = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMARGINWIDTHN:
|
|
|
|
if (ValidMargin(wParam))
|
|
|
|
return vs.ms[wParam].width;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_SETMARGINMASKN:
|
|
|
|
if (ValidMargin(wParam)) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.ms[wParam].mask = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMARGINMASKN:
|
|
|
|
if (ValidMargin(wParam))
|
|
|
|
return vs.ms[wParam].mask;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_SETMARGINSENSITIVEN:
|
|
|
|
if (ValidMargin(wParam)) {
|
|
|
|
vs.ms[wParam].sensitive = lParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMARGINSENSITIVEN:
|
|
|
|
if (ValidMargin(wParam))
|
|
|
|
return vs.ms[wParam].sensitive ? 1 : 0;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
case SCI_SETMARGINCURSORN:
|
|
|
|
if (ValidMargin(wParam))
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.ms[wParam].cursor = static_cast<int>(lParam);
|
2011-03-22 00:16:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMARGINCURSORN:
|
|
|
|
if (ValidMargin(wParam))
|
|
|
|
return vs.ms[wParam].cursor;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLECLEARALL:
|
|
|
|
vs.ClearStyles();
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_STYLESETFORE:
|
|
|
|
case SCI_STYLESETBACK:
|
|
|
|
case SCI_STYLESETBOLD:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_STYLESETWEIGHT:
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLESETITALIC:
|
|
|
|
case SCI_STYLESETEOLFILLED:
|
|
|
|
case SCI_STYLESETSIZE:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_STYLESETSIZEFRACTIONAL:
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLESETFONT:
|
|
|
|
case SCI_STYLESETUNDERLINE:
|
|
|
|
case SCI_STYLESETCASE:
|
|
|
|
case SCI_STYLESETCHARACTERSET:
|
|
|
|
case SCI_STYLESETVISIBLE:
|
|
|
|
case SCI_STYLESETCHANGEABLE:
|
|
|
|
case SCI_STYLESETHOTSPOT:
|
|
|
|
StyleSetMessage(iMessage, wParam, lParam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_STYLEGETFORE:
|
|
|
|
case SCI_STYLEGETBACK:
|
|
|
|
case SCI_STYLEGETBOLD:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_STYLEGETWEIGHT:
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLEGETITALIC:
|
|
|
|
case SCI_STYLEGETEOLFILLED:
|
|
|
|
case SCI_STYLEGETSIZE:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_STYLEGETSIZEFRACTIONAL:
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_STYLEGETFONT:
|
|
|
|
case SCI_STYLEGETUNDERLINE:
|
|
|
|
case SCI_STYLEGETCASE:
|
|
|
|
case SCI_STYLEGETCHARACTERSET:
|
|
|
|
case SCI_STYLEGETVISIBLE:
|
|
|
|
case SCI_STYLEGETCHANGEABLE:
|
|
|
|
case SCI_STYLEGETHOTSPOT:
|
|
|
|
return StyleGetMessage(iMessage, wParam, lParam);
|
|
|
|
|
|
|
|
case SCI_STYLERESETDEFAULT:
|
|
|
|
vs.ResetDefaultStyle();
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
case SCI_SETSTYLEBITS:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.EnsureStyle(0xff);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSTYLEBITS:
|
2015-06-07 21:19:26 +00:00
|
|
|
return 8;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETLINESTATE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->SetLineState(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETLINESTATE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetLineState(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETMAXLINESTATE:
|
|
|
|
return pdoc->GetMaxLineState();
|
|
|
|
|
|
|
|
case SCI_GETCARETLINEVISIBLE:
|
|
|
|
return vs.showCaretLineBackground;
|
|
|
|
case SCI_SETCARETLINEVISIBLE:
|
|
|
|
vs.showCaretLineBackground = wParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
case SCI_GETCARETLINEVISIBLEALWAYS:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.alwaysShowCaretLineBackground;
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETCARETLINEVISIBLEALWAYS:
|
2013-08-28 00:44:27 +00:00
|
|
|
vs.alwaysShowCaretLineBackground = wParam != 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_GETCARETLINEBACK:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.caretLineBackground.AsLong();
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETCARETLINEBACK:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.caretLineBackground = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
case SCI_GETCARETLINEBACKALPHA:
|
|
|
|
return vs.caretLineAlpha;
|
|
|
|
case SCI_SETCARETLINEBACKALPHA:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.caretLineAlpha = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Folding messages
|
|
|
|
|
|
|
|
case SCI_VISIBLEFROMDOCLINE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return cs.DisplayFromDoc(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_DOCLINEFROMVISIBLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return cs.DocFromDisplay(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_WRAPCOUNT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return WrapCount(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETFOLDLEVEL: {
|
2015-06-07 21:19:26 +00:00
|
|
|
int prev = pdoc->SetLevel(static_cast<int>(wParam), static_cast<int>(lParam));
|
|
|
|
if (prev != static_cast<int>(lParam))
|
2009-04-24 23:35:41 +00:00
|
|
|
RedrawSelMargin();
|
|
|
|
return prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_GETFOLDLEVEL:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetLevel(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETLASTCHILD:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetLastChild(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETFOLDPARENT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->GetFoldParent(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SHOWLINES:
|
2015-06-07 21:19:26 +00:00
|
|
|
cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), true);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_HIDELINES:
|
2009-04-25 23:38:15 +00:00
|
|
|
if (wParam > 0)
|
2015-06-07 21:19:26 +00:00
|
|
|
cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), false);
|
2009-04-24 23:35:41 +00:00
|
|
|
SetScrollBars();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETLINEVISIBLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return cs.GetVisible(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_GETALLLINESVISIBLE:
|
|
|
|
return cs.HiddenLines() ? 0 : 1;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETFOLDEXPANDED:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetFoldExpanded(static_cast<int>(wParam), lParam != 0);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETFOLDEXPANDED:
|
2015-06-07 21:19:26 +00:00
|
|
|
return cs.GetExpanded(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_SETAUTOMATICFOLD:
|
2015-06-07 21:19:26 +00:00
|
|
|
foldAutomatic = static_cast<int>(wParam);
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETAUTOMATICFOLD:
|
|
|
|
return foldAutomatic;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETFOLDFLAGS:
|
2015-06-07 21:19:26 +00:00
|
|
|
foldFlags = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_TOGGLEFOLD:
|
2015-06-07 21:19:26 +00:00
|
|
|
FoldLine(static_cast<int>(wParam), SC_FOLDACTION_TOGGLE);
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_FOLDLINE:
|
2015-06-07 21:19:26 +00:00
|
|
|
FoldLine(static_cast<int>(wParam), static_cast<int>(lParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_FOLDCHILDREN:
|
2015-06-07 21:19:26 +00:00
|
|
|
FoldExpand(static_cast<int>(wParam), static_cast<int>(lParam), pdoc->GetLevel(static_cast<int>(wParam)));
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_FOLDALL:
|
2015-06-07 21:19:26 +00:00
|
|
|
FoldAll(static_cast<int>(wParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_EXPANDCHILDREN:
|
2015-06-07 21:19:26 +00:00
|
|
|
FoldExpand(static_cast<int>(wParam), SC_FOLDACTION_EXPAND, static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
case SCI_CONTRACTEDFOLDNEXT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return ContractedFoldNext(static_cast<int>(wParam));
|
2011-03-22 00:16:49 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_ENSUREVISIBLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
EnsureLineVisible(static_cast<int>(wParam), false);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ENSUREVISIBLEENFORCEPOLICY:
|
2015-06-07 21:19:26 +00:00
|
|
|
EnsureLineVisible(static_cast<int>(wParam), true);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_SCROLLRANGE:
|
2015-06-07 21:19:26 +00:00
|
|
|
ScrollRange(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam)));
|
2013-08-28 00:44:27 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SEARCHANCHOR:
|
|
|
|
SearchAnchor();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SEARCHNEXT:
|
|
|
|
case SCI_SEARCHPREV:
|
|
|
|
return SearchText(iMessage, wParam, lParam);
|
|
|
|
|
|
|
|
case SCI_SETXCARETPOLICY:
|
2015-06-07 21:19:26 +00:00
|
|
|
caretXPolicy = static_cast<int>(wParam);
|
|
|
|
caretXSlop = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETYCARETPOLICY:
|
2015-06-07 21:19:26 +00:00
|
|
|
caretYPolicy = static_cast<int>(wParam);
|
|
|
|
caretYSlop = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETVISIBLEPOLICY:
|
2015-06-07 21:19:26 +00:00
|
|
|
visiblePolicy = static_cast<int>(wParam);
|
|
|
|
visibleSlop = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_LINESONSCREEN:
|
|
|
|
return LinesOnScreen();
|
|
|
|
|
|
|
|
case SCI_SETSELFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.selColours.fore = ColourOptional(wParam, lParam);
|
|
|
|
vs.selAdditionalForeground = ColourDesired(static_cast<long>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETSELBACK:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.selColours.back = ColourOptional(wParam, lParam);
|
|
|
|
vs.selAdditionalBackground = ColourDesired(static_cast<long>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETSELALPHA:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.selAlpha = static_cast<int>(wParam);
|
|
|
|
vs.selAdditionalAlpha = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELALPHA:
|
|
|
|
return vs.selAlpha;
|
|
|
|
|
|
|
|
case SCI_GETSELEOLFILLED:
|
|
|
|
return vs.selEOLFilled;
|
|
|
|
|
|
|
|
case SCI_SETSELEOLFILLED:
|
|
|
|
vs.selEOLFilled = wParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETWHITESPACEFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.whitespaceColours.fore = ColourOptional(wParam, lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETWHITESPACEBACK:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.whitespaceColours.back = ColourOptional(wParam, lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETCARETFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.caretcolour = ColourDesired(static_cast<long>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCARETFORE:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.caretcolour.AsLong();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETCARETSTYLE:
|
2013-08-28 00:44:27 +00:00
|
|
|
if (wParam <= CARETSTYLE_BLOCK)
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.caretStyle = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
else
|
|
|
|
/* Default to the line caret */
|
|
|
|
vs.caretStyle = CARETSTYLE_LINE;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCARETSTYLE:
|
|
|
|
return vs.caretStyle;
|
|
|
|
|
|
|
|
case SCI_SETCARETWIDTH:
|
2013-08-28 00:44:27 +00:00
|
|
|
if (static_cast<int>(wParam) <= 0)
|
2009-04-24 23:35:41 +00:00
|
|
|
vs.caretWidth = 0;
|
|
|
|
else if (wParam >= 3)
|
|
|
|
vs.caretWidth = 3;
|
|
|
|
else
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.caretWidth = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCARETWIDTH:
|
|
|
|
return vs.caretWidth;
|
|
|
|
|
|
|
|
case SCI_ASSIGNCMDKEY:
|
2015-06-07 21:19:26 +00:00
|
|
|
kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
|
|
|
|
Platform::HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_CLEARCMDKEY:
|
2015-06-07 21:19:26 +00:00
|
|
|
kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
|
|
|
|
Platform::HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_CLEARALLCMDKEYS:
|
|
|
|
kmap.Clear();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICSETSTYLE:
|
|
|
|
if (wParam <= INDIC_MAX) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.indicators[wParam].sacNormal.style = static_cast<int>(lParam);
|
|
|
|
vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETSTYLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.style : 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_INDICSETFORE:
|
|
|
|
if (wParam <= INDIC_MAX) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.indicators[wParam].sacNormal.fore = ColourDesired(static_cast<long>(lParam));
|
|
|
|
vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.fore.AsLong() : 0;
|
|
|
|
|
|
|
|
case SCI_INDICSETHOVERSTYLE:
|
|
|
|
if (wParam <= INDIC_MAX) {
|
|
|
|
vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETHOVERSTYLE:
|
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.style : 0;
|
|
|
|
|
|
|
|
case SCI_INDICSETHOVERFORE:
|
|
|
|
if (wParam <= INDIC_MAX) {
|
|
|
|
vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETHOVERFORE:
|
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsLong() : 0;
|
|
|
|
|
|
|
|
case SCI_INDICSETFLAGS:
|
|
|
|
if (wParam <= INDIC_MAX) {
|
|
|
|
vs.indicators[wParam].SetFlags(static_cast<int>(lParam));
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETFLAGS:
|
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].Flags() : 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_INDICSETUNDER:
|
|
|
|
if (wParam <= INDIC_MAX) {
|
|
|
|
vs.indicators[wParam].under = lParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETUNDER:
|
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].under : 0;
|
2009-06-24 19:09:31 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_INDICSETALPHA:
|
2010-08-21 23:59:56 +00:00
|
|
|
if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.indicators[wParam].fillAlpha = static_cast<int>(lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETALPHA:
|
2009-06-24 19:09:31 +00:00
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fillAlpha : 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_INDICSETOUTLINEALPHA:
|
|
|
|
if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) {
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.indicators[wParam].outlineAlpha = static_cast<int>(lParam);
|
2011-07-17 22:30:49 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICGETOUTLINEALPHA:
|
|
|
|
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].outlineAlpha : 0;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETINDICATORCURRENT:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->decorations.SetCurrentIndicator(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_GETINDICATORCURRENT:
|
|
|
|
return pdoc->decorations.GetCurrentIndicator();
|
|
|
|
case SCI_SETINDICATORVALUE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->decorations.SetCurrentValue(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SCI_GETINDICATORVALUE:
|
|
|
|
return pdoc->decorations.GetCurrentValue();
|
|
|
|
|
|
|
|
case SCI_INDICATORFILLRANGE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->DecorationFillRange(static_cast<int>(wParam), pdoc->decorations.GetCurrentValue(), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICATORCLEARRANGE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->DecorationFillRange(static_cast<int>(wParam), 0, static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_INDICATORALLONFOR:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->decorations.AllOnFor(static_cast<int>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_INDICATORVALUEAT:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->decorations.ValueAt(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_INDICATORSTART:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->decorations.Start(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_INDICATOREND:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->decorations.End(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_LINEDOWN:
|
|
|
|
case SCI_LINEDOWNEXTEND:
|
|
|
|
case SCI_PARADOWN:
|
|
|
|
case SCI_PARADOWNEXTEND:
|
|
|
|
case SCI_LINEUP:
|
|
|
|
case SCI_LINEUPEXTEND:
|
|
|
|
case SCI_PARAUP:
|
|
|
|
case SCI_PARAUPEXTEND:
|
|
|
|
case SCI_CHARLEFT:
|
|
|
|
case SCI_CHARLEFTEXTEND:
|
|
|
|
case SCI_CHARRIGHT:
|
|
|
|
case SCI_CHARRIGHTEXTEND:
|
|
|
|
case SCI_WORDLEFT:
|
|
|
|
case SCI_WORDLEFTEXTEND:
|
|
|
|
case SCI_WORDRIGHT:
|
|
|
|
case SCI_WORDRIGHTEXTEND:
|
|
|
|
case SCI_WORDLEFTEND:
|
|
|
|
case SCI_WORDLEFTENDEXTEND:
|
|
|
|
case SCI_WORDRIGHTEND:
|
|
|
|
case SCI_WORDRIGHTENDEXTEND:
|
|
|
|
case SCI_HOME:
|
|
|
|
case SCI_HOMEEXTEND:
|
|
|
|
case SCI_LINEEND:
|
|
|
|
case SCI_LINEENDEXTEND:
|
|
|
|
case SCI_HOMEWRAP:
|
|
|
|
case SCI_HOMEWRAPEXTEND:
|
|
|
|
case SCI_LINEENDWRAP:
|
|
|
|
case SCI_LINEENDWRAPEXTEND:
|
|
|
|
case SCI_DOCUMENTSTART:
|
|
|
|
case SCI_DOCUMENTSTARTEXTEND:
|
|
|
|
case SCI_DOCUMENTEND:
|
|
|
|
case SCI_DOCUMENTENDEXTEND:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_SCROLLTOSTART:
|
|
|
|
case SCI_SCROLLTOEND:
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_STUTTEREDPAGEUP:
|
|
|
|
case SCI_STUTTEREDPAGEUPEXTEND:
|
|
|
|
case SCI_STUTTEREDPAGEDOWN:
|
|
|
|
case SCI_STUTTEREDPAGEDOWNEXTEND:
|
|
|
|
|
|
|
|
case SCI_PAGEUP:
|
|
|
|
case SCI_PAGEUPEXTEND:
|
|
|
|
case SCI_PAGEDOWN:
|
|
|
|
case SCI_PAGEDOWNEXTEND:
|
|
|
|
case SCI_EDITTOGGLEOVERTYPE:
|
|
|
|
case SCI_CANCEL:
|
|
|
|
case SCI_DELETEBACK:
|
|
|
|
case SCI_TAB:
|
|
|
|
case SCI_BACKTAB:
|
|
|
|
case SCI_NEWLINE:
|
|
|
|
case SCI_FORMFEED:
|
|
|
|
case SCI_VCHOME:
|
|
|
|
case SCI_VCHOMEEXTEND:
|
|
|
|
case SCI_VCHOMEWRAP:
|
|
|
|
case SCI_VCHOMEWRAPEXTEND:
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_VCHOMEDISPLAY:
|
|
|
|
case SCI_VCHOMEDISPLAYEXTEND:
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_ZOOMIN:
|
|
|
|
case SCI_ZOOMOUT:
|
|
|
|
case SCI_DELWORDLEFT:
|
|
|
|
case SCI_DELWORDRIGHT:
|
|
|
|
case SCI_DELWORDRIGHTEND:
|
|
|
|
case SCI_DELLINELEFT:
|
|
|
|
case SCI_DELLINERIGHT:
|
|
|
|
case SCI_LINECOPY:
|
|
|
|
case SCI_LINECUT:
|
|
|
|
case SCI_LINEDELETE:
|
|
|
|
case SCI_LINETRANSPOSE:
|
|
|
|
case SCI_LINEDUPLICATE:
|
|
|
|
case SCI_LOWERCASE:
|
|
|
|
case SCI_UPPERCASE:
|
|
|
|
case SCI_LINESCROLLDOWN:
|
|
|
|
case SCI_LINESCROLLUP:
|
|
|
|
case SCI_WORDPARTLEFT:
|
|
|
|
case SCI_WORDPARTLEFTEXTEND:
|
|
|
|
case SCI_WORDPARTRIGHT:
|
|
|
|
case SCI_WORDPARTRIGHTEXTEND:
|
|
|
|
case SCI_DELETEBACKNOTLINE:
|
|
|
|
case SCI_HOMEDISPLAY:
|
|
|
|
case SCI_HOMEDISPLAYEXTEND:
|
|
|
|
case SCI_LINEENDDISPLAY:
|
|
|
|
case SCI_LINEENDDISPLAYEXTEND:
|
|
|
|
case SCI_LINEDOWNRECTEXTEND:
|
|
|
|
case SCI_LINEUPRECTEXTEND:
|
|
|
|
case SCI_CHARLEFTRECTEXTEND:
|
|
|
|
case SCI_CHARRIGHTRECTEXTEND:
|
|
|
|
case SCI_HOMERECTEXTEND:
|
|
|
|
case SCI_VCHOMERECTEXTEND:
|
|
|
|
case SCI_LINEENDRECTEXTEND:
|
|
|
|
case SCI_PAGEUPRECTEXTEND:
|
|
|
|
case SCI_PAGEDOWNRECTEXTEND:
|
|
|
|
case SCI_SELECTIONDUPLICATE:
|
|
|
|
return KeyCommand(iMessage);
|
|
|
|
|
|
|
|
case SCI_BRACEHIGHLIGHT:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetBraceHighlight(static_cast<int>(wParam), static_cast<int>(lParam), STYLE_BRACELIGHT);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_BRACEHIGHLIGHTINDICATOR:
|
|
|
|
if (lParam >= 0 && lParam <= INDIC_MAX) {
|
|
|
|
vs.braceHighlightIndicatorSet = wParam != 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.braceHighlightIndicator = static_cast<int>(lParam);
|
2011-07-17 22:30:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_BRACEBADLIGHT:
|
|
|
|
SetBraceHighlight(static_cast<int>(wParam), -1, STYLE_BRACEBAD);
|
|
|
|
break;
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_BRACEBADLIGHTINDICATOR:
|
|
|
|
if (lParam >= 0 && lParam <= INDIC_MAX) {
|
|
|
|
vs.braceBadLightIndicatorSet = wParam != 0;
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.braceBadLightIndicator = static_cast<int>(lParam);
|
2011-07-17 22:30:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_BRACEMATCH:
|
|
|
|
// wParam is position of char to find brace for,
|
|
|
|
// lParam is maximum amount of text to restyle to find it
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->BraceMatch(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_GETVIEWEOL:
|
|
|
|
return vs.viewEOL;
|
|
|
|
|
|
|
|
case SCI_SETVIEWEOL:
|
|
|
|
vs.viewEOL = wParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETZOOM:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.zoomLevel = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
NotifyZoom();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETZOOM:
|
|
|
|
return vs.zoomLevel;
|
|
|
|
|
|
|
|
case SCI_GETEDGECOLUMN:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.theEdge;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETEDGECOLUMN:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.theEdge = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETEDGEMODE:
|
|
|
|
return vs.edgeState;
|
|
|
|
|
|
|
|
case SCI_SETEDGEMODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.edgeState = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETEDGECOLOUR:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.edgecolour.AsLong();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETEDGECOLOUR:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.edgecolour = ColourDesired(static_cast<long>(wParam));
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETDOCPOINTER:
|
|
|
|
return reinterpret_cast<sptr_t>(pdoc);
|
|
|
|
|
|
|
|
case SCI_SETDOCPOINTER:
|
|
|
|
CancelModes();
|
|
|
|
SetDocPointer(reinterpret_cast<Document *>(lParam));
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_CREATEDOCUMENT: {
|
|
|
|
Document *doc = new Document();
|
2013-08-28 00:44:27 +00:00
|
|
|
doc->AddRef();
|
2009-04-24 23:35:41 +00:00
|
|
|
return reinterpret_cast<sptr_t>(doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_ADDREFDOCUMENT:
|
|
|
|
(reinterpret_cast<Document *>(lParam))->AddRef();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_RELEASEDOCUMENT:
|
|
|
|
(reinterpret_cast<Document *>(lParam))->Release();
|
|
|
|
break;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_CREATELOADER: {
|
|
|
|
Document *doc = new Document();
|
|
|
|
doc->AddRef();
|
2015-06-07 21:19:26 +00:00
|
|
|
doc->Allocate(static_cast<int>(wParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
doc->SetUndoCollection(false);
|
|
|
|
return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc));
|
|
|
|
}
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_SETMODEVENTMASK:
|
2015-06-07 21:19:26 +00:00
|
|
|
modEventMask = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_GETMODEVENTMASK:
|
|
|
|
return modEventMask;
|
|
|
|
|
|
|
|
case SCI_CONVERTEOLS:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->ConvertLineEnds(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document
|
2009-04-24 23:35:41 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_SETLENGTHFORENCODE:
|
2015-06-07 21:19:26 +00:00
|
|
|
lengthForEncode = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_SELECTIONISRECTANGLE:
|
2009-08-23 02:24:48 +00:00
|
|
|
return sel.selType == Selection::selRectangle ? 1 : 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETSELECTIONMODE: {
|
|
|
|
switch (wParam) {
|
|
|
|
case SC_SEL_STREAM:
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream));
|
|
|
|
sel.selType = Selection::selStream;
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SC_SEL_RECTANGLE:
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selRectangle));
|
|
|
|
sel.selType = Selection::selRectangle;
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
case SC_SEL_LINES:
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selLines));
|
|
|
|
sel.selType = Selection::selLines;
|
|
|
|
break;
|
|
|
|
case SC_SEL_THIN:
|
|
|
|
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selThin));
|
|
|
|
sel.selType = Selection::selThin;
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream));
|
|
|
|
sel.selType = Selection::selStream;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
InvalidateSelection(sel.RangeMain(), true);
|
2015-06-07 21:19:26 +00:00
|
|
|
break;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
case SCI_GETSELECTIONMODE:
|
2009-08-23 02:24:48 +00:00
|
|
|
switch (sel.selType) {
|
|
|
|
case Selection::selStream:
|
2009-04-24 23:35:41 +00:00
|
|
|
return SC_SEL_STREAM;
|
2009-08-23 02:24:48 +00:00
|
|
|
case Selection::selRectangle:
|
2009-04-24 23:35:41 +00:00
|
|
|
return SC_SEL_RECTANGLE;
|
2009-08-23 02:24:48 +00:00
|
|
|
case Selection::selLines:
|
2009-04-24 23:35:41 +00:00
|
|
|
return SC_SEL_LINES;
|
2009-08-23 02:24:48 +00:00
|
|
|
case Selection::selThin:
|
|
|
|
return SC_SEL_THIN;
|
2009-04-24 23:35:41 +00:00
|
|
|
default: // ?!
|
|
|
|
return SC_SEL_STREAM;
|
|
|
|
}
|
2009-08-23 02:24:48 +00:00
|
|
|
case SCI_GETLINESELSTARTPOSITION:
|
2009-04-24 23:35:41 +00:00
|
|
|
case SCI_GETLINESELENDPOSITION: {
|
2015-06-07 21:19:26 +00:00
|
|
|
SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(static_cast<int>(wParam))),
|
|
|
|
SelectionPosition(pdoc->LineEnd(static_cast<int>(wParam))));
|
2009-08-23 02:24:48 +00:00
|
|
|
for (size_t r=0; r<sel.Count(); r++) {
|
|
|
|
SelectionSegment portion = sel.Range(r).Intersect(segmentLine);
|
|
|
|
if (portion.start.IsValid()) {
|
|
|
|
return (iMessage == SCI_GETLINESELSTARTPOSITION) ? portion.start.Position() : portion.end.Position();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return INVALID_POSITION;
|
2009-04-24 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_SETOVERTYPE:
|
|
|
|
inOverstrike = wParam != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETOVERTYPE:
|
|
|
|
return inOverstrike ? 1 : 0;
|
|
|
|
|
|
|
|
case SCI_SETFOCUS:
|
|
|
|
SetFocusState(wParam != 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETFOCUS:
|
|
|
|
return hasFocus;
|
|
|
|
|
|
|
|
case SCI_SETSTATUS:
|
2015-06-07 21:19:26 +00:00
|
|
|
errorStatus = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSTATUS:
|
|
|
|
return errorStatus;
|
|
|
|
|
|
|
|
case SCI_SETMOUSEDOWNCAPTURES:
|
|
|
|
mouseDownCaptures = wParam != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMOUSEDOWNCAPTURES:
|
|
|
|
return mouseDownCaptures;
|
|
|
|
|
|
|
|
case SCI_SETCURSOR:
|
2015-06-07 21:19:26 +00:00
|
|
|
cursorMode = static_cast<int>(wParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
DisplayCursor(Window::cursorText);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCURSOR:
|
|
|
|
return cursorMode;
|
|
|
|
|
|
|
|
case SCI_SETCONTROLCHARSYMBOL:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.controlCharSymbol = static_cast<int>(wParam);
|
|
|
|
InvalidateStyleRedraw();
|
2009-04-24 23:35:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETCONTROLCHARSYMBOL:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.controlCharSymbol;
|
|
|
|
|
|
|
|
case SCI_SETREPRESENTATION:
|
|
|
|
reprs.SetRepresentation(reinterpret_cast<const char *>(wParam), CharPtrFromSPtr(lParam));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETREPRESENTATION: {
|
|
|
|
const Representation *repr = reprs.RepresentationFromCharacter(
|
|
|
|
reinterpret_cast<const char *>(wParam), UTF8MaxBytes);
|
|
|
|
if (repr) {
|
|
|
|
return StringResult(lParam, repr->stringRep.c_str());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_CLEARREPRESENTATION:
|
|
|
|
reprs.ClearRepresentation(reinterpret_cast<const char *>(wParam));
|
|
|
|
break;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_STARTRECORD:
|
|
|
|
recordingMacro = true;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_STOPRECORD:
|
|
|
|
recordingMacro = false;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SCI_MOVECARETINSIDEVIEW:
|
|
|
|
MoveCaretInsideView();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETFOLDMARGINCOLOUR:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.foldmarginColour = ColourOptional(wParam, lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETFOLDMARGINHICOLOUR:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.foldmarginHighlightColour = ColourOptional(wParam, lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETHOTSPOTACTIVEFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.hotspotColours.fore = ColourOptional(wParam, lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETHOTSPOTACTIVEFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.hotspotColours.fore.AsLong();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETHOTSPOTACTIVEBACK:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.hotspotColours.back = ColourOptional(wParam, lParam);
|
2009-04-24 23:35:41 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETHOTSPOTACTIVEBACK:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.hotspotColours.back.AsLong();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
case SCI_SETHOTSPOTACTIVEUNDERLINE:
|
|
|
|
vs.hotspotUnderline = wParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETHOTSPOTACTIVEUNDERLINE:
|
|
|
|
return vs.hotspotUnderline ? 1 : 0;
|
|
|
|
|
|
|
|
case SCI_SETHOTSPOTSINGLELINE:
|
|
|
|
vs.hotspotSingleLine = wParam != 0;
|
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETHOTSPOTSINGLELINE:
|
|
|
|
return vs.hotspotSingleLine ? 1 : 0;
|
|
|
|
|
|
|
|
case SCI_SETPASTECONVERTENDINGS:
|
|
|
|
convertPastes = wParam != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETPASTECONVERTENDINGS:
|
|
|
|
return convertPastes ? 1 : 0;
|
|
|
|
|
2009-04-25 23:38:15 +00:00
|
|
|
case SCI_GETCHARACTERPOINTER:
|
|
|
|
return reinterpret_cast<sptr_t>(pdoc->BufferPointer());
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_GETRANGEPOINTER:
|
2015-06-07 21:19:26 +00:00
|
|
|
return reinterpret_cast<sptr_t>(pdoc->RangePointer(static_cast<int>(wParam), static_cast<int>(lParam)));
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
case SCI_GETGAPPOSITION:
|
|
|
|
return pdoc->GapPosition();
|
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
case SCI_SETEXTRAASCENT:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.extraAscent = static_cast<int>(wParam);
|
2009-06-24 19:09:31 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETEXTRAASCENT:
|
|
|
|
return vs.extraAscent;
|
|
|
|
|
|
|
|
case SCI_SETEXTRADESCENT:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.extraDescent = static_cast<int>(wParam);
|
2009-06-24 19:09:31 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETEXTRADESCENT:
|
|
|
|
return vs.extraDescent;
|
|
|
|
|
|
|
|
case SCI_MARGINSETSTYLEOFFSET:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.marginStyleOffset = static_cast<int>(wParam);
|
2009-06-24 19:09:31 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARGINGETSTYLEOFFSET:
|
|
|
|
return vs.marginStyleOffset;
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_SETMARGINOPTIONS:
|
2015-06-07 21:19:26 +00:00
|
|
|
marginOptions = static_cast<int>(wParam);
|
2011-07-17 22:30:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMARGINOPTIONS:
|
|
|
|
return marginOptions;
|
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
case SCI_MARGINSETTEXT:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->MarginSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARGINGETTEXT: {
|
2015-06-07 21:19:26 +00:00
|
|
|
const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam));
|
|
|
|
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_MARGINSETSTYLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->MarginSetStyle(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARGINGETSTYLE: {
|
2015-06-07 21:19:26 +00:00
|
|
|
const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
return st.style;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_MARGINSETSTYLES:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->MarginSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_MARGINGETSTYLES: {
|
2015-06-07 21:19:26 +00:00
|
|
|
const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam));
|
|
|
|
return BytesResult(lParam, st.styles, st.length);
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_MARGINTEXTCLEARALL:
|
|
|
|
pdoc->MarginClearAll();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONSETTEXT:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->AnnotationSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONGETTEXT: {
|
2015-06-07 21:19:26 +00:00
|
|
|
const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam));
|
|
|
|
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONGETSTYLE: {
|
2015-06-07 21:19:26 +00:00
|
|
|
const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
return st.style;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONSETSTYLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->AnnotationSetStyle(static_cast<int>(wParam), static_cast<int>(lParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONSETSTYLES:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->AnnotationSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONGETSTYLES: {
|
2015-06-07 21:19:26 +00:00
|
|
|
const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam));
|
|
|
|
return BytesResult(lParam, st.styles, st.length);
|
2009-06-24 19:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONGETLINES:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->AnnotationLines(static_cast<int>(wParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
|
|
|
|
case SCI_ANNOTATIONCLEARALL:
|
|
|
|
pdoc->AnnotationClearAll();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONSETVISIBLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetAnnotationVisible(static_cast<int>(wParam));
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONGETVISIBLE:
|
|
|
|
return vs.annotationVisible;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONSETSTYLEOFFSET:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.annotationStyleOffset = static_cast<int>(wParam);
|
2009-06-24 19:09:31 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ANNOTATIONGETSTYLEOFFSET:
|
|
|
|
return vs.annotationStyleOffset;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_RELEASEALLEXTENDEDSTYLES:
|
|
|
|
vs.ReleaseAllExtendedStyles();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ALLOCATEEXTENDEDSTYLES:
|
2015-06-07 21:19:26 +00:00
|
|
|
return vs.AllocateExtendedStyles(static_cast<int>(wParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
case SCI_ADDUNDOACTION:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->AddUndoAction(static_cast<int>(wParam), lParam & UNDO_MAY_COALESCE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETMOUSESELECTIONRECTANGULARSWITCH:
|
|
|
|
mouseSelectionRectangularSwitch = wParam != 0;
|
2009-06-24 19:09:31 +00:00
|
|
|
break;
|
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
case SCI_GETMOUSESELECTIONRECTANGULARSWITCH:
|
|
|
|
return mouseSelectionRectangularSwitch;
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
case SCI_SETMULTIPLESELECTION:
|
|
|
|
multipleSelection = wParam != 0;
|
|
|
|
InvalidateCaret();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMULTIPLESELECTION:
|
|
|
|
return multipleSelection;
|
|
|
|
|
|
|
|
case SCI_SETADDITIONALSELECTIONTYPING:
|
|
|
|
additionalSelectionTyping = wParam != 0;
|
|
|
|
InvalidateCaret();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETADDITIONALSELECTIONTYPING:
|
|
|
|
return additionalSelectionTyping;
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
case SCI_SETMULTIPASTE:
|
2015-06-07 21:19:26 +00:00
|
|
|
multiPasteMode = static_cast<int>(wParam);
|
2010-07-12 22:19:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMULTIPASTE:
|
|
|
|
return multiPasteMode;
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
case SCI_SETADDITIONALCARETSBLINK:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.additionalCaretsBlink = wParam != 0;
|
2009-08-23 02:24:48 +00:00
|
|
|
InvalidateCaret();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETADDITIONALCARETSBLINK:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.additionalCaretsBlink;
|
2009-08-23 02:24:48 +00:00
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
case SCI_SETADDITIONALCARETSVISIBLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
view.additionalCaretsVisible = wParam != 0;
|
2010-07-12 22:19:51 +00:00
|
|
|
InvalidateCaret();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETADDITIONALCARETSVISIBLE:
|
2015-06-07 21:19:26 +00:00
|
|
|
return view.additionalCaretsVisible;
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
case SCI_GETSELECTIONS:
|
|
|
|
return sel.Count();
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_GETSELECTIONEMPTY:
|
|
|
|
return sel.Empty();
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
case SCI_CLEARSELECTIONS:
|
|
|
|
sel.Clear();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETSELECTION:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.SetSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam)));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_ADDSELECTION:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.AddSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam)));
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_DROPSELECTIONN:
|
|
|
|
sel.DropSelection(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETMAINSELECTION:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.SetMain(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETMAINSELECTION:
|
|
|
|
return sel.Main();
|
|
|
|
|
|
|
|
case SCI_SETSELECTIONNCARET:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELECTIONNCARET:
|
|
|
|
return sel.Range(wParam).caret.Position();
|
|
|
|
|
|
|
|
case SCI_SETSELECTIONNANCHOR:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
case SCI_GETSELECTIONNANCHOR:
|
|
|
|
return sel.Range(wParam).anchor.Position();
|
|
|
|
|
|
|
|
case SCI_SETSELECTIONNCARETVIRTUALSPACE:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(wParam).caret.SetVirtualSpace(static_cast<int>(lParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELECTIONNCARETVIRTUALSPACE:
|
|
|
|
return sel.Range(wParam).caret.VirtualSpace();
|
|
|
|
|
|
|
|
case SCI_SETSELECTIONNANCHORVIRTUALSPACE:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(wParam).anchor.SetVirtualSpace(static_cast<int>(lParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELECTIONNANCHORVIRTUALSPACE:
|
|
|
|
return sel.Range(wParam).anchor.VirtualSpace();
|
|
|
|
|
|
|
|
case SCI_SETSELECTIONNSTART:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELECTIONNSTART:
|
|
|
|
return sel.Range(wParam).Start().Position();
|
|
|
|
|
|
|
|
case SCI_SETSELECTIONNEND:
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETSELECTIONNEND:
|
|
|
|
return sel.Range(wParam).End().Position();
|
|
|
|
|
|
|
|
case SCI_SETRECTANGULARSELECTIONCARET:
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!sel.IsRectangular())
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
|
|
|
sel.selType = Selection::selRectangle;
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Rectangular().caret.SetPosition(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETRECTANGULARSELECTIONCARET:
|
|
|
|
return sel.Rectangular().caret.Position();
|
|
|
|
|
|
|
|
case SCI_SETRECTANGULARSELECTIONANCHOR:
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!sel.IsRectangular())
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
|
|
|
sel.selType = Selection::selRectangle;
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETRECTANGULARSELECTIONANCHOR:
|
|
|
|
return sel.Rectangular().anchor.Position();
|
|
|
|
|
|
|
|
case SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE:
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!sel.IsRectangular())
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
|
|
|
sel.selType = Selection::selRectangle;
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Rectangular().caret.SetVirtualSpace(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE:
|
|
|
|
return sel.Rectangular().caret.VirtualSpace();
|
|
|
|
|
|
|
|
case SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE:
|
2010-07-12 22:19:51 +00:00
|
|
|
if (!sel.IsRectangular())
|
2009-08-23 02:24:48 +00:00
|
|
|
sel.Clear();
|
|
|
|
sel.selType = Selection::selRectangle;
|
2015-06-07 21:19:26 +00:00
|
|
|
sel.Rectangular().anchor.SetVirtualSpace(static_cast<int>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
SetRectangularRange();
|
|
|
|
Redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE:
|
|
|
|
return sel.Rectangular().anchor.VirtualSpace();
|
|
|
|
|
|
|
|
case SCI_SETVIRTUALSPACEOPTIONS:
|
2015-06-07 21:19:26 +00:00
|
|
|
virtualSpaceOptions = static_cast<int>(wParam);
|
2009-08-23 02:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETVIRTUALSPACEOPTIONS:
|
|
|
|
return virtualSpaceOptions;
|
|
|
|
|
|
|
|
case SCI_SETADDITIONALSELFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.selAdditionalForeground = ColourDesired(static_cast<long>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETADDITIONALSELBACK:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.selAdditionalBackground = ColourDesired(static_cast<long>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SETADDITIONALSELALPHA:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.selAdditionalAlpha = static_cast<int>(wParam);
|
2009-08-23 02:24:48 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETADDITIONALSELALPHA:
|
|
|
|
return vs.selAdditionalAlpha;
|
2010-07-12 22:19:51 +00:00
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
case SCI_SETADDITIONALCARETFORE:
|
2015-06-07 21:19:26 +00:00
|
|
|
vs.additionalCaretColour = ColourDesired(static_cast<long>(wParam));
|
2009-08-23 02:24:48 +00:00
|
|
|
InvalidateStyleRedraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETADDITIONALCARETFORE:
|
2013-08-28 00:44:27 +00:00
|
|
|
return vs.additionalCaretColour.AsLong();
|
2009-08-23 02:24:48 +00:00
|
|
|
|
|
|
|
case SCI_ROTATESELECTION:
|
|
|
|
sel.RotateMain();
|
|
|
|
InvalidateSelection(sel.RangeMain(), true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_SWAPMAINANCHORCARET:
|
|
|
|
InvalidateSelection(sel.RangeMain());
|
|
|
|
sel.RangeMain() = SelectionRange(sel.RangeMain().anchor, sel.RangeMain().caret);
|
|
|
|
break;
|
|
|
|
|
2010-08-21 23:59:56 +00:00
|
|
|
case SCI_CHANGELEXERSTATE:
|
2015-06-07 21:19:26 +00:00
|
|
|
pdoc->ChangeLexerState(static_cast<int>(wParam), static_cast<int>(lParam));
|
2010-08-21 23:59:56 +00:00
|
|
|
break;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_SETIDENTIFIER:
|
2015-06-07 21:19:26 +00:00
|
|
|
SetCtrlID(static_cast<int>(wParam));
|
2011-07-17 22:30:49 +00:00
|
|
|
break;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
case SCI_GETIDENTIFIER:
|
|
|
|
return GetCtrlID();
|
2010-08-21 23:59:56 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
case SCI_SETTECHNOLOGY:
|
|
|
|
// No action by default
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCI_GETTECHNOLOGY:
|
|
|
|
return technology;
|
|
|
|
|
|
|
|
case SCI_COUNTCHARACTERS:
|
2015-06-07 21:19:26 +00:00
|
|
|
return pdoc->CountCharacters(static_cast<int>(wParam), static_cast<int>(lParam));
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
default:
|
|
|
|
return DefWndProc(iMessage, wParam, lParam);
|
|
|
|
}
|
|
|
|
//Platform::DebugPrintf("end wnd proc\n");
|
|
|
|
return 0l;
|
|
|
|
}
|