window, editor: take coords rather than iterators parameters

This commit is contained in:
Maxime Coste 2013-05-23 19:21:34 +02:00
parent 4f1ba860f8
commit 52b77c1915
4 changed files with 9 additions and 12 deletions

View File

@ -61,9 +61,8 @@ public:
void flip_selections(); void flip_selections();
void keep_selection(int index); void keep_selection(int index);
void remove_selection(int index); void remove_selection(int index);
void select(const BufferIterator& it, void select(const BufferCoord& c, SelectMode mode = SelectMode::Replace)
SelectMode mode = SelectMode::Replace) { auto it = m_buffer->iterator_at(c); select(Selection{ it, it }, mode); }
{ select(Selection{ it, it }, mode); }
void select(const Selection& sel, void select(const Selection& sel,
SelectMode mode = SelectMode::Replace); SelectMode mode = SelectMode::Replace);
void select(const Selector& selector, void select(const Selector& selector,

View File

@ -49,11 +49,8 @@ void goto_commands(Context& context)
int count = context.numeric_param(); int count = context.numeric_param();
if (count != 0) if (count != 0)
{ {
BufferIterator target =
context.editor().buffer().iterator_at_line_begin(count-1);
context.push_jump(); context.push_jump();
context.editor().select(target); context.editor().select(BufferCoord{count - 1, 0});
if (context.has_window()) if (context.has_window())
context.window().center_selection(); context.window().center_selection();
} }

View File

@ -176,20 +176,21 @@ void Window::scroll_to_keep_cursor_visible_ifn()
} }
} }
DisplayCoord Window::display_position(const BufferIterator& iterator) DisplayCoord Window::display_position(const BufferCoord& coord)
{ {
DisplayCoord res{0,0}; DisplayCoord res{0,0};
for (auto& line : m_display_buffer.lines()) for (auto& line : m_display_buffer.lines())
{ {
if (line.buffer_line() == iterator.line()) if (line.buffer_line() == coord.line)
{ {
for (auto& atom : line) for (auto& atom : line)
{ {
auto& content = atom.content; auto& content = atom.content;
if (content.has_buffer_range() and if (content.has_buffer_range() and
iterator.coord() >= content.begin() and iterator.coord() < content.end()) coord >= content.begin() and coord < content.end())
{ {
res.column += utf8::distance(buffer().iterator_at(content.begin()), iterator); res.column += utf8::distance(buffer().iterator_at(content.begin()),
buffer().iterator_at(coord));
return res; return res;
} }
res.column += content.length(); res.column += content.length();

View File

@ -37,7 +37,7 @@ public:
void scroll(LineCount offset); void scroll(LineCount offset);
void update_display_buffer(); void update_display_buffer();
DisplayCoord display_position(const BufferIterator& it); DisplayCoord display_position(const BufferCoord& coord);
HighlighterGroup& highlighters() { return m_highlighters; } HighlighterGroup& highlighters() { return m_highlighters; }