Package ui.main

Class CodeAreaManager


  • final class CodeAreaManager
    extends java.lang.Object
    The CodeAreaManager class is used manage the CodeArea where the user inputs their code.
    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      CodeAreaManager​(org.fxmisc.richtext.CodeArea codeArea, javafx.scene.control.TextField tabSizeField, int tabSize)
      Constructs a CodeAreaManager for managing a CodeArea object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.scene.text.TextFlow compileInput()
      Compiles the code currently in the CodeArea, and outputs the result.
      java.lang.String getCaretPosition()
      Returns the current line and column of the caret, formatted as a String.
      void limitTabSize​(int charLimit)
      Limits how many characters can be displayed in the tab size Label.
      void updateTabSize()
      Updates the tab size to reflect the contents of the tabSizeField.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CodeAreaManager

        public CodeAreaManager​(org.fxmisc.richtext.CodeArea codeArea,
                               javafx.scene.control.TextField tabSizeField,
                               int tabSize)
        Constructs a CodeAreaManager for managing a CodeArea object.

        The TextField containing the size of the tabs, as defined by the user, is read every time the user makes changes to it. These changes are reflected in tabSize.

        Parameters:
        codeArea - The CodeArea to be managed
        tabSizeField - The TextField defining the size of tabs
        tabSize - The initial tab size
    • Method Detail

      • compileInput

        public javafx.scene.text.TextFlow compileInput()
        Compiles the code currently in the CodeArea, and outputs the result.

        The code is retrieved from the CodeArea and converted into a String, which is then compiled by the Compiler, and the output being returned in the form of a TextFlow object.

        The parse tree and symbol table are printed to the console when ever this method runs.

        Returns:
        A TextFlow object containing the output
      • getCaretPosition

        public java.lang.String getCaretPosition()
        Returns the current line and column of the caret, formatted as a String.
        Returns:
        The current position of the caret
      • updateTabSize

        public void updateTabSize()
        Updates the tab size to reflect the contents of the tabSizeField.

        The text is retrieved from the Label containing the user-defined tab size. If the input is not an integer, or is larger than 99/less than 1, the tab size is not updated and the tabSizeField text is reset back to its last value.

      • limitTabSize

        public void limitTabSize​(int charLimit)
        Limits how many characters can be displayed in the tab size Label.

        If the users input is greater than the specified limit, the excess text is removed from the Label.

        Parameters:
        charLimit - the maximum amount of characters allowed