mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-24 16:15:38 +03:00
Remove Buffer::iterator_at_line_{begin,end}, use iterator_at(line{,+1})
This commit is contained in:
parent
503f0cce25
commit
c4f9253634
@ -108,30 +108,6 @@ BufferCoord Buffer::clamp(BufferCoord coord) const
|
||||
return coord;
|
||||
}
|
||||
|
||||
BufferIterator Buffer::iterator_at_line_begin(LineCount line) const
|
||||
{
|
||||
line = Kakoune::clamp(line, 0_line, line_count()-1);
|
||||
kak_assert(line_length(line) > 0);
|
||||
return BufferIterator(*this, { line, 0 });
|
||||
}
|
||||
|
||||
BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) const
|
||||
{
|
||||
return iterator_at_line_begin(iterator.line());
|
||||
}
|
||||
|
||||
BufferIterator Buffer::iterator_at_line_end(LineCount line) const
|
||||
{
|
||||
line = Kakoune::clamp(line, 0_line, line_count()-1);
|
||||
kak_assert(line_length(line) > 0);
|
||||
return ++BufferIterator(*this, { line, line_length(line) - 1 });
|
||||
}
|
||||
|
||||
BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const
|
||||
{
|
||||
return iterator_at_line_end(iterator.line());
|
||||
}
|
||||
|
||||
BufferIterator Buffer::begin() const
|
||||
{
|
||||
return BufferIterator(*this, { 0_line, 0 });
|
||||
@ -729,8 +705,7 @@ bool Buffer::is_valid(const BufferCoord& c) const
|
||||
|
||||
bool Buffer::is_end(const BufferCoord& c) const
|
||||
{
|
||||
return (c.line == line_count() and c.column == 0) or
|
||||
(c.line == line_count() - 1 and c.column == m_lines.back().length());
|
||||
return c >= BufferCoord{line_count() - 1, m_lines.back().length()};
|
||||
}
|
||||
|
||||
char Buffer::byte_at(const BufferCoord& c) const
|
||||
|
@ -151,19 +151,6 @@ public:
|
||||
// returns nearest valid coordinates from given ones
|
||||
BufferCoord clamp(BufferCoord coord) const;
|
||||
|
||||
// returns an iterator pointing to the first character of the line
|
||||
// iterator is on
|
||||
BufferIterator iterator_at_line_begin(const BufferIterator& iterator) const;
|
||||
// the same but taking a line number instead of an iterator
|
||||
BufferIterator iterator_at_line_begin(LineCount line) const;
|
||||
|
||||
// returns an iterator pointing to the character after the last of the
|
||||
// line iterator is on (which is the first of the next line if iterator is
|
||||
// not on the last one)
|
||||
BufferIterator iterator_at_line_end(const BufferIterator& iterator) const;
|
||||
// the same but taking a line number instead of an iterator
|
||||
BufferIterator iterator_at_line_end(LineCount line) const;
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
String display_name() const;
|
||||
|
||||
|
@ -42,7 +42,7 @@ void expand_tabulations(Buffer& buffer, Selection& selection, String& content)
|
||||
{
|
||||
int column = 0;
|
||||
const auto position = buffer.iterator_at(selection.last());
|
||||
for (auto it = buffer.iterator_at_line_begin(position);
|
||||
for (auto it = buffer.iterator_at(position.line());
|
||||
it != position; ++it)
|
||||
{
|
||||
kak_assert(*it != '\n');
|
||||
@ -67,7 +67,7 @@ struct RegexFilter
|
||||
void operator() (Buffer& buffer, Selection& selection, String& content)
|
||||
{
|
||||
const auto position = buffer.iterator_at(selection.last());
|
||||
auto line_begin = buffer.iterator_at_line_begin(position);
|
||||
auto line_begin = buffer.iterator_at(position.line());
|
||||
boost::match_results<BufferIterator> results;
|
||||
if (boost::regex_match(content.c_str(), m_insert_match) and
|
||||
boost::regex_match(line_begin, position, results, m_line_match))
|
||||
|
@ -235,7 +235,7 @@ void expand_tabulations(const Window& window, DisplayBuffer& display_buffer)
|
||||
atom_it = line.split(atom_it, (it+1).coord());
|
||||
|
||||
int column = 0;
|
||||
for (auto line_it = buffer.iterator_at_line_begin(it);
|
||||
for (auto line_it = buffer.iterator_at(it.line());
|
||||
line_it != it; ++line_it)
|
||||
{
|
||||
kak_assert(*line_it != '\n');
|
||||
|
@ -92,7 +92,7 @@ void goto_commands(Context& context)
|
||||
{
|
||||
context.push_jump();
|
||||
const Buffer& buf = editor.buffer();
|
||||
editor.select(buf.iterator_at_line_begin(buf.line_count() - 1), mode);
|
||||
editor.select(buf.iterator_at(buf.line_count() - 1), mode);
|
||||
break;
|
||||
}
|
||||
case 'e':
|
||||
@ -103,7 +103,7 @@ void goto_commands(Context& context)
|
||||
if (context.has_window())
|
||||
{
|
||||
auto line = context.window().position().line;
|
||||
editor.select(editor.buffer().iterator_at_line_begin(line), mode);
|
||||
editor.select(editor.buffer().iterator_at(line), mode);
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
@ -111,7 +111,7 @@ void goto_commands(Context& context)
|
||||
{
|
||||
auto& window = context.window();
|
||||
auto line = window.position().line + window.dimensions().line - 1;
|
||||
editor.select(editor.buffer().iterator_at_line_begin(line), mode);
|
||||
editor.select(editor.buffer().iterator_at(line), mode);
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
@ -119,7 +119,7 @@ void goto_commands(Context& context)
|
||||
{
|
||||
auto& window = context.window();
|
||||
auto line = window.position().line + window.dimensions().line / 2;
|
||||
editor.select(editor.buffer().iterator_at_line_begin(line), mode);
|
||||
editor.select(editor.buffer().iterator_at(line), mode);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
@ -608,8 +608,8 @@ void scroll(Context& context)
|
||||
position.line += (window.dimensions().line - 2);
|
||||
cursor_line = position.line + window.dimensions().line - 1;
|
||||
}
|
||||
auto cursor_pos = utf8::advance(buffer.iterator_at_line_begin(position.line),
|
||||
buffer.iterator_at_line_end(position.line),
|
||||
auto cursor_pos = utf8::advance(buffer.iterator_at(position.line),
|
||||
buffer.iterator_at(position.line+1),
|
||||
position.column);
|
||||
window.select(cursor_pos);
|
||||
window.set_position(position);
|
||||
|
@ -68,7 +68,7 @@ void test_editor()
|
||||
}
|
||||
editor.undo();
|
||||
|
||||
Selection sel{ buffer.iterator_at_line_begin(2_line), buffer.end()-1 };
|
||||
Selection sel{ buffer.iterator_at(2_line), buffer.end()-1 };
|
||||
editor.select(sel, SelectMode::Replace);
|
||||
editor.insert("",InsertMode::Replace);
|
||||
kak_assert(not buffer.is_end(editor.main_selection().first()));
|
||||
|
Loading…
Reference in New Issue
Block a user