Package jexer

Class TField

    • Field Detail

      • backgroundChar

        protected int backgroundChar
        Background character for unfilled-in text.
      • text

        protected java.lang.String text
        Field text.
      • fixed

        protected boolean fixed
        If true, only allow enough characters that will fit in the width. If false, allow the field to scroll to the right.
      • position

        protected int position
        Current editing position within text.
      • screenPosition

        protected int screenPosition
        Current editing position screen column number.
      • windowStart

        protected int windowStart
        Beginning of visible portion.
      • insertMode

        protected boolean insertMode
        If true, new characters are inserted at position.
      • mouse

        protected TMouseEvent mouse
        Remember mouse state.
      • enterAction

        protected TAction enterAction
        The action to perform when the user presses enter.
      • updateAction

        protected TAction updateAction
        The action to perform when the text is updated.
    • Constructor Detail

      • TField

        public TField​(TWidget parent,
                      int x,
                      int y,
                      int width,
                      boolean fixed)
        Public constructor.
        Parameters:
        parent - parent widget
        x - column relative to parent
        y - row relative to parent
        width - visible text width
        fixed - if true, the text cannot exceed the display width
      • TField

        public TField​(TWidget parent,
                      int x,
                      int y,
                      int width,
                      boolean fixed,
                      java.lang.String text)
        Public constructor.
        Parameters:
        parent - parent widget
        x - column relative to parent
        y - row relative to parent
        width - visible text width
        fixed - if true, the text cannot exceed the display width
        text - initial text, default is empty string
      • TField

        public TField​(TWidget parent,
                      int x,
                      int y,
                      int width,
                      boolean fixed,
                      java.lang.String text,
                      TAction enterAction)
        Public constructor.
        Parameters:
        parent - parent widget
        x - column relative to parent
        y - row relative to parent
        width - visible text width
        fixed - if true, the text cannot exceed the display width
        text - initial text, default is empty string
        enterAction - function to call when enter key is pressed
      • TField

        public TField​(TWidget parent,
                      int x,
                      int y,
                      int width,
                      boolean fixed,
                      java.lang.String text,
                      TAction enterAction,
                      TAction updateAction)
        Public constructor.
        Parameters:
        parent - parent widget
        x - column relative to parent
        y - row relative to parent
        width - visible text width
        fixed - if true, the text cannot exceed the display width
        text - initial text, default is empty string
        enterAction - function to call when enter key is pressed
        updateAction - function to call when the text is updated
    • Method Detail

      • mouseOnField

        protected boolean mouseOnField()
        Returns true if the mouse is currently on the field.
        Returns:
        if true the mouse is currently on the field
      • onMouseDown

        public void onMouseDown​(TMouseEvent mouse)
        Handle mouse button presses.
        Overrides:
        onMouseDown in class TWidget
        Parameters:
        mouse - mouse button event
      • onKeypress

        public void onKeypress​(TKeypressEvent keypress)
        Handle keystrokes.
        Overrides:
        onKeypress in class TWidget
        Parameters:
        keypress - keystroke event
      • onCommand

        public void onCommand​(TCommandEvent command)
        Handle posted command events.
        Overrides:
        onCommand in class TWidget
        Parameters:
        command - command event
      • setHeight

        public void setHeight​(int height)
        Override TWidget's height: we can only set height at construction time.
        Overrides:
        setHeight in class TWidget
        Parameters:
        height - new widget height (ignored)
      • draw

        public void draw()
        Draw the text field.
        Overrides:
        draw in class TWidget
      • getBackgroundChar

        public final int getBackgroundChar()
        Get field background character.
        Returns:
        background character
      • setBackgroundChar

        public void setBackgroundChar​(int backgroundChar)
        Set field background character.
        Parameters:
        backgroundChar - the background character
      • getText

        public final java.lang.String getText()
        Get field text.
        Returns:
        field text
      • setText

        public void setText​(java.lang.String text)
        Set field text.
        Parameters:
        text - the new field text
      • dispatch

        protected void dispatch​(boolean enter)
        Dispatch to the action function.
        Parameters:
        enter - if true, the user pressed Enter, else this was an update to the text.
      • screenToTextPosition

        protected int screenToTextPosition​(int screenPosition)
        Determine string position from screen position.
        Parameters:
        screenPosition - the position on screen
        Returns:
        the equivalent position in text
      • updateCursor

        protected void updateCursor()
        Update the visible cursor position to match the location of position and windowStart.
      • normalizeWindowStart

        protected void normalizeWindowStart()
        Normalize windowStart such that most of the field data if visible.
      • appendChar

        protected void appendChar​(int ch)
        Append char to the end of the field.
        Parameters:
        ch - char to append
      • insertChar

        protected void insertChar​(int ch)
        Insert char somewhere in the middle of the field.
        Parameters:
        ch - char to append
      • home

        public void home()
        Position the cursor at the first column. The field may adjust the window start to show as much of the field as possible.
      • end

        public void end()
        Set the editing position to the last filled character. The field may adjust the window start to show as much of the field as possible.
      • setPosition

        public void setPosition​(int position)
        Set the editing position. The field may adjust the window start to show as much of the field as possible.
        Parameters:
        position - the new position
        Throws:
        java.lang.IndexOutOfBoundsException - if position is outside the range of the available text
      • setActiveColorKey

        public void setActiveColorKey​(java.lang.String activeColorKey)
        Set the active color key.
        Parameters:
        activeColorKey - ColorTheme key color to use when this field is active
      • setInactiveColorKey

        public void setInactiveColorKey​(java.lang.String inactiveColorKey)
        Set the inactive color key.
        Parameters:
        inactiveColorKey - ColorTheme key color to use when this field is inactive
      • setEnterAction

        public void setEnterAction​(TAction action)
        Set the action to perform when the user presses enter.
        Parameters:
        action - the action to perform when the user presses enter
      • setUpdateAction

        public void setUpdateAction​(TAction action)
        Set the action to perform when the field is updated.
        Parameters:
        action - the action to perform when the field is updated
      • isEditMenuCut

        public boolean isEditMenuCut()
        Check if the cut menu item should be enabled.
        Specified by:
        isEditMenuCut in interface EditMenuUser
        Returns:
        true if the cut menu item should be enabled
      • isEditMenuCopy

        public boolean isEditMenuCopy()
        Check if the copy menu item should be enabled.
        Specified by:
        isEditMenuCopy in interface EditMenuUser
        Returns:
        true if the copy menu item should be enabled
      • isEditMenuPaste

        public boolean isEditMenuPaste()
        Check if the paste menu item should be enabled.
        Specified by:
        isEditMenuPaste in interface EditMenuUser
        Returns:
        true if the paste menu item should be enabled
      • isEditMenuClear

        public boolean isEditMenuClear()
        Check if the clear menu item should be enabled.
        Specified by:
        isEditMenuClear in interface EditMenuUser
        Returns:
        true if the clear menu item should be enabled