Browse Source

Made go function

grissess
Sarah Inzerillo 3 years ago
parent
commit
96269455fe
  1. 17
      src/Buffer.cpp
  2. 9
      src/Buffer.h
  3. 6
      src/FileBrowser.cpp

17
src/Buffer.cpp

@ -32,3 +32,20 @@ bool Buffer::open(const string & new_file_name)
ix_top_line_ = 0;
return true;
}
bool go(int & link)
{
string f_name = v_links[link - 1];
if(!open(f_name))
return false;
else
return true;
}
void back()
{
}

9
src/Buffer.h

@ -16,6 +16,9 @@ public:
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);
back();
bool open(const std::string & file_name);
void set_window_height(int h) { window_height_ = h; }
@ -40,4 +43,10 @@ inline void Buffer::move_to_previous_page()
ix_top_line_ = 0;
}
inline int Buffer::max::links()
{
//return v_links.length();
return 1;
}
#endif

6
src/FileBrowser.cpp

@ -46,12 +46,14 @@ void FileBrowser::execute_command(char command, bool & done)
ss.str(temp);
ss >> link;
if (!ss) {
error_message_ = "Could not open " + temp;
error_message_ = temp + " is not a valid link";
}
if (link < 1 || link > buffer_.max_links()) {
error_message_ = "Could not open " + temp + " because the file is out of range";
}
buffer_.go(link);
if(!buffer_.go(link)){
error_message_ = "Could not open link " + link;
}
break;
}
case 'n': {

Loading…
Cancel
Save