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

@@ -318,11 +318,11 @@ struct IConsoleWindow : Window
return r;
}
const char *GetTextCharacterAtPosition(const Point &pt) const override
ptrdiff_t GetTextCharacterAtPosition(const Point &pt) const override
{
int delta = std::min<int>(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
if (!IsInsideMM(pt.y, this->height - this->line_height, this->height)) return nullptr;
if (!IsInsideMM(pt.y, this->height - this->line_height, this->height)) return -1;
return GetCharAtPosition(_iconsole_cmdline.buf, pt.x - delta);
}