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.

51 lines
1.4 KiB

File Browser
COMPONENT: class FileBrowser
A simple file browser. See program specification for details.
Public method:
* void run()
Runs the browser.
Implementation note: Holds the lines of text in a Buffer object. The displaying of the buffer contents and the execution of the commands is delegated to the Buffer object.
Collaborator: Buffer.
COMPONENT: class Buffer
A buffer for a simple file browser. Holds the lines of text and executes commands on them. Displays the contents of the buffer. See program specification for details on commands.
Public methods:
* Buffer()
(Compiler-generated.) Creates an empty buffer.
* void display() const
Displays the lines of text that the user is currently viewing.
* const string & file_name() const
Returns the name of the file.
* void move_to_next_page()
void move_to_previous_page()
bool open(const string & file_name)
Executes the corresponding file viewer command on the buffer. See program specification for details. The method open returns true if successful.
* void set_window_height(int h)
Implementation note: Stores each line of text as a string and all the lines in a vector. Also stores the index of the line currently displayed at the top of the window, as well as the name of the file and the window height.