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.

56 lines
1.6 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. File Browser
  3. COMPONENT: class FileBrowser
  4. A simple file browser. See program specification for details.
  5. Public method:
  6. * void run()
  7. Runs the browser.
  8. 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.
  9. Collaborator: Buffer.
  10. COMPONENT: class Buffer
  11. 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.
  12. Public methods:
  13. * Buffer()
  14. (Compiler-generated.) Creates an empty buffer.
  15. * void display() const
  16. Displays the lines of text that the user is currently viewing.
  17. * const string & file_name() const
  18. Returns the name of the file.
  19. * void move_to_next_page()
  20. void move_to_previous_page()
  21. bool open(const string & file_name)
  22. bool go(int link)
  23. bool back()
  24. Executes the corresponding file viewer command on the buffer.
  25. See program specification for details. The methods open, go, and back returns true if successful.
  26. * int max_links()
  27. Gives FileViewer access to the amount of links stored.
  28. * void set_window_height(int h)
  29. Self-explanatory.
  30. 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.