Package mars.settings
Class Settings
java.lang.Object
mars.settings.Settings
Contains various IDE settings. Persistent settings are maintained for the
current user and on the current machine using Java's Preference objects.
Failing that, default setting values come from default_settings.properties file.
If both of those fail, default values are defined in this class.
NOTE: If the Preference objects fail due to security exceptions, changes to settings will not carry over from one MARS session to the next.
Actual implementation of the Preference objects is platform-dependent. For Windows, they are stored in Registry. To see, run regedit and browse to: HKEY_CURRENT_USER\Software\JavaSoft\Prefs\mars
- Author:
- Pete Sanderson
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BooleanSetting
Flag to control whether a file is immediately and automatically assembled upon opening.final IntegerSetting
Maximum number of errors that a single assembler run can produce.final BooleanSetting
Flag to control whether the editor will use the auto-indent feature.final BooleanSetting[]
final IntegerSetting
Caret blink rate in milliseconds. 0 means don't blink.final ColorSetting[]
final FontSetting
Font for the console displays in the Messages and Console tabs.final IntegerSetting
Maximum number of lines that can be kept in a console at once.final IntegerSetting
Number of extra lines to be trimmed when the number of lines in a console exceeds the maximum.final ColorSetting
RGB color for data segment highlighted backgroundfinal ColorSetting
RGB color for data segment highlighted foregroundfinal BooleanSetting
Flag to control whether delayed branching is simulated.final BooleanSetting
Flag to control whether memory addresses are displayed in hexadecimal.final BooleanSetting
Flag to control whether the editor will display line numbers on the side.final BooleanSetting
Flag to control whether operand, memory, and register values are displayed in hexadecimal.final FontSetting
Font for the text editor.final IntegerSetting
Number of letters to be matched by editor's instruction guide before popup generated (if popup enabled).final IntegerSetting
Editor tab size in characters.final StringSetting
The special label treated as the entry point for a program.final BooleanSetting
Flag to control whether the currently selected exception handler source file will be included in each assembly operation.final StringSetting
Current specified exception handler file (a MIPS assembly source file).final BooleanSetting
Flag to control whether the assembler will be limited to basic MIPS instructions and formats.final FontSetting[]
final BooleanSetting
Flag to control whether the editor will highlight the line currently being edited.final IntegerSetting[]
final BooleanSetting
Flag to control whether the symbol table window will be visible upon successful assembly in the Execute tab.final StringSetting
The name of the look and feel to use for the GUI.final IntegerSetting
Maximum number of "backstep" operations that can be taken.final IntegerSetting
Maximum number of recent files to be kept in the "Recent Files" menu.final StringSetting
Identifier of current memory configuration.final BooleanSetting
Flag to control whether values in the memory viewer are highlighted during stepped execution.final StringSetting
Acceptable file extensions for MIPS assembly files.final BooleanSetting
Flag to control whether the editor will provide popup instruction guidance while typing.final BooleanSetting
Flag to control whether the simulator will use popup dialogs for input syscalls.final StringSetting
The list of files which were open in tabs in the previous session.final StringSetting
The list of files which have been opened recently, ordered from most to least recent.final ColorSetting
RGB color for register highlighted backgroundfinal ColorSetting
RGB color for register highlighted foregroundfinal BooleanSetting
Flag to control whether registers in the register window are highlighted during stepped execution.final BooleanSetting
Flag to control whether a program can write binary code to the text or data segment and execute that code.final BooleanSetting
Flag to control whether the assembler automatically initializes program counter to the address of global labelmain
, if defined.final StringSetting[]
final IntegerSetting
State for sorting label window display.final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting
final SyntaxStyleSetting[]
final SyntaxStyleSetting
final FontSetting
Font for the various table displays (registers, text segment, memory viewer, symbol table).final FontSetting
Font for highlighted text in table displays (overridestableFont
in those cells).final StringSetting
Order of text segment table columns.final ColorSetting
RGB color for text segment highlighted backgroundfinal ColorSetting
RGB color for text segment highlighted foregroundfinal ColorSetting
RGB color for text segment fetch highlighted backgroundfinal ColorSetting
RGB color for text segment fetch highlighted foregroundfinal IntegerSetting
UI scale multiplier as a percentage. 100 is at 1:1 scale.final BooleanSetting
Flag to control whether the big-endian byte ordering is used in memory and register addressing.final BooleanSetting
Flag to control whether to accept and use program arguments.final BooleanSetting
Flag to control whether assembler warnings are automatically promoted to errors. -
Constructor Summary
ConstructorsConstructorDescriptionSettings()
Create and initialize an instance ofSettings
based on configuration defaults and user-defined values from permanent storage. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(Settings.Listener listener) decodeFileList
(String string) void
static String
encodeFileList
(List<File> files) getDefaultSyntaxStyle
(int index) Obtain the defaultSyntaxStyle
corresponding to a given token type.getSyntaxStyle
(int index) Obtain the user-definedSyntaxStyle
corresponding to a given token type.getSyntaxStyleOrDefault
(int index) Obtain the currentSyntaxStyle
corresponding to a given token type.Obtain the user-definedSyntaxStyle
s in the form of an array.Obtain the currentSyntaxStyle
s in the form of an array.void
Load application-wide settings.void
removeListener
(Settings.Listener listener) void
saveBooleanSetting
(String key, boolean value, boolean notify) Save the key-value pair in thePreferences
object and ensure it is written to persistent storage.void
saveIntegerSetting
(String key, int value, boolean notify) void
saveStringSetting
(String key, String value, boolean notify) Save the key-value pair in thePreferences
object and ensure it is written to persistent storage.void
setSyntaxStyle
(int index, SyntaxStyle style) Assign aSyntaxStyle
to a given token type.void
Update any default values that are derived from the UI theme.
-
Field Details
-
extendedAssemblerEnabled
Flag to control whether the assembler will be limited to basic MIPS instructions and formats. -
assembleOnOpenEnabled
Flag to control whether a file is immediately and automatically assembled upon opening. Handy when using an external editor, for example. -
labelWindowVisible
Flag to control whether the symbol table window will be visible upon successful assembly in the Execute tab. -
displayAddressesInHex
Flag to control whether memory addresses are displayed in hexadecimal. If this flag is set to false, they are displayed in decimal. -
displayValuesInHex
Flag to control whether operand, memory, and register values are displayed in hexadecimal. If this flag is set to false, they are displayed in decimal. -
exceptionHandlerEnabled
Flag to control whether the currently selected exception handler source file will be included in each assembly operation. -
delayedBranchingEnabled
Flag to control whether delayed branching is simulated. Delayed branching is a feature of actual hardware where the instruction immediately following a branch instruction is always executed, even if the branch is taken, due to CPU pipelining. Thus, with delayed branching disabled, there is effectively a hiddennop
after every branch instruction.DPS 14 June 2007
-
displayEditorLineNumbers
Flag to control whether the editor will display line numbers on the side. -
warningsAreErrors
Flag to control whether assembler warnings are automatically promoted to errors. -
useProgramArguments
Flag to control whether to accept and use program arguments. -
memoryHighlightingEnabled
Flag to control whether values in the memory viewer are highlighted during stepped execution. -
registerHighlightingEnabled
Flag to control whether registers in the register window are highlighted during stepped execution. -
startAtMain
Flag to control whether the assembler automatically initializes program counter to the address of global labelmain
, if defined. -
highlightCurrentEditorLine
Flag to control whether the editor will highlight the line currently being edited. -
popupInstructionGuidance
Flag to control whether the editor will provide popup instruction guidance while typing. -
popupSyscallInput
Flag to control whether the simulator will use popup dialogs for input syscalls. -
autoIndentEnabled
Flag to control whether the editor will use the auto-indent feature. -
selfModifyingCodeEnabled
Flag to control whether a program can write binary code to the text or data segment and execute that code. -
useBigEndian
Flag to control whether the big-endian byte ordering is used in memory and register addressing. If true, big-endian is used, meaning bytes of values are stored from most to least significant. If false, little-endian is used instead, meaning bytes are stored from least to most significant. -
booleanSettings
-
uiScale
UI scale multiplier as a percentage. 100 is at 1:1 scale. -
maxRecentFiles
Maximum number of recent files to be kept in the "Recent Files" menu. -
consoleMaxLines
Maximum number of lines that can be kept in a console at once. -
consoleTrimLines
Number of extra lines to be trimmed when the number of lines in a console exceeds the maximum. This allows the console to be trimmed less frequently for performance reasons. -
assemblerMaxErrors
Maximum number of errors that a single assembler run can produce. -
maxBacksteps
Maximum number of "backstep" operations that can be taken. An instruction may produce more than one (e.g.trap
instruction may set several registers). -
symbolTableSortState
State for sorting label window display. -
caretBlinkRate
Caret blink rate in milliseconds. 0 means don't blink. -
editorTabSize
Editor tab size in characters. -
editorPopupPrefixLength
Number of letters to be matched by editor's instruction guide before popup generated (if popup enabled). -
integerSettings
-
mipsFileExtensions
Acceptable file extensions for MIPS assembly files. Stored as the extensions (e.g.asm
) separated by semicolons. -
entryPointLabel
The special label treated as the entry point for a program. -
exceptionHandlerPath
Current specified exception handler file (a MIPS assembly source file). -
memoryConfiguration
Identifier of current memory configuration. -
textSegmentColumnOrder
Order of text segment table columns. Stored as the ordered column indices separated by spaces. -
previouslyOpenFiles
The list of files which were open in tabs in the previous session. Stored as the full file paths separated by semicolons. -
recentFiles
The list of files which have been opened recently, ordered from most to least recent. Stored as the full file paths separated by semicolons. -
lookAndFeelName
The name of the look and feel to use for the GUI. -
stringSettings
-
registerHighlightForeground
RGB color for register highlighted foreground -
registerHighlightBackground
RGB color for register highlighted background -
textSegmentExecuteHighlightForeground
RGB color for text segment highlighted foreground -
textSegmentExecuteHighlightBackground
RGB color for text segment highlighted background -
textSegmentFetchHighlightForeground
RGB color for text segment fetch highlighted foreground -
textSegmentFetchHighlightBackground
RGB color for text segment fetch highlighted background -
dataSegmentHighlightForeground
RGB color for data segment highlighted foreground -
dataSegmentHighlightBackground
RGB color for data segment highlighted background -
colorSettings
-
editorFont
Font for the text editor. -
tableFont
Font for the various table displays (registers, text segment, memory viewer, symbol table). -
tableHighlightFont
Font for highlighted text in table displays (overridestableFont
in those cells). -
consoleFont
Font for the console displays in the Messages and Console tabs. -
fontSettings
-
syntaxStyleDefault
-
syntaxStyleComment
-
syntaxStyleInstruction
-
syntaxStyleDirective
-
syntaxStyleRegister
-
syntaxStyleStringLiteral
-
syntaxStyleCharLiteral
-
syntaxStyleLabel
-
syntaxStyleInvalid
-
syntaxStyleMacroArgument
-
syntaxStyleSettings
-
-
Constructor Details
-
Settings
public Settings()Create and initialize an instance ofSettings
based on configuration defaults and user-defined values from permanent storage.
-
-
Method Details
-
encodeFileList
-
decodeFileList
-
addListener
-
removeListener
-
dispatchChangedEvent
public void dispatchChangedEvent() -
getSyntaxStyles
Obtain the user-definedSyntaxStyle
s in the form of an array. The indices of elements in the array correspond to constants from theToken
class. Anull
element indicates that the syntax style defers to the theme default.- Returns:
- The syntax styles.
- See Also:
-
getSyntaxStylesOrDefault
Obtain the currentSyntaxStyle
s in the form of an array. The indices of elements in the array correspond to constants from theToken
class. Each element is the user-defined style, if set, or the theme default otherwise. Anull
element indicates that the theme default does not assign a syntax style to the token, and no user-defined value is set.- Returns:
- The syntax styles.
- See Also:
-
getSyntaxStyle
Obtain the user-definedSyntaxStyle
corresponding to a given token type. If the syntax style defers to the theme default,null
is returned.- Parameters:
index
- The index of the desired syntax style, which should be one of the token type constants inToken
.- Returns:
- The syntax style, or
null
if there is no syntax style assigned to the token type. - See Also:
-
getSyntaxStyleOrDefault
Obtain the currentSyntaxStyle
corresponding to a given token type. If the user has defined a custom syntax style, it is returned. Otherwise, the theme default syntax style is returned.- Parameters:
index
- The index of the desired syntax style, which should be one of the token type constants inToken
.- Returns:
- The syntax style, or
null
if there is no syntax style assigned to the token type. - See Also:
-
getDefaultSyntaxStyle
Obtain the defaultSyntaxStyle
corresponding to a given token type. This default value derives from theme-specific defaults.- Parameters:
index
- The index of the desired syntax style, which should be one of the token type constants inToken
.- Returns:
- The syntax style, or
null
if there is no syntax style assigned to the token type. - See Also:
-
setSyntaxStyle
Assign aSyntaxStyle
to a given token type.- Parameters:
index
- The index of the desired syntax style, which should be one of the token type constants inToken
.style
- The syntax style to be associated with the token type, ornull
to assume the default.- See Also:
-
saveBooleanSetting
Save the key-value pair in thePreferences
object and ensure it is written to persistent storage. In most cases, theBooleanSetting.set(boolean)
method should be used on an existing setting instead of calling this method directly. -
saveIntegerSetting
-
saveStringSetting
Save the key-value pair in thePreferences
object and ensure it is written to persistent storage. In most cases, theStringSetting.set(String)
method should be used on an existing setting instead of calling this method directly. -
loadValues
public void loadValues()Load application-wide settings. For each setting, the saved user preference is used if it exists. Otherwise, the default value stored in/config/default_settings.properties
is used. If the defaults file can't be read, or if the setting is not present in the defaults file, the built-in defaults set by this class are used. -
updateThemeDefaults
public void updateThemeDefaults()Update any default values that are derived from the UI theme. This should be called anytime the theme changes, and exists to reduce the overhead it would induce to constantly request the same theme default when it hasn't changed.
-