From 43052321c4bbab2458e831f0a77a195c257e703d Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 7 May 2017 19:10:00 -0400 Subject: [PATCH] add initial BufferView class --- src/core/BufferView.cc | 22 ++++++++++++++++++++++ src/core/BufferView.h | 26 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/core/BufferView.cc create mode 100644 src/core/BufferView.h diff --git a/src/core/BufferView.cc b/src/core/BufferView.cc new file mode 100644 index 0000000..abb8708 --- /dev/null +++ b/src/core/BufferView.cc @@ -0,0 +1,22 @@ +#include "BufferView.h" + +BufferView::BufferView(std::shared_ptr buffer, + std::shared_ptr iterator) + : m_buffer(buffer), + m_iterator(iterator) +{ + m_width = 1; + m_height = 1; + m_tabstop = 1; +} + +void BufferView::resize(int width, int height) +{ + m_width = std::max(1, width); + m_height = std::max(1, height); +} + +void BufferView::set_tabstop(int tabstop) +{ + m_tabstop = std::max(1, tabstop); +} diff --git a/src/core/BufferView.h b/src/core/BufferView.h new file mode 100644 index 0000000..defe8e2 --- /dev/null +++ b/src/core/BufferView.h @@ -0,0 +1,26 @@ +#ifndef BUFFERVIEW_H +#define BUFFERVIEW_H + +#include "Buffer.h" + +/** + * Tracks a "view" of a buffer, which is a two-dimensional grid of characters + * that displays a section of a buffer's contents. + */ +class BufferView +{ +public: + BufferView(std::shared_ptr buffer, + std::shared_ptr iterator); + void resize(int width, int height); + void set_tabstop(int tabstop); + +protected: + std::shared_ptr m_buffer; + std::shared_ptr m_iterator; + int m_width; + int m_height; + int m_tabstop; +}; + +#endif