diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-09-05 19:06:31 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-09-05 19:06:31 +0000 |
| commit | 6668151c780ac774f59fcd6aa60ddd00015cfeb7 (patch) | |
| tree | d713db764c85d3e84d3180aea7da3082c87befa8 /src/buffer.hh | |
| parent | d5012c93795945c5ba36ba2fab10e67bfddc386d (diff) | |
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.
Diffstat (limited to 'src/buffer.hh')
| -rw-r--r-- | src/buffer.hh | 17 |
1 files changed, 8 insertions, 9 deletions
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 <string> #include <vector> +#include "utils.hh" + namespace Kakoune { @@ -13,13 +15,10 @@ typedef int BufferSize; typedef char BufferChar; typedef std::basic_string<BufferChar> 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; } |
