|
|
@ -49,7 +49,6 @@ vector<string> Buffer::split_line(string str) { |
|
|
|
//Check if the string part can still be chopped
|
|
|
|
if (str_part.length() != str.length()) { |
|
|
|
str_part = str.substr(0, total_pos); |
|
|
|
cout << str_part << endl; |
|
|
|
str = str.substr(total_pos + 1, str.length()); |
|
|
|
v.push_back(str_part); |
|
|
|
} |
|
|
@ -79,12 +78,13 @@ size_t Buffer::get_tag_(const string & line) |
|
|
|
return p_tag; |
|
|
|
} |
|
|
|
|
|
|
|
bool Buffer::open(const string & new_file_name) |
|
|
|
bool Buffer::open(const string & new_file_name, bool add_to_hist_) |
|
|
|
{ |
|
|
|
std::ifstream file(new_file_name); |
|
|
|
if (!file) |
|
|
|
return false; |
|
|
|
|
|
|
|
v_links_.clear(); |
|
|
|
v_lines_.clear(); |
|
|
|
//Note: the vector is cleared only after we know the file
|
|
|
|
//opened successfully.
|
|
|
@ -163,39 +163,38 @@ bool Buffer::open(const string & new_file_name) |
|
|
|
ix_top_line_ = 0; |
|
|
|
file_name_ = new_file_name; |
|
|
|
|
|
|
|
if(add_to_hist_ == 1){ |
|
|
|
v_hist_.push_back(file_name_); |
|
|
|
curr_link_itr = v_hist_.end() - 1; |
|
|
|
if(add_to_hist_){ |
|
|
|
v_hist_.push_back(file_name_); |
|
|
|
curr_link_itr = v_hist_.end() - 1; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool Buffer::go(int link) |
|
|
|
{ |
|
|
|
string f_name = v_links_[link-1].first; |
|
|
|
v_links_.clear(); |
|
|
|
|
|
|
|
add_to_hist_ = 1; |
|
|
|
if(!open(f_name)) |
|
|
|
return false; |
|
|
|
else |
|
|
|
{ |
|
|
|
if(open(f_name)) |
|
|
|
return true; |
|
|
|
} |
|
|
|
else |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
bool Buffer::back() |
|
|
|
{ |
|
|
|
if(v_hist_.empty()) |
|
|
|
if(v_hist_.size() <= 1) |
|
|
|
return false; |
|
|
|
|
|
|
|
curr_link_itr = curr_link_itr - 1; |
|
|
|
|
|
|
|
v_hist_.erase(curr_link_itr + 1); |
|
|
|
|
|
|
|
if(v_hist_.empty()) |
|
|
|
return false; |
|
|
|
open(*curr_link_itr, false); |
|
|
|
|
|
|
|
add_to_hist_ = 0; |
|
|
|
open(*curr_link_itr); |
|
|
|
// for(string x : v_hist_)
|
|
|
|
// cout << x << ' ';
|
|
|
|
// cin.get();
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |