add initial BufferView class
This commit is contained in:
parent
c071c43c5c
commit
43052321c4
22
src/core/BufferView.cc
Normal file
22
src/core/BufferView.cc
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "BufferView.h"
|
||||||
|
|
||||||
|
BufferView::BufferView(std::shared_ptr<Buffer> buffer,
|
||||||
|
std::shared_ptr<Buffer::Iterator> 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);
|
||||||
|
}
|
26
src/core/BufferView.h
Normal file
26
src/core/BufferView.h
Normal file
@ -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> buffer,
|
||||||
|
std::shared_ptr<Buffer::Iterator> iterator);
|
||||||
|
void resize(int width, int height);
|
||||||
|
void set_tabstop(int tabstop);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<Buffer> m_buffer;
|
||||||
|
std::shared_ptr<Buffer::Iterator> m_iterator;
|
||||||
|
int m_width;
|
||||||
|
int m_height;
|
||||||
|
int m_tabstop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user