Codechange: C++-ify the Layouter and related functions

They all now access a std::string_view, instead of a "const char *"
or std::string (in some cases).

Additionally, GetCharAtPosition and friends now return an index
instead of a "const char *", as it makes for a more clear interface.
This commit is contained in:
Patric Stout
2023-05-06 19:53:02 +02:00
committed by Patric Stout
parent 61d1b330d1
commit 60399e17bd
10 changed files with 84 additions and 157 deletions

View File

@@ -896,9 +896,9 @@ Rect QueryString::GetBoundingRect(const Window *w, int wid, const char *from, co
* @param w Window the edit box is in.
* @param wid Widget index.
* @param pt Position to test.
* @return Pointer to the character at the position or nullptr if no character is at the position.
* @return Index of the character position or -1 if no character is at the position.
*/
const char *QueryString::GetCharAtPosition(const Window *w, int wid, const Point &pt) const
ptrdiff_t QueryString::GetCharAtPosition(const Window *w, int wid, const Point &pt) const
{
const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
@@ -910,7 +910,7 @@ const char *QueryString::GetCharAtPosition(const Window *w, int wid, const Point
Rect r = wi->GetCurrentRect().Indent(clearbtn_width, !rtl).Shrink(WidgetDimensions::scaled.framerect);
if (!IsInsideMM(pt.y, r.top, r.bottom)) return nullptr;
if (!IsInsideMM(pt.y, r.top, r.bottom)) return -1;
/* Clamp caret position to be inside our current width. */
const Textbuf *tb = &this->text;