Package mars.venus.editor
Class Editor
java.lang.Object
mars.venus.editor.Editor
Manage the file being edited.
Currently only manages one file at a time, but can be expanded.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
close()
Perform "close" operation on current tab's file.boolean
closeAll()
Close all currently open files.Get name of current directory for Save or Save As operation.Generates the next default file name.void
newFile()
Perform "new" operation to create an empty tab.open()
Launch a file chooser for the user to select one or more files, attempting to open them in new editor tabs afterward.boolean
save()
Perform "save" operation on current tab's file.boolean
saveAll()
Perform save operation on all open files (tabs).boolean
saveAs()
Perform "save as" operation on current tab's file.void
setCurrentSaveDirectory
(String currentSaveDirectory) Set name of current directory for Save operation.
-
Field Details
-
MIN_TAB_SIZE
public static final int MIN_TAB_SIZE- See Also:
-
MAX_TAB_SIZE
public static final int MAX_TAB_SIZE- See Also:
-
MIN_BLINK_RATE
public static final int MIN_BLINK_RATE- See Also:
-
MAX_BLINK_RATE
public static final int MAX_BLINK_RATE- See Also:
-
-
Constructor Details
-
Editor
Create editor.- Parameters:
gui
- the GUI that owns this editor
-
-
Method Details
-
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
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
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
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.)
-