7 changed files with 270 additions and 266 deletions
-
166docs/design.md
-
2docs/status_report.txt
-
276src/Buffer.cpp
-
16src/Buffer.h
-
50src/FileBrowser.cpp
-
4src/FileBrowser.h
-
22src/main.cpp
@ -1,81 +1,85 @@ |
|||
# File Browser |
|||
|
|||
|
|||
## DESIGN DOCUMENT |
|||
|
|||
|
|||
### COMPONENT: class FileBrowser |
|||
|
|||
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. 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. |
|||
|
|||
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. |
|||
|
|||
* back() |
|||
|
|||
Opens the previously open file. |
|||
|
|||
* 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. |
|||
|
|||
* 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. |
|||
|
|||
* void max_links() |
|||
|
|||
Returns the maximum number of links on the page. This is used by the file browser. |
|||
|
|||
* void move_to_next_page() |
|||
|
|||
Self-explanatory. |
|||
|
|||
* void move_to_previous_page() |
|||
|
|||
Self-explanatory. |
|||
|
|||
* bool open(const string & file_name) |
|||
|
|||
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) |
|||
|
|||
Self-explanatory. |
|||
|
|||
* 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, 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. |
|||
|
|||
# File Browser |
|||
|
|||
|
|||
## DESIGN DOCUMENT |
|||
|
|||
|
|||
### COMPONENT: class FileBrowser |
|||
|
|||
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. 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. |
|||
|
|||
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. |
|||
|
|||
* back() |
|||
|
|||
Opens the previously open file. Removes the current file from the history before going back. |
|||
|
|||
* 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. |
|||
|
|||
* 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. |
|||
|
|||
* void max_links() |
|||
|
|||
Returns the maximum number of links on the page. This is used by the file browser. |
|||
|
|||
* void move_to_next_page() |
|||
|
|||
Self-explanatory. |
|||
|
|||
* void move_to_previous_page() |
|||
|
|||
Self-explanatory. |
|||
|
|||
* bool open(const string & file_name) |
|||
|
|||
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. This incorperates the split_line function as well. The method open returns true if successful, otherwise false. |
|||
|
|||
* void Buffer::split_line(string str) |
|||
|
|||
Takes a copy of the line given to it, and then splits the line up into subtrings that are less than the maximum length. If a word is longer than the maximum length, it prints that word on a line on its own. |
|||
|
|||
* void set_maximum_length(int l) |
|||
|
|||
Self-explanatory. |
|||
|
|||
* 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, 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. |
|||
|
@ -1,3 +1,3 @@ |
|||
Ryan Stewart, Cameron Weinfurt, Sarah Inzerillo |
|||
Sarah Inzerillo, Ryan Stewart, and Cameron Weinfurt, |
|||
|
|||
Our file fiewer is complete and runs as expected. |
@ -1,11 +1,11 @@ |
|||
// Launches the the browser
|
|||
|
|||
#include "FileBrowser.h"
|
|||
|
|||
int main() |
|||
{ |
|||
FileBrowser browser; |
|||
browser.run(); |
|||
|
|||
return 0; |
|||
} |
|||
// Launches the the browser
|
|||
|
|||
#include "FileBrowser.h"
|
|||
|
|||
int main() |
|||
{ |
|||
FileBrowser browser; |
|||
browser.run(); |
|||
|
|||
return 0; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue