Minor code cleanups in buffer.{cc,hh}

This commit is contained in:
Maxime Coste 2014-05-10 16:25:07 +01:00
parent fc13a90175
commit 05b79921a9
2 changed files with 12 additions and 19 deletions

View File

@ -178,23 +178,16 @@ struct Buffer::Modification
{
enum Type { Insert, Erase };
Type type;
Type type;
ByteCoord coord;
String content;
String content;
Modification(Type type, ByteCoord coord, String content)
: type(type), coord(coord), content(std::move(content)) {}
Modification inverse() const
{
Type inverse_type = Insert;
switch (type)
{
case Insert: inverse_type = Erase; break;
case Erase: inverse_type = Insert; break;
default: kak_assert(false);
}
return {inverse_type, coord, content};
return {type == Insert ? Erase : Insert, coord, content};
}
};

View File

@ -117,20 +117,20 @@ public:
char byte_at(ByteCoord c) const;
ByteCount offset(ByteCoord c) const;
ByteCount distance(ByteCoord begin, ByteCoord end) const;
ByteCoord advance(ByteCoord coord, ByteCount count) const;
ByteCoord next(ByteCoord coord) const;
ByteCoord prev(ByteCoord coord) const;
ByteCoord advance(ByteCoord coord, ByteCount count) const;
ByteCoord next(ByteCoord coord) const;
ByteCoord prev(ByteCoord coord) const;
ByteCoord char_next(ByteCoord coord) const;
ByteCoord char_prev(ByteCoord coord) const;
ByteCoord char_next(ByteCoord coord) const;
ByteCoord char_prev(ByteCoord coord) const;
ByteCoord back_coord() const;
ByteCoord end_coord() const;
ByteCoord back_coord() const;
ByteCoord end_coord() const;
bool is_valid(ByteCoord c) const;
bool is_end(ByteCoord c) const;
ByteCoord last_modification_coord() const;
ByteCoord last_modification_coord() const;
BufferIterator begin() const;
BufferIterator end() const;
@ -144,7 +144,7 @@ public:
BufferIterator iterator_at(ByteCoord coord) const;
// returns nearest valid coordinates from given ones
ByteCoord clamp(ByteCoord coord) const;
ByteCoord clamp(ByteCoord coord) const;
ByteCoord offset_coord(ByteCoord coord, CharCount offset);
ByteCoord offset_coord(ByteCoord coord, LineCount offset);