module

Tryst::UI::OptionErrorTranslation

@api private

Creation-only options differ per widget family - see #creation_only_options below for the three buckets.

Constants

EMPTY_KWARGS = {} of String => TclArgValue
MAX_DISTANCE = 2
MAX_SUGGESTIONS = 15
PROBE_PATH = ".__tryst_ui_option_probe__"

A failed widget CREATION never leaves a real widget behind to query (Tk validates every option before creating anything at all - confirmed directly), so this path is used purely to ask a throwaway instance of the same tk_command what its options are, then destroyed.

UNKNOWN_OPTION = /unknown option "-([\w-]+)"/

Class methods

creation_only_options(tk_command : String) : Array(String)

The creation-only options a live dump never shows, per family - confirmed identically on Tcl 8.6 and 9.x. Not one universal list: a ttk widget's dump already reports -class (queryable, just not settable post-creation), a toplevel's dump reports all five, and only a classic non-toplevel widget (canvas, listbox, text, menu, ...) hides every one of them.

Source
translate!(ex : Exception, app : AppContract, type : Symbol, name : Symbol | Nil, path : String, tk_command : String, creation : Bool) : NoReturn

Translates a TclError raised by an "unknown option" failure into an OptionError - or re-raises ex UNCHANGED if it isn't that kind of error at all, so nothing here ever masks or misattributes a different failure. Tk remains the sole judge of validity; this only phrases the message once Tk has already rejected something.

creation: true adds the fixed per-family creation-only supplement (#creation_only_options) to the suggestion pool - only relevant for a CREATION failure, since none of those options are legal in a post-creation #configure call regardless of what a dump does or doesn't show.

Source
valid_options_for(app : AppContract, tk_command : String) : Array(String)

Every real (5-tuple) option name a live configure dump reports for tk_command - a throwaway instance is created and destroyed purely to ask it (see PROBE_PATH). Synonyms (2-tuple entries, e.g. -bg -> -background) are dropped; their canonical forms exist as regular 5-tuple entries.

Source