diff options
author | Neil <nyamatongwe@gmail.com> | 2020-06-10 13:00:05 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2020-06-10 13:00:05 +1000 |
commit | 0b9c12bf9cc211c30a40b13d7ba72dbba5328369 (patch) | |
tree | fd85a6039819158a325b5b9f2a881434d6a9fdbf | |
parent | 6516d81f0ad2574e49732c0def87d19c5a23ddeb (diff) | |
download | scintilla-mirror-0b9c12bf9cc211c30a40b13d7ba72dbba5328369.tar.gz |
Feature [feature-requests:1355]. Round instead of truncating for SCI_TEXTWIDTH.
-rw-r--r-- | doc/ScintillaHistory.html | 5 | ||||
-rw-r--r-- | src/Editor.cxx | 6 | ||||
-rw-r--r-- | src/Editor.h | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6f1a31c61..fc698298c 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -577,6 +577,11 @@ The latex lexer supports lstlisting environment that is similar to verbatim. <a href="https://sourceforge.net/p/scintilla/feature-requests/1358/">Feature #1358</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> </ul> <h3> <a href="https://www.scintilla.org/scite443.zip">Release 4.4.3</a> diff --git a/src/Editor.cxx b/src/Editor.cxx index b7636adb2..234a2aaa6 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1823,11 +1823,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)); + return std::lround(surface->WidthText(vs.styles[style].font, text)); } else { return 1; } @@ -6757,7 +6757,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_TEXTWIDTH: PLATFORM_ASSERT(wParam < vs.styles.size()); PLATFORM_ASSERT(lParam); - return TextWidth(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); + return TextWidth(wParam, CharPtrFromSPtr(lParam)); case SCI_TEXTHEIGHT: RefreshStyleData(); diff --git a/src/Editor.h b/src/Editor.h index 80203d319..dda14c311 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; |