From 66aa9c523530d295f2d9e80efe093da6f3bad753 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 9 Jan 2017 20:26:18 -0500 Subject: [PATCH] add Buffer::Iterator::{prev,next}() --- src/core/Buffer-Iterator.cc | 14 ++++++++++++++ src/core/Buffer.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/core/Buffer-Iterator.cc b/src/core/Buffer-Iterator.cc index daa0ce7..40029bf 100644 --- a/src/core/Buffer-Iterator.cc +++ b/src/core/Buffer-Iterator.cc @@ -201,3 +201,17 @@ void Buffer::Iterator::warp_to_offset(size_t offset) } } } + +Buffer::Iterator Buffer::Iterator::prev() +{ + Iterator i = *this; + i.go_back(); + return i; +} + +Buffer::Iterator Buffer::Iterator::next() +{ + Iterator i = *this; + i.go_forward(); + return i; +} diff --git a/src/core/Buffer.h b/src/core/Buffer.h index a98d258..3fe2602 100644 --- a/src/core/Buffer.h +++ b/src/core/Buffer.h @@ -41,6 +41,8 @@ public: bool go_right_in_line(bool allow_eol); bool go_previous_line(); bool go_next_line(); + Iterator prev(); + Iterator next(); void warp(ssize_t offset_offset, ssize_t line_offset) { m_offset += offset_offset;