aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-06-10 13:00:05 +1000
committerNeil <nyamatongwe@gmail.com>2020-06-10 13:00:05 +1000
commitb50d82d5dd2c07da8064c4accbedb523a51b500d (patch)
treee6889d04df874025c54e43ed08ab9cdcf56f2c4c
parentc6f1f1c7c7f486fd19c394a7e33df9f0980b55c8 (diff)
downloadscintilla-mirror-b50d82d5dd2c07da8064c4accbedb523a51b500d.tar.gz
Backport: Feature [feature-requests:1355]. Round instead of truncating for SCI_TEXTWIDTH.
Backport of changeset 8297:3665e2c20cd4.
-rw-r--r--doc/ScintillaHistory.html5
-rw-r--r--src/Editor.cxx4
-rw-r--r--src/Editor.h2
3 files changed, 8 insertions, 3 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index f572606af..2338f4ece 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -581,6 +581,11 @@
<a href="https://sourceforge.net/p/scintilla/feature-requests/1347/">Feature #1347</a>.
</li>
<li>
+ Round SCI_TEXTWIDTH instead of truncating as this may be more accurate when sizing application
+ elements to match text.
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1355/">Feature #1355</a>.
+ </li>
+ <li>
Fixed bug in Batch lexer where a single character line with a single character line end continued
state onto the next line.
</li>
diff --git a/src/Editor.cxx b/src/Editor.cxx
index c1bc8d435..e655b7e82 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1819,11 +1819,11 @@ Sci::Position Editor::FormatRange(bool draw, const Sci_RangeToFormat *pfr) {
return view.FormatRange(draw, pfr, surface, surfaceMeasure, *this, vs);
}
-int Editor::TextWidth(int style, const char *text) {
+long Editor::TextWidth(uptr_t style, const char *text) {
RefreshStyleData();
AutoSurface surface(this);
if (surface) {
- return static_cast<int>(surface->WidthText(vs.styles[style].font, text, static_cast<int>(strlen(text))));
+ return Sci::lround(surface->WidthText(vs.styles[style].font, text, static_cast<int>(strlen(text))));
} else {
return 1;
}
diff --git a/src/Editor.h b/src/Editor.h
index eb87c470d..626b67325 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -388,7 +388,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void RefreshPixMaps(Surface *surfaceWindow);
void Paint(Surface *surfaceWindow, PRectangle rcArea);
Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr);
- int TextWidth(int style, const char *text);
+ long TextWidth(uptr_t style, const char *text);
virtual void SetVerticalScrollPos() = 0;
virtual void SetHorizontalScrollPos() = 0;