diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 5 | ||||
| -rw-r--r-- | src/Editor.cxx | 12 | 
2 files changed, 13 insertions, 4 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index b1b25eb45..225c18cda 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -470,6 +470,11 @@  	<a href="http://sourceforge.net/p/scintilla/bugs/1585/">Bug #1585</a>.  	</li>  	<li> +	Caret positioning changed a little to appear inside characters less often by +	rounding the caret position to the pixel grid instead of truncating. +	<a href="http://sourceforge.net/p/scintilla/bugs/1588/">Bug #1588</a>. +	</li> +	<li>  	Bug fixed where automatic indentation wrong when caret in virtual space.  	<a href="http://sourceforge.net/p/scintilla/bugs/1586/">Bug #1586</a>.  	</li> diff --git a/src/Editor.cxx b/src/Editor.cxx index c340bedf2..6c29e7100 100644 --- a/src/Editor.cxx +++ b/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 < ' '; @@ -3417,7 +3421,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 +3437,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 +3459,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;  | 
