From 6668151c780ac774f59fcd6aa60ddd00015cfeb7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 5 Sep 2011 19:06:31 +0000 Subject: LineAndColumn: segregate into WindowCoord and BufferCoord Having the same type to specify coordinates in window space or buffer space is error prone, now the compiler will tell if we use one for another. --- src/buffer.hh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/buffer.hh') diff --git a/src/buffer.hh b/src/buffer.hh index dd2762a5..66136f82 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -4,6 +4,8 @@ #include #include +#include "utils.hh" + namespace Kakoune { @@ -13,13 +15,10 @@ typedef int BufferSize; typedef char BufferChar; typedef std::basic_string BufferString; -struct LineAndColumn +struct BufferCoord : LineAndColumn { - BufferPos line; - BufferPos column; - - LineAndColumn(BufferPos line = 0, BufferPos column = 0) - : line(line), column(column) {} + BufferCoord(int line = 0, int column = 0) + : LineAndColumn(line, column) {} }; class BufferIterator @@ -82,10 +81,10 @@ public: BufferSize length() const; - BufferIterator iterator_at(const LineAndColumn& line_and_column) const; - LineAndColumn line_and_column_at(const BufferIterator& iterator) const; + BufferIterator iterator_at(const BufferCoord& line_and_column) const; + BufferCoord line_and_column_at(const BufferIterator& iterator) const; - LineAndColumn clamp(const LineAndColumn& line_and_column) const; + BufferCoord clamp(const BufferCoord& line_and_column) const; const std::string& name() const { return m_name; } -- cgit v1.2.3