Browse Source

done but i need to fix many many errors :)))

grissess
Sarah Inzerillo 4 years ago
parent
commit
00cc3e45f6
  1. 27
      src/Buffer.cpp
  2. 9
      src/Buffer.h
  3. 7
      src/FileBrowser.cpp

27
src/Buffer.cpp

@ -31,7 +31,7 @@ bool Buffer::open(const string & new_file_name)
// Remove any newlines that are in the file.
for(auto char_loc = line.find_first_of('\n'); char_loc != -1; char_loc = line.find_first_of('\n'))
line.erase(char_loc, 1);
// Replace break tags with newlines.
for(auto char_loc = line.find("<br>"); char_loc != -1; char_loc = line.find("<br>"))
line.replace(char_loc, 4, "\n");
@ -49,7 +49,7 @@ bool Buffer::open(const string & new_file_name)
std::string link_name = link_tag.substr(second_space_loc + 1);
v_links_.push_back({file_name, link_name});
line.replace(tag_loc, tag_len + 1, "<" + link_name + ">[" + to_string(curr_link) + "]");
}
@ -63,7 +63,7 @@ bool Buffer::open(const string & new_file_name)
// However, if the paragraph is empty, then it shouldn't be added.
if(curr_p != "")
{
{
v_lines_.push_back(curr_p);
curr_p = "";
}
@ -79,22 +79,33 @@ bool Buffer::open(const string & new_file_name)
file_name_ = new_file_name;
ix_top_line_ = 0;
v_hist_.push_back(file_name);
curr_link_itr = v_hist_.end() - 1;
return true;
}
bool go(int & link)
{
string f_name = v_links[link - 1];
string f_name = v_links[link].first;
if(!open(f_name))
return false;
else
v_hist_.push_back(f_name);
curr_link_itr = v_hist_.end() - 1;
return true;
}
void back()
bool back()
{
v_hist_.erase(curr_link_itr);
if(v_hist_.size() == 0)
return false;
curr_link_itr = prev(curr_link_itr);
open(*current_link_itr);
return true;
}

9
src/Buffer.h

@ -19,13 +19,15 @@ public:
void move_to_previous_page();
int max_links();
bool go(int & link);
back();
bool back();
bool open(const std::string & file_name);
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_;
std::vector<std::pair<std::string, std::string>> v_links_;
std::vector<std::string> v_hist_;
auto curr_link_itr = v_hist_.end();
int ix_top_line_ = 0;
std::string file_name_;
int window_height_;
@ -47,8 +49,7 @@ inline void Buffer::move_to_previous_page()
inline int Buffer::max::links()
{
//return v_links.length();
return 1;
return v_links_.length();
}
#endif

7
src/FileBrowser.cpp

@ -33,8 +33,9 @@ void FileBrowser::display()
void FileBrowser::execute_command(char command, bool & done)
{
switch (command) {
/*case 'b': {
buffer_.back();
case 'b': {
if(!buffer_.back())
error_message_ = "No pervious links to open";
break;
}
case 'g': {
@ -55,7 +56,7 @@ void FileBrowser::execute_command(char command, bool & done)
error_message_ = "Could not open link " + link;
}
break;
}*/
}
case 'n': {
buffer_.move_to_next_page();
break;

Loading…
Cancel
Save