You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
46 lines
1.0 KiB
// Buffer.h
|
|
|
|
#ifndef _Buffer_h_
|
|
#define _Buffer_h_
|
|
|
|
#include <fstream>
|
|
#include <iomanip>
|
|
#include <sstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class Buffer
|
|
{
|
|
public:
|
|
void display() const;
|
|
const std::string & file_name() const { return file_name_; }
|
|
void move_to_next_page();
|
|
void move_to_previous_page();
|
|
bool open(const std::string & file_name);
|
|
std::string* get_lines() const;
|
|
void set_window_height(int h) { window_height_ = h; }
|
|
|
|
private:
|
|
std::vector<std::string> v_lines_;
|
|
std::vector<std::pair<std::string, std::string>> v_links_;
|
|
int ix_top_line_ = 0;
|
|
std::string file_name_;
|
|
int window_height_;
|
|
};
|
|
|
|
inline void Buffer::move_to_next_page()
|
|
{
|
|
ix_top_line_ += window_height_;
|
|
if (ix_top_line_ >= v_lines_.size())
|
|
ix_top_line_ -= window_height_;
|
|
}
|
|
|
|
inline void Buffer::move_to_previous_page()
|
|
{
|
|
ix_top_line_ -= window_height_;
|
|
if (ix_top_line_ < 0)
|
|
ix_top_line_ = 0;
|
|
}
|
|
|
|
#endif
|