Browse Source

Updated design docs with current information. Proof read this and make sure I didn't forget anything important.

stew^2
Cameron Weinfurt 4 years ago
parent
commit
be6110dce0
  1. 50
      docs/design.md

50
docs/design.md

@ -6,13 +6,21 @@
### COMPONENT: class FileBrowser
A simple file browser. See program specification for details.
A simple file browser. Acts as the interface between the user and its components.
#### Public method:
* void display()
Updates the contents of the screen with the file contents that the user should see as well as UI and prompts surronding it.
* void execute(char command, bool & done)
Executes the command that the user inputs, represented by a single character. The user can open a file, scroll through the contents of the file, open links, open previously opened files and exit the program.
* void run()
Runs the browser.
Runs the browser. It obtains size parameters from the user and then enters the browser's primary loop.
**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.
@ -29,41 +37,45 @@ A buffer for a simple file browser. Holds the lines of text and executes comman
(Compiler-generated.) Creates an empty buffer.
* void display() const
* back()
Opens the previously open file.
Displays the lines of text that the user is currently viewing.
* void display() const
Displays the lines of text that the user is currently viewing.
* const string & file_name() const
* const string & file_name() const
Returns the name of the file.
Returns the name of the file.
* bool go(int link)
* bool go(int link)
Goes to the specified link in the current file. This opens the new link file and adds it to the open history.
Goes to the specified link in the current file. This opens the new link file and adds it to the open history.
* void max_links()
* void max_links()
Returns the maximum number of links on the page. This is used by the file browser.
Returns the maximum number of links on the page. This is used by the file browser.
* void move_to_next_page()
* void move_to_next_page()
Self-explanatory.
Self-explanatory.
* void move_to_previous_page()
* void move_to_previous_page()
Self-explanatory.
Self-explanatory.
* bool open(const string & file_name)
* 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.
Executes the corresponding file viewer command on the buffer. If a file is currently open, it adds the previous file to the open history. Lines in the file are formatted. Paragraph tags(<p>) define bodies of text which are seperated by other bodies of text by a line. Break tags(<br>) become a newline in the viewer. Anchor tags(<a>) are links. The method open returns true if successful.
* void set_maximum_length(int l)
* void set_maximum_length(int l)
Self-explanatory.
* void set_window_height(int h)
* void set_window_height(int h)
Self-explanatory.
**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.
**Implementation note**: Stores each line of text as a string and all the lines in a vector, which should be formatted and ready to display without further processing. The links that are processed in the open command are stored as a pair in another 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. A utility function that handles the processing of lines that would be longer than the browser's set width into multible lines.
Loading…
Cancel
Save