Text editor
Version 1.0

DESIGN


COMPONENT: class TextEditor

A simple text editor.  See program specification for details.

Public method:

o void run()

    Runs the editor. 
    
    Implementation: A simple loop that displays the buffer, the menu of commands, reads a command and executes it.  The displaying is delegated to private method display.

Private method:

o void display() 

    Displays the buffer and menu of commands, including the name of the file and the three lines of dashes.  See program specification for details.  

Implementation: Holds the lines of text in a Buffer object.  The displaying of the buffer contents and execution of the commands is delegated to the Buffer object.

Collaborator: Buffer.


COMPONENT: class Buffer

A buffer for a simple text editor.  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:
          
o Buffer() 

    (Compiler-generated.) Creates an empty buffer and sets the current line to the end line.

o void display() const

    Displays the contents of buffer.

o const string & get_file_name() const

    Returns the name of the file.

o void move_to_next_line() 
  void move_to_previous_line() 
  void insert(const string & new_line)
  void erase()
  bool open(const string & new_file_name)
  bool save(const string & new_file_name)
  
    Executes the corresponding editor command on the buffer.  See program specification for details.  he methods Topen and save return true if successful.

o void set_window_height(int h)

    Self-explanatory.

Implementation:  Stores each line of text as a string and all the lines in a vector.  Maintains the index of the current line, the index of the line currently displayed at the top of the window, the name of the file and the window height.
             
