Class Editor

java.lang.Object
mars.venus.editor.Editor

public class Editor extends Object
Manage the file being edited. Currently only manages one file at a time, but can be expanded.
  • Field Details

  • Constructor Details

    • Editor

      public Editor(VenusUI gui)
      Create editor.
      Parameters:
      gui - the GUI that owns this editor
  • Method Details

    • getCurrentSaveDirectory

      public String getCurrentSaveDirectory()
      Get name of current directory for Save or Save As operation.
      Returns:
      String containing directory pathname. Returns null if there is no EditTab. Returns default (the directory MARS is launched from) if no Save or Save As operations have been performed.
    • setCurrentSaveDirectory

      public void setCurrentSaveDirectory(String currentSaveDirectory)
      Set name of current directory for Save operation. The contents of this directory will be displayed when Save dialog is launched.
      Parameters:
      currentSaveDirectory - String containing pathname for current Save directory. If it does not exist or is not a directory, the default (MARS launch directory) will be used.
    • getNextDefaultFilename

      public String getNextDefaultFilename()
      Generates the next default file name.
      Returns:
      String "untitled-N.asm", where N is a number that increments upon each call.
    • newFile

      public void newFile()
      Perform "new" operation to create an empty tab.
    • close

      public boolean close()
      Perform "close" operation on current tab's file.
      Returns:
      true if succeeded, else false.
    • closeAll

      public boolean closeAll()
      Close all currently open files.
      Returns:
      true if succeeded, else false.
    • save

      public boolean save()
      Perform "save" operation on current tab's file.
      Returns:
      true if succeeded, else false.
    • saveAs

      public boolean saveAs()
      Perform "save as" operation on current tab's file.
      Returns:
      true if succeeded, else false.
    • saveAll

      public boolean saveAll()
      Perform save operation on all open files (tabs).
      Returns:
      true if succeeded, else false.
    • open

      public List<File> open()
      Launch a file chooser for the user to select one or more files, attempting to open them in new editor tabs afterward.
      Returns:
      The list of files which could not be opened due to an error. (Can be empty.)