menu

package
v0.0.0-...-be74371 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRecord

type CommandRecord struct {
	Keys    string `json:"KEYS"`              // Input key(s) to trigger command (space-separated)
	Command string `json:"CMD"`               // Command string (e.g., GOTO:MENU, RUN:PROG, LOGOFF)
	ACS     string `json:"ACS"`               // Access Control String
	Hidden  bool   `json:"HIDDEN"`            // Whether the command is hidden (H flag)
	AutoRun string `json:"AUTORUN,omitempty"` // Type of auto-run (e.g., "ONCE_PER_SESSION")
}

CommandRecord holds the definition of a single command from a .CFG file.

func LoadCommands

func LoadCommands(menuName string, configPath string) ([]CommandRecord, error)

LoadCommands reads a .CFG file (assumed JSON) for the given menu name.

func (*CommandRecord) GetHidden

func (cr *CommandRecord) GetHidden() bool

GetHidden is a helper method to safely access the Hidden field. (Kept for potential future use, though direct access is fine)

type LightbarOption

type LightbarOption struct {
	X, Y           int    // Screen coordinates
	Text           string // Display text
	HotKey         string // Command hotkey
	HighlightColor int    // Color code when highlighted
	RegularColor   int    // Color code when not highlighted
}

LightbarOption represents a single option in a lightbar menu

type MenuExecutor struct {
	ConfigPath     string                       // DEPRECATED: Use MenuSetPath + "/cfg" or RootConfigPath
	AssetsPath     string                       // DEPRECATED: Use MenuSetPath + "/ansi" or RootAssetsPath
	MenuSetPath    string                       // NEW: Path to the active menu set (e.g., "menus/v3")
	RootConfigPath string                       // NEW: Path to global configs (e.g., "configs")
	RootAssetsPath string                       // NEW: Path to global assets (e.g., "assets")
	RunRegistry    map[string]RunnableFunc      // Map RUN: targets to functions (Use local RunnableFunc)
	DoorRegistry   map[string]config.DoorConfig // Map DOOR: targets to configurations
	OneLiners      []string                     // Loaded oneliners (Consider if these should be menu-set specific)
	LoadedStrings  config.StringsConfig         // Loaded global strings configuration
	Theme          config.ThemeConfig           // Loaded theme configuration
	MessageMgr     *message.MessageManager      // <-- ADDED FIELD
	FileMgr        *file.FileManager            // <-- ADDED FIELD: File manager instance
}

MenuExecutor handles the loading and execution of ViSiON/2 menus.

func NewExecutor

func NewExecutor(menuSetPath, rootConfigPath, rootAssetsPath string, oneLiners []string, doorRegistry map[string]config.DoorConfig, loadedStrings config.StringsConfig, theme config.ThemeConfig, msgMgr *message.MessageManager, fileMgr *file.FileManager) *MenuExecutor

NewExecutor creates a new MenuExecutor. Added oneLiners, loadedStrings, theme, messageMgr, and fileMgr parameters Updated paths to use new structure << UPDATED Signature with msgMgr and fileMgr

func (e *MenuExecutor) Run(s ssh.Session, terminal *term.Terminal, userManager *user.UserMgr, currentUser *user.User, startMenu string, nodeNumber int, sessionStartTime time.Time, autoRunLog types.AutoRunTracker, outputMode ansi.OutputMode, currentAreaName string) (string, *user.User, error)

Run executes the menu logic for a given starting menu name. Reverted s parameter back to ssh.Session Added outputMode parameter Added currentAreaName parameter

type MenuRecord struct {
	// Fields expected from JSON .MNU
	ClrScrBefore bool   `json:"CLR"`
	UsePrompt    bool   `json:"USEPROMPT"`
	Prompt1      string `json:"PROMPT1"`
	Prompt2      string `json:"PROMPT2"`
	Fallback     string `json:"FALLBACK"`
	ACS          string `json:"ACS"`
	Password     string `json:"PASS"`
}

MenuRecord adapted for JSON parsing of .MNU files. Assumes JSON keys match the tags.

func LoadMenu

func LoadMenu(menuName string, configPath string) (*MenuRecord, error)

LoadMenu reads a .MNU file (assumed JSON) for the given menu name.

func (mr *MenuRecord) GetClrScrBefore() bool

Getters for boolean fields (using the JSON bool types directly)

func (mr *MenuRecord) GetUsePrompt() bool

type RunnableFunc

type RunnableFunc func(e *MenuExecutor, s ssh.Session, terminal *term.Terminal, userManager *user.UserMgr, currentUser *user.User, nodeNumber int, sessionStartTime time.Time, args string, outputMode ansi.OutputMode) (authenticatedUser *user.User, nextAction string, err error)

RunnableFunc defines the signature for functions executable via RUN: Returns: authenticatedUser, nextAction (e.g., "GOTO:MENU"), err

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL