use BufferLineWalker from BufferView
This commit is contained in:
parent
52751338c3
commit
545e73bd07
@ -3,19 +3,17 @@
|
||||
BufferView::BufferView(std::shared_ptr<Buffer> buffer,
|
||||
std::shared_ptr<Buffer::Iterator> iterator,
|
||||
CharacterWidthDeterminer & character_width_determiner)
|
||||
: m_buffer(buffer),
|
||||
m_iterator(iterator),
|
||||
m_character_width_determiner(character_width_determiner)
|
||||
: m_iterator(iterator)
|
||||
{
|
||||
m_width = 1;
|
||||
m_height = 1;
|
||||
m_scroll_offset = 0;
|
||||
m_cursor_screen_row = 0;
|
||||
m_buffer_line_walker = std::make_shared<BufferLineWalker>(buffer, character_width_determiner);
|
||||
}
|
||||
|
||||
void BufferView::resize(int width, int height)
|
||||
{
|
||||
m_width = std::max(1, width);
|
||||
m_buffer_line_walker->set_width(width);
|
||||
m_height = std::max(1, height);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "Buffer.h"
|
||||
#include "CharacterWidthDeterminer.h"
|
||||
#include <functional>
|
||||
#include "BufferLineWalker.h"
|
||||
|
||||
/**
|
||||
* Tracks a "view" of a buffer, which is a two-dimensional grid of characters
|
||||
@ -18,15 +19,19 @@ public:
|
||||
void resize(int width, int height);
|
||||
void set_scroll_offset(int scroll_offset);
|
||||
void iter_lines(std::function<bool(const Buffer::Iterator &)> callback);
|
||||
void walk_line(
|
||||
const Buffer::Iterator & start_of_line,
|
||||
std::function<bool(int, int, int, int, const Buffer::Iterator &)> callback)
|
||||
{
|
||||
m_buffer_line_walker->walk_line(start_of_line, callback);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Buffer> m_buffer;
|
||||
std::shared_ptr<Buffer::Iterator> m_iterator;
|
||||
CharacterWidthDeterminer & m_character_width_determiner;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_scroll_offset;
|
||||
int m_cursor_screen_row;
|
||||
std::shared_ptr<BufferLineWalker> m_buffer_line_walker;
|
||||
|
||||
int effective_scroll_offset()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user