aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Scintilla.h6
-rw-r--r--include/Scintilla.iface24
-rw-r--r--src/Editor.cxx264
-rw-r--r--src/Editor.h7
-rw-r--r--src/Selection.cxx12
-rw-r--r--src/Selection.h6
-rw-r--r--src/ViewStyle.cxx11
-rw-r--r--src/ViewStyle.h4
8 files changed, 212 insertions, 122 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h
index d4980577d..5e89ddb84 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -749,6 +749,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCVS_USERACCESSIBLE 2
#define SCI_SETVIRTUALSPACEOPTIONS 2596
#define SCI_GETVIRTUALSPACEOPTIONS 2597
+#define SCI_SETADDITIONALSELFORE 2600
+#define SCI_SETADDITIONALSELBACK 2601
+#define SCI_SETADDITIONALSELALPHA 2602
+#define SCI_GETADDITIONALSELALPHA 2603
+#define SCI_SETADDITIONALCARETFORE 2604
+#define SCI_GETADDITIONALCARETFORE 2605
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 8abafb69a..08217edcc 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -477,10 +477,10 @@ set void StyleSetCharacterSet=2066(int style, int characterSet)
# Set a style to be a hotspot or not.
set void StyleSetHotSpot=2409(int style, bool hotspot)
-# Set the foreground colour of the selection and whether to use this setting.
+# Set the foreground colour of the main and additional selections and whether to use this setting.
fun void SetSelFore=2067(bool useSetting, colour fore)
-# Set the background colour of the selection and whether to use this setting.
+# Set the background colour of the main and additional selections and whether to use this setting.
fun void SetSelBack=2068(bool useSetting, colour back)
# Get the alpha of the selection.
@@ -1995,6 +1995,26 @@ val SCVS_USERACCESSIBLE=2
set void SetVirtualSpaceOptions=2596(int virtualSpace,)
get int GetVirtualSpaceOptions=2597(,)
+# Set the foreground colour of additional selections.
+# Must have previously called SetSelFore with non-zero first argument for this to have an effect.
+set void SetAdditionalSelFore=2600(colour fore,)
+
+# Set the background colour of additional selections.
+# Must have previously called SetSelBack with non-zero first argument for this to have an effect.
+set void SetAdditionalSelBack=2601(colour back,)
+
+# Set the alpha of the selection.
+set void SetAdditionalSelAlpha=2602(int alpha,)
+
+# Get the alpha of the selection.
+get int GetAdditionalSelAlpha=2603(,)
+
+# Set the foreground colour of additional carets.
+set void SetAdditionalCaretFore=2604(colour fore,)
+
+# Get the foreground colour of additional carets.
+get colour GetAdditionalCaretFore=2605(,)
+
# Start notifying the container of all key presses and commands.
fun void StartRecord=3001(,)
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 6218ad195..a1b403f19 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2123,15 +2123,21 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
}
}
-ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw) {
- return primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated;
+ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw, bool main) {
+ return primarySelection ?
+ (main ? vsDraw.selbackground.allocated : vsDraw.selAdditionalBackground.allocated) :
+ vsDraw.selbackground2.allocated;
}
ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
- ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
- if (inSelection) {
+ ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
+ if (inSelection == 1) {
if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
- return SelectionBackground(vsDraw);
+ return SelectionBackground(vsDraw, true);
+ }
+ } else if (inSelection == 2) {
+ if (vsDraw.selbackset && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) {
+ return SelectionBackground(vsDraw, false);
}
} else {
if ((vsDraw.edgeState == EDGE_BACKGROUND) &&
@@ -2251,40 +2257,44 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
rcSegment.left = xEol + xStart;
rcSegment.right = xEol + xStart + virtualSpace;
surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
- if (!hideSelection && vsDraw.selAlpha == SC_ALPHA_NOALPHA) {
+ if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) {
SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line))));
for (size_t r=0; r<sel.Count(); r++) {
- SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
- if (!portion.Empty()) {
- const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
- rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
- rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
- rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
- rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
- surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
+ int alpha = (r == sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
+ if (alpha == SC_ALPHA_NOALPHA) {
+ SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
+ if (!portion.Empty()) {
+ const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+ rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
+ rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
+ rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
+ rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
+ surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main()));
+ }
}
}
}
}
int posAfterLineEnd = pdoc->LineStart(line + 1);
- bool eolInSelection = (subLine == (ll->lines - 1)) && sel.InSelectionForEOL(posAfterLineEnd);
+ int eolInSelection = (subLine == (ll->lines - 1)) ? sel.InSelectionForEOL(posAfterLineEnd) : 0;
+ int alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
for (int eolPos=ll->numCharsBeforeEOL; eolPos<ll->numCharsInLine; eolPos++) {
rcSegment.left = xStart + ll->positions[eolPos] + virtualSpace;
rcSegment.right = xStart + ll->positions[eolPos+1] + virtualSpace;
const char *ctrlChar = ControlCharacterString(ll->chars[eolPos]);
- bool inSelection = false;
+ int inSelection = 0;
bool inHotspot = false;
int styleMain = ll->styles[eolPos];
ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, eolPos, ll);
ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
- if (vsDraw.selAlpha == SC_ALPHA_NOALPHA) {
- surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
+ if (alpha == SC_ALPHA_NOALPHA) {
+ surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
} else {
surface->FillRectangle(rcSegment, textBack);
- SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+ SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
}
} else {
surface->FillRectangle(rcSegment, textBack);
@@ -2295,24 +2305,24 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
rcSegment.left = ll->positions[ll->numCharsInLine] + xStart + virtualSpace;
rcSegment.right = ll->positions[ll->numCharsInLine] + vsDraw.aveCharWidth + xStart + virtualSpace;
- if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
- surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
+ if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
+ surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
} else {
if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
} else {
surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
}
- if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha != SC_ALPHA_NOALPHA)) {
- SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+ if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+ SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
}
}
rcSegment.left = ll->positions[ll->numCharsInLine] + vsDraw.aveCharWidth + xStart + virtualSpace;
rcSegment.right = rcLine.right;
- if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
- surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
+ if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) {
+ surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
} else {
if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
@@ -2321,8 +2331,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
} else {
surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
}
- if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha != SC_ALPHA_NOALPHA)) {
- SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+ if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
+ SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
}
}
@@ -2607,7 +2617,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
int styleMain = ll->styles[i];
- const bool inSelection = !hideSelection && sel.CharacterInSelection(iDoc);
+ const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
if (ll->chars[i] == '\t') {
@@ -2700,9 +2710,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if (vsDraw.hotspotForegroundSet)
textFore = vsDraw.hotspotForeground.allocated;
}
- const bool inSelection = !hideSelection && sel.CharacterInSelection(iDoc);
+ const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
if (inSelection && (vsDraw.selforeset)) {
- textFore = vsDraw.selforeground.allocated;
+ textFore = (inSelection == 1) ? vsDraw.selforeground.allocated : vsDraw.selAdditionalForeground.allocated;
}
bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
@@ -2872,7 +2882,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
xStart, subLine, subLineStart, overrideBackground, background,
drawWrapMarkEnd, wrapColour);
}
- if (!hideSelection && vsDraw.selAlpha != SC_ALPHA_NOALPHA) {
+ if (!hideSelection && ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA))) {
// For each selection draw
int virtualSpaces = 0;
if (subLine == (ll->lines - 1)) {
@@ -2880,15 +2890,17 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
SelectionSegment virtualSpaceRange(SelectionPosition(posLineStart), SelectionPosition(posLineStart + lineEnd, virtualSpaces));
for (size_t r=0; r<sel.Count(); r++) {
- SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
- if (!portion.Empty()) {
- const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
- rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
- rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
- rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
- rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
- SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw),
- (r == sel.Main()) ? vsDraw.selAlpha : vsDraw.selAlpha / 2);
+ int alpha = (r == sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
+ if (alpha != SC_ALPHA_NOALPHA) {
+ SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange);
+ if (!portion.Empty()) {
+ const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
+ rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth;
+ rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth;
+ rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
+ rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
+ SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, r == sel.Main()), alpha);
+ }
}
}
}
@@ -2923,7 +2935,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
-void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret) {
+void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
+ int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour) {
int lineStart = ll->LineStart(subLine);
int posBefore = posCaret;
@@ -2982,7 +2995,7 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll,
surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font,
rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar,
numCharsToDraw, vsDraw.styles[styleMain].back.allocated,
- vsDraw.caretcolour.allocated);
+ caretColour);
}
void Editor::RefreshPixMaps(Surface *surfaceWindow) {
@@ -3118,10 +3131,11 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
rcCaret.left = xposCaret - caretWidthOffset;
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
+ ColourAllocated caretColour = mainCaret ? vsDraw.caretcolour.allocated : vsDraw.additionalCaretColour.allocated;
if (drawBlockCaret) {
- DrawBlockCaret(surface, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret);
+ DrawBlockCaret(surface, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour);
} else {
- surface->FillRectangle(rcCaret, mainCaret ? vsDraw.caretcolour.allocated : vsDraw.selbackground2.allocated);
+ surface->FillRectangle(rcCaret, caretColour);
}
}
}
@@ -3415,6 +3429,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
vsPrint.selbackset = false;
vsPrint.selforeset = false;
vsPrint.selAlpha = SC_ALPHA_NOALPHA;
+ vsPrint.selAdditionalAlpha = SC_ALPHA_NOALPHA;
vsPrint.whitespaceBackgroundSet = false;
vsPrint.whitespaceForegroundSet = false;
vsPrint.showCaretLineBackground = false;
@@ -3796,7 +3811,7 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
return;
}
sel.Clear();
- sel.RangeMain() = SelectionRange(pos, pos);
+ sel.RangeMain() = SelectionRange(pos);
int line = pdoc->LineFromPosition(sel.MainCaret());
pdoc->BeginUndoAction();
sel.RangeMain().caret = SelectionPosition(
@@ -5075,77 +5090,80 @@ int Editor::GetWhitespaceVisible() {
}
void Editor::Indent(bool forwards) {
- //Platform::DebugPrintf("INdent %d\n", forwards);
- int lineOfAnchor = pdoc->LineFromPosition(sel.MainAnchor());
- int lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret());
- if (lineOfAnchor == lineCurrentPos) {
- if (forwards) {
- pdoc->BeginUndoAction();
- ClearSelection();
- if (pdoc->GetColumn(sel.MainCaret()) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
- pdoc->tabIndents) {
- int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- int indentationStep = pdoc->IndentSize();
- pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
- SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
- } else {
- if (pdoc->useTabs) {
- pdoc->InsertChar(sel.MainCaret(), '\t');
- SetEmptySelection(sel.MainCaret() + 1);
+ 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) {
+ pdoc->BeginUndoAction();
+ pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
+ caretPosition = sel.Range(r).caret.Position();
+ if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
+ pdoc->tabIndents) {
+ int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ int indentationStep = pdoc->IndentSize();
+ pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
+ sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos));
} else {
- int numSpaces = (pdoc->tabInChars) -
- (pdoc->GetColumn(sel.MainCaret()) % (pdoc->tabInChars));
- if (numSpaces < 1)
- numSpaces = pdoc->tabInChars;
- for (int i = 0; i < numSpaces; i++) {
- pdoc->InsertChar(sel.MainCaret() + i, ' ');
+ if (pdoc->useTabs) {
+ pdoc->InsertChar(caretPosition, '\t');
+ sel.Range(r) = SelectionRange(caretPosition+1);
+ } else {
+ int numSpaces = (pdoc->tabInChars) -
+ (pdoc->GetColumn(caretPosition) % (pdoc->tabInChars));
+ if (numSpaces < 1)
+ numSpaces = pdoc->tabInChars;
+ for (int i = 0; i < numSpaces; i++) {
+ pdoc->InsertChar(caretPosition + i, ' ');
+ }
+ sel.Range(r) = SelectionRange(caretPosition+numSpaces);
}
- SetEmptySelection(sel.MainCaret() + numSpaces);
+ }
+ pdoc->EndUndoAction();
+ } else {
+ if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) &&
+ pdoc->tabIndents) {
+ pdoc->BeginUndoAction();
+ int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ int indentationStep = pdoc->IndentSize();
+ pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
+ SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
+ pdoc->EndUndoAction();
+ } 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);
}
}
+ } 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
+ pdoc->BeginUndoAction();
+ pdoc->Indent(forwards, lineBottomSel, lineTopSel);
pdoc->EndUndoAction();
- } else {
- if (pdoc->GetColumn(sel.MainCaret()) <= pdoc->GetLineIndentation(lineCurrentPos) &&
- pdoc->tabIndents) {
- pdoc->BeginUndoAction();
- int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- int indentationStep = pdoc->IndentSize();
- pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
- SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos));
- pdoc->EndUndoAction();
+ 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));
} else {
- int newColumn = ((pdoc->GetColumn(sel.MainCaret()) - 1) / pdoc->tabInChars) *
- pdoc->tabInChars;
- if (newColumn < 0)
- newColumn = 0;
- int newPos = sel.MainCaret();
- while (pdoc->GetColumn(newPos) > newColumn)
- newPos--;
- SetEmptySelection(newPos);
+ 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));
}
}
- } else {
- int anchorPosOnLine = sel.MainAnchor() - pdoc->LineStart(lineOfAnchor);
- int currentPosPosOnLine = sel.MainCaret() - 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.MainAnchor() || pdoc->LineStart(lineBottomSel) == sel.MainCaret())
- lineBottomSel--; // If not selecting any characters on a line, do not indent
- pdoc->BeginUndoAction();
- pdoc->Indent(forwards, lineBottomSel, lineTopSel);
- pdoc->EndUndoAction();
- if (lineOfAnchor < lineCurrentPos) {
- if (currentPosPosOnLine == 0)
- SetSelection(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor));
- else
- SetSelection(pdoc->LineStart(lineCurrentPos + 1), pdoc->LineStart(lineOfAnchor));
- } else {
- if (anchorPosOnLine == 0)
- SetSelection(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor));
- else
- SetSelection(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor + 1));
- }
}
}
@@ -5638,7 +5656,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
sel.selType = alt ? Selection::selRectangle : Selection::selStream;
selectionType = selChar;
originalAnchorPos = sel.MainCaret();
- sel.Rectangular() = SelectionRange(newPos, newPos);
+ sel.Rectangular() = SelectionRange(newPos);
SetRectangularRange();
}
}
@@ -7477,12 +7495,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETSELFORE:
vs.selforeset = wParam != 0;
vs.selforeground.desired = ColourDesired(lParam);
+ vs.selAdditionalForeground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
vs.selbackset = wParam != 0;
vs.selbackground.desired = ColourDesired(lParam);
+ vs.selAdditionalBackground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
@@ -8253,6 +8273,32 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETVIRTUALSPACEOPTIONS:
return virtualSpaceOptions;
+ case SCI_SETADDITIONALSELFORE:
+ vs.selAdditionalForeground.desired = ColourDesired(wParam);
+ InvalidateStyleRedraw();
+ break;
+
+ case SCI_SETADDITIONALSELBACK:
+ vs.selAdditionalBackground.desired = ColourDesired(wParam);
+ InvalidateStyleRedraw();
+ break;
+
+ case SCI_SETADDITIONALSELALPHA:
+ vs.selAdditionalAlpha = wParam;
+ InvalidateStyleRedraw();
+ break;
+
+ case SCI_GETADDITIONALSELALPHA:
+ return vs.selAdditionalAlpha;
+
+ case SCI_SETADDITIONALCARETFORE:
+ vs.additionalCaretColour.desired = ColourDesired(wParam);
+ InvalidateStyleRedraw();
+ break;
+
+ case SCI_GETADDITIONALCARETFORE:
+ return vs.additionalCaretColour.desired.AsLong();
+
default:
return DefWndProc(iMessage, wParam, lParam);
}
diff --git a/src/Editor.h b/src/Editor.h
index 051eb9329..de7aac98f 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -324,8 +324,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
LineLayout *RetrieveLineLayout(int lineNumber);
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
int width=LineLayout::wrapWidthInfinite);
- ColourAllocated SelectionBackground(ViewStyle &vsDraw);
- ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
+ ColourAllocated SelectionBackground(ViewStyle &vsDraw, bool main);
+ ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour);
void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
@@ -338,7 +338,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
PRectangle rcLine, LineLayout *ll, int subLine);
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine);
- void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret);
+ void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
+ int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour);
void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine);
void RefreshPixMaps(Surface *surfaceWindow);
diff --git a/src/Selection.cxx b/src/Selection.cxx
index 28a70b62b..d9c59cdb1 100644
--- a/src/Selection.cxx
+++ b/src/Selection.cxx
@@ -314,20 +314,20 @@ void Selection::AddSelection(SelectionPosition spStartPos, SelectionPosition spE
nRanges++;
}
-bool Selection::CharacterInSelection(int posCharacter) const {
+int Selection::CharacterInSelection(int posCharacter) const {
for (size_t i=0; i<nRanges; i++) {
if (ranges[i].ContainsCharacter(posCharacter))
- return true;
+ return i == mainRange ? 1 : 2;
}
- return false;
+ return 0;
}
-bool Selection::InSelectionForEOL(int pos) const {
+int Selection::InSelectionForEOL(int pos) const {
for (size_t i=0; i<nRanges; i++) {
if (!ranges[i].Empty() && (pos > ranges[i].Start().Position()) && (pos <= ranges[i].End().Position()))
- return true;
+ return i == mainRange ? 1 : 2;
}
- return false;
+ return 0;
}
int Selection::VirtualSpaceFor(int pos) const {
diff --git a/src/Selection.h b/src/Selection.h
index 0cb1200f8..6fe828a2c 100644
--- a/src/Selection.h
+++ b/src/Selection.h
@@ -84,6 +84,8 @@ struct SelectionRange {
}
SelectionRange(SelectionPosition single) : caret(single), anchor(single) {
}
+ SelectionRange(int single) : caret(single), anchor(single) {
+ }
SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) : caret(caret_), anchor(anchor_) {
}
SelectionRange(int caret_, int anchor_) : caret(caret_), anchor(anchor_) {
@@ -152,8 +154,8 @@ public:
void TrimSelection(SelectionPosition startPos, SelectionPosition endPos);
void AddSelection(SelectionPosition spPos);
void AddSelection(SelectionPosition spStartPos, SelectionPosition spEndPos, bool anchorLeft);
- bool CharacterInSelection(int posCharacter) const;
- bool InSelectionForEOL(int pos) const;
+ int CharacterInSelection(int posCharacter) const;
+ int InSelectionForEOL(int pos) const;
int VirtualSpaceFor(int pos) const;
void Clear();
void EmptyRanges();
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 0955928b0..e162f722a 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -92,10 +92,13 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
selforeset = source.selforeset;
selforeground.desired = source.selforeground.desired;
+ selAdditionalForeground.desired = source.selAdditionalForeground.desired;
selbackset = source.selbackset;
selbackground.desired = source.selbackground.desired;
+ selAdditionalBackground.desired = source.selAdditionalBackground.desired;
selbackground2.desired = source.selbackground2.desired;
selAlpha = source.selAlpha;
+ selAdditionalAlpha = source.selAdditionalAlpha;
selEOLFilled = source.selEOLFilled;
foldmarginColourSet = source.foldmarginColourSet;
@@ -117,6 +120,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
selbar.desired = source.selbar.desired;
selbarlight.desired = source.selbarlight.desired;
caretcolour.desired = source.caretcolour.desired;
+ additionalCaretColour.desired = source.additionalCaretColour.desired;
showCaretLineBackground = source.showCaretLineBackground;
caretLineBackground.desired = source.caretLineBackground.desired;
caretLineAlpha = source.caretLineAlpha;
@@ -176,10 +180,13 @@ void ViewStyle::Init(size_t stylesSize_) {
selforeset = false;
selforeground.desired = ColourDesired(0xff, 0, 0);
+ selAdditionalForeground.desired = ColourDesired(0xff, 0, 0);
selbackset = true;
selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+ selAdditionalBackground.desired = ColourDesired(0xd7, 0xd7, 0xd7);
selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
selAlpha = SC_ALPHA_NOALPHA;
+ selAdditionalAlpha = SC_ALPHA_NOALPHA;
selEOLFilled = false;
foldmarginColourSet = false;
@@ -196,6 +203,7 @@ void ViewStyle::Init(size_t stylesSize_) {
styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
caretcolour.desired = ColourDesired(0, 0, 0);
+ additionalCaretColour.desired = ColourDesired(0x7f, 0x7f, 0x7f);
showCaretLineBackground = false;
caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
caretLineAlpha = SC_ALPHA_NOALPHA;
@@ -258,7 +266,9 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
markers[i].RefreshColourPalette(pal, want);
}
pal.WantFind(selforeground, want);
+ pal.WantFind(selAdditionalForeground, want);
pal.WantFind(selbackground, want);
+ pal.WantFind(selAdditionalBackground, want);
pal.WantFind(selbackground2, want);
pal.WantFind(foldmarginColour, want);
@@ -269,6 +279,7 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
pal.WantFind(selbar, want);
pal.WantFind(selbarlight, want);
pal.WantFind(caretcolour, want);
+ pal.WantFind(additionalCaretColour, want);
pal.WantFind(caretLineBackground, want);
pal.WantFind(edgecolour, want);
pal.WantFind(hotspotForeground, want);
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 5390848e5..fe17a0aa7 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -58,10 +58,13 @@ public:
unsigned int spaceWidth;
bool selforeset;
ColourPair selforeground;
+ ColourPair selAdditionalForeground;
bool selbackset;
ColourPair selbackground;
+ ColourPair selAdditionalBackground;
ColourPair selbackground2;
int selAlpha;
+ int selAdditionalAlpha;
bool selEOLFilled;
bool whitespaceForegroundSet;
ColourPair whitespaceForeground;
@@ -93,6 +96,7 @@ public:
bool viewEOL;
bool showMarkedLines;
ColourPair caretcolour;
+ ColourPair additionalCaretColour;
bool showCaretLineBackground;
ColourPair caretLineBackground;
int caretLineAlpha;