mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-23 19:46:33 +03:00
Add a display coord to buffer coord method to Window
This commit is contained in:
parent
d3738b858b
commit
3e28539b81
@ -234,7 +234,7 @@ ByteCoord find_buffer_coord(const DisplayLine& line, const Buffer& buffer,
|
||||
}
|
||||
}
|
||||
|
||||
CharCoord Window::display_position(ByteCoord coord)
|
||||
CharCoord Window::display_position(ByteCoord coord) const
|
||||
{
|
||||
LineCount l = 0;
|
||||
for (auto& line : m_display_buffer.lines())
|
||||
@ -247,6 +247,13 @@ CharCoord Window::display_position(ByteCoord coord)
|
||||
return { 0, 0 };
|
||||
}
|
||||
|
||||
ByteCoord Window::buffer_coord(CharCoord coord) const
|
||||
{
|
||||
if (0_line <= coord.line and coord.line < m_display_buffer.lines().size())
|
||||
return find_buffer_coord(m_display_buffer.lines()[(int)coord.line], buffer(), coord.column);
|
||||
return { 0, 0 };
|
||||
}
|
||||
|
||||
ByteCoord Window::offset_coord(ByteCoord coord, CharCount offset)
|
||||
{
|
||||
return buffer().offset_coord(coord, offset);
|
||||
|
@ -31,7 +31,8 @@ public:
|
||||
void scroll(CharCount offset);
|
||||
void update_display_buffer(const Context& context);
|
||||
|
||||
CharCoord display_position(ByteCoord coord);
|
||||
CharCoord display_position(ByteCoord coord) const;
|
||||
ByteCoord buffer_coord(CharCoord coord) const;
|
||||
|
||||
Highlighter& highlighters() { return m_highlighters; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user