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.
 
 

56 lines
1.2 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();
int max_links();
bool go(int link);
void back();
bool open(const std::string & file_name);
std::string* get_lines() const;
void set_window_height(int h) { window_height = h; }
//Made window height public so the display function can be removed
int window_height = 0;
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_;
};
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;
}
inline int Buffer::max_links()
{
//return v_links.length();
return 1;
}
#endif