Package mars.settings

Class Settings

java.lang.Object
mars.settings.Settings

public class Settings extends Object
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
  • Field Details

    • extendedAssemblerEnabled

      public final BooleanSetting extendedAssemblerEnabled
      Flag to control whether the assembler will be limited to basic MIPS instructions and formats.
    • assembleOnOpenEnabled

      public final BooleanSetting assembleOnOpenEnabled
      Flag to control whether a file is immediately and automatically assembled upon opening. Handy when using an external editor, for example.
    • labelWindowVisible

      public final BooleanSetting labelWindowVisible
      Flag to control whether the symbol table window will be visible upon successful assembly in the Execute tab.
    • displayAddressesInHex

      public final BooleanSetting displayAddressesInHex
      Flag to control whether memory addresses are displayed in hexadecimal. If this flag is set to false, they are displayed in decimal.
    • displayValuesInHex

      public final BooleanSetting 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

      public final BooleanSetting exceptionHandlerEnabled
      Flag to control whether the currently selected exception handler source file will be included in each assembly operation.
    • delayedBranchingEnabled

      public final BooleanSetting 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 hidden nop after every branch instruction.

      DPS 14 June 2007

    • displayEditorLineNumbers

      public final BooleanSetting displayEditorLineNumbers
      Flag to control whether the editor will display line numbers on the side.
    • warningsAreErrors

      public final BooleanSetting warningsAreErrors
      Flag to control whether assembler warnings are automatically promoted to errors.
    • useProgramArguments

      public final BooleanSetting useProgramArguments
      Flag to control whether to accept and use program arguments.
    • memoryHighlightingEnabled

      public final BooleanSetting memoryHighlightingEnabled
      Flag to control whether values in the memory viewer are highlighted during stepped execution.
    • registerHighlightingEnabled

      public final BooleanSetting registerHighlightingEnabled
      Flag to control whether registers in the register window are highlighted during stepped execution.
    • startAtMain

      public final BooleanSetting startAtMain
      Flag to control whether the assembler automatically initializes program counter to the address of global label main, if defined.
    • highlightCurrentEditorLine

      public final BooleanSetting highlightCurrentEditorLine
      Flag to control whether the editor will highlight the line currently being edited.
    • popupInstructionGuidance

      public final BooleanSetting popupInstructionGuidance
      Flag to control whether the editor will provide popup instruction guidance while typing.
    • popupSyscallInput

      public final BooleanSetting popupSyscallInput
      Flag to control whether the simulator will use popup dialogs for input syscalls.
    • autoIndentEnabled

      public final BooleanSetting autoIndentEnabled
      Flag to control whether the editor will use the auto-indent feature.
    • selfModifyingCodeEnabled

      public final BooleanSetting selfModifyingCodeEnabled
      Flag to control whether a program can write binary code to the text or data segment and execute that code.
    • useBigEndian

      public final BooleanSetting 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

      public final BooleanSetting[] booleanSettings
    • uiScale

      public final IntegerSetting uiScale
      UI scale multiplier as a percentage. 100 is at 1:1 scale.
    • maxRecentFiles

      public final IntegerSetting maxRecentFiles
      Maximum number of recent files to be kept in the "Recent Files" menu.
    • consoleMaxLines

      public final IntegerSetting consoleMaxLines
      Maximum number of lines that can be kept in a console at once.
    • consoleTrimLines

      public final IntegerSetting 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

      public final IntegerSetting assemblerMaxErrors
      Maximum number of errors that a single assembler run can produce.
    • maxBacksteps

      public final IntegerSetting 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

      public final IntegerSetting symbolTableSortState
      State for sorting label window display.
    • caretBlinkRate

      public final IntegerSetting caretBlinkRate
      Caret blink rate in milliseconds. 0 means don't blink.
    • editorTabSize

      public final IntegerSetting editorTabSize
      Editor tab size in characters.
    • editorPopupPrefixLength

      public final IntegerSetting editorPopupPrefixLength
      Number of letters to be matched by editor's instruction guide before popup generated (if popup enabled).
    • integerSettings

      public final IntegerSetting[] integerSettings
    • mipsFileExtensions

      public final StringSetting mipsFileExtensions
      Acceptable file extensions for MIPS assembly files. Stored as the extensions (e.g. asm) separated by semicolons.
    • entryPointLabel

      public final StringSetting entryPointLabel
      The special label treated as the entry point for a program.
    • exceptionHandlerPath

      public final StringSetting exceptionHandlerPath
      Current specified exception handler file (a MIPS assembly source file).
    • memoryConfiguration

      public final StringSetting memoryConfiguration
      Identifier of current memory configuration.
    • textSegmentColumnOrder

      public final StringSetting textSegmentColumnOrder
      Order of text segment table columns. Stored as the ordered column indices separated by spaces.
    • previouslyOpenFiles

      public final StringSetting previouslyOpenFiles
      The list of files which were open in tabs in the previous session. Stored as the full file paths separated by semicolons.
    • recentFiles

      public final StringSetting 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

      public final StringSetting lookAndFeelName
      The name of the look and feel to use for the GUI.
    • stringSettings

      public final StringSetting[] stringSettings
    • registerHighlightForeground

      public final ColorSetting registerHighlightForeground
      RGB color for register highlighted foreground
    • registerHighlightBackground

      public final ColorSetting registerHighlightBackground
      RGB color for register highlighted background
    • textSegmentExecuteHighlightForeground

      public final ColorSetting textSegmentExecuteHighlightForeground
      RGB color for text segment highlighted foreground
    • textSegmentExecuteHighlightBackground

      public final ColorSetting textSegmentExecuteHighlightBackground
      RGB color for text segment highlighted background
    • textSegmentFetchHighlightForeground

      public final ColorSetting textSegmentFetchHighlightForeground
      RGB color for text segment fetch highlighted foreground
    • textSegmentFetchHighlightBackground

      public final ColorSetting textSegmentFetchHighlightBackground
      RGB color for text segment fetch highlighted background
    • dataSegmentHighlightForeground

      public final ColorSetting dataSegmentHighlightForeground
      RGB color for data segment highlighted foreground
    • dataSegmentHighlightBackground

      public final ColorSetting dataSegmentHighlightBackground
      RGB color for data segment highlighted background
    • colorSettings

      public final ColorSetting[] colorSettings
    • editorFont

      public final FontSetting editorFont
      Font for the text editor.
    • tableFont

      public final FontSetting tableFont
      Font for the various table displays (registers, text segment, memory viewer, symbol table).
    • tableHighlightFont

      public final FontSetting tableHighlightFont
      Font for highlighted text in table displays (overrides tableFont in those cells).
    • consoleFont

      public final FontSetting consoleFont
      Font for the console displays in the Messages and Console tabs.
    • fontSettings

      public final FontSetting[] fontSettings
    • syntaxStyleDefault

      public final SyntaxStyleSetting syntaxStyleDefault
    • syntaxStyleComment

      public final SyntaxStyleSetting syntaxStyleComment
    • syntaxStyleInstruction

      public final SyntaxStyleSetting syntaxStyleInstruction
    • syntaxStyleDirective

      public final SyntaxStyleSetting syntaxStyleDirective
    • syntaxStyleRegister

      public final SyntaxStyleSetting syntaxStyleRegister
    • syntaxStyleStringLiteral

      public final SyntaxStyleSetting syntaxStyleStringLiteral
    • syntaxStyleCharLiteral

      public final SyntaxStyleSetting syntaxStyleCharLiteral
    • syntaxStyleLabel

      public final SyntaxStyleSetting syntaxStyleLabel
    • syntaxStyleInvalid

      public final SyntaxStyleSetting syntaxStyleInvalid
    • syntaxStyleMacroArgument

      public final SyntaxStyleSetting syntaxStyleMacroArgument
    • syntaxStyleSettings

      public final SyntaxStyleSetting[] syntaxStyleSettings
  • Constructor Details

    • Settings

      public Settings()
      Create and initialize an instance of Settings based on configuration defaults and user-defined values from permanent storage.
  • Method Details

    • encodeFileList

      public static String encodeFileList(List<File> files)
    • decodeFileList

      public static List<File> decodeFileList(String string)
    • addListener

      public void addListener(Settings.Listener listener)
    • removeListener

      public void removeListener(Settings.Listener listener)
    • dispatchChangedEvent

      public void dispatchChangedEvent()
    • getSyntaxStyles

      public SyntaxStyle[] getSyntaxStyles()
      Obtain the user-defined SyntaxStyles in the form of an array. The indices of elements in the array correspond to constants from the Token class. A null element indicates that the syntax style defers to the theme default.
      Returns:
      The syntax styles.
      See Also:
    • getSyntaxStylesOrDefault

      public SyntaxStyle[] getSyntaxStylesOrDefault()
      Obtain the current SyntaxStyles in the form of an array. The indices of elements in the array correspond to constants from the Token class. Each element is the user-defined style, if set, or the theme default otherwise. A null 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

      public SyntaxStyle getSyntaxStyle(int index)
      Obtain the user-defined SyntaxStyle 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 in Token.
      Returns:
      The syntax style, or null if there is no syntax style assigned to the token type.
      See Also:
    • getSyntaxStyleOrDefault

      public SyntaxStyle getSyntaxStyleOrDefault(int index)
      Obtain the current SyntaxStyle 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 in Token.
      Returns:
      The syntax style, or null if there is no syntax style assigned to the token type.
      See Also:
    • getDefaultSyntaxStyle

      public SyntaxStyle getDefaultSyntaxStyle(int index)
      Obtain the default SyntaxStyle 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 in Token.
      Returns:
      The syntax style, or null if there is no syntax style assigned to the token type.
      See Also:
    • setSyntaxStyle

      public void setSyntaxStyle(int index, SyntaxStyle style)
      Assign a SyntaxStyle to a given token type.
      Parameters:
      index - The index of the desired syntax style, which should be one of the token type constants in Token.
      style - The syntax style to be associated with the token type, or null to assume the default.
      See Also:
    • saveBooleanSetting

      public void saveBooleanSetting(String key, boolean value, boolean notify)
      Save the key-value pair in the Preferences object and ensure it is written to persistent storage. In most cases, the BooleanSetting.set(boolean) method should be used on an existing setting instead of calling this method directly.
    • saveIntegerSetting

      public void saveIntegerSetting(String key, int value, boolean notify)
    • saveStringSetting

      public void saveStringSetting(String key, String value, boolean notify)
      Save the key-value pair in the Preferences object and ensure it is written to persistent storage. In most cases, the StringSetting.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.