Interactive Interface Management
Interactive interface state management.
This module provides state management and business logic for interactive terminal interfaces.
- class simulchip.interactive.KeyAction[source]
Bases:
Enum
Standard key actions for interactive interfaces.
- UP = 'up'
- DOWN = 'down'
- PAGE_UP = 'page_up'
- PAGE_DOWN = 'page_down'
- TOP = 'top'
- BOTTOM = 'bottom'
- SELECT = 'select'
- TOGGLE = 'toggle'
- INCREMENT = 'increment'
- DECREMENT = 'decrement'
- SET_VALUE = 'set_value'
- RESET = 'reset'
- FILTER_ADD_CHAR = 'filter_add_char'
- FILTER_BACKSPACE = 'filter_backspace'
- FILTER_CLEAR = 'filter_clear'
- SAVE_AND_EXIT = 'save_and_exit'
- CANCEL = 'cancel'
- TOGGLE_MODE = 'toggle_mode'
- HELP = 'help'
- UNKNOWN = 'unknown'
- class simulchip.interactive.InteractiveState[source]
Bases:
object
State for interactive interfaces.
- class simulchip.interactive.KeyMapper[source]
Bases:
object
Maps keyboard input to actions.
- ESCAPE_SEQUENCES = {'\x1b[5~': KeyAction.PAGE_UP, '\x1b[6~': KeyAction.PAGE_DOWN, '\x1b[A': KeyAction.UP, '\x1b[B': KeyAction.DOWN, '\x1b[C': KeyAction.INCREMENT, '\x1b[D': KeyAction.DECREMENT}
- SINGLE_CHARS = {'\x03': KeyAction.SAVE_AND_EXIT, '\x04': KeyAction.PAGE_DOWN, '\x08': KeyAction.FILTER_BACKSPACE, '\n': KeyAction.SELECT, '\r': KeyAction.SELECT, '\x15': KeyAction.PAGE_UP, '\x1b': KeyAction.SAVE_AND_EXIT, ' ': KeyAction.TOGGLE, '0': KeyAction.RESET, '1': KeyAction.SET_VALUE, '2': KeyAction.SET_VALUE, '3': KeyAction.SET_VALUE, '4': KeyAction.SET_VALUE, '5': KeyAction.SET_VALUE, '6': KeyAction.SET_VALUE, '7': KeyAction.SET_VALUE, '8': KeyAction.SET_VALUE, '9': KeyAction.SET_VALUE, '?': KeyAction.HELP, 'E': KeyAction.TOGGLE_MODE, 'G': KeyAction.BOTTOM, 'e': KeyAction.TOGGLE_MODE, 'g': KeyAction.TOP, 'h': KeyAction.HELP, 'j': KeyAction.UP, 'k': KeyAction.DOWN, 'q': KeyAction.SAVE_AND_EXIT, '\x7f': KeyAction.FILTER_BACKSPACE}
Process navigation actions and update state.
- Parameters:
state (
InteractiveState
) – Current interactive stateaction (
KeyAction
) – Navigation action to processtotal_items (
int
) – Total number of itemspage_size (
int
) – Number of items per page
- Return type:
- Returns:
True if state was modified
- simulchip.interactive.process_filter_action(state, action, value=None, reset_selection_on_change=True)[source]
Process filter actions and update state.
- Parameters:
state (
InteractiveState
) – Current interactive stateaction (
KeyAction
) – Filter action to processreset_selection_on_change (
bool
) – Whether to reset selection when filter changes
- Return type:
- Returns:
True if state was modified
- class simulchip.interactive.InteractiveController[source]
Bases:
object
Controller for interactive interfaces.
- __init__(key_mapper=None, page_size=10, reset_selection_on_filter_change=True)[source]
Initialize controller with configuration.