summaryrefslogtreecommitdiffstats
path: root/scintilla/src/Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'scintilla/src/Editor.cxx')
-rw-r--r--scintilla/src/Editor.cxx49
1 files changed, 38 insertions, 11 deletions
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx
index 5dab852..334643c 100644
--- a/scintilla/src/Editor.cxx
+++ b/scintilla/src/Editor.cxx
@@ -88,6 +88,10 @@ Timer::Timer() :
Idler::Idler() :
state(false), idlerID(0) {}
+static int RoundXYPosition(XYPOSITION xyPos) {
+ return int(xyPos+0.5);
+}
+
static inline bool IsControlCharacter(int ch) {
// iscntrl returns true for lots of chars > 127 which are displayable
return ch >= 0 && ch < ' ';
@@ -269,6 +273,8 @@ void Editor::SetRepresentations() {
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
@@ -382,6 +388,10 @@ PRectangle Editor::GetClientRectangle() {
return wMain.GetClientPosition();
}
+PRectangle Editor::GetClientDrawingRectangle() {
+ return GetClientRectangle();
+}
+
PRectangle Editor::GetTextRectangle() {
PRectangle rc = GetClientRectangle();
rc.left += vs.textStart;
@@ -645,6 +655,10 @@ void Editor::RedrawRect(PRectangle rc) {
}
}
+void Editor::DiscardOverdraw() {
+ // Overridden on platforms that may draw outside visible area.
+}
+
void Editor::Redraw() {
//Platform::DebugPrintf("Redraw all\n");
PRectangle rcClient = GetClientRectangle();
@@ -655,7 +669,10 @@ void Editor::Redraw() {
}
void Editor::RedrawSelMargin(int line, bool allAfter) {
- if (!AbandonPaint()) {
+ bool abandonDraw = false;
+ if (!wMargin.GetID()) // Margin in main window so may need to abandon and retry
+ abandonDraw = AbandonPaint();
+ if (!abandonDraw) {
if (vs.maskInLine) {
Redraw();
} else {
@@ -2540,14 +2557,20 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
char hexits[4];
const char *ctrlChar;
unsigned char chEOL = ll->chars[eolPos];
+ int styleMain = ll->styles[eolPos];
+ ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll);
if (UTF8IsAscii(chEOL)) {
ctrlChar = ControlCharacterString(chEOL);
} else {
- sprintf(hexits, "x%2X", chEOL);
- ctrlChar = hexits;
+ Representation *repr = reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos);
+ if (repr) {
+ ctrlChar = repr->stringRep.c_str();
+ eolPos = ll->numCharsInLine;
+ } else {
+ sprintf(hexits, "x%2X", chEOL);
+ ctrlChar = hexits;
+ }
}
- int styleMain = ll->styles[eolPos];
- ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll);
ColourDesired textFore = vsDraw.styles[styleMain].fore;
if (eolInSelection && vsDraw.selColours.fore.isSet) {
textFore = (eolInSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground;
@@ -3417,7 +3440,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
bool caretAtEOL = false;
bool drawBlockCaret = false;
XYPOSITION widthOverstrikeCaret;
- int caretWidthOffset = 0;
+ XYPOSITION caretWidthOffset = 0;
PRectangle rcCaret = rcLine;
if (posCaret.Position() == pdoc->Length()) { // At end of document
@@ -3433,11 +3456,11 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
widthOverstrikeCaret = 3;
if (xposCaret > 0)
- caretWidthOffset = 1; // Move back so overlaps both character cells.
+ caretWidthOffset = 0.51f; // Move back so overlaps both character cells.
xposCaret += xStart;
if (posDrag.IsValid()) {
/* Dragging text, use a line caret */
- rcCaret.left = xposCaret - caretWidthOffset;
+ rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
} else if (inOverstrike && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret */
@@ -3455,7 +3478,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
}
} else {
/* Line caret */
- rcCaret.left = xposCaret - caretWidthOffset;
+ rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
@@ -5090,6 +5113,7 @@ void Editor::NewLine() {
// Remove non-main ranges
InvalidateSelection(sel.RangeMain(), true);
sel.SetSelection(sel.RangeMain());
+ sel.RangeMain().ClearVirtualSpace();
// Clear main range and insert line end
bool needGroupUndo = !sel.Empty();
@@ -6791,7 +6815,7 @@ int Editor::PositionAfterArea(PRectangle rcArea) const {
// The start of the document line after the display line after the area
// This often means that the line after a modification is restyled which helps
// detect multiline comment additions and heals single line comments
- int lineAfter = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1;
+ int lineAfter = TopLineOfMain() + (rcArea.bottom - 1) / vs.lineHeight + 1;
if (lineAfter < cs.LinesDisplayed())
return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1);
else
@@ -6801,7 +6825,7 @@ int Editor::PositionAfterArea(PRectangle rcArea) const {
// 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) {
- int endWindow = (vs.marginInside) ? (PositionAfterArea(GetClientRectangle())) : (pdoc->Length());
+ int endWindow = PositionAfterArea(GetClientDrawingRectangle());
if (pos > endWindow)
pos = endWindow;
int styleAtEnd = pdoc->StyleAt(pos-1);
@@ -6809,6 +6833,9 @@ void Editor::StyleToPositionInView(Position pos) {
if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) {
// Style at end of line changed so is multi-line change like starting a comment
// so require rest of window to be styled.
+ DiscardOverdraw(); // Prepared bitmaps may be invalid
+ // DiscardOverdraw may have truncated client drawing area so recalculate endWindow
+ endWindow = PositionAfterArea(GetClientDrawingRectangle());
pdoc->EnsureStyledTo(endWindow);
}
}