diff options
author | nyamatongwe <unknown> | 2011-12-13 11:30:09 +1100 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-12-13 11:30:09 +1100 |
commit | 73baf3f2a33512975b3a9a2bbadf96d5935e0a02 (patch) | |
tree | 2ac78e1c575f60aaf1942ec1c36764ec2b7998a2 | |
parent | a6d786df58e4f1fad37a4a7a44060801cf323f52 (diff) | |
download | scintilla-mirror-73baf3f2a33512975b3a9a2bbadf96d5935e0a02.tar.gz |
Allow non-integral space width. From Jason Haslam.
-rw-r--r-- | src/Editor.cxx | 32 | ||||
-rw-r--r-- | src/Style.h | 2 | ||||
-rw-r--r-- | src/ViewStyle.h | 2 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 96dc76c1e..51632bc40 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -442,7 +442,7 @@ Point Editor::LocationFromPosition(SelectionPosition pos) { } pt.x += vs.fixedColumnWidth - xOffset; } - pt.x += pos.VirtualSpace() * static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth); + pt.x += pos.VirtualSpace() * vs.styles[ll->EndLineStyle()].spaceWidth; return pt; } @@ -526,7 +526,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, i++; } if (virtualSpace) { - const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth); + const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; return SelectionPosition(lineEnd + posLineStart, spaceOffset); @@ -617,7 +617,7 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { } i++; } - const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth); + const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; int spaceOffset = (x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; return SelectionPosition(lineEnd + posLineStart, spaceOffset); } @@ -2252,7 +2252,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou int startseg = 0; // Start of the current segment, in char. number XYACCUMULATOR startsegx = 0; // Start of the current segment, in pixels ll->positions[0] = 0; - unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars; + XYPOSITION tabWidth = vstyle.spaceWidth * pdoc->tabInChars; bool lastSegItalics = false; Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font; @@ -2272,7 +2272,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou if (isControl) { if (ll->chars[charInLine] == '\t') { ll->positions[charInLine + 1] = ((((static_cast<int>(startsegx) + 2) / - tabWidth) + 1) * tabWidth) - startsegx; + static_cast<int>(tabWidth)) + 1) * tabWidth) - startsegx; } else if (controlCharSymbol < 32) { if (ctrlCharWidth[ll->chars[charInLine]] == 0) { const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); @@ -2526,15 +2526,15 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin PRectangle rcSegment = rcLine; const bool lastSubLine = subLine == (ll->lines - 1); - int virtualSpace = 0; + XYPOSITION virtualSpace = 0; if (lastSubLine) { - const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth); + const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth; } // Fill in a PRectangle representing the end of line characters - int xEol = ll->positions[lineEnd] - subLineStart; + XYPOSITION xEol = ll->positions[lineEnd] - subLineStart; // Fill the virtual space and show selections within it if (virtualSpace) { @@ -2548,11 +2548,11 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin 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); + const XYPOSITION spaceWidth = 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); + rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left; + rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right; surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main())); } } @@ -3231,11 +3231,11 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis 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); + const XYPOSITION spaceWidth = 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); + rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left; + rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right; SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, r == sel.Main()), alpha); } } @@ -3412,8 +3412,8 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS const bool mainCaret = r == sel.Main(); const SelectionPosition posCaret = (drawDrag ? posDrag : sel.Range(r).caret); const int offset = posCaret.Position() - posLineStart; - const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth); - const int virtualOffset = posCaret.VirtualSpace() * spaceWidth; + const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; + const XYPOSITION virtualOffset = posCaret.VirtualSpace() * spaceWidth; if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) { XYPOSITION xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)]; if (ll->wrapIndent != 0) { diff --git a/src/Style.h b/src/Style.h index ab433107d..018ab70f5 100644 --- a/src/Style.h +++ b/src/Style.h @@ -48,7 +48,7 @@ struct FontMeasurements { unsigned int descent; unsigned int externalLeading; unsigned int aveCharWidth; - unsigned int spaceWidth; + XYPOSITION spaceWidth; int sizeZoomed; FontMeasurements(); void Clear(); diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 39cd77339..4ee7f2a3e 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -72,7 +72,7 @@ public: unsigned int maxAscent; unsigned int maxDescent; unsigned int aveCharWidth; - unsigned int spaceWidth; + XYPOSITION spaceWidth; bool selforeset; ColourDesired selforeground; ColourDesired selAdditionalForeground; |