|
|
@ -14,6 +14,18 @@ void Buffer::display() const |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
string* Buffer::get_lines() const |
|
|
|
{ |
|
|
|
string* lines = new string[window_height_]; |
|
|
|
int line = 0; |
|
|
|
while (line < window_height_ && line + ix_top_line_ < v_lines_.size()) { |
|
|
|
lines[line - ix_top_line_] = v_lines_[line]; |
|
|
|
++line; |
|
|
|
} |
|
|
|
|
|
|
|
return lines; |
|
|
|
} |
|
|
|
|
|
|
|
bool Buffer::open(const string & new_file_name) |
|
|
|
{ |
|
|
|
std::ifstream file(new_file_name); |
|
|
@ -28,10 +40,6 @@ bool Buffer::open(const string & new_file_name) |
|
|
|
std::string curr_p, line; |
|
|
|
while(getline(file, line)) |
|
|
|
{ |
|
|
|
// 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"); |
|
|
@ -71,7 +79,7 @@ bool Buffer::open(const string & new_file_name) |
|
|
|
line = extra_text; |
|
|
|
} |
|
|
|
// Append any data left on this line to the current paragraph being read.
|
|
|
|
curr_p += line; |
|
|
|
curr_p += " " + line; |
|
|
|
} |
|
|
|
|
|
|
|
// Push the contents of curr_p as it has the last paragraph in the file.
|
|
|
|